package RPS::Import::Universal::v65;

use strict;

use base 'RPS::Import::Universal::v33';

sub _fieldMap {
    {
        labelName    => 'C',
        serviceID    => 'J',
        dateBegin    => 'G',
        countryCode  => 'A',
        artistName   => 'D',
        productType  => 'H',
        formatType   => 'I',
        units        => 'M',
        price        => 'P',
        currencyCode => 'L',
    };
}

sub _unverifiedFieldMap {
    {
        itemID => 'F',    # upc or isrc
        title  => 'E',    # album or track name
    };
}

sub _headerIdentifier { ( dateBegin => 'Sales Period' ) }

sub currencyCode {
    return shift->RPS::Import::Importer::currencyCode();
}

sub albumName {
    my $self  = shift;
    my $title = $self->_getByFieldName('title');
    return $title if ( $self->productType eq RPS::File::Sale::TYPE_ALBUM );

    if ( !defined $self->productType ) {
        my $upc = $self->_getByFieldName('upc');
        $upc =~ s/^10//;    # remove leading "10"
        return $title if ( $upc =~ /^\d+$/ );    # if it's all numbers then it might be a UPC ...
    }
}

sub trackName {
    my $self  = shift;
    my $title = $self->_getByFieldName('title');
    return $title if ( $self->productType eq RPS::File::Sale::TYPE_TRACK );

    if ( !defined $self->productType ) {
        my $isrc = $self->_getByFieldName('itemID');
        $isrc =~ s/^5//;                         # remove leading "5"
        return $title if ( $isrc =~ /^[a-z]{2}/i );    # if it starts with 2 letters then it might be an ISRC ...
    }
}

1;
