From c471f7e966349119f4b529f7ca56a0df56167b05 Mon Sep 17 00:00:00 2001 From: senator Date: Fri, 7 Jan 2011 20:06:18 +0000 Subject: [PATCH] Backport r19134 from trunk Acq: fix prorating bug When prorating, the system decides what funds to target by looking at what funds have already been spent against. Previously, the system only looked at acqie objects, but an invoice can also be composed of acqii objects. git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@19135 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm index 25e5e8a853..d0c20d296a 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm @@ -392,9 +392,16 @@ sub prorate_invoice { my @lid_debits; push(@lid_debits, @{find_entry_debits($e, $_, 'f', entry_amount_per_item($_))}) for @{$invoice->entries}; + my $inv_items = $e->search_acq_invoice_item([ + {"invoice" => $invoice_id, "fund_debit" => {"!=" => undef}}, + {"flesh" => 1, "flesh_fields" => {"acqii" => ["fund_debit"]}} + ]) or return $e->die_event; + + my @item_debits = map { $_->fund_debit } @$inv_items; + my %fund_totals; my $total_entry_paid = 0; - for my $debit (@lid_debits) { + for my $debit (@lid_debits, @item_debits) { $fund_totals{$debit->fund} = 0 unless $fund_totals{$debit->fund}; $fund_totals{$debit->fund} += $debit->amount; $total_entry_paid += $debit->amount; -- 2.11.0