X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_pkg.cgi;fp=httemplate%2Fedit%2Fprocess%2Fpart_pkg.cgi;h=69138bc65eb17c15973abb6f6a2ae3d436d14e58;hp=82c4e1e1583b31e9d7a911e92bfbc3a63ac15011;hb=4427ad71b12bf27eac2a05d88141a82f9372d03f;hpb=76275769ed7ea66b154aef4d2dd00120a53196df diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 82c4e1e15..69138bc65 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -264,6 +264,21 @@ if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) { }; } +my $targets = FS::part_pkg_usageprice->targets; +foreach my $amount_param ( grep /^usagepricepart(\d+)_amount$/, $cgi->param ) { + $amount_param =~ /^usagepricepart(\d+)_amount$/ or die 'unpossible'; + my $num = $1; + my $amount = $cgi->param($amount_param); + if ( ! $amount && ! $cgi->param("usagepricepart${num}_price") ) { + #don't add empty rows just because the dropdowns have a value + $cgi->param("usagepricepart${num}_$_", '') for qw( currency action target ); + next; + } + my $target = $cgi->param("usagepricepart${num}_target"); + $amount *= $targets->{$target}{multiplier} if $targets->{$target}{multiplier}; + $cgi->param($amount_param, $amount); +} + my @process_o2m = ( { 'table' => 'part_pkg_msgcat', @@ -272,6 +287,7 @@ my @process_o2m = ( { 'table' => 'part_pkg_usageprice', 'fields' => [qw( price currency action target amount )], + } );