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

use strict;
use warnings;
use lib '/app/tools/common/lib';

use lib '/app/tools/rps/lib';
use RPS::Price::Price;
use RPS::Price::PriceLevelList;
use RPS::RoyaltyRun::RoyaltyRunStatusList;

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

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

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

    my $priceID = $args{priceID};

    if ($priceID) {
        $self->{Price} = RPS::Price::Price->new( priceID => $priceID );
    } else {
        $self->{Price} = RPS::Price::Price->new();
    }

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

    return $self;
}

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

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

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

    return $self->{Price}->PriceID();
}

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

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

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

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

    return $valid;
}

###
1;    #
###
