3 $cgi->param('crednum') =~ /^(\d*)$/ or die "Illegal crednum!";
6 my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } )
7 or die "No such crednum";
9 my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_credit->custnum } )
10 or die "Bogus credit: not attached to customer";
12 my $custnum = $cust_main->custnum;
15 if ($cgi->param('invnum') =~ /^Refund$/) {
16 $new = new FS::cust_refund ( {
17 'reason' => $cust_credit->reason,
18 'refund' => $cgi->param('amount'),
20 #'_date' => $cgi->param('_date'),
22 'crednum' => $crednum,
25 $new = new FS::cust_credit_bill ( {
27 $_, scalar($cgi->param($_));
28 #} qw(custnum _date amount invnum)
29 } fields('cust_credit_bill')
33 my $error = $new->insert;
36 $cgi->param('error', $error);
37 print $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string );
39 print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");