Repository navigation
feature/Allow restricting credit vouchers to incidents and/or requests - #270
Open
anthonymontebrun wants to merge 2 commits into
Open
anthonymontebrun wants to merge 2 commits into
anthonymontebrun wants to merge 2 commits into
Conversation
Add "Usable for incidents" and "Usable for requests" options on credit vouchers (both enabled by default, including for existing vouchers on migration). Vouchers not usable for the ticket type are filtered out of voucher dropdowns, default vouchers are ignored when not applicable, the consume block is hidden when no voucher applies, and consumption is rejected server side.
Check that the voucher can be used for the ticket type when a consumption is added, or when its ticket or voucher is changed (massive action, API). Reset ticket default vouchers that cannot be used for the ticket type, from both the ticket form and the ticket tab. Fix test relying on item_add hook, which is not registered in tests.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Description
This PR adds two options on each credit voucher, Usable for incidents and Usable for requests, to control the ticket types on which the voucher can be consumed. Both options are enabled by default, so existing behaviour is unchanged.
Voucher configuration
is_for_incidents/is_for_requestsonglpi_plugin_credit_entities(default1). They are available in the entity tab add form, in the voucher form, in the vouchers list and as search options (998 / 999).1. Running it again is safe.Ticket side
Enforcement
PluginCreditTicket::prepareInputForAdd()/prepareInputForUpdate()reject a consumption whose voucher cannot be used for the ticket type. This covers the followup / task / solution hook, the ticket tab, the "Update" massive action and the API. On update, the check only runs when the ticket or the voucher changes, so editing the quantity of an older consumption still works.PluginCreditTicketConfigresets a ticket default voucher that does not match the ticket type, and shows a warning. This applies both from the ticket form, which uses the type submitted in the same form, and from the ticket tab.Tests
tests/Units/TicketTypeVoucherTest.php: