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

use strict;
use Carp;
use Data::Dumper;

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

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

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

sub _init {

    # The idea here is to get a list of the distinct income source ids
    # for a statement, so that we can efficiently create a legend.
    #
    my ( $self, %args ) = @_;
    my $timer = Common::Timer->new();

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

    my $statementID = $args{artistRoyaltyStatementID};

    my $collection;

    if ( $args{skipNonPayable} ) {
        $collection = RPS::DB::Item::ArtistRoyaltyIncomeItem->GetIncomeSourcesByStatementSkipNonPayable($statementID);
    } else {
        $collection = RPS::DB::Item::ArtistRoyaltyIncomeItem->GetIncomeSourcesByStatement($statementID);
    }

    while ( $collection->hasNext() ) {
        my $obj = $collection->next();

        push @{ $self->{IncomeSource} }, $obj->income_source_id;
    }

    return $self;
}

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

    return $self->{IncomeSource};
}

1;
