X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcredit-cust_bill_pkg.html;h=12b68c0f5f59949178e7b8a922d52deaa5a3a543;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hp=8e66368d4bc54096a735246dc310c5e6a82e193a;hpb=54a357b171aa44f9399b4c146acd2afd3b686075;p=freeside.git diff --git a/httemplate/edit/process/credit-cust_bill_pkg.html b/httemplate/edit/process/credit-cust_bill_pkg.html index 8e66368d4..12b68c0f5 100644 --- a/httemplate/edit/process/credit-cust_bill_pkg.html +++ b/httemplate/edit/process/credit-cust_bill_pkg.html @@ -3,7 +3,7 @@ %} else { <& /elements/header-popup.html, 'Credit successful' &> % } @@ -27,19 +27,35 @@ foreach my $billpkgnum_setuprecur (@billpkgnum_setuprecurs) { push @amounts, $amount; } -my $error = FS::cust_credit->credit_lineitems( +my $reasonnum = $cgi->param('reasonnum'); +$reasonnum =~ /^(-?\d+)$/ or die "Illegal reasonnum"; +$reasonnum = $1; + +my $error; +if ($reasonnum == -1) { + my $new_reason = FS::reason->new({ + map { $_ => scalar( $cgi->param("select_reason_new_$_") ) } + qw( reason_type reason ) + }); + $error = $new_reason->insert; + $reasonnum = $new_reason->reasonnum; +} + +if ( !$reasonnum ) { + $error ||= 'Reason required' +} + +$error ||= FS::cust_credit->credit_lineitems( #the lineitems to credit 'billpkgnums' => \@billpkgnums, 'setuprecurs' => \@setuprecurs, 'amounts' => \@amounts, 'apply' => ( $cgi->param('apply') eq 'yes' ), + 'reasonnum' => $reasonnum, - #the credit - 'newreasonnum' => scalar($cgi->param('newreasonnum')), - 'newreasonnum_type' => scalar($cgi->param('newreasonnumT')), map { $_ => scalar($cgi->param($_)) } #fields('cust_credit') - qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum + qw( custnum _date amount addlinfo ), #pkgnum eventnum );