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. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Enable the new syspref EdifactInvoiceImport 4) Run the edi cronjob to import a new invoice file 5) View EDI messages table at /acqui/edifactmsgs.pl 6) Note the invoice files is not processes, and retains the status of 'new' 7) Use the 'import' button to process the invoice 8) Note the invoice is now marked 'received' and the 'import' button is gone 9) Verify the invoice was actually processes Signed-off-by: Debi Stears <DDStears@washoecounty.us> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
8cbf2841ad
commit
d8696702ce
|
|
@ -19,10 +19,13 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use CGI;
|
||||
use Koha::Database;
|
||||
use C4::Koha;
|
||||
|
||||
use C4::Auth;
|
||||
use C4::Koha;
|
||||
use C4::Output;
|
||||
use Koha::Database;
|
||||
use Koha::EDI qw(process_invoice);
|
||||
use Koha::Plugins::Handler;
|
||||
|
||||
my $q = CGI->new;
|
||||
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
|
||||
|
|
@ -44,6 +47,27 @@ 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 ) {
|
||||
$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,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
|
@ -174,6 +174,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'),
|
||||
|
|
|
|||
|
|
@ -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 %]
|
||||
|
|
|
|||
|
|
@ -122,3 +122,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."
|
||||
|
|
|
|||
|
|
@ -121,36 +121,37 @@ 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;
|
||||
|
||||
process_invoice($invoice) unless $plugin_used;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
my @downloaded_responses = $schema->resultset('EdifactMessage')->search(
|
||||
|
|
|
|||
Loading…
Reference in New Issue