package BookPub::Import::Importer::Christianaudio::Version2;

use strict;

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

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

sub _fieldMap {
    {
        rIsbn13    => 'H',
        rTitle     => 'G',
        rUnits     => 'I',
        rListPrice => 'N',
        rRevenue   => 'O',
    };
}

sub _unverifiedFieldMap {
    { subscriptionPrice => 'M', };
}

sub priceType    { 'rrp' }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeAudioBook }

sub countryCode  { 'US' }
sub currencyCode { 'USD' }

# filename is of format hbg-YYYY-MM.xls
#
sub _getDateBegin {
    my $self     = shift;
    my $filename = $self->filename;

    if ( $filename =~ /(\d{4}-\d{2})\./ ) {
        return $1 = $1;
    } else {
        die "Unable to determine date from filename";
    }

    return;
}

sub _getDateEnd {
    shift->_getDateBegin();
}

sub _dateNormalization { 'month' }

1;
