Open lanitochka17 opened 2 weeks ago
Triggered auto assignment to @bfitzexpensify (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@bfitzexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Edited by proposal-police: This proposal was edited at 2024-08-30 00:03:36 UTC.
Track tax - Tax rate does not update when editing distance rate offline
getTaxName
to get the tax and when distance transaction is created, the taxCode
is filled by the backend. When we update the rate after the transaction is created, taxCode
is used, which will be only updated the backend api call is successful.
https://github.com/Expensify/App/blob/8c0386a562ac8ecdc0aa8e0496c8ed24971a5089/src/libs/TransactionUtils/index.ts#L885-L891transaction?.taxCode
is not present, so we are using the defaultTaxCode
, getDefaultTaxCode
will return the correct tax using the customUnitRateID
.
https://github.com/Expensify/App/blob/8c0386a562ac8ecdc0aa8e0496c8ed24971a5089/src/libs/TransactionUtils/index.ts#L836-L845selectDistanceRate
, we are already calculating taxAmount
and taxRateExternalID
(taxCode), we can modify the updateMoneyRequestDistanceRate
util function to accept 2 new parameters taxAmount
and taxRateExternalID
(taxCode).
https://github.com/Expensify/App/blob/489312e0d75cbbbf5d0d78fae48bb37635f921d6/src/pages/iou/request/step/IOURequestStepDistanceRate.tsx#L88-L108selectDistanceRate
we will pass the taxAmount
and taxRateExternalID
(taxCode) to updateMoneyRequestDistanceRate
.transactionChanges
object in updateMoneyRequestDistanceRate
function to also include taxAmount
& taxRate
.
https://github.com/Expensify/App/blob/489312e0d75cbbbf5d0d78fae48bb37635f921d6/src/libs/actions/IOU.ts#L3122-L3145taxAmount
& taxRate
field without modifying the fields to look for change in customUnitRateID
field.We can do few things here:
defaultTaxCode
as the primary value. customUnitRateID
then use defaultTaxCode
as the primary value..taxRate
and taxAmount
fields we can check if the request is of type distance and if true we will also use customUnitRateID
for pending action.
<OfflineWithFeedback pendingAction={isDistanceRequest ? getPendingFieldAction('taxCode') ?? getPendingFieldAction('customUnitRateID') : getPendingFieldAction('taxCode')}>
Tax rate does not update after changing distance rate offline in transaction thread. The only thing that updates is the removal of "default" label in tax rate field Tax rate and tax amount field are not gray out
Tax rate does not update after changing distance rate offline in transaction thread. The only thing that updates is the removal of "default" label in tax rate field
When we're in the edit flow, we don't update the tax rate and tax amount in optimistic data in getUpdateMoneyRequestParams
function
Tax rate and tax amount field are not gray out
Tax rate/tax amount is only grayed out if we have pending action on tax rate/tax amount https://github.com/Expensify/App/blob/489312e0d75cbbbf5d0d78fae48bb37635f921d6/src/components/ReportActionItem/MoneyRequestView.tsx#L621
Tax rate will update after changing distance rate offline in transaction thread, as it works on confirmation page (Step 7)
For this bug, we can follow the same way we do in IOURequestStepDistanceRate
to update the tax rate and tax amount in optimistic data when we edit the distance rate after creating. We can create a util
function getTaxRateAndTaxAmountForTrackTax(transaction: OnyxInputOrEntry<Transaction>, policy: OnyxInputOrEntry<Policy>, isPolicyExpenseChat: boolean, customUnitRateID = '') {
if (!transaction || !policy || !customUnitRateID || !PolicyUtils.isTaxTrackingEnabled(isPolicyExpenseChat, policy, true)) {
return {
taxCode: undefined,
taxAmount: undefined,
};
}
const mileageRates = DistanceRequestUtils.getMileageRates(policy, true);
const {unit} = mileageRates[customUnitRateID] ?? DistanceRequestUtils.getDefaultMileageRate(policy);
const policyCustomUnitRate = getCustomUnitRate(policy, customUnitRateID);
const taxRateExternalID = policyCustomUnitRate?.attributes?.taxRateExternalID ?? '-1';
const taxableAmount = DistanceRequestUtils.getTaxableAmount(policy, customUnitRateID, getDistanceInMeters(transaction, unit));
const taxPercentage = getTaxValue(policy, transaction ?? undefined, taxRateExternalID) ?? '';
const taxAmount = convertToBackendAmount(calculateTaxAmount(taxPercentage, taxableAmount, mileageRates[customUnitRateID].currency ?? CONST.CURRENCY.USD));
return {taxCode: taxRateExternalID, taxAmount};
}
const {taxCode, taxAmount} = getTaxRateAndTaxAmountForTrackTax(transaction, policy, isFromExpenseReport, customUnitRateID);
if (hasModifiedRouteWithPendingWaypoints || hasModifiedRateWithPendingWaypoints) {
return {
amount: CONST.IOU.DEFAULT_AMOUNT,
modifiedAmount: CONST.IOU.DEFAULT_AMOUNT,
modifiedMerchant: Localize.translateLocal('iou.fieldPending'),
...(taxCode ? {taxCode} : {}),
...(taxAmount ? {taxAmount} : {}),
};
}
...
return {
amount: updatedAmount,
modifiedAmount: updatedAmount,
modifiedMerchant: updatedMerchant,
modifiedCurrency: updatedCurrency,
...(taxCode ? {taxCode} : {}),
...(taxAmount ? {taxAmount} : {}),
};
and use this in calculateAmountForUpdatedWaypointOrRate
function
Tax rate and tax amount field will gray out
For this bug, we can check if the request is distance request we will add the fallback pending action for tax rate and tax amount with the pending action of distance rate here
<OfflineWithFeedback pendingAction={isDistanceRequest ? getPendingFieldAction('taxCode') ?? getPendingFieldAction('customUnitRateID') : getPendingFieldAction('taxCode')}>
<OfflineWithFeedback pendingAction={isDistanceRequest ? getPendingFieldAction('taxAmount') ?? getPendingFieldAction('customUnitRateID') : getPendingFieldAction('taxAmount')}>
NA
@bfitzexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!
Job added to Upwork: https://www.upwork.com/jobs/~01c25cfebc45c34fc3
Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif (External
)
Thanks for the proposals. Can you please share demo videos after applying your solution?
Please make sure that Tax rate and tax amount field are not gray out
bug is also fixed.
@aimane-chnaif The result here.
https://github.com/user-attachments/assets/c6d0e61c-f512-439f-bee5-edcd8df4e896
I am heading out of office until September 21st, so assigning a buddy to watch over this in my absence.
Current status: working through proposals
Triggered auto assignment to @lschurr (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@lschurr, @bfitzexpensify, @aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!
@aimane-chnaif what do you think of these proposals? CC: @MonilBhavsar for eyes.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@Krishna2323's main solution looks good. 🎀👀🎀 C+ reviewed
Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Keep in mind: Code of Conduct | Contributing 📖
@marcaaron @lschurr @bfitzexpensify @Krishna2323 @aimane-chnaif this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
@aimane-chnaif, PR ready for review ^
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.26-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4902670 Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Issue reported by:Applause - Internal Team
Action Performed:
Precondition:
Expected Result:
Actual Result:
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/8b3c5a70-32ea-4bb2-bd98-bcbed30ee528
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @aimane-chnaif