$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;
}
$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;
}
{"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) %]"},
--- /dev/null
+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;
+