package BookPub::Import::Importer::OLF::Version12;

use strict;

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

use base 'BookPub::Import::Importer::OLF';

sub _unverifiedFieldMap {
    my $self = shift;

    my %fieldMap = (
        12 => {
            month => 'B32',
            year  => 'B29',
        },
    );

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

sub priceType {
    my $self     = shift;
    my $clientID = Common::RSApp::GetClientID;

    if ( $clientID == 318 ) {    # MMUS
        return 'rrp';
    } elsif ( $clientID == 359 ) {    # MMUK
        return 'rrp+tax';
    } else {
        return;
    }
}

sub _dateFormat { [ 'iso', 'numerical' ] }

sub _getDateBegin {
    my $self  = shift;
    my $month = $self->_getByFieldName('month');
    my $year  = $self->_getByFieldName('year');

    my $string = sprintf( "%04d-%02d-01", $year, $month );
    my $date = new Common::Date($string);

    return $date;
}

sub _getDateEnd {
    my $self    = shift;
    my $dateEnd = $self->_getDateBegin();

    return $dateEnd;
}

sub currencyCode {
    my $self = shift;
    my $code = $self->_getByFieldName('currencyCode');

    if ( $code eq 'LS' ) {
        return 'GBP';
    } elsif ( $code eq 'US' ) {
        return 'USD';
    }
}

sub rListPriceCurrency {
    my $self = shift;

    return $self->currencyCode();
}

sub rPurchasePriceCurrency {
    my $self = shift;

    return $self->currencyCode();
}

1;
