OBPIH-6644 Fix calculating inverse item after reducing ordered quantity (invoice item edit)#4822
Conversation
…ty (invoice item edit)
| 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 | ||
| } |
There was a problem hiding this comment.
looks like a method that should be placed in the domain, what do you think @awalkowiak?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| 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 | ||
| } |
There was a problem hiding this comment.
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
fe3397c
into
feature/OBPIH-6398-partial-invoices-for-prepaid-po
…ty (invoice item edit) (#4822)
✨ 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
Description of test plan (if applicable):
According to the test plan
✅ Quality Checks
[OBS-123]for Jira,[#0000]for GitHub, or[OBS-123, OBPIH-123]if there are multiple), or with[N/A]if not applicable