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

use strict;
use warnings;

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

use lib '/app/tools/rps/lib';
use RPS::DistributorContract::DistributorContractList;
use RPS::DistributorPayee::DistributorPayee;
use RPS::DB::Item::DistributorContract;
use RPS::CountryList;
use RPS::StateList;
use RPS::Payor::PayorList;

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

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

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

	if($args{distributorPayeeID})
	{
		$self->{DistributorPayee} = RPS::DistributorPayee::DistributorPayee->new(distributorPayeeID => $args{distributorPayeeID});

        $self->{DistributorContractList} = RPS::DistributorContract::DistributorContractList->new(distributorPayeeID => $args{distributorPayeeID});
	}
	else
	{
		$self->{DistributorPayee} = RPS::DistributorPayee::DistributorPayee->new();
	}

    $self->{CountryList} = RPS::CountryList->new();
    $self->{StateList} = RPS::StateList->new();
    $self->{PayorList} = RPS::Payor::PayorList->new();

	return $self;
}

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

	# The Product (and contained objects) can be edited.
	#
	if ($propertyName eq 'DistributorPayee')
	{
		return 1;
	}

	return 0;
}

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

	$self->{DistributorPayee}->save();
}


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

	my $valid = $self->{DistributorPayee}->validate();
	return $valid;
}



sub getDistributorPayeeID
{
	my ($self) = @_;
	return $self->{DistributorPayee}->DistributorPayeeID();
}


###
1;#
###
