Skip to content

OBPIH-6644 Fix calculating inverse item after reducing ordered quantity (invoice item edit)#4822

Merged
awalkowiak merged 1 commit intofeature/OBPIH-6398-partial-invoices-for-prepaid-pofrom
OBPIH-6644
Sep 4, 2024
Merged

OBPIH-6644 Fix calculating inverse item after reducing ordered quantity (invoice item edit)#4822
awalkowiak merged 1 commit intofeature/OBPIH-6398-partial-invoices-for-prepaid-pofrom
OBPIH-6644

Conversation

@awalkowiak
Copy link
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket:
https://pihemr.atlassian.net/browse/OBPIH-6644

Description:
This is an improvement to my previous PR (#4820). I forgot about invoice item editing on confirm page...


📈 Test Plan

  • Frontend automation tests (unit)
  • Backend automation tests (unit, API, smoke)
  • End-to-end tests (Playwright)
  • Manual tests (please describe below)
  • Not Applicable

Description of test plan (if applicable):
According to the test plan


✅ Quality Checks

  • The pull request title is prefixed with the issue/ticket number (Ex: [OBS-123] for Jira, [#0000] for GitHub, or [OBS-123, OBPIH-123] if there are multiple), or with [N/A] if not applicable
  • The pull request description has enough information for someone without context to be able to understand the change and why it is needed
  • The change has tests that prove the issue is fixed / the feature works as intended

@github-actions github-actions bot added the domain: backend Changes or discussions relating to the backend server label Sep 3, 2024
Comment on lines +347 to +354
Integer getQuantityToInverse(OrderItem orderItem, Integer quantityInvoiced, Integer quantityInverseable) {
if (orderItem.isCompletelyFulfilled() && orderItem.isFullyInvoiced()) {
// If quantity if fully shipped and fully invoiced set full inverse quantity
return quantityInverseable
}

return quantityInvoiced >= quantityInverseable ? quantityInverseable : quantityInvoiced
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like a method that should be placed in the domain, what do you think @awalkowiak?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say it's difficult to determine in which domain it should be placed, because in most of those we operate on an order item, so it would be weird to place it in the InvoiceItem domain, especially that all the values passed in this method are not transients, but some values calculated in some other methods, e.g. getQuantityToInverse that is already placed in this service a few lines above.

I will let you guys debate on that and make a final decision

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically it potentially could be on the order item, but since it did not rely only on the data that could be pulled from the order item or prepayment item easily (it relies also on the specific invoice item quantity, currently created or edited) I think it is more suiting here.

Comment on lines +347 to +354
Integer getQuantityToInverse(OrderItem orderItem, Integer quantityInvoiced, Integer quantityInverseable) {
if (orderItem.isCompletelyFulfilled() && orderItem.isFullyInvoiced()) {
// If quantity if fully shipped and fully invoiced set full inverse quantity
return quantityInverseable
}

return quantityInvoiced >= quantityInverseable ? quantityInverseable : quantityInvoiced
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say it's difficult to determine in which domain it should be placed, because in most of those we operate on an order item, so it would be weird to place it in the InvoiceItem domain, especially that all the values passed in this method are not transients, but some values calculated in some other methods, e.g. getQuantityToInverse that is already placed in this service a few lines above.

I will let you guys debate on that and make a final decision

@awalkowiak awalkowiak merged commit fe3397c into feature/OBPIH-6398-partial-invoices-for-prepaid-po Sep 4, 2024
@awalkowiak awalkowiak deleted the OBPIH-6644 branch September 4, 2024 08:01
awalkowiak added a commit that referenced this pull request Sep 6, 2024
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants