# 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