package BookPub::Import::Importer::OverDrive::Version4;

use strict;

use lib '/app/tools/bookpub/lib';
use base 'BookPub::Import::Importer::OverDrive::Base';

sub _fieldMap {
    {
        countryCode => 'H',
        dateBegin   => 'A',
        rIsbn13     => 'C',
        rTitle      => 'D',
        rSubtitle   => 'E',
        rAuthor     => 'F',
        rFormat     => 'I',
        rListPrice  => 'J',
        rDiscount   => 'K',
        rRevenue    => 'L',
    };
}

sub units { shift->rRevenue >= 0 ? 1 : -1 }

sub priceType {
    my $self     = shift;
    my $discount = $self->_getByFieldName('rDiscount');
    my $clientID = Common::RSApp::GetClientID();

    # Special behavior for Hachette (308) and Wiley (324)
    if ( $discount eq '30%' && ( $clientID == 308 || $clientID == 324 ) ) {
        return 'agency';
    } else {
        return 'rrp';
    }

}

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

###
1;    # Play nicely.
###
