From: Bill Erickson Date: Fri, 28 Sep 2012 15:32:28 +0000 (-0400) Subject: invoice regex repairs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0066e60930facd30f8dc9de6e23759f78a52d445;p=evergreen%2Fequinox.git invoice regex repairs Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/support-scripts/test-scripts/edi_parser.pl b/Open-ILS/src/support-scripts/test-scripts/edi_parser.pl index 9639cc65bb..82b4bccb26 100644 --- a/Open-ILS/src/support-scripts/test-scripts/edi_parser.pl +++ b/Open-ILS/src/support-scripts/test-scripts/edi_parser.pl @@ -16,12 +16,12 @@ my $PO_NUM_RE = '^RFF\+ON:(\S+)'; my $BUYER_SAN_RE = '^NAD\+BY\+([^:]+).*'; my $VENDOR_SAN_RE = '^NAD\+SU\+([^:]+).*'; my $LIN_INDEX_RE = '^LIN\+([^\+]+).*'; -my $LIN_IDENT_RE = '^LIN\+\S+\++(.*)'; # e.g. ISBN -my $LIN_QUANTITY_RE = '^QTY\+47:(\d+)'; +my $LIN_IDENT_RE = '^LIN\+\S+\++([^:]+).*'; # e.g. ISBN +my $LIN_QUANTITY_RE = '^QTY\+47:(\d+).*'; my $LIN_AMOUNT_RE = '^MOA\+203:(\d+)'; my $LIN_ID_RE = '^RFF\+LI:\S+\/(\S+)'; my $TOTAL_BILLED_RE = '^MOA\+86:(\d+)'; -my $MISC_CHARGE_TYPE_RE = '^ALC\+C\++(\S+)'; +my $MISC_CHARGE_TYPE_RE = '^ALC\+C\++([^\+]+).*'; my $MISC_CHARGE_AMT_RE = '^MOA\+(8|131):(\d+)'; my @msgs; @@ -29,7 +29,7 @@ my @msgs; foreach (split(/'/, $edi)) { my $msg = $msgs[-1]; - if ($_ =~ /^UNH/) { # header. start a new message. + if ($_ =~ /^UNH/) { # starting a new message. $msg = {lineitems => [], misc_charges => []}; ($msg->{msg_type} = $_) =~ s/$MSG_TYPE_RE/$1/; @@ -37,19 +37,19 @@ foreach (split(/'/, $edi)) { push(@msgs, $msg); } + ($msg->{buyer_san} = $_) =~ s/$BUYER_SAN_RE/$1/g if /$BUYER_SAN_RE/; + ($msg->{vendor_san} = $_) =~ s/$VENDOR_SAN_RE/$1/g if /$VENDOR_SAN_RE/; + if ($msg and $msg->{msg_type} eq 'INVOIC') { ($msg->{inv_ident} = $_) =~ s/$INV_IDENT_RE/$1/g if /$INV_IDENT_RE/; ($msg->{po_number} = $_) =~ s/$PO_NUM_RE/$1/g if /$PO_NUM_RE/; - ($msg->{buyer_san} = $_) =~ s/$BUYER_SAN_RE/$1/g if /$BUYER_SAN_RE/; - ($msg->{vendor_san} = $_) =~ s/$VENDOR_SAN_RE/$1/g if /$VENDOR_SAN_RE/; - if ($_ =~ /^LIN\+/) { - # starting a new lineitem + if ($_ =~ /^LIN\+/) { # starting a new lineitem $msg->{_current_li} = {}; ($msg->{_current_li}->{index} = $_) =~ s/$LIN_INDEX_RE/$1/g; - ($msg->{_current_li}->{ident} = $_) =~ s/$LIN_IDENT_RE/$1/g; + ($msg->{_current_li}->{ident} = $_) =~ s/$LIN_IDENT_RE/$1/g if /$LIN_IDENT_RE/; push(@{$msg->{lineitems}}, $msg->{_current_li}); }