package BookPub::Import::Importer::Booktopia::Version4;

use strict;

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

sub _fieldMap {
    return {
        currencyCode           => 'K',
        rAuthor                => 'D',
        rTitle                 => 'C',
        rIsbn13                => 'B',
        countryCode            => 'J',
        rUnits                 => 'E',
        rListPrice             => 'G',
        rListPriceCurrency     => 'K',
        rPurchasePrice         => 'F',
        rPurchasePriceCurrency => 'K',
        rRevenue               => 'I',
    };
}

sub priceType { 'rrp' }

sub rListPriceCurrency { shift->_getByFieldName('rListPriceCurrency') }

sub isFree {
    my $self = shift;

    return ( $self->rListPrice == 0 ) ? 'Y' : 'N';
}

sub rDiscount { undef }

sub rTaxAmount {
    my $self = shift;

    return $self->rTaxUnitPrice * $self->rUnits;
}

sub rTaxUnitPrice {
    my $self = shift;

    return $self->rPurchasePrice - $self->rListPrice;
}

1;
