package BookPub::Import::Importer::OLF::Version11;

use strict;

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

use base 'BookPub::Import::Importer::OLF';

sub _unverifiedFieldMap {
    my $self = shift;

    my %fieldMap = (
        11 => {
            month => 'B33',
            year  => 'B30',
            vat   => 'W',
            novat => 'X',
        },
    );

    return $fieldMap{ $self->_version() };
}

sub priceType { 'rrp' }
sub _dateFormat { [ 'iso', 'numerical' ] }

sub rTaxUnitPrice {
    my $self  = shift;
    my $vat   = $self->_getByFieldName('vat');
    my $novat = $self->_getByFieldName('novat');

    return $vat - $novat;
}

sub _getDateBegin {
    my $self  = shift;
    my $month = $self->_getByFieldName('month');
    my $year  = $self->_getByFieldName('year');

    my $string = sprintf( "%04d-%02d-01", $year, $month );
    my $date = new Common::Date($string);

    return $date;
}

sub _getDateEnd {
    my $self    = shift;
    my $dateEnd = $self->_getDateBegin();

    return $dateEnd;
}

1;
