@aptos-scp/scp-component-store-selling-features-domain-model 2.30.0 → 2.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -741,8 +741,19 @@ function getOriginalTenderRefundableAmount(originalTender, refundDue, originalTr
741
741
  const originalTran = (_b = originalTransactionDetails) === null || _b === void 0 ? void 0 : _b.find((origTran) => origTran.originalTransactionId === originalTenderReferenceTranId);
742
742
  if (refundDue) {
743
743
  const returnTotalAmount = getReturnOrCancelTotalAmount(originalTran);
744
+ const originalTenderId = originalTender.isMappedTender
745
+ ? originalTender.mappedOriginTenderId
746
+ : originalTender.tenderId;
747
+ // originalTranTenderAdjustmentTotal is the aggregate of all adjustments that were applied to
748
+ // the tender in the source transaction
749
+ const originalTranTenderAdjustmentTotal = originalTran.originalTenders.reduce((adjustmentTotal, tender) => tender.tenderId === originalTenderId && tender.adjustmentAmount instanceof scp_component_business_core_1.Money
750
+ ? adjustmentTotal.plus(tender.adjustmentAmount)
751
+ : adjustmentTotal, new scp_component_business_core_1.Money(0, refundDue.currency));
752
+ // adjust the raw refundableAmount of origTranRef to factor in the total adjustments
753
+ // applied to the tender
754
+ const adjustedOriginalTranRefRefundableAmount = adjustAmount(origTranRef.refundableAmount, originalTranTenderAdjustmentTotal);
744
755
  // If transaction was partially returned, tranRef.refundableAmount will have the full original tender amount, default to the partial return total amount
745
- const originalTenderAmount = getLowestRefundDue(undefined, returnTotalAmount, origTranRef.refundableAmount);
756
+ const originalTenderAmount = getLowestRefundDue(undefined, returnTotalAmount, adjustedOriginalTranRefRefundableAmount);
746
757
  // Mapped tenders will only use their transaction references for refund amount calculation, if they have been fully tendered,
747
758
  // they will not have transaction references, do not subtract refunded amount
748
759
  const currentTranRefundableAmount = calculateRefundableAmount(originalTenderAmount, originalTender.isMappedTender ? undefined : originalTender.refundedAmount, returnTotalAmount, refundDue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-scp/scp-component-store-selling-features-domain-model",
3
- "version": "2.30.0",
3
+ "version": "2.30.1",
4
4
  "description": "This component library provides the common components to handle the coordination of processing the business events from the UI.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENSE.md",