Bug 24157

Summary: Additional acquisitions permissions
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: AcquisitionsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Alex Arnaud <alex.arnaud>
Severity: enhancement    
Priority: P5 - low CC: alex.arnaud, fiona.borthwick, lucas, mark.gavillet, martin.renvoize
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20375
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Add more granularity in the acquisition permissions: - reopen_closed_invoices to reopen and close invoices - edit_invoices to edit invoices - delete_invoices to delete invoices - merge_invoices to merge invoices - delete_baskets to delete baskets
Version(s) released in:
20.11.00
Circulation function:
Attachments: Bug 24157: New permission - reopen_closed_invoices
Bug 24157: New permission - edit_invoices
Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Bug 24157: New permission - delete_invoices
Bug 24157: New permission - delete_baskets
Bug 24157: New permission - reopen_closed_invoices
Bug 24157: New permission - edit_invoices
Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Bug 24157: New permission - delete_invoices
Bug 24157: New permission - delete_baskets
Bug 24157: New permission - reopen_closed_invoices
Bug 24157: New permission - edit_invoices
Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Bug 24157: New permission - delete_invoices
Bug 24157: New permission - delete_baskets
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice
Bug 24157: New permission - reopen_closed_invoices
Bug 24157: New permission - edit_invoices
Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Bug 24157: New permission - delete_invoices
Bug 24157: New permission - delete_baskets
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice
Bug 24157: New permission - merge_invoices
Bug 24157: (follow-up) New permission - delete_invoices
Bug 24157: Handle the case where logged in user does not have edit_invoices
Bug 24157: New permission - reopen_closed_invoices
Bug 24157: New permission - edit_invoices
Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Bug 24157: New permission - delete_invoices
Bug 24157: New permission - delete_baskets
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice
Bug 24157: New permission - merge_invoices
Bug 24157: (follow-up) New permission - delete_invoices
Bug 24157: Handle the case where logged in user does not have edit_invoices

Description Jonathan Druart 2019-12-03 19:34:23 UTC
Add separate permissions allowing selected users to:
 * Reopen a closed invoice
 * Edit an invoice
 * Delete a basket
 * Delete an invoice
Comment 1 Jonathan Druart 2019-12-13 17:10:12 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2019-12-13 17:10:15 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2019-12-13 17:10:18 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2019-12-13 17:10:22 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2019-12-13 17:10:25 UTC Comment hidden (obsolete)
Comment 6 Martin Renvoize (ashimema) 2020-02-10 13:53:42 UTC
Created attachment 98651 [details] [review]
Bug 24157: New permission - reopen_closed_invoices

New permission to reopen a closed invoice.

Test plan:
- Remove the new permission "reopen_closed_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, close it
=> You are not able to reopen the invoice
- Add the permission
=> You are able to reopen the invoice

Sponsored-by: Galway-Mayo Institute of Technology
Comment 7 Martin Renvoize (ashimema) 2020-02-10 13:53:45 UTC
Created attachment 98652 [details] [review]
Bug 24157: New permission - edit_invoices

Add a new permission to edit invoices

Test plan:
- Remove the new permission "edit_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, edit it (click "detail")
=> You can see the detail of the invoice, but cannot edit it. It's a read-only view.
- Add the permission
=> The form is back and you can modify the invoices and save the changes.
Also, you are able to create adjustments.

Sponsored-by: Galway-Mayo Institute of Technology
Comment 8 Martin Renvoize (ashimema) 2020-02-10 13:53:49 UTC
Created attachment 98653 [details] [review]
Bug 24157: Add new method Acq::Invoice::Adjustement->fund

Moving to its own commit in case we want to cherry-pick or move it to
its own bug report.

Sponsored-by: Galway-Mayo Institute of Technology
Comment 9 Martin Renvoize (ashimema) 2020-02-10 13:53:52 UTC
Created attachment 98654 [details] [review]
Bug 24157: New permission - delete_invoices

Add a new permission to delete invoices

Test plan:
- Remove the new permission "delete_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the invoice

Sponsored-by: Galway-Mayo Institute of Technology
Comment 10 Martin Renvoize (ashimema) 2020-02-10 13:53:55 UTC
Created attachment 98655 [details] [review]
Bug 24157: New permission - delete_baskets

Add a new permission to delete acquisition baskets

Test plan:
- Remove the new permission "delete_basket" for a given patron,
use it to log in into Koha
- Create basket, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the basket

Sponsored-by: Galway-Mayo Institute of Technology
Comment 11 Martin Renvoize (ashimema) 2020-02-10 13:54:16 UTC
Rebased to allow the application to sandboxes for testing.
Comment 12 Owen Leonard 2020-03-06 19:19:24 UTC
Created attachment 100283 [details] [review]
Bug 24157: New permission - reopen_closed_invoices

New permission to reopen a closed invoice.

Test plan:
- Remove the new permission "reopen_closed_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, close it
=> You are not able to reopen the invoice
- Add the permission
=> You are able to reopen the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 13 Owen Leonard 2020-03-06 19:19:27 UTC
Created attachment 100284 [details] [review]
Bug 24157: New permission - edit_invoices

Add a new permission to edit invoices

Test plan:
- Remove the new permission "edit_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, edit it (click "detail")
=> You can see the detail of the invoice, but cannot edit it. It's a read-only view.
- Add the permission
=> The form is back and you can modify the invoices and save the changes.
Also, you are able to create adjustments.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 14 Owen Leonard 2020-03-06 19:19:30 UTC
Created attachment 100285 [details] [review]
Bug 24157: Add new method Acq::Invoice::Adjustement->fund

Moving to its own commit in case we want to cherry-pick or move it to
its own bug report.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 15 Owen Leonard 2020-03-06 19:19:33 UTC
Created attachment 100286 [details] [review]
Bug 24157: New permission - delete_invoices

Add a new permission to delete invoices

Test plan:
- Remove the new permission "delete_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 16 Owen Leonard 2020-03-06 19:19:36 UTC
Created attachment 100287 [details] [review]
Bug 24157: New permission - delete_baskets

Add a new permission to delete acquisition baskets

Test plan:
- Remove the new permission "delete_basket" for a given patron,
use it to log in into Koha
- Create basket, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the basket

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 17 Owen Leonard 2020-03-06 19:19:38 UTC
Created attachment 100288 [details] [review]
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice

This follow-up makes minor changes to the template so that the checkbox
for reopening or closing an invoice are not displayed when the user
doens't have the correct permissions.

To test, apply the patch and try the process of viewing or editing an
invoice as a user with these various permissions:

 - edit_invoices ON
 - edit_invoices OFF
 - reopen_closed_invoices ON
 - reopen_closed_invoices OFF
Comment 18 Martin Renvoize (ashimema) 2020-03-25 11:29:28 UTC
Followup looks good to me.. Setting to signedoff :)
Comment 19 Alex Arnaud 2020-07-10 10:07:51 UTC
I think the third commit "Add new method Acq::Invoice::Adjustement->fund" is not the right place here. Right ?
I don't see any use of it and no old code removed.
Comment 20 Alex Arnaud 2020-07-10 10:23:05 UTC
Blocker:

I still see the "Merge selected invoices" button in invoices list if i don't have the "edit_invoices" permission.
So i can select invoices, click on it, but i get an empty invoice form and merge is not done.

So IMO there is two options:

1) i can see the merge option and the merge should be done,
2) i can't see the merge option and the checkboxes if i don't have the "edit_invoices" permission.

Questioning: should we assume that merging is editing and deleting ?
Comment 21 Daphne Hoolahan 2020-07-14 16:35:04 UTC
Comment on attachment 100288 [details] [review]
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice

Review of attachment 100288 [details] [review]:
-----------------------------------------------------------------

Suggested extension of this to conditionally show controls to delete invoices too, so that the checkbox
for deleting an invoice is not displayed when the user doesn't have the correct permissions.
Comment 22 Jonathan Druart 2020-07-21 09:13:21 UTC
Created attachment 107132 [details] [review]
Bug 24157: New permission - reopen_closed_invoices

New permission to reopen a closed invoice.

Test plan:
- Remove the new permission "reopen_closed_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, close it
=> You are not able to reopen the invoice
- Add the permission
=> You are able to reopen the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 23 Jonathan Druart 2020-07-21 09:13:25 UTC
Created attachment 107133 [details] [review]
Bug 24157: New permission - edit_invoices

Add a new permission to edit invoices

Test plan:
- Remove the new permission "edit_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, edit it (click "detail")
=> You can see the detail of the invoice, but cannot edit it. It's a read-only view.
- Add the permission
=> The form is back and you can modify the invoices and save the changes.
Also, you are able to create adjustments.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 24 Jonathan Druart 2020-07-21 09:13:28 UTC
Created attachment 107134 [details] [review]
Bug 24157: Add new method Acq::Invoice::Adjustement->fund

Moving to its own commit in case we want to cherry-pick or move it to
its own bug report.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 25 Jonathan Druart 2020-07-21 09:13:31 UTC
Created attachment 107135 [details] [review]
Bug 24157: New permission - delete_invoices

Add a new permission to delete invoices

Test plan:
- Remove the new permission "delete_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 26 Jonathan Druart 2020-07-21 09:13:35 UTC
Created attachment 107136 [details] [review]
Bug 24157: New permission - delete_baskets

Add a new permission to delete acquisition baskets

Test plan:
- Remove the new permission "delete_basket" for a given patron,
use it to log in into Koha
- Create basket, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the basket

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 27 Jonathan Druart 2020-07-21 09:13:39 UTC
Created attachment 107137 [details] [review]
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice

This follow-up makes minor changes to the template so that the checkbox
for reopening or closing an invoice are not displayed when the user
doens't have the correct permissions.

To test, apply the patch and try the process of viewing or editing an
invoice as a user with these various permissions:

 - edit_invoices ON
 - edit_invoices OFF
 - reopen_closed_invoices ON
 - reopen_closed_invoices OFF
Comment 28 Jonathan Druart 2020-07-21 09:13:42 UTC
Created attachment 107138 [details] [review]
Bug 24157: New permission - merge_invoices

Add a new permission to merge invoices

Test plan:
- Remove the new permission "merge_invoices" for a given patron,
use it to log in into Koha
- Create 2 invoices, try to merge them
=> There is no way to merge it
- Add the permission
=> Now you can merge the invoices

Sponsored-by: Galway-Mayo Institute of Technology
Comment 29 Jonathan Druart 2020-07-21 09:13:45 UTC
Created attachment 107139 [details] [review]
Bug 24157: (follow-up) New permission - delete_invoices

Hide the "Delete" invoice link if necessary on
/cgi-bin/koha/acqui/invoice.pl?invoiceid=X
Comment 30 Jonathan Druart 2020-07-21 09:14:05 UTC
(In reply to Alex Arnaud from comment #19)
> I think the third commit "Add new method Acq::Invoice::Adjustement->fund" is
> not the right place here. Right ?
> I don't see any use of it and no old code removed.

Hi Alex,
It is used in "Bug 24157: New permission - edit_invoices"

  [% adjustement.fund.budget_name | html %]


(In reply to Alex Arnaud from comment #20)
> Blocker:
> 
> I still see the "Merge selected invoices" button in invoices list if i don't
> have the "edit_invoices" permission.
> So i can select invoices, click on it, but i get an empty invoice form and
> merge is not done.
> 
> So IMO there is two options:
> 
> 1) i can see the merge option and the merge should be done,
> 2) i can't see the merge option and the checkboxes if i don't have the
> "edit_invoices" permission.
> 
> Questioning: should we assume that merging is editing and deleting ?

I created a new merge_invoices permissions.

(In reply to Daphne Hoolahan from comment #21)
> Comment on attachment 100288 [details] [review] [review]
> Bug 24157: (follow-up) Conditionally show controls to reopen and close
> invoice
> 
> Review of attachment 100288 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> Suggested extension of this to conditionally show controls to delete
> invoices too, so that the checkbox
> for deleting an invoice is not displayed when the user doesn't have the
> correct permissions.

Hi Daphne,
I found a "Delete" link on the invoice detail page, but I did not find one on a view where a checkbox is visible. Can you detail a bit more please?
Comment 31 Alex Arnaud 2020-07-24 10:33:50 UTC
I have the "Merge invoices" permission, but not "Edit invoices"
  => I see the merge button but it doesn't work. I get redirect to an empty invoice form and merge is not done.

I have the "Reopen closed invoices" but not "Edit invoices"
  => I see the reopen button ut it doesn't work. I get redirect to an empty invoice form and reopening is not done.
Comment 32 Jonathan Druart 2020-07-24 11:07:25 UTC
Created attachment 107309 [details] [review]
Bug 24157: Handle the case where logged in user does not have edit_invoices

This patch make possible the reopening and merging of invoices even if
the logged in user does not have the edit_invoices permission

I don't think it really makes sense but at least it's now possible.
Comment 33 Jonathan Druart 2020-07-24 11:08:41 UTC
This is a bit an edge case and I don't think it really makes sense. But it should be handled correctly now. Thanks Alex!
Comment 34 Alex Arnaud 2020-07-24 12:50:35 UTC
(In reply to Jonathan Druart from comment #32)
> Created attachment 107309 [details] [review] [review]
> Bug 24157: Handle the case where logged in user does not have edit_invoices
> 
> This patch make possible the reopening and merging of invoices even if
> the logged in user does not have the edit_invoices permission
> 
> I don't think it really makes sense but at least it's now possible.

It makes sense IMO. If you see the button or link, you should be able to do it.
I would have agreed with hidding this buttons also.
Comment 35 Alex Arnaud 2020-07-24 13:08:02 UTC
Created attachment 107346 [details] [review]
Bug 24157: New permission - reopen_closed_invoices

New permission to reopen a closed invoice.

Test plan:
- Remove the new permission "reopen_closed_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, close it
=> You are not able to reopen the invoice
- Add the permission
=> You are able to reopen the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 36 Alex Arnaud 2020-07-24 13:08:08 UTC
Created attachment 107347 [details] [review]
Bug 24157: New permission - edit_invoices

Add a new permission to edit invoices

Test plan:
- Remove the new permission "edit_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, edit it (click "detail")
=> You can see the detail of the invoice, but cannot edit it. It's a read-only view.
- Add the permission
=> The form is back and you can modify the invoices and save the changes.
Also, you are able to create adjustments.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 37 Alex Arnaud 2020-07-24 13:08:13 UTC
Created attachment 107348 [details] [review]
Bug 24157: Add new method Acq::Invoice::Adjustement->fund

Moving to its own commit in case we want to cherry-pick or move it to
its own bug report.

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 38 Alex Arnaud 2020-07-24 13:08:19 UTC
Created attachment 107349 [details] [review]
Bug 24157: New permission - delete_invoices

Add a new permission to delete invoices

Test plan:
- Remove the new permission "delete_invoices" for a given patron,
use it to log in into Koha
- Create an invoice, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the invoice

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 39 Alex Arnaud 2020-07-24 13:08:24 UTC
Created attachment 107350 [details] [review]
Bug 24157: New permission - delete_baskets

Add a new permission to delete acquisition baskets

Test plan:
- Remove the new permission "delete_basket" for a given patron,
use it to log in into Koha
- Create basket, try to delete it
=> There is no way to delete it
- Add the permission
=> Now you can delete the basket

Sponsored-by: Galway-Mayo Institute of Technology

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 40 Alex Arnaud 2020-07-24 13:08:29 UTC
Created attachment 107351 [details] [review]
Bug 24157: (follow-up) Conditionally show controls to reopen and close invoice

This follow-up makes minor changes to the template so that the checkbox
for reopening or closing an invoice are not displayed when the user
doens't have the correct permissions.

To test, apply the patch and try the process of viewing or editing an
invoice as a user with these various permissions:

 - edit_invoices ON
 - edit_invoices OFF
 - reopen_closed_invoices ON
 - reopen_closed_invoices OFF

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 41 Alex Arnaud 2020-07-24 13:08:34 UTC
Created attachment 107352 [details] [review]
Bug 24157: New permission - merge_invoices

Add a new permission to merge invoices

Test plan:
- Remove the new permission "merge_invoices" for a given patron,
use it to log in into Koha
- Create 2 invoices, try to merge them
=> There is no way to merge it
- Add the permission
=> Now you can merge the invoices

Sponsored-by: Galway-Mayo Institute of Technology
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 42 Alex Arnaud 2020-07-24 13:08:40 UTC
Created attachment 107353 [details] [review]
Bug 24157: (follow-up) New permission - delete_invoices

Hide the "Delete" invoice link if necessary on
/cgi-bin/koha/acqui/invoice.pl?invoiceid=X

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 43 Alex Arnaud 2020-07-24 13:08:45 UTC
Created attachment 107354 [details] [review]
Bug 24157: Handle the case where logged in user does not have edit_invoices

This patch make possible the reopening and merging of invoices even if
the logged in user does not have the edit_invoices permission

I don't think it really makes sense but at least it's now possible.

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 44 Jonathan Druart 2020-07-30 15:46:41 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 45 Lucas Gass (lukeg) 2020-07-31 21:23:40 UTC
enhancement will not be backported to 20.05.x series
Comment 46 Katrin Fischer 2020-08-05 10:44:44 UTC
*** Bug 20375 has been marked as a duplicate of this bug. ***