package BookPub::Import::Importer::Kobo::Version6;

use strict;

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

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

# We have to do some odd things with the field map here because this importer has
# different column definitions of seperate tabs.  The map is defined by tab name below.
# The summary tab is ignored (returns and empty field set).
sub _fieldMap {
    my $self = shift;

    my $map = {
        'us non taxable' => {
            currencyCode => 'L',
            countryCode  => 'B',
            dateBegin    => 'A',
            isbn         => 'F',
            rTitle       => 'H',
            rAuthor      => 'G',
            rUnits       => 'E',
            rListPrice   => 'I',
            rCOGS        => 'J',
            rRevenue     => 'K',
        },
        'us taxable' => {
            currencyCode => 'L',
            countryCode  => 'B',
            dateBegin    => 'A',
            isbn         => 'F',
            rTitle       => 'H',
            rAuthor      => 'G',
            rUnits       => 'E',
            rListPrice   => 'I',
            rCOGS        => 'J',
            rRevenue     => 'K',
        },
        'ca' => {
            currencyCode => 'K',
            countryCode  => 'B',
            dateBegin    => 'A',
            isbn         => 'E',
            rTitle       => 'G',
            rAuthor      => 'F',
            rUnits       => 'D',
            rListPrice   => 'H',
            rCOGS        => 'I',
            rRevenue     => 'J',
        },
        'world' => {
            currencyCode => 'K',
            countryCode  => 'B',
            dateBegin    => 'A',
            isbn         => 'E',
            rTitle       => 'G',
            rAuthor      => 'F',
            rUnits       => 'D',
            rListPrice   => 'H',
            rCOGS        => 'I',
            rRevenue     => 'J',
        },
    };

    my $sheet = lc( $self->sheetname ) || return {};
    return {} if ( $sheet =~ /(summary)/i );

    die "Unrecognized tab name '" . $self->sheetname . "'" unless ( $map->{$sheet} );

    return $map->{$sheet};
}

sub priceType    { 'agency' }
sub purchaseType { BookPub::DB::Item::Sale::kPurchaseTypeDownload }
sub productType  { BookPub::DB::Item::Sale::kProductTypeEBook }

1;
