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

use strict;
use warnings;

use Data::Dumper;

use lib '/app/tools/common/lib';
use Common::Client;
use Common::Assert;
#use Common::DiskCache;

use lib '/app/tools/rps/lib';

use RPS::Payee::ArtistPayeeAccount;
use RPS::Statement::Artist::BaseStatement;
use base 'RPS::Statement::Artist::BaseStatement';


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

    $self->SUPER::_initProperties($props);

	$self->{ArtistPayeeAccount} = RPS::Payee::ArtistPayeeAccount->new
    (
        artistPayeeID => $props->{payee_id}, 
        payorID => $props->{payor_id}, 
        showPendingPaymentsOnly => 1,
    );

}


sub clearPayments
{
    my ($self) = @_;
    
    $self->{ArtistPayeeAccount}->clearPayments();
}


sub setPaymentsToMin
{
    my ($self) = @_;

    $self->{ArtistPayeeAccount}->clearPayments();
    $self->{ArtistPayeeAccount}->setFirstPayment($self->MinimumPayment());
}

sub setPaymentsToFull
{
    my ($self) = @_;

    $self->{ArtistPayeeAccount}->clearPayments();
    my $amountDue = $self->AmountDue();
    if ($amountDue > 0)
    {
        $self->{ArtistPayeeAccount}->setFirstPayment($amountDue);
    }
}


# Overriding validate to _skip_ validating the inherited members, including ArtistPayee.
# This is because we don't need to bother with that here - I just want to make sure the 
# transactions are good within the account.
#
sub validate
{
    my ($self, $skipRequiredFields) = @_;

    return $self->{ArtistPayeeAccount}->validate($skipRequiredFields);
}

sub save
{
    my ($self) = @_;

    $self->{ArtistPayeeAccount}->save();
}

###
1;#
###
