OBPIH-6498 Show confirmation dialog when trying to generate a partial invoice#4774
Conversation
| } | ||
|
|
||
| Boolean isFullyInvoiceable() { | ||
| return orderItems.every{ it -> it.invoiceable } |
There was a problem hiding this comment.
I believe you want the order item check here to be invoiceable || has already been invoiced.
If we've previously generated an invoice for some of the order items, those will no longer be invoiceable but shouldn't cause the pop-up if the remaining items are invoiceable
There was a problem hiding this comment.
you are correct, I made some changes that should reflect this behavior.
I decided to check invoicebale against encumbered items which should make sense, right?
Additionally added a simple unit test to reinforce this method
…ed items and add unit test
| return Mock(OrderItem) { | ||
| isEncumbered() >> encumbered | ||
| isInvoiceable() >> invoiceable | ||
| toString() >> "encumbered: $encumbered, invoiceable: $invoiceable" |
There was a problem hiding this comment.
clever overriding the toString() here!
|
|
||
| Boolean isFullyInvoiceable() { | ||
| Set<OrderItem> encumberedOrderItems = orderItems.findAll{ it -> it.encumbered } | ||
| return encumberedOrderItems && encumberedOrderItems.every{ it -> it.invoiceable } |
There was a problem hiding this comment.
Any particular reason to not do it in one loop with something like:
return !orderItems.any{ it -> it.encumbered && !it.invoiceable }
There was a problem hiding this comment.
the example you have provided fails on cases where none of our items is encumbered.
If none of them are encumbered it returns false for .any{} and a negation returns true for isFullyInvoiceable which does not make sense which is why I added an additional check for if there are any encumbered items.
There was a problem hiding this comment.
Last thought: What about adjustments? If we have items that are encumbered and non-invoiceable, but we have an invoiceable adjustment, we'd still want the confirmation to pop up, right?
|
|
||
| Boolean isFullyInvoiceable() { | ||
| Set<OrderItem> encumberedOrderItems = orderItems.findAll{ it -> it.encumbered } | ||
| return encumberedOrderItems && !encumberedOrderItems.any{ it -> !it.invoiceable } |
There was a problem hiding this comment.
Would not encumberedOrderItems?.every { it -> it.invoiceable } be cleaner? Plus this should also look into orderAdjustments, because if you won't have order items, just order adjustments, then you will always get the warning. On top of that invoiceable checks if item is invoiceable, not fully invoiceable, as you can see, there is
quantityAvailableToInvoice > 0 and in you case you are more interested in if quantityAvailableToInvoice == quantity remaining to invoice
There was a problem hiding this comment.
good point on the adjustments but as for return encumberedOrderItems?.every { it -> it.invoiceable } this will not work since it is not the same as return encumberedOrderItems && encumberedOrderItems.every { it -> it.invoiceable }
The first check for encumberedOrderItems is for a case where we do .every on an empty list that will return true and we don't want that
|
The tests are going to fail ATM I am working on adding some new ones since the logic for checking if Order is fully invoiceable has changed. But feel free to give you approval or disapproval for the current version of the |
…s fully invoiceable
59ad7b9 to
53b10db
Compare
✨ Description of Change
Link to GitHub issue or Jira ticket: OBPIH-6498
Description:
Add a confirmation popup when users is trying to generate a partial invoice.
📷 Screenshots & Recordings (optional)
video: https://jam.dev/c/5b9137ba-ff96-4506-b86c-5fe6281ef3ac
