Skip to content

OBPIH-6691 Add partially invoiced order summary status for order adjustments#4857

Merged
awalkowiak merged 3 commits intorelease/0.9.2-hotfix1from
OBPIH-6691
Sep 26, 2024
Merged

OBPIH-6691 Add partially invoiced order summary status for order adjustments#4857
awalkowiak merged 3 commits intorelease/0.9.2-hotfix1from
OBPIH-6691

Conversation

@alannadolny
Copy link
Collaborator

@alannadolny alannadolny self-assigned this Sep 23, 2024
@github-actions github-actions bot added the flag: schema change Hilights a pull request that contains a change to the database schema label Sep 23, 2024
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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

AND SUM(items_and_adjustments_union.total_adjustments) > 0 this should be as well invoiced_amount > 0

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

Few key points from my local testing / local review:

  1. As mentioned in previous review, the PARTIALLY_INVOICED checks are wrong and need to be improved.
  2. If nothing is invoiced, then order status should not be partially invoiced, but should properly reflect the current order state.
  3. The invoiced amount calculation does not take into account if invoice is posted (here we only count only posted invoices).
  4. 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.

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

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.

@awalkowiak awalkowiak merged commit a4d2235 into release/0.9.2-hotfix1 Sep 26, 2024
@awalkowiak awalkowiak deleted the OBPIH-6691 branch September 26, 2024 18:14
jwalbers pushed a commit to jwalbers/openboxes that referenced this pull request Oct 29, 2024
jwalbers pushed a commit to jwalbers/openboxes that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: schema change Hilights a pull request that contains a change to the database schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants