-
END
die unless $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
-print qq!Credit #!, $crednum, qq!!;
+my $credited = $cust_credit->credited;
+
+print "Credit # $crednum".
+ qq!!.
+ '
Date: '. time2str("%D", $cust_credit->_date). ''.
+ '
Amount: $'. $cust_credit->amount. ''.
+ "
Unapplied amount: \$$credited".
+ '
Reason: '. $cust_credit->reason. ''
+ ;
+
+my @cust_bill = grep $_->owed != 0,
+ qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );
+
+print <
+function changed(what) {
+ cust_bill = what.options[what.selectedIndex].value;
+END
+
+foreach my $cust_bill ( @cust_bill ) {
+ my $invnum = $cust_bill->invnum;
+ my $changeto = $cust_bill->owed < $cust_credit->credited
+ ? $cust_bill->owed
+ : $cust_credit->credited;
+ print <
+END
-print qq!\nInvoice #