#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::Import::JBHifiMusic::v1;

use strict;

use lib '/app/tools/common/lib';
use Common::Assert;
use Common::UTF8;

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

sub _fieldMap {
    {
        dateBegin        => 'C',
        dateEnd          => 'D',
        formatType       => 'E',
        artistName       => 'H',
        upc              => 'J',
        isrc             => 'G',
        trackName        => 'I',
        albumName        => 'L',
        units            => 'M',
        countryCode      => 'B',
    }
}

sub _headerIdentifier { ( trackName => 'Track Title' ) }

sub saleDates {
    my $self = shift;

    my $dateBegin;
    my $dateEnd;

    my $startDate = $self->_getDateBegin();
    my $endDate   = $self->_getDateEnd();

    if( $startDate && $endDate )
    {
        ($dateBegin,$dateEnd) = $self->_getDates( date_begin => $startDate, date_end => $endDate, type => 'eur' );
    }

    return ($dateBegin, $dateEnd);
}

sub productType { RPS::File::Sale::TYPE_TRACK; }
sub currencyCode { 'AUD'; }
sub mediaType { RPS::DB::Item::MediaType::kMediaTypeAudio; }

sub formatType  {
    my $self = shift;
    my $fmt = $self->_getByFieldName( 'formatType' );
    if( $fmt =~ /^ps$/i )
    {
        return RPS::File::Sale::FORMAT_STREAM;
    }
    $self->fail("Unable to determine format from '$fmt'");
}

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