package BookPub::Import::Importer::Amazon::Version60;

use strict;

use lib '/app/tools/bookpub/lib';
use base 'BookPub::Import::Importer';

sub _fieldMap {
    {
        serviceProductID       => 'B',
        rClientProductID       => 'B',
        rListPrice             => 'C',
        rRevenue               => 'D',
        dateBegin              => 'A',
    };
}

sub _headerIdentifier { ( rRevenue => 'Payment Amount' ) }
sub _isSaleRec   { shift->dateBegin }

sub rServiceName { 'Amazon' }
sub priceType    { 'rrp' }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }
sub rProductType { shift->productType() }

sub countryCode  { 'US' }
sub currencyCode { 'USD' }
sub discount { 0 }
sub rDiscount { 0 }

sub rUnits {
    my $self = shift;
    my $revenue = $self->rRevenue();
    return $revenue <=> 0;
}

sub rRevenue {
    my $self    = shift;
    my $revenue = $self->SUPER::rRevenue();

    if ( $revenue =~ s/[)(]//g ) {
        $revenue *= -1;
    }

    return $revenue;
}

1;
