#------------------------------------------------------------
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package BookPub::Price::Job::PriceValidation;

use strict;
use warnings;

use Data::Dumper;
use Date::Format;

use lib '/app/tools/common/lib';
use Common::Log;
use Common::Assert;
use Common::RSApp;
use Common::Client;

use lib '/app/tools/rps/lib';

use lib '/app/tools/job/lib';
use Job::Job;

use base 'Job::Job';

sub _defaultClass    { 'Tracker' }
sub _defaultSubclass { 'PriceValidation' }

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

    my $client = Common::Client->new( clientID => $self->clientID );
    my $date = time2str( "%Y%m", time );

    return Common::RSApp::GetConfig( job => 'importer_log_dir' ) . '/' . $client->ClientNameClean . '/' . $date;
}

sub _defaultLogFile { 'price_validation.log' }

sub _generateCommandLine {
    my ( $self, %args ) = @_;

    my $clientID    = $self->clientID();
    my $tolerance   = $self->getCommandLineArg('tolerance');
    my $fileID      = $self->getCommandLineArg('fileID');
    my $priceTypeID = $self->getCommandLineArg('priceTypeID');
    my $saleID      = $self->getCommandLineArg('saleID');
    my $importID    = $self->getCommandLineArg('catalogImportID');

    my $script = Common::RSApp::GetConfig( bookpub => 'validation_price_script' );

    my $commandLine = "$script " . " -c $clientID" . " --clear";

    $commandLine .= " -t $tolerance"                 if ($tolerance);
    $commandLine .= " -f $fileID"                    if ($fileID);
    $commandLine .= " -p $priceTypeID"               if ($priceTypeID);
    $commandLine .= " -s $saleID"                    if ($saleID);
    $commandLine .= " --catalog_import_id $importID" if ($importID);

    return $commandLine;
}

###
1;    #
###
