From 371196c9e7ce67bf0b2d4f48443b3dbaf51356b2 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Fri, 29 Oct 2021 16:28:20 -0700 Subject: [PATCH] LP#1949243: tweak FTX and LIN in EDI messages There are a couple of errors in EDIWriter's output: 1. The FTX line is missing a field. We produce FTX+LIN+1+First Nations but should be producing FTX+LIN+1++First Nations (note the extra + sign). 2. We are enumerating lineitems using the internal lineitem ID (e.g. LIN+523964), but they should be enumerated sequentially starting at 1 (e.g. LIN+1). This commit fixes both errors. Signed-off-by: Jeff Davis --- Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIWriter.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIWriter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIWriter.pm index b0349ee1bb..38ceb805fa 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIWriter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIWriter.pm @@ -458,11 +458,14 @@ NAD+SU+$c{provider_id}::92' CUX+2:$c{currency_type}:9' EDI - # EDI lineitem segments - $edi .= $self->build_lineitem_segments($_) for @lis; - my $li_count = scalar(@lis); + # EDI lineitem segments + for (my $i = 1; $i <= $li_count; $i++) { + $lis[$i]->{seq_id} = $i; + $edi .= $self->build_lineitem_segments($lis[$i]); + } + # Count the number of segments in the EDI message by counting the # number of newlines. Add to count for lines below, not including # the UNZ segment. @@ -502,9 +505,10 @@ sub build_lineitem_segments { my $idqual = $li_hash->{idqual}; my $quantity = $li_hash->{quantity}; my $price = $li_hash->{estimated_unit_price}; + my $seq_id = $li_hash->{seq_id}; # Line item identifier segments - my $edi = "LIN+$id++$idval:$idqual'\n"; + my $edi = "LIN+$seq_id++$idval:$idqual'\n"; $edi .= "PIA+5+$idval:$idqual'\n"; $edi .= $self->IMD('BTI', $li_hash->{title}); @@ -526,7 +530,7 @@ sub build_lineitem_segments { for my $note (@{$li_hash->{notes}}) { if ($note) { - $edi .= "FTX+LIN+1+$note'\n" + $edi .= "FTX+LIN+1++$note'\n" } else { $edi .= "FTX+LIN+1'\n" } -- 2.11.0