=================================================================== RCS file: /cvs/RT/Invoicing/lib/RTI/State.pm,v retrieving revision 1.6 retrieving revision 1.8 diff -u -r1.6 -r1.8 --- RT/Invoicing/lib/RTI/State.pm 2012/08/18 21:21:54 1.6 +++ RT/Invoicing/lib/RTI/State.pm 2012/11/28 02:25:13 1.8 @@ -112,6 +112,15 @@ : $self->{_table}->{unpaid}; } +sub credits { + my ( $self, $custid ) = @_; + + $self->_match_payments; + return defined $custid + ? $self->{_table}->{credit}->{$custid} + : $self->{_table}->{credit}; +} + sub save { my ($self) = @_; @@ -194,7 +203,7 @@ delete $credit{$custid} unless $credit{$custid}; } - foreach my $id ( sort { $b <=> $a } keys %owes ) { + foreach my $id ( sort { $a <=> $b } keys %owes ) { my $i = $invoices->{$id}; my $custid = $i->{custid} or next;