X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=201ada91c3259b33c0142fdac34d1b471127ba7d;hp=3317a32bd4392503305e1772a7d5d389ec5eaaa8;hb=c2146ae32fdef80049abfa13098db2d45f3ebdd5;hpb=cfe85e45bcba97089988b4dc22a895aec687f2c3 diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 3317a32bd..201ada91c 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -150,6 +150,8 @@ sub insert { } } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + #false laziness w/ cust_credit::insert if ( $unsuspendauto && $old_balance && $cust_main->balance <= 0 ) { my @errors = $cust_main->unsuspend; @@ -165,7 +167,7 @@ sub insert { #my $cust_main = $self->cust_main; if ( $conf->exists('payment_receipt_email') - && grep { $_ ne 'POST' } $cust_main->invoicing_list + && grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) { my $receipt_template = new Text::Template ( @@ -176,12 +178,13 @@ sub insert { return ''; }; - my @invoicing_list = grep { $_ ne 'POST' } $cust_main->invoicing_list; + my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list; my $payby = $self->payby; my $payinfo = $self->payinfo; $payby =~ s/^BILL$/Check/ if $payinfo; - $payinfo = $self->payinfo_masked if $payby eq 'CARD'; + $payinfo = $self->payinfo_masked if $payby eq 'CARD' || $payby eq 'CHEK'; + $payby =~ s/^CHEK$/Electronic check/; my $error = send_email( 'from' => $conf->config('invoice_from'), #??? well as good as any @@ -325,13 +328,7 @@ sub delete { =item replace OLD_RECORD -Currently unimplemented (accounting reasons). - -=cut - -sub replace { - return "Can't (yet?) modify cust_pay records!"; -} +You probably shouldn't modify payments... =item check @@ -361,7 +358,7 @@ sub check { $self->_date(time) unless $self->_date; - $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby"; + $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREP)$/ or return "Illegal payby"; $self->payby($1); #false laziness with cust_refund::check @@ -396,7 +393,8 @@ payment. sub cust_bill_pay { my $self = shift; - sort { $a->_date <=> $b->_date } + sort { $a->_date <=> $b->_date + || $a->invnum <=> $b->invnum } qsearch( 'cust_bill_pay', { 'paynum' => $self->paynum } ) ; } @@ -432,6 +430,21 @@ sub unapplied { sprintf("%.2f", $amount ); } +=item unrefunded + +Returns the amount of this payment that has not been refuned; which is +paid minus all refund applications (see L). + +=cut + +sub unrefunded { + my $self = shift; + my $amount = $self->paid; + $amount -= $_->amount foreach ( $self->cust_pay_refund ); + sprintf("%.2f", $amount ); +} + + =item cust_main Returns the parent customer object (see L). @@ -452,8 +465,16 @@ by 'x'es. Useful for displaying credit cards. sub payinfo_masked { my $self = shift; - my $payinfo = $self->payinfo; - 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); + #some false laziness w/cust_main::paymask + if ( $self->payby eq 'CARD' ) { + my $payinfo = $self->payinfo; + 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); + } elsif ( $self->payby eq 'CHEK' ) { + my( $account, $aba ) = split('@', $self->payinfo ); + 'x'x(length($account)-2). substr($account,(length($account)-2)). "@". $aba; + } else { + $self->payinfo; + } } =back