Bug 31115

Summary: Additional fields for invoices
Product: Koha Reporter: Michaela Sieber <michaela.sieber>
Component: AcquisitionsAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, katrin.fischer, lucas, michaela.sieber, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15774
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Caroline Cyr La Rose Documentation submission: https://gitlab.com/koha-community/koha-manual/-/merge_requests/628
Text to go in the release notes:
This new feature adds the ability to define additional fields to store information about vendor invoices. There is a new 'Manage invoice fields' page in the acquisitions administration to configure the fields. Users can name additional fields, tie them to authorised values, and specify whether the fields can be searched in the acquisitions module. This also adds a new entry to the admin page for additional fields.
Version(s) released in:
22.11.00
Bug Depends on:    
Bug Blocks: 31956    
Attachments: Documentation Bug31115 Additional fields for invoices
Bug 31115: Add support for additional fields for invoices
Bug 31115: Add invoice fields manage link
Bug 31115: Add additional_attributes support to GetInvoices
Bug 31115: Add additional field filtering for invoice search
Bug 31115: Add support for additional fields for invoices
Bug 31115: Add invoice fields manage link
Bug 31115: Add additional_attributes support to GetInvoices
Bug 31115: Add additional field filtering for invoice search
Bug 31115: Add support for additional fields for invoices
Bug 31115: Add invoice fields manage link
Bug 31115: Add additional_attributes support to GetInvoices
Bug 31115: Add additional field filtering for invoice search
Bug 31115: (QA follow-up) Remove hr
Bug 31115: (QA follow-up) Use more specific permission for sidebar link

Description Michaela Sieber 2022-07-07 09:28:04 UTC
This new feature adds the ability to define additional fields to store information about vendor invoices in the acquisition module.

For further information see attached documentation.

Test plan:

  1. Create a Vendor (under Acquisition -> New Vendor).
  2. Create a Basket 
  3. Apply patch.
  4. Visit Additional fields under administration, and verify that
     the option for invoices exists
  5. Create at least four fields for aqinvoice for each combination of
     searchable/not-searchable and with/without an authorized value.
  6. Create a Vendor invoice (-> Receive shipment) , and verify that all fields are visible and
     correctly save.
  7. Edit the invoice, verifying that changes to these additional fields
     are saved.
  8. Search the invoice by using an additional field (Acquisitions > Invoices)
  9. Verify that only the searchable fields show in the form, and that
     their contents may be searched.
Comment 1 Michaela Sieber 2022-07-07 09:35:12 UTC
Created attachment 137252 [details]
Documentation Bug31115 Additional fields for invoices
Comment 2 Tomás Cohen Arazi 2022-10-19 20:28:04 UTC
Created attachment 142210 [details] [review]
Bug 31115: Add support for additional fields for invoices

This patch adds support for additional fields for invoices. A new option
is added to the 'Additional fields' admin page, for the 'aqinvoices'
table.

Adding/editing invoices now supports this additional fields.

To test:
1. Apply this patches
2. Verify the original test plan works
=> SUCCESS: It does!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 3 Tomás Cohen Arazi 2022-10-19 20:28:09 UTC
Created attachment 142211 [details] [review]
Bug 31115: Add invoice fields manage link

This patch adds a link on the acquisitions page for reaching the
additional fields config for invoices in an easy way.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 4 Tomás Cohen Arazi 2022-10-19 20:28:14 UTC
Created attachment 142212 [details] [review]
Bug 31115: Add additional_attributes support to GetInvoices

This patch adds support for searching additional_fields when retrieving
invoices using C4::Acquisition::Invoices.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Acquisition.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 5 Tomás Cohen Arazi 2022-10-19 20:28:19 UTC
Created attachment 142213 [details] [review]
Bug 31115: Add additional field filtering for invoice search

This patch adds support for filtering invoice searches on additional
fields. To test:

1. Generate additional fields for invoices
2. Have invoices with additional fields
3. Use invoice searching and play with filtering by additional fields.
=> SUCCESS: It works!
4. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Comment 6 Lukas Koszyk 2022-10-20 14:32:23 UTC
Created attachment 142250 [details] [review]
Bug 31115: Add support for additional fields for invoices

This patch adds support for additional fields for invoices. A new option
is added to the 'Additional fields' admin page, for the 'aqinvoices'
table.

Adding/editing invoices now supports this additional fields.

To test:
1. Apply this patches
2. Verify the original test plan works
=> SUCCESS: It does!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 7 Lukas Koszyk 2022-10-20 14:32:27 UTC
Created attachment 142251 [details] [review]
Bug 31115: Add invoice fields manage link

This patch adds a link on the acquisitions page for reaching the
additional fields config for invoices in an easy way.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 8 Lukas Koszyk 2022-10-20 14:32:32 UTC
Created attachment 142252 [details] [review]
Bug 31115: Add additional_attributes support to GetInvoices

This patch adds support for searching additional_fields when retrieving
invoices using C4::Acquisition::Invoices.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Acquisition.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 9 Lukas Koszyk 2022-10-20 14:32:37 UTC
Created attachment 142253 [details] [review]
Bug 31115: Add additional field filtering for invoice search

This patch adds support for filtering invoice searches on additional
fields. To test:

1. Generate additional fields for invoices
2. Have invoices with additional fields
3. Use invoice searching and play with filtering by additional fields.
=> SUCCESS: It works!
4. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 10 Katrin Fischer 2022-10-24 17:05:44 UTC
Created attachment 142533 [details] [review]
Bug 31115: Add support for additional fields for invoices

This patch adds support for additional fields for invoices. A new option
is added to the 'Additional fields' admin page, for the 'aqinvoices'
table.

Adding/editing invoices now supports this additional fields.

To test:
1. Apply this patches
2. Verify the original test plan works
=> SUCCESS: It does!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 11 Katrin Fischer 2022-10-24 17:05:49 UTC
Created attachment 142534 [details] [review]
Bug 31115: Add invoice fields manage link

This patch adds a link on the acquisitions page for reaching the
additional fields config for invoices in an easy way.

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 12 Katrin Fischer 2022-10-24 17:05:54 UTC
Created attachment 142535 [details] [review]
Bug 31115: Add additional_attributes support to GetInvoices

This patch adds support for searching additional_fields when retrieving
invoices using C4::Acquisition::Invoices.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Acquisition.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 13 Katrin Fischer 2022-10-24 17:05:58 UTC
Created attachment 142536 [details] [review]
Bug 31115: Add additional field filtering for invoice search

This patch adds support for filtering invoice searches on additional
fields. To test:

1. Generate additional fields for invoices
2. Have invoices with additional fields
3. Use invoice searching and play with filtering by additional fields.
=> SUCCESS: It works!
4. Sign off :-D

Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 14 Katrin Fischer 2022-10-24 17:06:03 UTC
Created attachment 142537 [details] [review]
Bug 31115: (QA follow-up) Remove hr

The hr created a visible white line with a darker background and
doesn't make sense here style wise.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 15 Katrin Fischer 2022-10-24 17:06:08 UTC
Created attachment 142538 [details] [review]
Bug 31115: (QA follow-up) Use more specific permission for sidebar link

Moves from any acq permission to edit_invoices.

Manage order baskets uses order_manage, to this is supposed to make
things a little more consistent.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 16 Katrin Fischer 2022-10-24 17:08:04 UTC
1) Unit tests pass
2) QA tools pass

3) Permission check / links in navigation

+ [% IF CAN_user_acquisition && CAN_user_parameters_manage_additional_fields %]
+ <li>
+   <a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=aqinvoices">Manage invoice fields</a>
+  </li>
+ [% END %]
[% IF CAN_user_acquisition_order_manage && CAN_user_parameters_manage_additional_fields %]

The new link for additional invoice fields will need "any acq permission" + the specific administration permission.
The old link for additional basket fields uses the more specific permission "order_manage".

I've provided a follow-up using edit_invoices for the first link to make things a bit more consistent.

I could also imagine merging the links into "Manage additional fields" might be logical a next step, as we also have bug 11844 hopefully moving soon.

4) Tiny follow up for strange hr

Feel free to omit or push at your preference :)
I set the background to a darker color for better contrast and that made it show up as a strange white line.
Comment 17 Tomás Cohen Arazi 2022-10-24 17:41:23 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 18 Lucas Gass 2022-12-05 22:36:49 UTC
Enhancement will not be backported to 22.05.x series