#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DB::Item::LicenseIncome;
use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::DB::Item;
use Common::DB::ItemCollection;
use Common::Assert;
use base 'Common::DB::Item';

use constant kTable => 'license_income';
use constant kDB => Common::DB::Item::kClientDB();

use constant kParentAlbumContract => 1;
use constant kParentTrackContract => 2;


sub GetByFileID
{
    my ($class, $id) = @_;
    assert($id);

    my $sql = "SELECT * FROM " . kTable . " WHERE file_id=$id ORDER BY license_income_id";

    return $class->GetAll($sql);
}

sub GetByParent
{
    my ($class, $id, $type) = @_;

    my $sql = "SELECT * FROM ".kTable." WHERE parent_type=$type AND parent_id=$id";

    return $class->GetAll($sql);
}

sub GetBySource
{
    my ($class, $type) = @_;

    my $sql = "SELECT * FROM ".kTable." WHERE license_income_source_id=$type";

    return $class->GetAll($sql);
}

sub GetAllUnprocessed
{
    my ($class) = @_;

    my $sql = "SELECT * FROM " . kTable . " WHERE processed=0";

    return $class->GetAll($sql);
}


1;

