package BookPub::Import::Importer::Scribd::Version10;

use strict;

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

# map version num to the field order
sub _fieldMap {
    my $self = shift;

    my %fieldMap = (
        10 => {
            dateBegin              => 'T',
            purchaseType           => 'N',
            priceType              => 'H',
            rAuthor                => 'K',
            rTitle                 => 'J',
            rIsbn13                => 'I',
            rImprint               => 'L',
            countryCode            => 'S',
            rUnitPrice             => 'X',
            rListPrice             => 'F',
            rListPriceCurrency     => 'G',
            rPurchasePrice         => 'E',
            rPurchasePriceCurrency => 'G',
            rDiscount              => 'V',
            rRevenue               => 'C',
            currencyCode           => 'D',
            rDuration              => 'P',
            rPreviousDuration      => 'O',
            rTransactionCategory   => 'M',
        },
    );
    return $fieldMap{ $self->_version() };
}

# the discount value is sometimes blank, returning a defined discount, but
# no value for it, so I'm coercing it to be undefined in that case.
sub rDiscount {
    my $self     = shift;
    my $discount = $self->_getByFieldName('rDiscount');

    if ( defined $discount && $discount eq '' ) {
        return undef;
    }

    return $discount;
}

1;
