From bdea2cd3ecd03a96e8b4c2cfee8d552398a97d30 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 13 May 2010 19:05:09 +0000 Subject: [PATCH] use estimed_unit_price directly on the lineitem in JEDI creation. strip protocol/port info from the edi account host before attempting remote delivery. more strict check of successfull login for RemoteAccount git-svn-id: svn://svn.open-ils.org/ILS/trunk@16429 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/EDI.pm | 7 +-- .../perlmods/OpenILS/Utils/RemoteAccount.pm | 5 +- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 2 +- .../upgrade/0262.data.acq.jedi_template.sql | 48 +++++++++++++++++++ 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0262.data.acq.jedi_template.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm index 1e303a3041..f4fa24b968 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/EDI.pm @@ -264,9 +264,10 @@ sub field_map { $args{remote_path} = $vendor->in_dir; # override "path" with "in_dir" } my $host = $args{remote_host} || ''; - ($host =~ /^(S?FTP):/i and $args{type} = uc($1)) or - ($host =~ /^(SSH|SCP):/i and $args{type} = 'SCP' ) ; - $host =~ /:(\d+)$/ and $args{port} = $1; + ($host =~ s/^(S?FTP)://i and $args{type} = uc($1)) or + ($host =~ s/^(SSH|SCP)://i and $args{type} = 'SCP' ) ; + $host =~ s/:(\d+)$// and $args{port} = $1; + ($args{remote_host} = $host) =~ s#/+##; $verbose and $logger->warn("field_map: " . Dumper(\%args)); return %args; } diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm b/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm index 89596accc3..fb08723a3c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/RemoteAccount.pm @@ -498,8 +498,9 @@ sub _uftp { $self->{$_} or last; push @login_args, $self->{$_}; } - eval { $ftp->login(@login_args) }; - if ($@) { + my $login_ok = 0; + eval { $login_ok = $ftp->login(@login_args) }; + if ($@ or !$login_ok) { $logger->error($self->_error("failed login to", $self->remote_host, "w/ args(" . join(',', @login_args) . ") : $@")); return; } diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 25ad274eb9..ed8d02dfe4 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0261'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0262'); -- berick CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index f4b5e6e9cc..a6e928d460 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4737,7 +4737,7 @@ $$[%- USE date -%] {"id-qualifier":"SA","id":"[% li.id %]"}, {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn', li.attributes) %]"} ], - "price":[% helpers.get_li_attr('estimated_price', '', li.attributes) %], + "price":[% li.estimated_unit_price || '0.00' %], "desc":[ {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"}, {"BPU":"[% helpers.get_li_attr('publisher', '', li.attributes) %]"}, diff --git a/Open-ILS/src/sql/Pg/upgrade/0262.data.acq.jedi_template.sql b/Open-ILS/src/sql/Pg/upgrade/0262.data.acq.jedi_template.sql new file mode 100644 index 0000000000..99dcaee2ec --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0262.data.acq.jedi_template.sql @@ -0,0 +1,48 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0262'); + +UPDATE action_trigger.event_definition SET template = +$$[%- USE date -%] +[%# start JEDI document -%] +[%- BLOCK big_block -%] +["order", { + "po_number":[% target.id %], + "date":"[% date.format(date.now, '%Y%m%d') %]", + "buyer":[ + {"id":"[% target.ordering_agency.mailing_address.san %]", + "reference":{"API":"[% target.ordering_agency.mailing_address.san %]"}} + ], + "vendor":[ + "[% target.provider.san %]", // [% target.provider.name %] ([% target.provider.id %]) + {"id-qualifier":"91", "reference":{"IA":"[% target.provider.id %]"}, "id":"[% target.provider.san %]"} + ], + "currency":"[% target.provider.currency_type %]", + "items":[ + [% FOR li IN target.lineitems %] + { + "identifiers":[ + {"id-qualifier":"SA","id":"[% li.id %]"}, + {"id-qualifier":"IB","id":"[% helpers.get_li_attr('isbn', li.attributes) %]"} + ], + "price":[% li.estimated_unit_price || '0.00' %], + "desc":[ + {"BTI":"[% helpers.get_li_attr('title', '', li.attributes) %]"}, + {"BPU":"[% helpers.get_li_attr('publisher', '', li.attributes) %]"}, + {"BPD":"[% helpers.get_li_attr('pubdate', '', li.attributes) %]"}, + {"BPH":"[% helpers.get_li_attr('pagination','', li.attributes) %]"} + ], + "quantity":[% li.lineitem_details.size %] + [%-# TODO: lineitem details (later) -%] + }[% UNLESS loop.last %],[% END -%] + [%- END %] + ], + "line_items":[% target.lineitems.size %] +}] +[% END %] +[% tempo = PROCESS big_block; helpers.escape_json(tempo) %] +$$ +WHERE id = 23; + +COMMIT; + -- 2.43.2