Acq: Don't forget invoice items (extra charges, not purchases) when totaling
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Nov 2010 14:46:24 +0000 (14:46 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Nov 2010 14:46:24 +0000 (14:46 +0000)
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

index 79d10e7..25e5e8a 100644 (file)
@@ -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;