package BookPub::Import::Importer::Kobo::Version36;

use strict;

use lib '/app/tools/bookpub/lib';

use base 'BookPub::Import::Importer::Kobo::Version35';

sub _fieldMap {
    {
        dateBegin              => 'A',
        rProductType           => 'G',
        rAuthor                => 'N',
        rTitle                 => 'O',
        rIsbn13                => 'M',
        rImprint               => 'L',
        rState                 => 'C',
        rPostalCode            => 'F',
        countryCode            => 'B',
        rUnits                 => 'H',
        rAdjustments           => 'Z',
        rListPrice             => 'Q',
        rPurchasePrice         => 'W',
        rPurchasePriceCurrency => 'Y',
        rCOGS                  => 'R',
        rRevenue               => 'AA',
        currencyCode           => 'AB',
        rTaxAmount             => 'AC',
        rPromoCode             => 'J',
        rComments              => 'I',
    };
}

sub _unverifiedFieldMap {
    {
        nativeLPCurrency => 'T',
        currencyConv     => 'U',
    };
}

sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }

sub rServiceName {
    return BookPub::Tracker::Service::GetDefaultServiceName(
        service_id => shift->serviceID
    );
}

sub priceType {
    my $self      = shift;
    my $priceType = 'rrp';

    # the default price type is RRP
    if ( $self->productType eq BookPub::DB::Item::Sale::kProductTypeAudioBook ) {
        return $priceType;
    }

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

    # Hachette UK
    if ( $clientID == 355 && $self->countryCode =~ /^(AT|CA|BE|CY|FI|FR|DE|GR|IE|IT|LU|MT|NL|PT|SK|SI|ES|CH|GB|UK)$/ ) {
        $priceType = 'agency';
    }

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

    # Macmillan AU
    if ( $clientID == 348 && $self->countryCode =~ /^(AU|NZ|CA|EU|UK|US)$/ ) {
        $priceType = 'agency+tax';
    }

    return $priceType;
}


1;
