X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fcredit-cust_bill_pkg.html;h=75900bde5a0b10b9304548f131bd7f50d5a1384f;hb=3cda3a85eb0daa5b8b9f4d30cd0896da6ccf4a9b;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..75900bde5 100644 --- a/httemplate/edit/process/credit-cust_bill_pkg.html +++ b/httemplate/edit/process/credit-cust_bill_pkg.html @@ -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 );