Skip to content

Commit

Permalink
Explain why the update distance unit should come from the rate
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-marcellini committed Oct 11, 2024
1 parent 7a9d0ea commit 1e87ca3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libs/DistanceRequestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ function getRate({
/**
* Get the updated distance unit from the selected rate instead of the distanceUnit stored on the transaction.
* Useful for updating the transaction distance unit when the distance or rate changes.
*
* For example, if an expense is '10 mi @ $1.00 / mi' and the rate is updated to '$1.00 / km',
* then the updated distance unit should be 'km' from the updated rate, not 'mi' from the currently stored transaction distance unit.
*/
function getUpdatedDistanceUnit({transaction, policy, policyDraft}: {transaction: OnyxEntry<Transaction>; policy: OnyxEntry<Policy>; policyDraft?: OnyxEntry<Policy>}) {
return getRate({transaction, policy, policyDraft, useTransactionDistanceUnit: false}).unit;
Expand Down

0 comments on commit 1e87ca3

Please sign in to comment.