#---------------------------------------------------------------
# ____                   _ _         ____  _                    
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___ 
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/                            
#
# Copyright (C) 2013 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::LabelRoyalty::Fast::Final::DB::SaleRunMap;

use strict;
use Data::Dumper;
use File::Path;

use lib '/app/tools/common/lib';
use lib '/app/tools/rps/lib';
use lib '/app/tools/raptor/lib';
use Common::RSApp;
use Common::RSDB;
use Common::Assert;

use Data::Dumper;
use DB_File;

use RPS::LabelRoyalty::Fast::Mapped::Data;
use RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyLabelItem;

use Common::Log;

use base 'RPS::LabelRoyalty::Fast::Final::DB';

use constant kSaleID                    => 0;
use constant kLabelRoyaltyIncomeItemID  => 1;
use constant kRunID                     => 2;
use constant kRunType                   => 3;
use constant kStatus                    => 4;



my @gFields =
(
'sale_id',
'statement_item_id',
'run_id',
'run_type',
'status',
);

sub Fields { return \@gFields; }



sub FileName { 'sale_run_map' }

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

    return 0;
}


my $gRunID;
sub Init
{
    my ($class, $outputDirectory, $dataPath, $runID) = @_;
    assert($dataPath, "MISSING dataPath");

    # Call the inherited method first.
    #
    $class->SUPER::Init($outputDirectory);

    $gRunID = $runID;
}


sub new
{
    my ($class, $data, $label, $statement) = @_;

    my $item = $class->BlankItem();

    $item->[kSaleID] = $data->[RPS::LabelRoyalty::Fast::Mapped::Data::kSaleID];
    $item->[kLabelRoyaltyIncomeItemID] = $label->[RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyLabelItem::kLabelRoyaltyLabelItemID];
    $item->[kRunID] = $gRunID;
    $item->[kRunType] = 'LABR';
    $item->[kStatus] = 'paid';

    return bless($item, $class);
}


# No-op
#
sub _sendSummaryData
{
}

1;

