Bugzilla – Attachment 93170 Details for
Bug 23682
Add ability to manually import EDI invoices as an alternative to automatic importing on download
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23682 - Add ability to manually import EDI invoices as an alternative to automatic importing on download
Bug-23682---Add-ability-to-manually-import-EDI-inv.patch (text/plain), 8.12 KB, created by
ByWater Sandboxes
on 2019-09-26 18:21:51 UTC
(
hide
)
Description:
Bug 23682 - Add ability to manually import EDI invoices as an alternative to automatic importing on download
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2019-09-26 18:21:51 UTC
Size:
8.12 KB
patch
obsolete
>From 0092ec3500ac56a4856f9c97e9588153a0612b87 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 26 Sep 2019 10:39:36 -0400 >Subject: [PATCH] Bug 23682 - Add ability to manually import EDI invoices as an > alternative to automatic importing on download > >Some library would like to delay the importing of invoices until a time of their choosing. The invoices should be imported into the database as they do now, but the invoice processing should be skipped. Instead, any invoice file with a status of 'new' should have an 'Import' button to process the invoice. >--- > acqui/edifactmsgs.pl | 24 +++++++++ > installer/data/mysql/atomicupdate/bug_23682.perl | 10 ++++ > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/acqui/edifactmsgs.tt | 3 ++ > .../en/modules/admin/preferences/acquisitions.pref | 8 +++ > misc/cronjobs/edi_cron.pl | 57 +++++++++++----------- > 6 files changed, 75 insertions(+), 28 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_23682.perl > >diff --git a/acqui/edifactmsgs.pl b/acqui/edifactmsgs.pl >index 12e22570f7..57e1d14dda 100755 >--- a/acqui/edifactmsgs.pl >+++ b/acqui/edifactmsgs.pl >@@ -45,6 +45,30 @@ if ( $cmd && $cmd eq 'delete' ) { > $msg->update; > } > >+if ( $cmd && $cmd eq 'import' ) { >+ my $id = $q->param('message_id'); >+ my $invoice = $schema->resultset('EdifactMessage')->find($id); >+ >+ my $plugin_used = 0; >+ if ( my $plugin_class = $invoice->edi_acct->plugin ) { >+ my $plugin = $plugin_class->new(); >+ if ( $plugin->can('edifact_process_invoice') ) { >+ $plugin_used = 1; >+ Koha::Plugins::Handler->run( >+ { >+ class => $plugin_class, >+ method => 'edifact_process_invoice', >+ params => { >+ invoice => $invoice, >+ } >+ } >+ ); >+ } >+ } >+ >+ process_invoice($invoice) unless $plugin_used; >+} >+ > my @msgs = $schema->resultset('EdifactMessage')->search( > { > deleted => 0, >diff --git a/installer/data/mysql/atomicupdate/bug_23682.perl b/installer/data/mysql/atomicupdate/bug_23682.perl >new file mode 100644 >index 0000000000..8aa64325fc >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23682.perl >@@ -0,0 +1,10 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if ( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+ ('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice') >+ }); >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 5b916426bf..a8495ff7cd 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -160,6 +160,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('DumpTemplateVarsIntranet', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.', 'YesNo'), > ('DumpTemplateVarsOpac', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.', 'YesNo'), > ('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'), >+('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'), > ('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL), > ('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL), > ('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >index 5f0dc43ac6..9c69e8afcb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt >@@ -71,6 +71,9 @@ > <td class="actions"> > <a class="btn btn-default btn-xs view_message" target="_blank" href="/cgi-bin/koha/acqui/edimsg.pl?id=[% msg.id | html %]"><i class="fa fa-search"></i> View message</a> > <a class="btn btn-default btn-xs delete_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=delete&message_id=[% msg.id | html %]"><i class="fa fa-trash"></i> Delete</a> >+ [% IF msg.status == 'new' %] >+ <a class="btn btn-default btn-xs import_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=import&message_id=[% msg.id | html %]"><i class="fa fa-cog"></i> Import</a> >+ [% END %] > </td> > </tr> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref >index c6d8d8d55c..14447982d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref >@@ -121,3 +121,11 @@ Acquisitions: > "pdfformat::layout3pagesfr": French 3-page > "pdfformat::layout2pagesde": German 2-page > - layout when printing basket groups. >+ EDIFACT: >+ - >+ - pref: EdifactInvoiceImport >+ default: no >+ choices: >+ automatic: "Do" >+ manual: "Don't" >+ - " automatically import EDIFACT invoice message file when they are downloaded." >diff --git a/misc/cronjobs/edi_cron.pl b/misc/cronjobs/edi_cron.pl >index b345dc4616..1ddf294622 100755 >--- a/misc/cronjobs/edi_cron.pl >+++ b/misc/cronjobs/edi_cron.pl >@@ -121,37 +121,38 @@ foreach my $quote_file (@downloaded_quotes) { > } > > # process any downloaded invoices >- >-my @downloaded_invoices = $schema->resultset('EdifactMessage')->search( >- { >- message_type => 'INVOICE', >- status => 'new', >- } >-)->all; >- >-foreach my $invoice (@downloaded_invoices) { >- my $filename = $invoice->filename(); >- $logger->trace("Processing invoice $filename"); >- >- my $plugin_used = 0; >- if ( my $plugin_class = $invoice->edi_acct->plugin ) { >- my $plugin = $plugin_class->new(); >- if ( $plugin->can('edifact_process_invoice') ) { >- $plugin_used = 1; >- Koha::Plugins::Handler->run( >- { >- class => $plugin_class, >- method => 'edifact_process_invoice', >- params => { >- invoice => $invoice, >+if ( C4::Context->preference('EdifactInvoiceImport') eq 'automatic' ) { >+ my @downloaded_invoices = $schema->resultset('EdifactMessage')->search( >+ { >+ message_type => 'INVOICE', >+ status => 'new', >+ } >+ )->all; >+ >+ foreach my $invoice (@downloaded_invoices) { >+ my $filename = $invoice->filename(); >+ $logger->trace("Processing invoice $filename"); >+ >+ my $plugin_used = 0; >+ if ( my $plugin_class = $invoice->edi_acct->plugin ) { >+ my $plugin = $plugin_class->new(); >+ if ( $plugin->can('edifact_process_invoice') ) { >+ $plugin_used = 1; >+ Koha::Plugins::Handler->run( >+ { >+ class => $plugin_class, >+ method => 'edifact_process_invoice', >+ params => { >+ invoice => $invoice, >+ } > } >- } >- ); >+ ); >+ } > } >- } > >- process_invoice($invoice) unless $plugin_used; >-} >+ process_invoice($invoice) unless $plugin_used; >+ } >+} > > my @downloaded_responses = $schema->resultset('EdifactMessage')->search( > { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23682
:
93170
|
93171
|
105927
|
108210
|
108943
|
109030
|
109064
|
109065
|
109066
|
109212
|
109213
|
109214
|
109374
|
109619