Browse Source

Bug 23682: Dedup plugin calls my moving to a single call in process_invoice()

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Kyle Hall 3 years ago
committed by Jonathan Druart
parent
commit
85405a2143
  1. 24
      Koha/EDI.pm
  2. 17
      acqui/edifactmsgs.pl
  3. 20
      misc/cronjobs/edi_cron.pl

24
Koha/EDI.pm

@ -211,12 +211,30 @@ sub process_invoice {
my $logger = Log::Log4perl->get_logger();
my $vendor_acct;
my $plugin = $invoice_message->edi_acct()->plugin();
my $plugin_class = $invoice_message->edi_acct()->plugin();
# Plugin has its own invoice processor, only run it and not the standard invoice processor below
if ( $plugin_class ) {
my $plugin = $plugin_class->new();
if ( $plugin->can('edifact_process_invoice') ) {
Koha::Plugins::Handler->run(
{
class => $plugin_class,
method => 'edifact_process_invoice',
params => {
invoice => $invoice_message,
}
}
);
return;
}
}
my $edi_plugin;
if ( $plugin ) {
if ( $plugin_class ) {
$edi_plugin = Koha::Plugins::Handler->run(
{
class => $plugin,
class => $plugin_class,
method => 'edifact',
params => {
invoice_message => $invoice_message,

17
acqui/edifactmsgs.pl

@ -50,22 +50,7 @@ if ( $cmd && $cmd eq 'delete' ) {
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 ) {
$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);
}
my @msgs = $schema->resultset('EdifactMessage')->search(

20
misc/cronjobs/edi_cron.pl

@ -132,25 +132,7 @@ if ( C4::Context->preference('EdifactInvoiceImport') eq 'automatic' ) {
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);
}
}

Loading…
Cancel
Save