X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fquick-charge.cgi;h=e87be62724c2bc8c1ecd6d3f852ecfd14e411fc7;hp=07797d0c4346b6dbf56651ccb5ecd806087c58d5;hb=2457752a82358108aa078f175a4e866f1786299a;hpb=e2213aaeab76983c26d92c1e1d928fe4e062accf diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 07797d0c4..e87be6272 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -36,7 +36,7 @@ exists($curuser->agentnums_href->{$cust_main->agentnum}) my $message; -if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { +if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { #modifying an existing one-time charge $message = "One-time charge changed"; my $pkgnum = $1; die "access denied" @@ -48,18 +48,20 @@ if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { my $part_pkg = $cust_pkg->part_pkg; die "pkgnum $pkgnum is not a one-time charge" unless $part_pkg->freq eq '0'; - my ($amount, $quantity, $start_date); + my ($amount, $setup_cost, $quantity); if ( $cgi->param('amount') =~ /^\s*(\d*(\.\d{1,2})*)\s*$/ ) { $amount = sprintf('%.2f', $1); } + if ( $cgi->param('setup_cost') =~ /^\s*(\d*(\.\d{1,2})*)\s*$/ ) { + $setup_cost = sprintf('%.2f', $1); + } if ( $cgi->param('quantity') =~ /^\s*(\d*)\s*$/ ) { $quantity = $1 || 1; } - if ( $cgi->param('start_date') ) { - $start_date = parse_datetime($cgi->param('start_date')); - } else { - $start_date = time; - } + + my $start_date = $cgi->param('start_date') + ? parse_datetime($cgi->param('start_date')) + : time; $error = $cust_pkg->modify_charge( 'pkg' => scalar($cgi->param('pkg')), @@ -67,17 +69,24 @@ if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { 'additional' => \@description, 'adjust_commission' => ($cgi->param('adjust_commission') ? 1 : 0), 'amount' => $amount, + 'setup_cost' => $setup_cost, 'quantity' => $quantity, 'start_date' => $start_date, ); -} else { +} else { # the usual case: new one-time charge + $message = "One-time charge added"; - # the usual case: new one-time charge + $param->{"amount"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/ or $error .= "Illegal amount " . $param->{"amount"} . " "; my $amount = $1; + my $setup_cost = ''; + $param->{"setup_cost"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/ + or $error .= "Illegal setup_cost " . $param->{"setup_cost"} . " "; + my $setup_cost = $1; + my $quantity = 1; if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) { $quantity = $1; @@ -101,6 +110,7 @@ if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { $error ||= $cust_main->charge( { 'amount' => $amount, + 'setup_cost' => $setup_cost, 'quantity' => $quantity, 'bill_now' => scalar($cgi->param('bill_now')), 'invoice_terms' => scalar($cgi->param('invoice_terms')),