package BookPub::Import::Importer::BolindaDigital::Version6;

use strict;

use lib '/app/tools/common/lib';
use Common::CurrencyFormat;

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

sub _fieldMap {
    my $self = shift;

    my %fieldMap = (
        6 => {
            currencyCode       => 'A4',
            countryCode        => 'A',
            dateBegin          => 'A2',
            dateEnd            => 'A2',
            rIsbn13            => 'B',
            rTitle             => 'C',
            rAuthor            => 'D',
            rImprint           => 'F',
            rUnits             => 'I',
            rListPrice         => 'G',
            rListPriceCurrency => 'A',
            rDiscount          => 'H',
            rRevenue           => 'K',
        },
    );

    return $fieldMap{ $self->_version() };
}

sub _unverifiedFieldMap {
    my $self = shift;

    my %fieldMap = (
        6 => {
            subtotalCheck => 'J',
        },
    );

    return $fieldMap{ $self->_version() };
}

sub rListPriceCurrency {
    my $self        = shift;
    my $countryCode = $self->_getByFieldName('rListPriceCurrency');

    if ( $countryCode eq "NZ" || $countryCode eq 'AU' ) {
        return "AUD";
    }
    if ( $countryCode eq "GB" || $countryCode eq 'IE' ) {
        return "GBP";
    }
    $self->fail("Invalid country code: $countryCode");
}

1;
