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

[P2P Distance] Rate currency doesn't match expense currency #50142

Merged
merged 8 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
const hasRoute = TransactionUtils.hasRoute(transactionBackup ?? transaction, isDistanceRequest);
const rateID = TransactionUtils.getRateID(transaction) ?? '-1';

const currency = policy ? policy.outputCurrency : PolicyUtils.getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD;
const currency = transactionCurrency ?? CONST.CURRENCY.USD;

const mileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? DistanceRequestUtils.getRateForP2P(currency) : distanceRates[rateID] ?? {};
const {unit} = mileageRate;
Expand Down
3 changes: 1 addition & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ import type {
PayerSettledParams,
PaySomeoneParams,
ReconciliationWorksParams,
ReimbursementRateParams,
RemovedFromApprovalWorkflowParams,
RemovedTheRequestParams,
RemoveMemberPromptParams,
Expand Down Expand Up @@ -1009,7 +1008,7 @@ const translations = {
changed: 'changed',
removed: 'removed',
transactionPending: 'Transaction pending.',
chooseARate: ({unit}: ReimbursementRateParams) => `Select a workspace reimbursement rate per ${unit}`,
chooseARate: `Select a workspace reimbursement rate per mile or kilometer`,
nyomanjyotisa marked this conversation as resolved.
Show resolved Hide resolved
unapprove: 'Unapprove',
unapproveReport: 'Unapprove report',
headsUp: 'Heads up!',
Expand Down
3 changes: 1 addition & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ import type {
PayerSettledParams,
PaySomeoneParams,
ReconciliationWorksParams,
ReimbursementRateParams,
RemovedFromApprovalWorkflowParams,
RemovedTheRequestParams,
RemoveMemberPromptParams,
Expand Down Expand Up @@ -1003,7 +1002,7 @@ const translations = {
changed: 'cambió',
removed: 'eliminó',
transactionPending: 'Transacción pendiente.',
chooseARate: ({unit}: ReimbursementRateParams) => `Selecciona una tasa de reembolso por ${unit} del espacio de trabajo`,
chooseARate: `Selecciona una tasa de reembolso por milla o kilómetro para el espacio de trabajo`,
nyomanjyotisa marked this conversation as resolved.
Show resolved Hide resolved
unapprove: 'Desaprobar',
unapproveReport: 'Anular la aprobación del informe',
headsUp: 'Atención!',
Expand Down
5 changes: 1 addition & 4 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
import type {DelegateRole} from '@src/types/onyx/Account';
import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy';
import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName} from '@src/types/onyx/Policy';
import type {ViolationDataType} from '@src/types/onyx/TransactionViolation';

type AddressLineParams = {
Expand Down Expand Up @@ -279,8 +279,6 @@ type LogSizeAndDateParams = {size: number; date: string};

type HeldRequestParams = {comment: string};

type ReimbursementRateParams = {unit: Unit};

type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string};

type ChangePolicyParams = {fromPolicy: string; toPolicy: string};
Expand Down Expand Up @@ -648,7 +646,6 @@ export type {
PayerPaidAmountParams,
PayerPaidParams,
PayerSettledParams,
ReimbursementRateParams,
RemovedTheRequestParams,
RenamedRoomActionParams,
ReportArchiveReasonsClosedParams,
Expand Down
10 changes: 7 additions & 3 deletions src/pages/iou/request/step/IOURequestStepDistanceRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,26 @@ function IOURequestStepDistanceRate({

const currentRateID = TransactionUtils.getRateID(transaction) ?? '-1';

const transactionCurrency = TransactionUtils.getCurrency(transaction);

const rates = DistanceRequestUtils.getMileageRates(policy, false, currentRateID);

const navigateBack = () => {
Navigation.goBack(backTo);
};

const sections = Object.values(rates).map((rate) => {
const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, rate.currency, translate, toLocaleDigit);
const isSelected = currentRateID ? currentRateID === rate.customUnitRateID : rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE;

const rateForDisplay = DistanceRequestUtils.getRateForDisplay(rate.unit, rate.rate, isSelected ? transactionCurrency : rate.currency, translate, toLocaleDigit);

return {
text: rate.name ?? rateForDisplay,
alternateText: rate.name ? rateForDisplay : '',
keyForList: rate.customUnitRateID,
value: rate.customUnitRateID,
isDisabled: !rate.enabled,
isSelected: currentRateID ? currentRateID === rate.customUnitRateID : rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE,
isSelected,
};
});

Expand Down Expand Up @@ -118,7 +122,7 @@ function IOURequestStepDistanceRate({
shouldShowWrapper
testID={IOURequestStepDistanceRate.displayName}
>
<Text style={[styles.mh5, styles.mv4]}>{translate('iou.chooseARate', {unit})}</Text>
<Text style={[styles.mh5, styles.mv4]}>{translate('iou.chooseARate')}</Text>

<SelectionList
sections={[{data: sections}]}
Expand Down
Loading