package BookPub::Import::Importer::Amazon::Version84;

use strict;
use warnings;

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


sub _fieldMap {
    {
        dateBegin              => 'D',
        purchaseType           => 'BO',
        rAuthor                => 'I',
        rTitle                 => 'H',
        rIsbn13                => 'F',
        rState                 => 'AH',
        rPostalCode            => 'X',
        countryCode            => 'Y',
        serviceProductID       => 'G',
        rUnits                 => 'K',
        rListPrice             => 'M',
        rListPriceCurrency     => 'N',
        rPurchasePrice         => 'O',
        rPurchasePriceCurrency => 'P',
        rRevenue               => 'BK',
        currencyCode           => 'BL',
        rTaxAmount             => 'BM',
        isFree                 => 'L',
        rModel                 => 'BO',
        rTransactionCategory   => 'L',
    };
}

sub _unverifiedFieldMap {
    {
        transactionStatus         => 'L',
        transactionType           => 'R',
        pubRewardsCredits         => 'BP',
        pubRewardsCreditsCurrency => 'BQ',
        netCogs                   => 'BR',
    };
}

sub _headerIdentifier { currencyCode => 'payment_amount_currency' }


sub _isSaleRec {
    my $self = shift;

    my $pubRewardsCredits = $self->_getByFieldName('pubRewardsCredits');
    my $pubRewardsCreditsCurrency = $self->_getByFieldName('pubRewardsCreditsCurrency');
    my $netCogs = $self->_getByFieldName('netCogs');

    if ( $pubRewardsCredits || $pubRewardsCreditsCurrency || $netCogs ) {
        $self->fail("Data is present in the last three columns.");
    }

    return $self->SUPER::_isSaleRec(@_);
}


1;
