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

use strict;
use warnings;
use Carp;


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

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

use RPS::Statement::Mechanical::BaseStatement;
use base 'RPS::Statement::Mechanical::BaseStatement';


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

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


    $self->{PublisherAccount} = $self->_getPublisherAccount($props->{publisher_id}, $props->{payor_id});

}

sub _getPublisherAccount
{
    my ($self, $publisherID, $payorID) = @_;
    assert(0, 'override this');
}

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


sub setPaymentsToMin
{
    my ($self) = @_;
    $self->{PublisherAccount}->clearPayments();
    $self->{PublisherAccount}->setFirstPayment($self->MinimumPayment());
}

sub setPaymentsToFull
{
    my ($self) = @_;
    $self->{PublisherAccount}->clearPayments();
    my $amountDue = $self->AmountDue();
    if ($amountDue > 0)
    {
        $self->{PublisherAccount}->setFirstPayment($amountDue);
    }
}


sub save
{
    my ($self) = @_;
    $self->{PublisherAccount}->save();
}

###
1;#
###
