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

Use workspace's default currency when submitting expense #43416

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry<OnyxTypes.Policy>,
amount: 0,
comment,
created,
currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,
currency: policy?.outputCurrency ?? currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,
iouRequestType,
reportID,
transactionID: newTransactionID,
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,8 @@ function generateCustomUnitID(): string {
return NumberUtils.generateHexadecimalValue(13);
}

function buildOptimisticCustomUnits(): OptimisticCustomUnits {
const currency = allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD;
function buildOptimisticCustomUnits(reportCurrency?: string): OptimisticCustomUnits {
const currency = reportCurrency ?? allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD;
const customUnitID = generateCustomUnitID();
const customUnitRateID = generateCustomUnitID();

Expand Down Expand Up @@ -2038,7 +2038,7 @@ function createWorkspaceFromIOUPayment(iouReport: Report | EmptyObject): string
const workspaceName = generateDefaultWorkspaceName(sessionEmail);
const employeeAccountID = iouReport.ownerAccountID;
const employeeEmail = iouReport.ownerEmail ?? '';
const {customUnits, customUnitID, customUnitRateID} = buildOptimisticCustomUnits();
const {customUnits, customUnitID, customUnitRateID} = buildOptimisticCustomUnits(iouReport.currency);
const oldPersonalPolicyID = iouReport.policyID;
const iouReportID = iouReport.reportID;

Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/TeachersUnite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {AddSchoolPrincipalParams, ReferTeachersUniteVolunteerParams} from '
import {WRITE_COMMANDS} from '@libs/API/types';
import Navigation from '@libs/Navigation/Navigation';
import * as PhoneNumber from '@libs/PhoneNumber';
import {getPolicy} from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import type {OptimisticCreatedReportAction} from '@libs/ReportUtils';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -95,7 +96,7 @@ function addSchoolPrincipal(firstName: string, partnerUserID: string, lastName:
name: policyName,
role: CONST.POLICY.ROLE.USER,
owner: sessionEmail,
outputCurrency: allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD,
outputCurrency: getPolicy(policyID)?.outputCurrency ?? allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD,
employeeList: {
[sessionEmail]: {
role: CONST.POLICY.ROLE.USER,
Expand Down
Loading