diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bdf6ca823369..cb770bf98c1b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5092,6 +5092,7 @@ type UpdateMoneyRequestAmountAndCurrencyParams = { policy?: OnyxEntry; policyTagList?: OnyxEntry; policyCategories?: OnyxEntry; + taxCode: string; }; /** Updates the amount and currency fields of an expense */ @@ -5104,11 +5105,13 @@ function updateMoneyRequestAmountAndCurrency({ policy, policyTagList, policyCategories, + taxCode, }: UpdateMoneyRequestAmountAndCurrencyParams) { const transactionChanges = { amount, currency, ...(taxAmount && {taxAmount}), + taxCode, }; const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index b320766edd7a..c0f4349506fc 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -56,12 +56,12 @@ type IOURequestStepAmountProps = IOURequestStepAmountOnyxProps & transaction: OnyxEntry; }; -function getTaxAmount(transaction: OnyxEntry, policy: OnyxEntry, newAmount: number) { +function getTaxAmount(transaction: OnyxEntry, policy: OnyxEntry, newAmount: number, currency: string) { if (!transaction?.amount) { return; } const transactionTaxCode = transaction?.taxCode ?? ''; - const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction) ?? ''; + const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction, currency) ?? ''; const taxPercentage = TransactionUtils.getTaxValue(policy, transaction, transactionTaxCode ?? defaultTaxCode) ?? ''; return CurrencyUtils.convertToBackendAmount(TransactionUtils.calculateTaxAmount(taxPercentage, newAmount)); } @@ -290,9 +290,10 @@ function IOURequestStepAmount({ return; } - const taxAmount = getTaxAmount(transaction, policy, newAmount); + const taxAmount = getTaxAmount(transaction, policy, newAmount, currency); + const taxCode = TransactionUtils.getDefaultTaxCode(policy, transaction, currency) ?? ''; - IOU.updateMoneyRequestAmountAndCurrency({transactionID, transactionThreadReportID: reportID, currency, amount: newAmount, taxAmount}); + IOU.updateMoneyRequestAmountAndCurrency({transactionID, transactionThreadReportID: reportID, currency, amount: newAmount, taxAmount, taxCode}); Navigation.dismissModal(); };