#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Admin::Mcps::Form;

use strict;
use Data::Dumper;

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

use lib '/app/tools/rps/lib';
use RPS::Product::TypeList;
use RPS::CountryList;
use RPS::RoyaltyRun::RoyaltyRunStatusList;

use lib '/app/tools/admin/lib';
use Admin::Mcps::DefaultRoyaltyRateList;
use Admin::Mcps::ExportAllowanceList;
use Admin::Mcps::ExportUpliftHash;
use Admin::Mcps::RetentionRateList;
use Admin::Mcps::SalesPricingMode;

use Common::FormObject;
use base 'Common::FormObject';

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my $clientID = Common::RSApp::GetClientID();

    $self->{DefaultRoyaltyRateList} = Admin::Mcps::DefaultRoyaltyRateList->new();
    $self->{RetentionRateList}      = Admin::Mcps::RetentionRateList->new();
    $self->{ExportAllowanceList}    = Admin::Mcps::ExportAllowanceList->new();
    $self->{ExportUpliftList}       = Admin::Mcps::ExportUpliftHash->new();
    $self->{SalesPricingMode}       = Admin::Mcps::SalesPricingMode->new( clientID => $clientID );

    $self->{TypeList}    = RPS::Product::TypeList->new();
    $self->{CountryList} = RPS::CountryList->new();

    $self->{RoyaltyRunStatus} = new RPS::RoyaltyRun::RoyaltyRunStatusList( ukMechanical => 1 );

    return $self;
}

sub _propertyIsEditable {
    my ( $self, $propertyName ) = @_;

    # The ExportUpliftList (and contained objects) and Sales PricingMode can be edited.
    #
    if ( $propertyName eq 'ExportUpliftList' || $propertyName eq 'SalesPricingMode' ) {
        return 1;
    }
    return 0;
}

sub save {
    my ($self) = @_;

    $self->{ExportUpliftList}->save();
    $self->{SalesPricingMode}->save();
}

###
1;    #
###
