fix(dashboard,order): preview pending diff summary (#14221)

* wip: preview pending diff summary

* fix: return test

* fix: rm return calc from processAction_

* chore: cleanup

* chore: changeset

* feat: add estimated diff for return,claim,exchange forms

* chore: changeset
This commit is contained in:
Frane Polić
2025-12-08 09:57:13 +01:00
committed by GitHub
parent fe49b567d6
commit 6176f93ac5
6 changed files with 54 additions and 20 deletions
@@ -568,6 +568,16 @@ export const ClaimCreateForm = ({
}
}, [])
/**
* For estimated difference show pending difference and subtract the total of inbound items (assume all items will be returned correctly)
* We don't include inbound total in the pending difference because it will be considered returned when the receive flow is completed
*/
const estimatedDifference =
preview.summary.pending_difference -
inboundPreviewItems.reduce((acc, item) => {
return acc + item.total
}, 0)
const inboundShippingTotal = useMemo(() => {
const method = preview.shipping_methods.find(
(sm) =>
@@ -1010,10 +1020,7 @@ export const ClaimCreateForm = ({
{t("orders.claims.refundAmount")}
</span>
<span className="txt-small font-medium">
{getStylizedAmount(
preview.summary.pending_difference,
order.currency_code
)}
{getStylizedAmount(estimatedDifference, order.currency_code)}
</span>
</div>
</div>
@@ -272,6 +272,16 @@ export const ExchangeCreateForm = ({
}
}, [])
/**
* For estimated difference show pending difference and subtract the total of inbound items (assume all items will be returned correctly)
* We don't include inbound total in the pending difference because it will be considered returned when the receive flow is completed
*/
const estimatedDifference =
preview.summary.pending_difference -
inboundPreviewItems.reduce((acc, item) => {
return acc + item.total
}, 0)
const inboundShippingTotal = useMemo(() => {
const method = preview.shipping_methods.find(
(sm) =>
@@ -516,10 +526,7 @@ export const ExchangeCreateForm = ({
{t("orders.exchanges.refundAmount")}
</span>
<span className="txt-small font-medium">
{getStylizedAmount(
preview.summary.pending_difference,
order.currency_code
)}
{getStylizedAmount(estimatedDifference, order.currency_code)}
</span>
</div>
</div>
@@ -402,6 +402,16 @@ export const ReturnCreateForm = ({
return method?.total || 0
}, [preview.shipping_methods])
/**
* For estimated difference show pending difference and subtract the total of inbound items (assume all items will be returned correctly)
* We don't include inbound total in the pending difference because it will be considered returned when the receive flow is completed
*/
const estimatedDifference =
preview.summary.pending_difference -
previewItems.reduce((acc, item) => {
return acc + item.total
}, 0)
return (
<RouteFocusModal.Form
form={form}
@@ -707,10 +717,7 @@ export const ReturnCreateForm = ({
{t("orders.returns.estDifference")}
</span>
<span className="txt-small font-medium">
{getStylizedAmount(
preview.summary.pending_difference,
order.currency_code
)}
{getStylizedAmount(estimatedDifference, order.currency_code)}
</span>
</div>
</div>