package BookPub::Import::Importer::ColumbiaSouthernUniversity::v3;

use strict;

use lib '/app/tools/common/lib';

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

sub _fieldMap {
    {
        # Header
        currencyCode => 'H1',

        # Body
        rPurchaseType => 'M',
        priceType     => 'S',
        rDistributor  => 'C',
        rServiceName  => 'D',

        conversionRate => 'AB',

        countryCode => 'P',
        rState      => 'N',
        rPostalCode => 'O',

        dateBegin => 'A',
        dateEnd   => 'B',

        rProductType => 'K',
        rFormat      => 'L',
        isbn         => 'E',
        rTitle       => 'F',
        rSubtitle    => 'G',
        rAuthor      => 'H',
        rImprint     => 'J',

        rUnits                 => 'T',
        rListPrice             => 'W',
        rListPriceCurrency     => 'X',
        rPurchasePrice         => 'U',
        rPurchasePriceCurrency => 'V',
        rTaxAmount             => 'Z',
        rDiscount              => 'Y',
        rUnitPrice             => 'AC',
        rRevenue               => 'AD',

        rDuration    => 'R',
        rInstitution => 'Q',
    }
}

sub _unverifiedFieldMap {
    {
        headerUnits   => 'D1',
        headerRevenue => 'F1',
    }
}

sub priceType {
    my $self = shift;

    my $type = $self->_getByFieldName("priceType");
    return $type if $type;

    $self->fail("Could not determine price type from '$type'");
}

1;
