Skip to content

OBPIH-6746 Value in amount column of PO Invoice tab for regular POs#4880

Merged
awalkowiak merged 7 commits intorelease/0.9.2-hotfix1from
OBPIH-6746
Oct 8, 2024
Merged

OBPIH-6746 Value in amount column of PO Invoice tab for regular POs#4880
awalkowiak merged 7 commits intorelease/0.9.2-hotfix1from
OBPIH-6746

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

@alannadolny alannadolny self-assigned this Oct 7, 2024
@github-actions github-actions bot added domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server flag: schema change Hilights a pull request that contains a change to the database schema labels Oct 7, 2024
* Total shipment item value
* @deprecated From now should rely on the amount field instead always calculating it
*/
def getTotalAmount() {
Copy link
Member

Choose a reason for hiding this comment

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

This is being used in InvoiceService.getInvoiceItemsCsv. You should hopefully just need to switch to use amount instead of totalAmount

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, @alannadolny please replace it in the service as well

<preConditions onFail="MARK_RAN">
<and>
<columnExists tableName="invoice_item" columnName="amount"/>
<not>
Copy link
Member

Choose a reason for hiding this comment

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

Weird that liquibase requires this clunky syntax and doesn't have a better solution like expectedResult=">0" or <sqlCheck notExpectedResult="0">

</and>
</preConditions>

<sql>
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment here clarifying that this is only allowed because we've already migrated all prepayment invoices and so the only invoice items with a null amount at this point should be non-prepayment ones

Copy link
Member

@ewaterman ewaterman Oct 7, 2024

Choose a reason for hiding this comment

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

Also, I'm surprised you can't just do this:

UPDATE invoice_item
SET amount = quantity * IFNULL(unit_price, 0)
WHERE amount IS NULL;

* Total shipment item value
* @deprecated From now should rely on the amount field instead always calculating it
*/
def getTotalAmount() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, @alannadolny please replace it in the service as well

unitPriceAvailableToInvoice: orderAdjustment?.unitPriceAvailableToInvoice,
// Total amount and total prepayment amount are deprecated and amount field
// should be used instead (OBPIH-6398, OBPIH-6499)
totalAmount: totalAmount,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if technically these two fields should stay for now, because this was expected as a part of getPrepaymentItems. I am not sure if we have a defined API endpoint deprecation flow. However, there is really high probability we were the only ones using it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so what's the decision here? should I revert those properties?

SELECT id, quantity * IFNULL(unit_price, 0) AS calculated_amount
FROM invoice_item
) AS calculated_amount ON calculated_amount.id = item.id
SET item.amount = calculated_amount.calculated_amount
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's nitpicky, but calculated_amount.calculated_amount looks weird.

@awalkowiak awalkowiak merged commit 97df9fc into release/0.9.2-hotfix1 Oct 8, 2024
@awalkowiak awalkowiak deleted the OBPIH-6746 branch October 8, 2024 15:26
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 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.

3 participants