From c3690def55846204f4c7d42a5aabab8906986570 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 28 Sep 2012 17:56:19 -0400 Subject: [PATCH] Acq: EDI Invoices have fees defined in more places than we were looking So look a little harder. Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Acq/EDI.pm | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm index 6a5f34ef9f..c878e96790 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -842,6 +842,44 @@ sub create_acq_invoice_from_edi { # move on }; + # Look here for surcharges and taxes as well. + try { + # XXX i18n? How do we even? + my %usable_sg51_alc = ( + 'TX' => ['TAX', 'Tax from electronic invoice'], + 'CA' => ['PRO', 'Possible cataloging services'], # for B&T, anyway + 'DL' => ['SHP', 'Delivery'] + ); + + if ($invoice->{SG51}) { + foreach my $sg51 (@{ $invoice->{SG51} }) { + if ($sg51->{ALC} and $sg51->{MOA}) { + my $amount = $sg51->{MOA}[0]{C516}{5004}; + my $what = $sg51->{ALC}[0]{C214}{7161}; + + my ($type, $note); + if (not $usable_sg51_alc{$what}) { + $type = 'PRO'; # We have to choose something. + $note = "Unknown charge type '$what'"; # XXX i18n? + } else { + $type = $usable_sg51_alc{$what}->[0]; + $note = $usable_sg51_alc{$what}->[1]; + } + + my $eg_inv_item = Fieldmapper::acq::invoice_item->new; + + $eg_inv_item->inv_item_type($type); + $eg_inv_item->note($note); + $eg_inv_item->cost_billed($amount); + + push @eg_inv_items, $eg_inv_item; + } + } + } + } catch Error with { + # move on + }; + $e->xact_begin; # save changes to acq.edi_message row -- 2.11.0