diff options
Diffstat (limited to 'httemplate/edit/process/part_pkg.cgi')
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 16 |
1 files changed, 16 insertions, 0 deletions
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 )], + } ); |