From 2991b1660aff2f5d712f3e5d6b72d37e998a678e Mon Sep 17 00:00:00 2001 From: senator Date: Wed, 3 Nov 2010 14:46:24 +0000 Subject: [PATCH] Acq: Don't forget invoice items (extra charges, not purchases) when totaling debits for voucher git-svn-id: svn://svn.open-ils.org/ILS/trunk@18589 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm index 79d10e772c..25e5e8a853 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Invoice.pm @@ -251,6 +251,9 @@ sub amounts_spent_per_fund { my $entries = $e->search_acq_invoice_entry({"invoice" => $inv_id}) or return 0; + my $items = $e->search_acq_invoice_item({"invoice" => $inv_id}) or + return 0; + my %totals_by_fund; foreach my $entry (@$entries) { my $debits = find_entry_debits($e, $entry, "f") or return 0; @@ -260,6 +263,12 @@ sub amounts_spent_per_fund { } } + foreach my $item (@$items) { + next unless $item->fund and $item->amount_paid; + $totals_by_fund{$item->fund} ||= 0.0; + $totals_by_fund{$item->fund} += $item->amount_paid; + } + my @totals; foreach my $fund_id (keys %totals_by_fund) { my $fund = $e->retrieve_acq_fund($fund_id) or return 0; -- 2.11.0