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

use Carp;

use Data::Dumper;
use Date::Calc;

use lib '/app/tools/common/lib';
use Common::Assert;

use lib '/app/tools/rps/lib';
use RPS::DB::Item::MechanicalStatementRowAndCells;
use RPS::Statement::Mechanical::US::BaseStatement;
use RPS::DB::Item::MechanicalStatement;
use RPS::Payor::Payor;

use base 'RPS::Statement::FastRender::Mechanical::US';

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

    my $id       = $self->{_mechanicalStatementID};
    my $rowCount = RPS::DB::Item::MechanicalStatementRowAndCells->GetNumRowsPayee($id);
    return int( $rowCount / $self->{_pageSize} ) + 1;
}

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

    my $id = $self->{_mechanicalStatementID};

    my $firstRowIndex;
    my $lastRowIndex;

    if ( 'ALL' eq $self->{_page} ) {

        # We'll pass an enormous lastRowIndex to ensure we get them all.
        #
        $firstRowIndex = 0;
        $lastRowIndex  = 999999999;
    } else {
        my $actualPage = $self->{_page} - 1;
        $actualPage    = 0 if $actualPage < 0;
        $firstRowIndex = $actualPage * $self->{_pageSize};
        $lastRowIndex  = $firstRowIndex + $self->{_pageSize} - 1;
    }

    my $rowData = RPS::DB::Item::MechanicalStatementRowAndCells->GetPayeeStatementRowCells( $id, $firstRowIndex, $lastRowIndex );
    return $rowData;
}

###
1;    #
###
