package BookPub::Import::Importer::Chegg::Version18;

use strict;

use base 'BookPub::Import::Importer::Chegg::Version17';

sub _fieldMap {
    {
        dateBegin            => 'B',
        dateEnd              => 'B',
        purchaseType         => 'L',
        rTitle               => 'E',
        rIsbn10              => 'H',
        rIsbn13              => 'G',
        rInstitution         => 'S',
        rState               => 'U',
        rPostalCode          => 'V',
        countryCode          => 'W',
        rRevenue             => 'Q',
        rListPrice           => 'N',
        rDuration            => 'K',
        rTransactionCategory => 'L',
        rComments            => 'P',
        rTaxAmount           => 'O',
    };
}

sub rTaxAmount {
    my $self    = shift;

    my $tax = $self->_getByFieldName('rTaxAmount');
    my $revenue = $self->_getByFieldName('rRevenue');

    return ( $revenue < 0 && $tax > 0 )  ? abs($tax) * -1 : $tax;
}

sub priceType {
    my $self = shift;

    my $clientID = Common::RSApp::GetClientID();

    if ( $clientID == 318 && ($self->_getByFieldName("countryCode") =~ /^US|CA$/i)) {    # MMUS Macmillan US
        return 'agency';
    }

    return 'rrp';
}

1;
