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

package RPS::LabelRoyalty::Fast::Script::CommitFinalData;

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 DB_File;

use Common::Util;
use Common::Log;
use Common::Parser;
use Common::WriteXML;

use RPS::DB::Item::LabelRoyaltyRun;

use RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyStatement;
use RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyLabelItem;
use RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyTransactionItem;
use RPS::LabelRoyalty::Fast::Final::DB::SaleRunMap;
use RPS::LabelRoyalty::Fast::Final::File::LabelRoyaltySaleReportItem;

use base 'Common::Script';


sub _options {{
    client_id => 
    {
        short       => 'c',
        required    => 1,
        description => 'Limit to this client id',
        parameter    => 'i'
    },
    output_path => 
    {
        short       => 'o',
        required    => 1,
        description => 'path to directory to write output files',
        parameter    => 's'
    },
    run_id =>
    {
        short       => 'r',
        required    => 1,
        description => 'The label_royalty_run_id we are creating statements for.',
        parameter   => 'i',
    },
}}



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

    my $outputDirectory = $self->param('output_path');
    my $runID = $self->param('run_id');

    RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyStatement->Commit($outputDirectory);
    RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyLabelItem->Commit($outputDirectory);
    RPS::LabelRoyalty::Fast::Final::DB::LabelRoyaltyTransactionItem->Commit($outputDirectory);
    RPS::LabelRoyalty::Fast::Final::DB::SaleRunMap->Commit($outputDirectory);
    RPS::LabelRoyalty::Fast::Final::File::LabelRoyaltySaleReportItem->Commit($outputDirectory, $runID);
    #
    # !!! I guess this class will just know where the file is supposed to be copied to?

}

1;
