package BookPub::Import::Importer::CopyrightClearance::Version2;

use strict;
use Data::Dumper;

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

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

sub productType { BookPub::DB::Item::Sale::kProductTypeEBook }

sub rPurchasePriceCurrency {
    my $self = shift;

    return $self->currencyCode();
}

# we're being proviced the amount of the discount, so we derive the
# percentage here...
sub rDiscount {
    my $self          = shift;
    my $charge        = $self->_getByFieldName('rDiscount');
    my $purchasePrice = $self->_getByFieldName('rPurchasePrice');
    my $discount;

    if ( $charge && $purchasePrice != 0 ) {
        $discount = $charge / $purchasePrice;
    }

    return $discount;
}

1;
