[open-ils-commits] r12143 - trunk/Open-ILS/src/perlmods/OpenILS/Application (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 10 16:24:43 EST 2009
Author: erickson
Date: 2009-02-10 16:24:39 -0500 (Tue, 10 Feb 2009)
New Revision: 12143
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Log:
take advantage of the new billable_transaction_summary table. also, force caller to make_mbts to pass an editor in
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-02-10 20:51:55 UTC (rev 12142)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-02-10 21:24:39 UTC (rev 12143)
@@ -2065,8 +2065,7 @@
$e->rollback;
- #my @mbts = _make_mbts( @xacts );
- my @mbts = $U->make_mbts( @xacts );
+ my @mbts = $U->make_mbts( $e, @xacts );
if(defined($type)) {
@mbts = grep { $_->xact_type eq $type } @mbts;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-02-10 20:51:55 UTC (rev 12142)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-02-10 21:24:39 UTC (rev 12143)
@@ -1157,20 +1157,13 @@
sub fetch_mbts {
my $self = shift;
my $id = shift;
- my $editor = shift || OpenILS::Utils::CStoreEditor->new;
+ my $e = shift || OpenILS::Utils::CStoreEditor->new;
+ $id = $id->id if ref($id);
+
+ my $xact = $e->retrieve_money_billable_transaction_summary($id)
+ or return (undef, $e->event);
- $id = $id->id if (ref($id));
-
- my $xact = $editor->retrieve_money_billable_transaction(
- [
- $id, {
- flesh => 1,
- flesh_fields => { mbt => [ qw/billings payments grocery circulation/ ] }
- }
- ]
- ) or return (undef, $editor->event);
-
- return $self->make_mbts($xact);
+ return ($xact);
}
@@ -1180,59 +1173,9 @@
#--------------------------------------------------------------------
sub make_mbts {
my $self = shift;
+ my $e = shift;
my @xacts = @_;
-
- my @mbts;
- for my $x (@xacts) {
-
- my $s = new Fieldmapper::money::billable_transaction_summary;
-
- $s->id( $x->id );
- $s->usr( $x->usr );
- $s->xact_start( $x->xact_start );
- $s->xact_finish( $x->xact_finish );
-
- my $to = 0;
- my $lb = undef;
- for my $b (@{ $x->billings }) {
- next if ($self->is_true($b->voided));
- $to += ($b->amount * 100);
- $lb ||= $b->billing_ts;
- if ($b->billing_ts ge $lb) {
- $lb = $b->billing_ts;
- $s->last_billing_note($b->note);
- $s->last_billing_ts($b->billing_ts);
- $s->last_billing_type($b->billing_type);
- }
- }
-
- $s->total_owed( sprintf('%0.2f', $to / 100 ) );
-
- my $tp = 0;
- my $lp = undef;
- for my $p (@{ $x->payments }) {
- next if ($self->is_true($p->voided));
- $tp += ($p->amount * 100);
- $lp ||= $p->payment_ts;
- if ($p->payment_ts ge $lp) {
- $lp = $p->payment_ts;
- $s->last_payment_note($p->note);
- $s->last_payment_ts($p->payment_ts);
- $s->last_payment_type($p->payment_type);
- }
- }
-
- $s->total_paid( sprintf('%0.2f', $tp / 100 ) );
- $s->balance_owed( sprintf('%0.2f', ($to - $tp) / 100) );
- $s->xact_type('grocery') if ($x->grocery);
- $s->xact_type('circulation') if ($x->circulation);
-
- $logger->debug("Created mbts with balance_owed = ". $s->balance_owed);
-
- push @mbts, $s;
- }
-
- return @mbts;
+ return @{$e->search_money_billable_transaction_summary({id => [ map { $_->id } @xacts ]})};
}
More information about the open-ils-commits
mailing list