From: Bill Erickson Date: Wed, 5 Dec 2012 14:34:00 +0000 (-0500) Subject: EDI invoice date; invoice paid quantity/amount X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2f7c5eff26c310e4afe1ef73480249d013227f51;p=contrib%2FConifer.git EDI invoice date; invoice paid quantity/amount * capture the invoice date in EDIReader * apply the invoice date to inbound invoices when available instead of defaulting to 'now' * apply the quantity/amount billed to the quantity/amount paid to reduce staff data entry needs Signed-off-by: Bill Erickson Signed-off-by: Lebbeous Fogle-Weekley --- 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 09b6ce2d2f..7a6b4f4aa1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/EDI.pm @@ -449,13 +449,8 @@ sub process_parsed_msg { next; } - if ($li_hash->{expected_date}) { - my ($y, $m, $d) = $li_hash->{expected_date} =~ /^(\d{4})(\d{2})(\d{2})/g; - my $recv_time = $y; - $recv_time .= "-$m" if $m; - $recv_time .= "-$d" if $d; - $li->expected_recv_time($recv_time); - } + $li->expected_recv_time( + $class->edi_date_to_iso($li_hash->{expected_date})); $li->estimated_unit_price($li_hash->{unit_price}); @@ -681,6 +676,15 @@ sub cancel_lids { return ($cancel_count); } +sub edi_date_to_iso { + my ($class, $date) = @_; + return undef unless $date and $date =~ /\d+/; + my ($iso, $m, $d) = $date =~ /^(\d{4})(\d{2})(\d{2})/g; + $iso .= "-$m" if $m; + $iso .= "-$d" if $d; + return $iso; +} + # create_acq_invoice_from_edi() does what it sounds like it does for INVOIC # messages. For similar operation on ORDRSP messages, see the guts of @@ -704,6 +708,9 @@ sub create_acq_invoice_from_edi { # distinguish provider and shipper? $eg_inv->recv_method("EDI"); + $eg_inv->recv_date( + $class->edi_date_to_iso($invoice->{invoice_date})); + # some vendors encode the account number as the SAN. # starting with the san value, then the account value, @@ -793,6 +800,9 @@ sub create_acq_invoice_from_edi { my $eg_inv_entry = Fieldmapper::acq::invoice_entry->new; $eg_inv_entry->inv_item_count($quantity); + # amount staff agree to pay for + $eg_inv_entry->phys_item_count($quantity); + # XXX Validate by making sure the LI is on-order and belongs to # the right provider and ordering agency and all that. $eg_inv_entry->lineitem($li_id); @@ -803,6 +813,9 @@ sub create_acq_invoice_from_edi { # This is the total price for all units billed, not per-unit. $eg_inv_entry->cost_billed($lineitem_price); + # amount staff agree to pay + $eg_inv_entry->amount_paid($lineitem_price); + push @eg_inv_entries, $eg_inv_entry; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm index e6c872e043..532af2d2d7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/EDIReader.pm @@ -26,7 +26,8 @@ my %edi_fields = ( vendor_acct => qr/^NAD\+SU\+([^:]+)::91/, purchase_order => qr/^RFF\+ON:(\S+)/, invoice_ident => qr/^BGM\+380\+([^\+]+)/, - total_billed => qr/^MOA\+86:(\d+)/ + total_billed => qr/^MOA\+86:(\d+)/, + invoice_date => qr/^DTM\+137:([^:]+)/ ); my %edi_li_fields = (