|
use base ( 'Business::Shipping' ); $VERSION = do { my @r =( q$Revision: 1.3 $ =~/\d+/g); sprintf "%d." . "%03d" x $#r , @r };
new_hash_init => 'new' ,
grouped_fields_inherit => [
'required' => [
'service' ,
'from_zip' ,
'shipper' ,
],
'optional' => [
'from_country' ,
'to_country' ,
'to_zip' ,
'from_city' ,
'to_city' ,
],
'unique' => [
'service' ,
'from_zip' ,
'from_country' ,
'to_country' ,
'to_zip' ,
'from_city' ,
'to_city' ,
],
],
object_list => [
'Business::Shipping::Package' => {
'slot' => 'packages' ,
},
];
sub weight { return shift ->default_package->weight( @_ ); }
sub total_weight
{
my $self = shift ;
my $total_weight ;
foreach my $package ( @{ $self ->packages() } ) {
$total_weight += $package ->weight();
}
return $total_weight ;
}
sub default_package {
my $self = shift ;
if ( not defined $self ->packages_index( 0 ) ) {
debug( 'No default package defined yet, creating one...' );
$self ->packages_push( Business::Shipping::Package->new() );
}
$self ->packages_index( 0 );
}
1;
|