package BookPub::Import::Importer::Word;

use strict;

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

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

sub _fieldMap {
    my $self = shift;

    my %fieldMap = (
        1 => {
            serviceProductID => 'A',
            countryCode      => 'K',
            dateBegin        => 'J',
            rIsbn13          => 'D',
            rTitle           => 'C',
            rAuthor          => 'B',
            rSales           => 'H',
            rReturns         => 'I',
            rListPrice       => 'F',
            rPurchasePrice   => 'E',
            rTaxAmount       => 'G',
            rDiscount        => 'O',
            rRevenue         => 'L',

        },
    );

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

sub _useIsSaleRec          { 1 }
sub priceType              { 'agency' }
sub purchaseType           { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType            { BookPub::DB::Item::Sale::kProductTypeEBook }
sub currencyCode           { 'AUD' }
sub rListPriceCurrency     { 'AUD' }
sub rPurchasePriceCurrency { 'AUD' }

sub rDiscount {
    my $self = shift;

    my $discount = $self->_getByFieldName('rDiscount');
    if ( $discount =~ / (\d+)%/ ) {
        $discount = 1 - ( $1 / 100 );
        return $discount;
    }
}

1;
