Bug 23682

Summary: Add ability to manually import EDI invoices as an alternative to automatic importing on download
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: AcquisitionsAssignee: Kyle M Hall (khall) <kyle>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, lucas
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This feature allows libraries to delay the importing of EDI invoices until a time of their choosing. If the syspref is enabled, the invoices are be imported into the database, but the invoice processing is skipped. Instead, any invoice file with a status of 'new' will have an 'Import' button to process the invoice manually.
Version(s) released in:
20.11.00
Circulation function:
Attachments: 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 invoices as an alternative to automatic importing on download
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 invoices as an alternative to automatic importing on download
Bug 23682: Add ability to manually import EDI invoices as an alternative to automatic importing on download
Bug 23682: (QA follow-up) Fix typo in syspref description
Test Database
Bug 23682: Add ability to manually import EDI invoices as an alternative to automatic importing on download
Bug 23682: (QA follow-up) Fix typo in syspref description
Bug 23682: Add ability to manually import EDI invoices as an alternative to automatic importing on download
Bug 23682: (QA follow-up) Fix typo in syspref description
Bug 23682: INSERT IGORE systen preference in database update
Bug 23682: Dedup plugin calls my moving to a single call in process_invoice()
Bug 23682: Fix use Koha::Plugins::Handler statements

Description Kyle M Hall (khall) 2019-09-26 14:55:19 UTC
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.
Comment 1 ByWater Sandboxes 2019-09-26 18:21:51 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall (khall) 2019-09-26 18:29:52 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall (khall) 2020-06-16 15:24:26 UTC
Created attachment 105927 [details] [review]
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
Comment 4 Andrew Fuerste-Henry 2020-08-13 18:07:49 UTC
Created attachment 108210 [details] [review]
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>
Comment 5 Katrin Fischer 2020-08-22 23:06:49 UTC
Created attachment 108943 [details] [review]
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>
Comment 6 Katrin Fischer 2020-08-22 23:14:17 UTC
Hi Kyle,

can you please help me with testing this? I don't have any invoice data to use.

From review:

1) Pref description
" automatically import EDIFACT invoice message file when they are downloaded."
Small typo, I think it should read "files"?

2) Why pref driven and not an EDI account option?
From looking at the options available, I was wondering why this is our first EDIFACT preference. I would have expected this on the EDI account level, where we also have the "Automatic ordering:" and other workflow relevant options.
Comment 7 Kyle M Hall (khall) 2020-08-24 17:19:59 UTC
(In reply to Katrin Fischer from comment #6)
> Hi Kyle,
> 
> can you please help me with testing this? I don't have any invoice data to
> use.
> 
> From review:
> 
> 1) Pref description
> " automatically import EDIFACT invoice message file when they are
> downloaded."
> Small typo, I think it should read "files"?

You are correct!

 
> 2) Why pref driven and not an EDI account option?
> From looking at the options available, I was wondering why this is our first
> EDIFACT preference. I would have expected this on the EDI account level,
> where we also have the "Automatic ordering:" and other workflow relevant
> options.

This was a sponsored development and the spec was decided upon my the sponsor. I think as a general rule, if a library wants to manually import invoices from one vendor, they want to manually import invoices from *all* vendors. This change would be out of scope for the development.

That being said, I think it would make a fine future enhancement. The syspref value could be imported into a new column in the vendors table and then removed from the database.
Comment 8 Kyle M Hall (khall) 2020-08-24 17:21:41 UTC
Created attachment 109030 [details] [review]
Bug 23682: (QA follow-up) Fix typo in syspref description
Comment 9 Katrin Fischer 2020-08-24 18:44:13 UTC
I'll still need some data to test with please :)
Comment 10 Kyle M Hall (khall) 2020-08-25 12:05:10 UTC
Created attachment 109064 [details]
Test Database
Comment 11 Kyle M Hall (khall) 2020-08-25 12:08:53 UTC
Created attachment 109065 [details] [review]
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>
Comment 12 Kyle M Hall (khall) 2020-08-25 12:09:02 UTC
Created attachment 109066 [details] [review]
Bug 23682: (QA follow-up) Fix typo in syspref description
Comment 13 Kyle M Hall (khall) 2020-08-25 12:10:55 UTC
(In reply to Katrin Fischer from comment #9)
> I'll still need some data to test with please :)

Due to the amount of setup required for EDI, I've attached a database dump already set up for the kohadev instance.

Test Plan:
1) Check out master with this patch applied
2) Load the attached test database
3) Note there is one basket with two items in it, not received.
4) Browse to http://127.0.0.1:8081/cgi-bin/koha/acqui/edifactmsgs.pl and see the 'new' edifact invoice
5) Import the invoice using the import button
6) Note the items in the basket are now marked as recieved
7) Browse to http://127.0.0.1:8081/cgi-bin/koha/acqui/invoices.pl?op=do_search and note the newly created invoice
Comment 14 Katrin Fischer 2020-08-26 22:42:38 UTC
You are mean, the admin admin account doesn't work :)
Comment 15 Katrin Fischer 2020-08-26 22:44:00 UTC
But koha - koha does.
Comment 16 Katrin Fischer 2020-08-26 22:51:47 UTC
Created attachment 109212 [details] [review]
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>
Comment 17 Katrin Fischer 2020-08-26 22:51:51 UTC
Created attachment 109213 [details] [review]
Bug 23682: (QA follow-up) Fix typo in syspref description

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 18 Katrin Fischer 2020-08-26 22:51:54 UTC
Created attachment 109214 [details] [review]
Bug 23682: INSERT IGORE systen preference in database update

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 19 Jonathan Druart 2020-08-31 12:57:29 UTC
Kyle, should not we move the plugin hook (edifact_process_invoice) inside process_invoice?
Comment 20 Kyle M Hall (khall) 2020-08-31 17:06:39 UTC
Created attachment 109374 [details] [review]
Bug 23682: Dedup plugin calls my moving to a single call in process_invoice()
Comment 21 Jonathan Druart 2020-09-03 12:12:37 UTC
Created attachment 109619 [details] [review]
Bug 23682: Fix use Koha::Plugins::Handler statements
Comment 22 Jonathan Druart 2020-09-03 13:04:25 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 23 Lucas Gass (lukeg) 2020-09-14 21:55:21 UTC
enhancement will not be backported to 20.05.x series