package BookPub::Import::Importer::Google::Version10;

use strict;

use Common::Assert;
use Data::Dumper;

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

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

sub _fieldMap {
    {
        dateBegin          => 'B',
        rUnits             => 'E',
        rIsbn13            => 'G',
        rImprint           => 'H',
        rTitle             => 'I',
        rAuthor            => 'J',
        rListPriceCurrency => 'K',
        rListPrice         => 'L',
        countryCode        => 'M',
        rState             => 'N',
        rPostalCode        => 'O',
        rCOGS              => 'R',
        currencyCode       => 'T',
        rRevenue           => 'U',
    };
}

sub _unverifiedFieldMap {
    { unvConversionRate => 'W', };
}

sub priceType { 'agency' }

sub revenue {
    my $self = shift;

    my $convRate = $self->_getByFieldName('unvConversionRate');
    my $rRev     = $self->_getByFieldName('rRevenue');

    if ( !$convRate || $convRate == '' ) {
        $convRate = 1;
    }

    return $convRate * $rRev;

}

sub rAuthor {
    my $self = shift;

    my $author = $self->SUPER::rAuthor;

    $author =~ s/ ~autofilled~$//;

    return $author;
}

sub rTitle {
    my $self = shift;

    my $title = $self->SUPER::rTitle;

    $title =~ s/ ~autofilled~$//;

    return $title;
}

1;
