#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::Report::UKMechMissedSales;
use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::FormObject;
use Common::Assert;
use Common::Client;
use Common::Locale;

use lib '/app/tools/rps/lib';
use RPS::DB::Item::MechanicalRunMissedSaleLog;
use RPS::DB::Item::SaleRunMap;

use base 'RPS::Report';

sub _baseXMLName { 'MissedSale' }

sub _getDBItem() {
    my $self  = shift;
    my %args  = @_;
    my $runID = $args{runID};

    return RPS::DB::Item::MechanicalRunMissedSaleLog->GetByRunIDAndType( $runID, RPS::DB::Item::SaleRunMap::kRunTypeUKMechanical );
}

sub _reportColumns {
    my $self = shift;

    return (
        "CatalogNumber" => "Catalog #",
        "AlbumTitle"    => "Album Title",
        "ArtistName"    => "Artist",
        "ProductType"   => "Product",
        "Units"         => "Units",
        "Reason"        => "Reason",
        "Details"       => "Details",
    );
}

sub _fillInHash {
    my ( $self, $logLine ) = @_;

    my %data;

    $data{ArtistName}    = $logLine->artist_name;
    $data{CatalogNumber} = $logLine->catalog_number;
    $data{AlbumTitle}    = $logLine->album_title;
    $data{AlbumID}       = $logLine->album_id;
    $data{ProductID}     = $logLine->product_id;
    $data{ProductType}   = $logLine->product_type;
    $data{ProductTypeID} = $logLine->product_type_id;
    $data{Units}         = Common::Client::Current()->Locale()->formatNumber( $logLine->units );
    $data{TotalRevenue}  = Common::Client::Current()->Locale()->formatMoney( $logLine->total_revenue );
    $data{Reason}        = $logLine->reason;
    $data{Details}       = $logLine->details;

    return \%data;
}

###
1;    #
###
