Skip to content
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

Error message displayed for split distance created in Korean Won currency #52310

Open
1 of 8 tasks
m-natarajan opened this issue Nov 11, 2024 · 12 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@m-natarajan
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.59-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @jacobkim9881
Slack conversation (hyperlinked to channel name): ts_external_expensify_open_source

Action Performed:

Prerequisite: Default currency in Korean Won

  1. Create a group chat
  2. Click the + in composer and select split expense
  3. Select Distance and enter address for Start and Stop field
  4. Click Next

Expected Result:

Amount equally split and user able to click split button to submit the expense

Actual Result:

The sum of splits must equal the total amount error message displayed and split button non functional

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
2024-11-08.7.14.00.mov

Full Screen #36

View all open jobs on GitHub

@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 11, 2024
Copy link

melvin-bot bot commented Nov 11, 2024

Triggered auto assignment to @OfstadC (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.

@jacobkim9881
Copy link
Contributor

I found there is a difference between total amount and split shares:

transaction: 
Object
amount: 519357        /////// not rounded
attendees: [Object] (1)
billable: false
category: ""
comment: {waypoints: Object, customUnit: {customUnitRateID: "_FAKE_P2P_ID_", quantity: 4281.895}, isLoading: false}
created: "2024-11-12"
currency: "KRW"
errorFields: {}
iouRequestType: "distance"
isFromGlobalCreate: false
merchant: "4.28 km @ ₩1213.45 / km"
participants: [{accountID: 18602521, selected: true}] (1)
participantsAutoAssigned: true
pendingFields: {}
reportID: "4715962770440927"
routes: {route0: Object}
shouldShowOriginalAmount: false
splitPayerAccountIDs: [18608989] (1)
splitShares: Object
/////////////// rounded here below
18602521: {amount: 259700, isModified: false}
18608989: {amount: 259700, isModified: false}
Object 견본
transactionID: "1"

const {unit, rate} = mileageRate ?? {};
const distance = TransactionUtils.getDistanceInMeters(transaction, unit);
const currency = mileageRate?.currency ?? policyCurrency;
const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0);
IOU.setMoneyRequestAmount(transactionID, amount, currency);
const participantAccountIDs: number[] | undefined = participants?.map((participant) => Number(participant.accountID ?? -1));
if (isSplitRequest && amount && currency && !isPolicyExpenseChat) {
IOU.setSplitShares(transaction, amount, currency ?? '', participantAccountIDs ?? []);
}

There is code for decision how the total is same with split shares. I tried to round total amount from 519357 to 519400. For this calculation, round method is needed but needed parameter currency above always be undefined. Why mileageRate?.currency, policyCurrency are undefined? I am tracing the reason.

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 12, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

The sum of splits must equal the total amount error message displayed and split button non functional

What is the root cause of that problem?

The total amount is calculated by calculateAmount function

const splitAmount = IOUUtils.calculateAmount(participantsLength, amount, currency, isPayer);

The total amount of the split bill is rounded before we calculate the split amount

const totalInCurrencySubunit = Math.round((total / 100) * currencyUnit);

then if the rounded total amount is different from the current amount, the error appears here

if (sumOfShares !== iouAmount) {
setFormError('iou.error.invalidSplit');
return;

What changes do you think we should make in order to solve the problem?

When calculating the split amount, we should remove the Math.round here so that we do not round the total amount but only the split amount.

const totalInCurrencySubunit = (total / 100) * currencyUnit;

const totalInCurrencySubunit = Math.round((total / 100) * currencyUnit);

What alternative solutions did you explore? (Optional)

@OfstadC
Copy link
Contributor

OfstadC commented Nov 12, 2024

Can confirm
image

But this only happens for this currency - I tried two other currencies and did not get the same response. So not sure how high priority this will be. It's likely uncommon to split a mileage expense, and this would only affect a subset of users
image

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 13, 2024

@OfstadC This bug also happens for some other currencies like VND.

@OfstadC
Copy link
Contributor

OfstadC commented Nov 13, 2024

Added to Quality and posted in Slack for prioritization

@tgolen
Copy link
Contributor

tgolen commented Nov 13, 2024

Does this only affect distance expenses, or does it happen to any split?

@mkzie2
Copy link
Contributor

mkzie2 commented Nov 14, 2024

This only affects distance expense, the reason is the rate is odd.

@OfstadC
Copy link
Contributor

OfstadC commented Nov 14, 2024

Will test this a bit more first thing tomorrow morning - had a managed customer issue that threw my day off today 😓

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

Can confirm it does not affect regular splits - just distance. But for the life of me I cannot remember how to change the currency on a distance expense in ND 🤦‍♀️ So working on that now 😅

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

Figured the currency out - so ignore me lol. Testing them now

@OfstadC
Copy link
Contributor

OfstadC commented Nov 15, 2024

@mkzie2 I couldn't reproduce with VND - Or other currencies with 'decimals' => 0, I tested about 20 currencies all together🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

5 participants