-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix - [Unreported] Add distance rate to the distance expenses tracked in selfDM #74967
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
base: main
Are you sure you want to change the base?
Changes from all commits
2c9a4f8
4f385e5
81c56b4
20c4b84
99743f5
315b26e
20fa4e7
c77d855
826611b
96782d7
11e6ce9
c8b655b
3429cd5
f95d0a4
4a9c2e4
555dda3
4297392
d0f64c1
5040612
1df5aa1
0600580
c4a5d1a
ac4830b
02ff260
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 |
|---|---|---|
|
|
@@ -289,12 +289,14 @@ | |
| reportID, | ||
| isPolicyExpenseChat, | ||
| policy, | ||
| isTrackDistanceExpense = false, | ||
|
Member
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. what is the use of this param? Earlier we were dependent on
Contributor
Author
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. We use it for applying the default rate of |
||
| lastSelectedDistanceRates, | ||
| }: { | ||
| reportID: string | undefined; | ||
| isPolicyExpenseChat: boolean; | ||
| policy: OnyxEntry<Policy> | undefined; | ||
| lastSelectedDistanceRates?: OnyxEntry<LastSelectedDistanceRates>; | ||
| isTrackDistanceExpense?: boolean; | ||
| }): string { | ||
| let customUnitRateID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID; | ||
|
|
||
|
|
@@ -310,11 +312,11 @@ | |
| return customUnitRateID; | ||
| } | ||
|
|
||
| if (isPolicyExpenseChat) { | ||
| if (isPolicyExpenseChat || isTrackDistanceExpense) { | ||
| const distanceUnit = Object.values(policy.customUnits ?? {}).find((unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE); | ||
| const lastSelectedDistanceRateID = lastSelectedDistanceRates?.[policy.id]; | ||
| const lastSelectedDistanceRate = lastSelectedDistanceRateID ? distanceUnit?.rates[lastSelectedDistanceRateID] : undefined; | ||
| if (lastSelectedDistanceRate?.enabled && lastSelectedDistanceRateID) { | ||
| if (!isTrackDistanceExpense && lastSelectedDistanceRate?.enabled && lastSelectedDistanceRateID) { | ||
| customUnitRateID = lastSelectedDistanceRateID; | ||
| } else { | ||
| const defaultMileageRate = getDefaultMileageRate(policy); | ||
|
|
@@ -359,21 +361,24 @@ | |
| policy, | ||
| policyDraft, | ||
| useTransactionDistanceUnit = true, | ||
| policyForMovingExpenses, | ||
| }: { | ||
| transaction: OnyxEntry<Transaction>; | ||
| policy: OnyxEntry<Policy>; | ||
| policyDraft?: OnyxEntry<Policy>; | ||
| policyForMovingExpenses?: OnyxEntry<Policy>; | ||
| useTransactionDistanceUnit?: boolean; | ||
| }): MileageRate { | ||
| let mileageRates = getMileageRates(policy, true, transaction?.comment?.customUnit?.customUnitRateID); | ||
| if (isEmptyObject(mileageRates) && policyDraft) { | ||
| mileageRates = getMileageRates(policyDraft, true, transaction?.comment?.customUnit?.customUnitRateID); | ||
| } | ||
| const mileageRatesForMovingExpenses = getMileageRates(policyForMovingExpenses, true, transaction?.comment?.customUnit?.customUnitRateID); | ||
| const policyCurrency = policy?.outputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; | ||
| const defaultMileageRate = getDefaultMileageRate(policy); | ||
| const customUnitRateID = getRateID(transaction); | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
| const customMileageRate = (customUnitRateID && mileageRates?.[customUnitRateID]) || defaultMileageRate; | ||
| const customMileageRate = (customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) || defaultMileageRate; | ||
| const mileageRate = isCustomUnitRateIDForP2P(transaction) ? getRateForP2P(policyCurrency, transaction) : customMileageRate; | ||
| const unit = getDistanceUnit(useTransactionDistanceUnit ? transaction : undefined, mileageRate); | ||
| return { | ||
|
|
||
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.
Why is this different from Category field? Can we use
shouldNavigateToUpgradePathhere?