OBPIH-6691 Add partially invoiced order summary status for order adjustments#4857
OBPIH-6691 Add partially invoiced order summary status for order adjustments#4857awalkowiak merged 3 commits intorelease/0.9.2-hotfix1from
Conversation
| WHEN (SUM(items_and_adjustments_union.quantity_ordered) + SUM(items_and_adjustments_union.adjustments_count)) > 0 AND (SUM(items_and_adjustments_union.quantity_invoiced) + SUM(items_and_adjustments_union.adjustments_invoiced) > 0) THEN 'PARTIALLY_INVOICED' | ||
| WHEN SUM(items_and_adjustments_union.quantity_ordered) = 0 AND SUM(items_and_adjustments_union.invoiced_amount) = 0 THEN NULL | ||
| WHEN SUM(items_and_adjustments_union.quantity_ordered) = SUM(items_and_adjustments_union.quantity_invoiced) AND SUM(items_and_adjustments_union.total_adjustments) = SUM(items_and_adjustments_union.invoiced_amount) THEN 'INVOICED' | ||
| WHEN (SUM(items_and_adjustments_union.quantity_ordered) < SUM(items_and_adjustments_union.quantity_invoiced) AND SUM(items_and_adjustments_union.quantity_ordered) > 0) |
There was a problem hiding this comment.
I think this SUM(union.quantity_ordered) < SUM(union.quantity_invoiced should have the opposite sign. It's partially invoiced if only part of the ordered quantity is invoiced --> ordered > invoiced
plus this part: AND SUM(items_and_adjustments_union.quantity_ordered) > 0 should rather check if quantity_invoiced > 0
| WHEN SUM(items_and_adjustments_union.quantity_ordered) = 0 AND SUM(items_and_adjustments_union.invoiced_amount) = 0 THEN NULL | ||
| WHEN SUM(items_and_adjustments_union.quantity_ordered) = SUM(items_and_adjustments_union.quantity_invoiced) AND SUM(items_and_adjustments_union.total_adjustments) = SUM(items_and_adjustments_union.invoiced_amount) THEN 'INVOICED' | ||
| WHEN (SUM(items_and_adjustments_union.quantity_ordered) < SUM(items_and_adjustments_union.quantity_invoiced) AND SUM(items_and_adjustments_union.quantity_ordered) > 0) | ||
| OR (SUM(items_and_adjustments_union.invoiced_amount) < SUM(items_and_adjustments_union.total_adjustments) AND SUM(items_and_adjustments_union.total_adjustments) > 0) THEN 'PARTIALLY_INVOICED' |
There was a problem hiding this comment.
AND SUM(items_and_adjustments_union.total_adjustments) > 0 this should be as well invoiced_amount > 0
awalkowiak
left a comment
There was a problem hiding this comment.
Few key points from my local testing / local review:
- As mentioned in previous review, the
PARTIALLY_INVOICEDchecks are wrong and need to be improved. - If nothing is invoiced, then order status should not be
partially invoiced, but should properly reflect the current order state. - The invoiced amount calculation does not take into account if invoice is posted (here we only count only posted invoices).
- With the current solution there might be an ssue when we have an order adjutement with amount 0, that was invoiced for this amount (it should be treated as invoiced properly). Probably you could utilize the still available adjustment count and invoiced adjustment count on top of amount comparison for this case.
…tead of looking into the quantity invoiced
49b30df to
8c49c0c
Compare
awalkowiak
left a comment
There was a problem hiding this comment.
There still might be one case that is not working, but I am merging it as is (disregarding the one problematic case, it looks good) since there is a lot to QA here.
✨ Description of Change
Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6691