Skip to content
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: 2 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@
attendees: Attendee[] | string;
taxAmount?: number;
taxCode?: string;
taxValue?: string;
currency: string;
merchant: string;
waypoints?: WaypointCollection | string;
Expand Down Expand Up @@ -1051,7 +1052,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1055 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1059,7 +1060,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1063 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1077,7 +1078,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1081 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (currentUserAccountID) {
Expand All @@ -1089,7 +1090,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1093 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1097,7 +1098,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1101 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1107,7 +1108,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1111 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1115,7 +1116,7 @@

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1119 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1151,14 +1152,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1155 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1162 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1184,7 +1185,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1188 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -4679,6 +4680,7 @@
attendees: getAttendees(transaction, currentUserDetails),
taxAmount: getTaxAmount(transaction, isFromExpenseReport),
taxCode: getTaxCode(transaction),
taxValue: transaction.taxValue,
currency: getCurrency(transaction),
comment: getDescription(transaction),
merchant: getMerchant(transaction),
Expand Down
3 changes: 3 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type TransactionParams = {
tag?: string;
taxCode?: string;
taxAmount?: number;
taxValue?: string;
billable?: boolean;
pendingFields?: Partial<Record<TransactionPendingFieldsKey, ValueOf<typeof CONST.RED_BRICK_ROAD_PENDING_ACTION>>>;
reimbursable?: boolean;
Expand Down Expand Up @@ -437,6 +438,7 @@ function buildOptimisticTransaction(params: BuildOptimisticTransactionParams): T
tag = '',
taxCode = '',
taxAmount = 0,
taxValue,
billable = false,
pendingFields,
reimbursable = true,
Expand Down Expand Up @@ -550,6 +552,7 @@ function buildOptimisticTransaction(params: BuildOptimisticTransactionParams): T
tag,
taxCode,
taxAmount,
taxValue,
modifiedAmount,
billable,
reimbursable,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type InitialTransactionParams = {
reportID?: string;
taxCode: string;
taxAmount: number;
taxValue?: string;
isFromGlobalCreate?: boolean;
currency?: string;
participants?: Participant[];
Expand Down Expand Up @@ -390,6 +391,7 @@ function handleMoneyRequestStepScanParticipants({
currency: initialTransaction?.currency ?? 'USD',
taxCode: initialTransaction.taxCode,
taxAmount: initialTransaction.taxAmount,
taxValue: initialTransaction.taxValue,
quickAction,
policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [],
// No need to update recently used tags because no tags are used when the confirmation step is skipped
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/IOU/SendInvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ function getSendInvoiceInformation({
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
}: SendInvoiceOptions): SendInvoiceInformation {
const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, billable, comment, participants} = transaction ?? {};
const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {};
const trimmedComment = (comment?.comment ?? '').trim();
const senderWorkspaceID = participants?.find((participant) => participant?.isSender)?.policyID;
const receiverParticipant: Participant | InvoiceReceiver | undefined =
Expand Down Expand Up @@ -644,6 +644,7 @@ function getSendInvoiceInformation({
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable: true,
},
Expand Down
11 changes: 11 additions & 0 deletions src/libs/actions/IOU/Split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type SplitBillActionsParams = {
splitShares?: SplitShares;
taxCode?: string;
taxAmount?: number;
taxValue?: string;
isRetry?: boolean;
policyRecentlyUsedCategories?: OnyxEntry<OnyxTypes.RecentlyUsedCategories>;
policyRecentlyUsedTags: OnyxEntry<RecentlyUsedTags>;
Expand Down Expand Up @@ -176,6 +177,7 @@ function splitBill({
splitShares = {},
taxCode = '',
taxAmount = 0,
taxValue,
policyRecentlyUsedCategories,
isASAPSubmitBetaEnabled,
transactionViolations,
Expand Down Expand Up @@ -205,6 +207,7 @@ function splitBill({
iouRequestType,
taxCode,
taxAmount,
taxValue,
},
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
Expand Down Expand Up @@ -268,6 +271,7 @@ function splitBillAndOpenReport({
splitShares = {},
taxCode = '',
taxAmount = 0,
taxValue,
existingSplitChatReportID,
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
Expand Down Expand Up @@ -299,6 +303,7 @@ function splitBillAndOpenReport({
iouRequestType,
taxCode,
taxAmount,
taxValue,
},
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
Expand Down Expand Up @@ -359,6 +364,7 @@ function startSplitBill({
currency,
taxCode = '',
taxAmount = 0,
taxValue,
shouldPlaySound = true,
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
Expand All @@ -385,6 +391,7 @@ function startSplitBill({
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
},
Expand Down Expand Up @@ -545,6 +552,7 @@ function startSplitBill({
currency,
taxCode,
taxAmount,
taxValue,
quickAction,
policyRecentlyUsedCurrencies,
policyRecentlyUsedTags,
Expand Down Expand Up @@ -907,6 +915,7 @@ function completeSplitBill(
tag: updatedTransaction?.tag,
taxCode: updatedTransaction?.taxCode,
taxAmount: isPolicyExpenseChat ? -splitTaxAmount : splitAmount,
taxValue: updatedTransaction?.taxValue,
billable: updatedTransaction?.billable,
reimbursable: updatedTransaction?.reimbursable,
source: CONST.IOU.TYPE.SPLIT,
Expand Down Expand Up @@ -1183,6 +1192,7 @@ function updateSplitTransactions({
reimbursable: originalTransactionDetails?.reimbursable,
taxCode: originalTransactionDetails?.taxCode,
taxAmount: calculateIOUAmount(splitExpenses.length - 1, originalTransactionDetails?.taxAmount ?? 0, originalTransactionDetails?.currency ?? CONST.CURRENCY.USD, false),
taxValue: originalTransactionDetails?.taxValue,
billable: originalTransactionDetails?.billable,
waypoints: splitExpense.waypoints,
customUnit: splitExpense.customUnit,
Expand Down Expand Up @@ -1216,6 +1226,7 @@ function updateSplitTransactions({
linkedTrackedExpenseReportAction: currentReportAction,
taxCode: originalTransactionDetails?.taxCode,
taxAmount: calculateIOUAmount(splitExpenses.length - 1, originalTransactionDetails?.taxAmount ?? 0, originalTransactionDetails?.currency ?? CONST.CURRENCY.USD, false),
taxValue: originalTransactionDetails?.taxValue,
billable: originalTransactionDetails?.billable,
waypoints: splitExpense.waypoints,
customUnit: splitExpense.customUnit,
Expand Down
20 changes: 19 additions & 1 deletion src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ type BaseTransactionParams = {
tag?: string;
taxCode?: string;
taxAmount?: number;
taxValue?: string;
billable?: boolean;
reimbursable?: boolean;
customUnitRateID?: string;
Expand Down Expand Up @@ -379,13 +380,14 @@ type TrackExpenseInformation = {
onyxData: OnyxData<BuildOnyxDataForTrackExpenseKeys | BuildPolicyDataKeys | typeof ONYXKEYS.SELF_DM_REPORT_ID>;
};

type TrackedExpenseTransactionParams = Omit<BaseTransactionParams, 'taxCode' | 'taxAmount'> & {
type TrackedExpenseTransactionParams = Omit<BaseTransactionParams, 'taxCode' | 'taxAmount' | 'taxValue'> & {
waypoints?: string;
distance?: number;
transactionID: string | undefined;
receipt?: Receipt;
taxCode: string;
taxAmount: number;
taxValue?: string;
attendees?: Attendee[];
};

Expand Down Expand Up @@ -680,6 +682,7 @@ type TrackExpenseTransactionParams = {
tag?: string;
taxCode?: string;
taxAmount?: number;
taxValue?: string;
billable?: boolean;
reimbursable?: boolean;
validWaypoints?: WaypointCollection;
Expand Down Expand Up @@ -735,6 +738,7 @@ type GetTrackExpenseInformationTransactionParams = {
tag?: string;
taxCode?: string;
taxAmount?: number;
taxValue?: string;
billable?: boolean;
reimbursable?: boolean;
linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction;
Expand Down Expand Up @@ -792,6 +796,7 @@ type StartSplitBilActionParams = {
currency: string;
taxCode: string;
taxAmount: number;
taxValue?: string;
shouldPlaySound?: boolean;
policyRecentlyUsedCategories?: OnyxEntry<OnyxTypes.RecentlyUsedCategories>;
policyRecentlyUsedTags: OnyxEntry<RecentlyUsedTags>;
Expand Down Expand Up @@ -3305,6 +3310,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable = true,
linkedTrackedExpenseReportAction,
Expand Down Expand Up @@ -3468,6 +3474,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma
taxCode,
source,
taxAmount: isExpenseReport(iouReport) ? -(taxAmount ?? 0) : taxAmount,
taxValue,
billable,
pendingAction,
pendingFields: isDistanceRequest && !isManualDistanceRequest ? {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, ...pendingFields} : pendingFields,
Expand Down Expand Up @@ -3735,6 +3742,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
linkedTrackedExpenseReportAction,
Expand Down Expand Up @@ -3946,6 +3954,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T
tag,
taxCode,
taxAmount: taxAmount ? -taxAmount : undefined,
taxValue,
billable,
pendingFields: isDistanceRequest && !isManualDistanceRequest ? {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD} : undefined,
reimbursable,
Expand Down Expand Up @@ -6660,6 +6669,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
tag,
taxCode = '',
taxAmount = 0,
taxValue,
billable,
reimbursable,
gpsPoint,
Expand Down Expand Up @@ -6705,6 +6715,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
validWaypoints,
Expand Down Expand Up @@ -6758,6 +6769,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
linkedTrackedExpenseReportAction,
Expand Down Expand Up @@ -7062,6 +7074,7 @@ function createSplitsAndOnyxData({
iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL,
taxCode = '',
taxAmount = 0,
taxValue,
attendees,
},
policyRecentlyUsedCategories,
Expand Down Expand Up @@ -7099,6 +7112,7 @@ function createSplitsAndOnyxData({
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
pendingFields: isDistanceRequest ? {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD} : undefined,
Expand Down Expand Up @@ -7403,6 +7417,7 @@ function createSplitsAndOnyxData({
tag,
taxCode,
taxAmount: isExpenseReport(oneOnOneIOUReport) ? -splitTaxAmount : splitTaxAmount,
taxValue,
billable,
source: CONST.IOU.TYPE.SPLIT,
},
Expand Down Expand Up @@ -7599,6 +7614,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
tag,
taxAmount,
taxCode,
taxValue,
merchant,
modifiedAmount,
billable,
Expand Down Expand Up @@ -7653,6 +7669,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
iouRequestType: CONST.IOU.REQUEST_TYPE.DISTANCE,
taxCode,
taxAmount,
taxValue,
attendees,
},
policyRecentlyUsedCategories,
Expand Down Expand Up @@ -7734,6 +7751,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
tag,
taxCode,
taxAmount,
taxValue,
billable,
reimbursable,
attendees,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils';
import {hasOnlyPersonalPolicies as hasOnlyPersonalPoliciesUtil} from '@libs/PolicyUtils';
import {shouldValidateFile} from '@libs/ReceiptUtils';
import {getReportOrDraftReport, isSelfDM} from '@libs/ReportUtils';
import {getDefaultTaxCode} from '@libs/TransactionUtils';
import {getDefaultTaxCode, getTaxValue} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
Expand Down Expand Up @@ -129,6 +129,7 @@ function SubmitDetailsPage({
const transactionTaxAmount = transaction?.taxAmount ?? 0;
const defaultTaxCode = getDefaultTaxCode(policy, transaction);
const transactionTaxCode = (transaction?.taxCode ? transaction?.taxCode : defaultTaxCode) ?? '';
const transactionTaxValue = transaction?.taxValue ?? getTaxValue(policy, transaction, transactionTaxCode) ?? '';
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const [recentWaypoints] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS);

Expand All @@ -153,6 +154,7 @@ function SubmitDetailsPage({
tag: transaction.tag,
taxCode: transactionTaxCode,
taxAmount: transactionTaxAmount,
taxValue: transactionTaxValue,
billable: transaction.billable,
reimbursable: transaction.reimbursable,
merchant: transaction.merchant ?? '',
Expand Down Expand Up @@ -193,6 +195,7 @@ function SubmitDetailsPage({
tag: transaction.tag,
taxCode: transactionTaxCode,
taxAmount: transactionTaxAmount,
taxValue: transactionTaxValue,
billable: transaction.billable,
reimbursable: transaction.reimbursable,
merchant: transaction.merchant ?? '',
Expand Down
Loading
Loading