summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/part_pkg.cgi
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-01-07 22:55:58 -0800
committerIvan Kohler <ivan@freeside.biz>2014-01-07 22:55:58 -0800
commit4427ad71b12bf27eac2a05d88141a82f9372d03f (patch)
tree77c01abea411f601df63bc2bae722504e03ff5e1 /httemplate/edit/process/part_pkg.cgi
parent76275769ed7ea66b154aef4d2dd00120a53196df (diff)
time/data/etc. unit pricing add-ons, RT#24392
Diffstat (limited to 'httemplate/edit/process/part_pkg.cgi')
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi16
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 )],
+
}
);