LP 1154150 : repair formula entry retrieval
authorBill Erickson <berick@esilibrary.com>
Wed, 13 Mar 2013 20:16:50 +0000 (16:16 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 13 Mar 2013 20:55:01 +0000 (16:55 -0400)
Repair code thinkos in distribution formula entry fleshing call /
traversal.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Lineitem/BatchUpdate.pm

index 620ae06..0a8b9a3 100644 (file)
@@ -410,8 +410,14 @@ sub lineitem_batch_update_api {
         # It's important that we NOT flesh use_count here, if that [ever]
         # does anything.  We're going to abuse that field internally.
 
-        $dist_formula = $e->acq->retrieve_acq_distribution_formula([
-            int($dist_formula), {flesh=>1, flesh_fields=>["entries","fund"]}
+        $dist_formula = $e->retrieve_acq_distribution_formula([
+            int($dist_formula), {
+                flesh=>2, 
+                flesh_fields=>{
+                    acqdf => ["entries"],
+                    acqdfe => ["fund"]
+                }
+            }
         ]) or return $e->die_event;
 
         return $e->die_event unless
@@ -419,11 +425,13 @@ sub lineitem_batch_update_api {
 
         # If the distribution formula has a fund, there's an additional perm
         # test to do before proceeding.
-        if ($dist_formula->fund) {
-            return $e->die_event unless $e->allowed(
-                ["ADMIN_FUND", "MANAGE_FUND"],
-                $dist_formula->fund->org, $dist_formula->fund
-            );
+        for my $entry (@{$dist_formula->entries}) {
+            if ($entry->fund) {
+                return $e->die_event unless $e->allowed(
+                    ["ADMIN_FUND", "MANAGE_FUND"],
+                    $entry->fund->org, $entry->fund
+                );
+            }
         }
 
         # The following sort is crucial later.