package BookPub::Import::Importer::PeterPal::Version2;
use strict;

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

sub _headerIdentifier { ( rTitle => 'Product title' ) }

sub _dateFormat  { ['numerical_year_first', 'iso'] }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }

sub priceType {
    my $self = shift;

   my %priceTypes = (
        "01" => "rrp",
        "02" => "rrpplustax",
        "41" => "agency",
        "42" => "agencyplustax"
    );

    my $priceType = $self->_getByFieldName( 'priceType' );

    if(!$priceType) {
        $priceType = $self->_getByFieldName( 'secondaryPriceType' );
    }

    return $priceTypes{$priceType} || $priceType;
}

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

    if(!$rListPrice) {
        $rListPrice = $self->_getByFieldName( 'secondaryListPrice' );
    }

    return $rListPrice;
}

sub countryCode {
    my $self = shift;
    my $code = $self->_getByFieldName( 'countryCode' );

    if($code =~ /AU-NS/i) {
        return 'AU';
    }

    return $code;
}

sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }


1;
