package BookPub::Import::Importer::DNAML::Version1;

use strict;

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

sub priceType { 'agency' }

sub _fieldMap {
    {
        # In the header
        dateBegin    => 'C',
        rDiscount    => 'E',
        currencyCode => 'G',

        # In the data
        rTitle      => 'B',
        countryCode => 'F',
        rIsbn13     => 'C',
        rListPrice  => 'D',
        rRevenue    => 'G',
        rUnitPrice  => 'E',
    };
}

sub _preProcess {
    my $self = shift;
    my %args = @_;

    Log->info("Starting _preProcess");
    $self->SUPER::_preProcess(%args);

    my $foundDataTab = 0;
    my $sheetnum     = 0;
    foreach my $sheet ( @{ $args{sheets} } ) {
        my $sheetname = $args{sheet_names}->[$sheetnum];
        $sheetnum++;

        if ( $sheetname =~ /Data/i ) {
            $foundDataTab = 1;
        }
    }

    if ( $foundDataTab == 1 ) {
        $self->errstr('Found Data tab - importer must be updated to support this file');
        return undef;
    }

}

1;
