Recalculate mileage rate when editing distance expense date#93755
Recalculate mileage rate when editing distance expense date#93755Krishna2323 wants to merge 7 commits into
Conversation
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@codex review |
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7751a9fcf4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@codex review |
|
@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
| updatedTaxValue?: string; | ||
| }; | ||
|
|
||
| function getDistanceRateTaxUpdatesForTransaction({ |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The tax-amount computation in getDistanceRateTaxUpdatesForTransaction duplicates the logic already present in src/pages/iou/request/step/IOURequestStepDistanceRate.tsx (lines 186-192). Both run the same sequence: getDistanceRateCustomUnitRate → getDefaultTaxCode → getTaxableAmount → getTaxValue → calculateTaxAmount → convertToBackendAmount. Keeping two copies means a future change to how distance-rate tax is calculated (e.g. the || vs ?? fallback on taxRateExternalID, or which distance unit is used) must be applied in two places and risks divergence.
Extract this calculation into a single shared helper (e.g. in DistanceRequestUtils or IOUUtils) and call it from both getDistanceRateTaxUpdatesForTransaction and IOURequestStepDistanceRate:
// shared util
function getDistanceRateTaxUpdates(policy, transaction, customUnitRateID, distanceUnit) {
const policyCustomUnitRate = getDistanceRateCustomUnitRate(policy, customUnitRateID);
const defaultTaxCode = getDefaultTaxCode(policy, transaction, undefined, customUnitRateID) ?? '';
const taxRateExternalID = policyCustomUnitRate?.attributes?.taxRateExternalID || defaultTaxCode;
const taxableAmount = DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, getDistanceInMeters(transaction, distanceUnit));
const taxValue = taxRateExternalID ? getTaxValue(policy, transaction, taxRateExternalID) : undefined;
const mileageRates = DistanceRequestUtils.getMileageRates(policy);
const rateCurrency = mileageRates[customUnitRateID]?.currency ?? transaction.currency;
const taxAmount = convertToBackendAmount(calculateTaxAmount(taxValue, taxableAmount, getCurrencyDecimals(rateCurrency)));
return {taxAmount, taxRateExternalID, taxValue};
}Then reuse it in both call sites instead of repeating the chain.
Reviewed at: dcc54a6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcc54a683a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bb06e9d70
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: krishna2323 <belivethatkg@gmail.com>
trjExpensify
left a comment
There was a problem hiding this comment.
Core PR for a WN project. 👍
Explanation of Change
Fixed Issues
$ #89836
PROPOSAL:
Tests
Setup
Workspace with two date-bound mileage rates (e.g. 2025 + 2026). Existing workspace distance expense on 2025 date with 2025 rate.
Date edit → rate switches (RHP)
Date edit → rate unchanged (RHP)
Inline Search date edit → rate switches
Offline rate switch
Sanity check (out of scope)
Offline tests
QA Steps
Same as tests
Verify that no errors appear in the JS console
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari