Skip to content

OBPIH-6498 Show confirmation dialog when trying to generate a partial invoice#4774

Merged
awalkowiak merged 7 commits intodevelopfrom
OBPIH-6498-frontend-show-confirmation-popup-if-generating-a-partial-invoice
Aug 5, 2024
Merged

OBPIH-6498 Show confirmation dialog when trying to generate a partial invoice#4774
awalkowiak merged 7 commits intodevelopfrom
OBPIH-6498-frontend-show-confirmation-popup-if-generating-a-partial-invoice

Conversation

@drodzewicz
Copy link
Collaborator

@drodzewicz drodzewicz commented Jul 31, 2024

✨ 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
image

@drodzewicz drodzewicz added the domain: frontend Changes or discussions relating to the frontend UI label Jul 31, 2024
@drodzewicz drodzewicz self-assigned this Jul 31, 2024
@github-actions github-actions bot added domain: backend Changes or discussions relating to the backend server flag: config change Hilights a pull request that contains a change to the app config domain: l10n Changes or discussions relating to localization & Internationalization labels Jul 31, 2024
}

Boolean isFullyInvoiceable() {
return orderItems.every{ it -> it.invoiceable }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

return Mock(OrderItem) {
isEncumbered() >> encumbered
isInvoiceable() >> invoiceable
toString() >> "encumbered: $encumbered, invoiceable: $invoiceable"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever overriding the toString() here!


Boolean isFullyInvoiceable() {
Set<OrderItem> encumberedOrderItems = orderItems.findAll{ it -> it.encumbered }
return encumberedOrderItems && encumberedOrderItems.every{ it -> it.invoiceable }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to not do it in one loop with something like:
return !orderItems.any{ it -> it.encumbered && !it.invoiceable }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@drodzewicz
Copy link
Collaborator Author

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 isFullyInvoiceable
@awalkowiak

@drodzewicz drodzewicz force-pushed the OBPIH-6498-frontend-show-confirmation-popup-if-generating-a-partial-invoice branch from 59ad7b9 to 53b10db Compare August 2, 2024 13:50
@drodzewicz drodzewicz added warn: do not merge Marks a pull request that is not yet ready to be merged status: work in progress For issues or pull requests that are in progress but not yet completed and removed warn: do not merge Marks a pull request that is not yet ready to be merged labels Aug 2, 2024
@drodzewicz drodzewicz removed status: work in progress For issues or pull requests that are in progress but not yet completed flag: config change Hilights a pull request that contains a change to the app config labels Aug 5, 2024
@awalkowiak awalkowiak merged commit 4cc6776 into develop Aug 5, 2024
@awalkowiak awalkowiak deleted the OBPIH-6498-frontend-show-confirmation-popup-if-generating-a-partial-invoice branch August 5, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants