2 # ---------------------------------------------------------------
3 # Copyright (C) 2010 Equinox Software, Inc
4 # Author: Joe Atzberger <jatzberger@esilibrary.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # ---------------------------------------------------------------
23 use OpenILS::Application::Acq::EDI;
24 use OpenILS::Utils::CStoreEditor; # needs init() after IDL is loaded (by Cronscript session)
25 use OpenILS::Utils::Cronscript;
31 OpenILS::Utils::Cronscript->new()->session('open-ils.acq') or die "No session created";
32 OpenILS::Utils::CStoreEditor::init();
35 my $ed = OpenILS::Utils::CStoreEditor->new(@_) or die "Failed to get new CStoreEditor";
41 my $set = $e->retrieve_all_acq_edi_account();
42 my $total_accts = scalar(@$set);
44 ($total_accts) or die "No EDI accounts found in database (table: acq.edi_account)";
46 print "EDI Accounts Total : ", scalar(@$set), "\n";
48 my $subset = $e->search_acq_edi_account([
49 {'+acqpro' => {active => 't'}},
53 flesh_fields => {acqedi => ['provider']},
57 print "EDI Accounts Active: ", scalar(@$subset), "\n";
59 my $res = OpenILS::Application::Acq::EDI->retrieve_core();
60 print "Files retrieved: ", scalar(@$res), "\n";
61 $debug and print "retrieve_core returns ", scalar(@$res), " ids: " . join(', ', @$res), "\n";
63 $debug and print map {Dumper($_) . "\n"} @$subset;
68 =head1 edi_fetcher.pl - A script for retrieving and processing EDI files from remote accounts.
70 Note: This script is expected to be run via crontab.
72 Note: Depending on your vendors and you own network environment, you may want to set/export
73 the environmental variable FTP_PASSIVE like:
77 FTP_PASSIVE=1 Open-ILS/src/support-scripts/edi_fetcher.pl