Be more specific in EDI invoice amount billed extraction
authorBill Erickson <berick@esilibrary.com>
Thu, 27 Sep 2012 19:10:44 +0000 (15:10 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 27 Sep 2012 19:14:37 +0000 (15:14 -0400)
The lineitem-level amount billed specifically lives in the MOA+203
segment.  This change ensures that if there are multiple MOAs for a
linetiem, we specifically use the MOA+203 to determine the price.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm

index 97aa7ac..6a5f34e 100644 (file)
@@ -724,9 +724,22 @@ sub create_acq_invoice_from_edi {
 
         # Segment Group 26 concerns *lineitem* price (i.e, total for all copies
         # on this lineitem).
+        # e.g. MOA+203:56.62’ 
 
         my $lineitem_price = $sg25->{SG26}[0]{MOA}[0]{C516}{5004};
 
+        if (@{$sg25->{SG26}} > 1) {
+            # if there are multiple MOAs, use the MOA+203
+
+            for my $moa (@{$sg25->{SG26}}) {
+                $lineitem_price = $moa->{MOA}[0]{C516}{5004}
+                    if $moa->{MOA}[0]{C516}{5025} eq '203';
+            }
+        }
+
+        $logger->info($log_prefix . "extracted LI price $lineitem_price");
+
+
         # Segment Group 28 concerns *unit* (lineitem detail) price.  We may
         # not actually use this.  TBD.
         my $per_unit_price;