- $error = $cust_bill_pay->insert;
- if ( $error =~
- /total cust_bill_pay.amount and cust_credit_bill.amount .* for invnum .* greater than cust_bill.charged/ ) {
- #warn $error;
- my $cust_bill = qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
- $new->custnum($cust_bill->custnum);
- } elsif ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
- } else {
- $new->custnum($cust_bill_pay->cust_bill->custnum);
+
+ my @invoicing_list = grep { $_ ne 'POST' } $cust_main->invoicing_list;
+
+ my $error = send_email(
+ 'from' => $conf->config('invoice_from'), #??? well as good as any
+ 'to' => \@invoicing_list,
+ 'subject' => 'Payment receipt',
+ 'body' => [ $receipt_template->fill_in( HASH => {
+ 'date' => time2str("%a %B %o, %Y", $self->_date),
+ 'name' => $cust_main->name,
+ 'paynum' => $self->paynum,
+ 'paid' => $self->paid,
+ 'payby' => ucfirst(lc($self->payby)),
+ 'payinfo' => ( $self->payby eq 'CARD'
+ ? $self->payinfo_masked
+ : $self->payinfo ),
+ 'balance' => $cust_main->balance,
+ } ) ],
+ );
+ if ( $error ) {
+ warn "can't send payment receipt: $error";