package BookPub::Import::Importer::EDMap;

use strict;

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

sub _headerIdentifier { ( rTitle => 'Title' ) }

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

    my %fieldMap = (
        1 => {
            dateBegin    => 'E',
            rTitle       => 'D',
            rIsbn13      => 'C',
            rInstitution => 'A',
            rUnits       => 'G',
            rListPrice   => 'V',
            rPromoCode   => 'O',
        },
    );

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

sub purchaseType       { BookPub::DB::Item::Sale::kPurchaseTypeSubscriptionDL }
sub productType        { BookPub::DB::Item::Sale::kProductTypeEBook }
sub priceType          { 'rrp' }
sub countryCode        { 'US' }
sub currencyCode       { 'USD' }
sub rListPriceCurrency { 'USD' }
sub rDiscount          { 0 }

sub _dateFormat { [ 'us', 'iso' ] }
sub _useIsSaleRec              { 1 }
sub _autoParseTitleAndSubtitle { 1 }

sub rRevenue {
    my $self  = shift;
    my $list  = $self->_getByFieldName('rListPrice');
    my $units = $self->_getByFieldName('rUnits');

    my $revenue = $list * $units;

    return $revenue;
}

1;
