package BookPub::Import::Importer::Kobo::Version29;

use strict;

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

sub _headerIdentifier { ( isbn => 'eISBN' ) }

# 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 = {
        'sales' => {
            currencyCode           => 'U',
            conversionRate         => 'S',
            countryCode            => 'C',
            rState                 => 'D',
            rPostalCode            => 'E',
            dateBegin              => 'A',
            isbn                   => 'J',
            rTitle                 => 'L',
            rAuthor                => 'K',
            rImprint               => 'I',
            rSales                 => 'F',
            rReturns               => 'G',
            rListPrice             => 'N',
            rListPriceCurrency     => 'R',
            rPurchasePrice         => 'M',
            rPurchasePriceCurrency => 'R',
            rCOGS                  => 'P',
            rRevenue               => 'T',
        },
    };

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

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

    return $map->{$sheet};
}

1;
