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

package RPS::Report::Dynamic::Sales::Physical;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/report/lib';
use lib '/app/tools/rps/lib';
use lib '/app/tools/appuser/lib';

use Common::Log;
use Common::Assert;
use File::Path;
use AppUser::DB::Item::AccessLevel;
use Text::CSV::Encoded;
use Report::Dynamic::Parameters;

use RPS::DB::Item::DynamicReport::Sales::Base;

use base 'RPS::Report::Dynamic::Sales::Base';

sub Type         { 'Physical'; }
sub FilenameType { 'Sales_Physical' }

# defined at the end of this file
#
sub _ParamClass { 'RPS::Report::Dynamic::Sales::Physical::Parameters'; }

sub _getPrice {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return undef;
}

sub _getUnits {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return $rowItem->sales() - $rowItem->returns();
}

sub _getExtPrice {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return $rowItem->total_revenue();
}

sub _getNativePrice {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return undef;
}

sub _getNativeExtPrice {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return $rowItem->conversion_rate() * $rowItem->total_revenue();
}

sub _getNativeNetPrice {
    my ( $self, %args ) = @_;
    my $rowItem   = $args{row};
    my $fieldName = $args{field};

    return $rowItem->total_revenue() * $rowItem->conversion_rate() * ( 1 - $rowItem->dist_fee() );
}

1;

package RPS::Report::Dynamic::Sales::Physical::Parameters;
use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/report/lib';
use lib '/app/tools/rps/lib';
use base 'RPS::Report::Dynamic::Sales::Parameters';

1;
