-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[CP Staging] Fix split distance expense showing wrong currency after workspace currency change #83618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CP Staging] Fix split distance expense showing wrong currency after workspace currency change #83618
Changes from all commits
2a82ab9
fa34aa8
ff5b551
9955a6b
b30d222
e054219
86a88d9
dd82e84
01d9cd3
d169565
897a7ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1864,13 +1864,13 @@ function setIndividualShare(transactionID: string, participantAccountID: number, | |
| /** | ||
| * Calculate merchant for distance transactions based on distance and rate | ||
| */ | ||
| function getDistanceMerchantFromDistance(distanceInUnits: number, unit: Unit | undefined, rate: number | undefined, currency: string, transactionCurrency?: string): string { | ||
| function getDistanceMerchantFromDistance(distanceInUnits: number, unit: Unit | undefined, rate: number | undefined, currency: string): string { | ||
| if (!rate || rate <= 0 || !unit) { | ||
| return ''; | ||
| } | ||
|
|
||
| const distanceInMeters = DistanceRequestUtils.convertToDistanceInMeters(distanceInUnits, unit); | ||
| const currencyForMerchant = currency ?? transactionCurrency ?? CONST.CURRENCY.USD; | ||
| const currencyForMerchant = currency; | ||
| const currentLocale = IntlStore.getCurrentLocale(); | ||
| return DistanceRequestUtils.getDistanceMerchant( | ||
| true, | ||
|
|
@@ -1911,7 +1911,7 @@ function updateSplitExpenseDistanceFromAmount( | |
| quantity, | ||
| }; | ||
|
|
||
| const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, mileageRate?.currency ?? transactionCurrency ?? CONST.CURRENCY.USD, transactionCurrency); | ||
| const merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, transactionCurrency ?? mileageRate?.currency ?? CONST.CURRENCY.USD); | ||
|
|
||
| return {customUnit, merchant}; | ||
| } | ||
|
|
@@ -2339,8 +2339,8 @@ function updateSplitExpenseField( | |
| updatedItem.amount = calculatedAmount; | ||
|
|
||
| // Update merchant for distance transactions | ||
| const currency = mileageRate?.currency ?? originalTransaction.currency ?? CONST.CURRENCY.USD; | ||
| updatedItem.merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, currency, originalTransaction.currency); | ||
| const currency = originalTransaction.currency ?? mileageRate?.currency ?? CONST.CURRENCY.USD; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When saving split distance edits, this now prioritizes Useful? React with 👍 / 👎. |
||
| updatedItem.merchant = getDistanceMerchantFromDistance(distanceInUnits, unit, rate, currency); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes
updateSplitExpenseDistanceFromAmount()prefertransactionCurrencyovermileageRate.currency, which causes wrong merchant currency when a split expense rate is changed to one with a different currency. In split flows, amount recalculations (e.g.,updateSplitExpenseAmountField) passoriginalTransaction.currencyastransactionCurrency, so the amount is recomputed from the new rate but the merchant string is formatted with the old currency, creating a currency/amount mismatch for edited split distances.Useful? React with 👍 / 👎.