package BookPub::Import::Importer::Follett_Higher_Education::Version10;

use strict;

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

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

sub _fieldMap {
    {
        rState     => 'P',
        dateBegin  => 'C',
        rIsbn10    => 'F',
        rIsbn13    => 'E',
        rTitle     => 'J',
        rAuthor    => 'I',
        rSales     => 'K',
        rReturns   => 'K',
        rListPrice => 'L',
        rRevenue   => 'M',
    };
}

sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }
sub priceType    { 'rrp' }
sub countryCode  { 'US' }
sub currencyCode { 'USD' }
sub units        { 1 }

sub _useIsSaleRec { 1 }

sub rState {
    my $state = shift->SUPER::rState;

    return !$state || $state eq 'NULL' || $state eq '(blank)' ? undef : $state;
}

sub rSales {
    my $self = shift;
    my $type = $self->_getByFieldName('rSales');

    if ( $type eq 'Sale' || $type eq 'Sale Correction' || $type eq 'Standard' ) {
        return 1;
    }
    return;
}

sub rReturns {
    my $self = shift;
    my $type = $self->_getByFieldName('rReturns');

    if ( $type eq 'Refund' || $type eq 'Voided' ) {
        return 1;
    }
    return;
}

1;
