#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Payee::ArtistPayeeSimple;

use strict;
use warnings;

use lib '/app/tools/rps/lib';
use RPS::DB::Item::ArtistPayee;

use Common::FormObject;
use base 'Common::FormObject';

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my %properties;
    if ( $args{_dbItem} ) {
        $self->_propertiesFromDBItem( \%properties, $args{_dbItem} );
    } elsif ( $args{artistPayeeID} ) {
        $self->_propertiesFromDB( \%properties, $args{artistPayeeID} );
    } else {
        $self->_propertiesFromDefaults( \%properties );
    }

    $self->_initProperties( \%properties );
    $self->_initSubs( \%properties );

    return $self;
}

sub _propertiesFromDB {
    my ( $self, $hrProperties, $id ) = @_;

    my $dbItem = RPS::DB::Item::ArtistPayee->Lookup( artist_payee_id => $id );
    $self->_propertiesFromDBItem( $hrProperties, $dbItem );
}

sub _propertiesFromDBItem {
    my ( $self, $hrProperties, $dbItem ) = @_;

    $hrProperties->{artist_payee_id}   = $dbItem->artist_payee_id;
    $hrProperties->{name}              = $dbItem->name;
    $hrProperties->{client_account_id} = $dbItem->client_account_id;
    $hrProperties->{abacus_account_id} = $dbItem->abacus_account_id;
    $hrProperties->{abacus_contract_id} = $dbItem->abacus_contract_id;
}

sub _propertiesFromDefaults {
    my ( $self, $hrProperties ) = @_;
}

sub _initSubs {
    my ( $self, $hrProperties ) = @_;
}

sub _initProperties {
    my ( $self, $props ) = @_;

    $self->{ArtistPayeeID} = Common::FormObject::Scalar->new( value => $props->{artist_payee_id}, readOnly => 1 );
    $self->{Name} = Common::FormObject::Scalar::String->new( value => $props->{name}, required => 1 );
    $self->{ClientAccountID} = Common::FormObject::Scalar::String->new( value => $props->{client_account_id} );
    $self->{AbacusAccountID} = Common::FormObject::Scalar::String->new( value => $props->{abacus_account_id} );
    $self->{AbacusContractID} = Common::FormObject::Scalar::String->new( value => $props->{abacus_contract_id} );
}

###
1;    #
###
