Use Math.abs for taxable amount in negative expense tax calculation#83643
Use Math.abs for taxable amount in negative expense tax calculation#83643
Conversation
…e expenses Tax amount was calculated using the raw (negative) transaction amount, producing a negative tax value that the backend treated as zero. Wrapping in Math.abs ensures the tax calculation always receives a positive amount. Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
The failing checks are unrelated to this PR's changes. Failing checks: Root cause: A Node engine version mismatch in the CI environment. The This fails during the Evidence this is not PR-related:
No code fix from this PR can resolve this. It's a CI infrastructure issue that needs the Node version pinned/updated in the CI runner or the engine constraint relaxed in |
|
The failing checks are unrelated to this PR's changes. Failing checks: Root cause: The Mobile-Expensify submodule's Evidence this is unrelated:
The Mobile-Expensify submodule needs its |
|
@MelvinBot Code LGTM. Please mark the PR as "Ready for review" |
|
PR has been marked as Ready for review as requested. ✅ |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp83643-android-hybrid-001.mp4Android: mWeb Chrome83643-mweb-chrome-001.mp4iOS: HybridApp83643-ios-hybrid-001.mp4iOS: mWeb Safari83643-mweb-safari-001.mp4MacOS: Chrome / Safari83643-web-chrome-001.mp4 |
rojiphil
left a comment
There was a problem hiding this comment.
@inimaga @trjExpensify Changes LGTM and works well too.
Approving for your review. Thanks.
Explanation of Change
When creating a negative expense (e.g., -$5.00) with taxes enabled, the tax amount was calculated using the raw negative
transaction.amount, which produced a negative tax value. The confirmation page masked this by displaying the absolute value viagetTaxAmount, but the negative value was sent to the backend which treated it as zero.This change wraps the non-distance
taxableAmountinMath.abs()so thatcalculateTaxAmountalways receives a positive amount, producing the correct positive tax value that persists after expense creation.Fixed Issues
$ #83087
PROPOSAL: #83087 (comment)
Tests
Offline tests
N/A — Tax calculation is performed client-side before the API call. Offline behavior is unchanged.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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