package RPS::Import::Boundee::v2;

use strict;

use lib '/app/tools/common/lib';
use Common::Date;
use Common::Log;
use Common::Util qw(normalize_upc);

use lib '/app/tools/rps/lib';
use base 'RPS::Import::Boundee::Digital';

use Data::Dumper;

sub _headerIdentifier { ( type => 'Type' ) }

sub _fieldMap {
    {
        # Data
        upc              => 'B',
        dateBegin        => 'C',
        dateEnd          => 'C',
        type             => 'G',
        artistName       => 'O',
        albumName        => 'D',
        isrc             => 'N',
        trackName        => 'P',
        units            => 'L',
        sales            => 'R',
    }
}

sub _unverifiedFieldMap {
    {
        commission       => 'T',
    }
}

sub _dateFormat { 'numerical_year_first' }


sub price {
    my $self = shift;

    my $sales = $self->_getByFieldName('sales');
    my $commission = $self->_getByFieldName('commission');
    my $price = $sales - $commission;

    return $price;

}


sub upc { 
	my $self = shift;
	my $upc = $self->_getByFieldName( 'upc' );  

    if ((length($upc) != 12 && length($upc) != 13) || $upc =~ /\D/) {
            return undef;
    }
	
    return $upc;
}



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