projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4a46507
)
fix bug that charged full amounts of all open invoices as soon as balance went positi...
author
ivan
<ivan>
Mon, 15 Dec 2003 06:42:32 +0000
(06:42 +0000)
committer
ivan
<ivan>
Mon, 15 Dec 2003 06:42:32 +0000
(06:42 +0000)
FS/FS/cust_bill.pm
patch
|
blob
|
history
FS/FS/cust_main.pm
patch
|
blob
|
history
diff --git
a/FS/FS/cust_bill.pm
b/FS/FS/cust_bill.pm
index
353ab49
..
88f40da
100644
(file)
--- a/
FS/FS/cust_bill.pm
+++ b/
FS/FS/cust_bill.pm
@@
-594,7
+594,10
@@
sub realtime_bop {
my( $self, $method ) = @_;
my $cust_main = $self->cust_main;
my( $self, $method ) = @_;
my $cust_main = $self->cust_main;
- my $amount = $self->owed;
+ my $balance = $cust_main->balance;
+ my $amount = ( $balance < $self->owed ) ? $balance : $self->owed;
+ $amount = sprintf("%.2f", $amount);
+ return "not run (balance $balance)" unless $amount > 0;
my $description = 'Internet Services';
if ( $conf->exists('business-onlinepayment-description') ) {
my $description = 'Internet Services';
if ( $conf->exists('business-onlinepayment-description') ) {
diff --git
a/FS/FS/cust_main.pm
b/FS/FS/cust_main.pm
index
df7bf1a
..
41bfa58
100644
(file)
--- a/
FS/FS/cust_main.pm
+++ b/
FS/FS/cust_main.pm
@@
-1481,24
+1481,15
@@
sub collect {
}
}
}
}
- foreach my $cust_bill ( $self->cust_bill ) {
-
- #this has to be before next's
- my $amount = sprintf( "%.2f", $balance < $cust_bill->owed
- ? $balance
- : $cust_bill->owed
- );
- $balance = sprintf( "%.2f", $balance - $amount );
-
- next unless $cust_bill->owed > 0;
+ foreach my $cust_bill ( $self->open_cust_bill ) {
# don't try to charge for the same invoice if it's already in a batch
#next if qsearchs( 'cust_pay_batch', { 'invnum' => $cust_bill->invnum } );
# don't try to charge for the same invoice if it's already in a batch
#next if qsearchs( 'cust_pay_batch', { 'invnum' => $cust_bill->invnum } );
- warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ", amount $amount, balance $balance)" if $Debug;
-
- next unless $amount > 0;
+ last if $self->balance <= 0;
+ warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ")"
+ if $Debug;
foreach my $part_bill_event (
sort { $a->seconds <=> $b->seconds
foreach my $part_bill_event (
sort { $a->seconds <=> $b->seconds
@@
-1515,7
+1506,8
@@
sub collect {
'disabled' => '', } )
) {
'disabled' => '', } )
) {
- last unless $cust_bill->owed > 0; #don't run subsequent events if owed=0
+ last if $cust_bill->owed <= 0 # don't run subsequent events if owed<=0
+ || $self->balance <= 0; # or if balance<=0
warn "calling invoice event (". $part_bill_event->eventcode. ")\n"
if $Debug;
warn "calling invoice event (". $part_bill_event->eventcode. ")\n"
if $Debug;