package BookPub::Import::Importer::VitalSource::Version6;

use strict;

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

sub _fieldMap {
    {
        dateBegin  => 'A3',
        rIsbn13    => 'C',
        rTitle     => 'B',
        rUnits     => 'D',
        rListPrice => 'E',
        rDiscount  => 'F',
        rUnitPrice => 'G',
        rRevenue   => 'H',
    };
}

sub _autoParseTitleAndSubtitle { 1 }

sub _isSaleRec {
    my $self = shift;

    my $units     = $self->_getByFieldName('rUnits');
    my $unitPrice = $self->_getByFieldName('rUnitPrice');
    my $isbn      = $self->_getByFieldName('rIsbn13');
    my $title     = $self->_getByFieldName('rTitle');

    # We're going to skip the subtotal lines, which are blank for these fields
    if ( ( !$units && !$unitPrice && !$isbn && !$title ) || ( !$units == '' && $unitPrice == '' && $isbn == '' && $title == '' ) ) {
        return 0;
    }

    return $self->BookPub::Import::Importer::_isSaleRec();
}

###
1;    # Play nicely.
###
