-
-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent generating invoices when order's distributor can't generate invoices #12219
prevent generating invoices when order's distributor can't generate invoices #12219
Conversation
0ba4fe0
to
ee1f608
Compare
authorize! :invoice, @order | ||
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice | ||
if @order.distributor.can_invoice? | ||
authorize! :invoice, @order | ||
OrderInvoiceGenerator.new(@order).generate_or_update_latest_invoice | ||
else | ||
flash[:error] = t(:must_have_valid_business_number, | ||
enterprise_name: @order.distributor.name) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought was why we don't include that check in the Abilities class to have one source of truth. But that wouldn't provide us with a good error message. I guess that's one downside of CanCan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Great
Hi @abdellani, |
conflict resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
What? Why?
When I worked on this PR, we accidentally discovered that it's possible to generate invoices while the order's distributor can't generate invoices.
Check the following comments for more details:
#11918 (comment)
#11918 (comment)
What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates