Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/libs/actions/IOU/SendInvoice.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type {LocaleContextProps} from '@components/LocaleContextProvider';

import * as API from '@libs/API';
import type {SendInvoiceParams} from '@libs/API/parameters';
import {WRITE_COMMANDS} from '@libs/API/types';
import DateUtils from '@libs/DateUtils';
import {deferOrExecuteWrite} from '@libs/deferredLayoutWrite';
import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
import Log from '@libs/Log';
import {getReportActionHtml, getReportActionText} from '@libs/ReportActionsUtils';
import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction} from '@libs/ReportUtils';
Expand Down Expand Up @@ -85,6 +86,7 @@ type SendInvoiceOptions = {
policyRecentlyUsedTags?: OnyxEntry<OnyxTypes.RecentlyUsedTags>;
isFromGlobalCreate?: boolean;
senderPolicyTags: OnyxEntry<OnyxTypes.PolicyTagLists>;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
delegateAccountID: number | undefined;
};

Expand Down Expand Up @@ -589,6 +591,7 @@ function getSendInvoiceInformation({
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
senderPolicyTags,
formatPhoneNumber,
delegateAccountID,
}: SendInvoiceOptions): SendInvoiceInformation {
const {amount = 0, currency = '', created = '', merchant = '', category = '', tag = '', taxCode = '', taxAmount = 0, taxValue, billable, comment, participants} = transaction ?? {};
Expand Down Expand Up @@ -738,6 +741,7 @@ function sendInvoice({
policyRecentlyUsedTags,
isFromGlobalCreate = false,
senderPolicyTags,
formatPhoneNumber,
delegateAccountID,
}: SendInvoiceOptions) {
const parsedComment = getParsedComment(transaction?.comment?.comment?.trim() ?? '');
Expand Down Expand Up @@ -773,6 +777,7 @@ function sendInvoice({
policyRecentlyUsedCategories,
policyRecentlyUsedTags,
senderPolicyTags: senderPolicyTags ?? {},
formatPhoneNumber,
delegateAccountID,
});

Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC
const {backTo, reportID} = route.params;

const styles = useThemeStyles();
const {translate} = useLocalize();
const {translate, formatPhoneNumber} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {inputCallbackRef} = useAutoFocusInput();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -122,6 +122,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC
policyRecentlyUsedTags,
isFromGlobalCreate,
senderPolicyTags: policyTags ?? {},
formatPhoneNumber,
delegateAccountID,
});
cleanupAndNavigateAfterExpenseCreate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
} = params;

// Localization
const {translate, toLocaleDigit} = useLocalize();
const {translate, toLocaleDigit, formatPhoneNumber} = useLocalize();
const delegateAccountID = useDelegateAccountID();

// Permissions
Expand Down Expand Up @@ -1027,6 +1027,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) {
isFromGlobalCreate: getIsFromGlobalCreate(transaction),
policyRecentlyUsedTags,
senderPolicyTags: senderWorkspacePolicyTags ?? {},
formatPhoneNumber,
delegateAccountID,
});
if (shouldHandleNavigation) {
Expand Down
18 changes: 17 additions & 1 deletion tests/actions/IOUTest/SendInvoiceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import createRandomPolicy from '../../utils/collections/policies';
import createRandomTransaction from '../../utils/collections/transaction';
import getOnyxValue from '../../utils/getOnyxValue';
import initCurrencyListContext from '../../utils/initCurrencyListContext';
import {getGlobalFetchMock} from '../../utils/TestHelper';
import {formatPhoneNumber, getGlobalFetchMock} from '../../utils/TestHelper';
import waitForBatchedUpdates from '../../utils/waitForBatchedUpdates';

const topMostReportID = '23423423';
Expand Down Expand Up @@ -176,6 +176,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: existingRecentlyUsedCategories,
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand All @@ -202,6 +203,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: undefined,
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -254,6 +256,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: 'https://testcompany.com',
policyRecentlyUsedCategories: ['Services', 'Consulting'],
senderPolicyTags: mockPolicyTagList as PolicyTagLists,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -304,6 +307,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: 'https://testcompany.com',
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: DELEGATE_ACCOUNT_ID,
});

Expand Down Expand Up @@ -369,6 +373,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: 'https://clientcompany.com',
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -406,6 +411,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -456,6 +462,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -487,6 +494,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -540,6 +548,7 @@ describe('actions/SendInvoice', () => {
companyWebsite: undefined,
policyRecentlyUsedCategories: [],
senderPolicyTags: baseSenderPolicyTags,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -594,6 +603,7 @@ describe('actions/SendInvoice', () => {
policyRecentlyUsedCurrencies: [],
policyRecentlyUsedTags,
senderPolicyTags: senderPolicyTags ?? {},
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -642,6 +652,7 @@ describe('actions/SendInvoice', () => {
currentUserAccountID: 123,
policyRecentlyUsedCurrencies: [],
senderPolicyTags: senderPolicyTags ?? {},
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -675,6 +686,7 @@ describe('actions/SendInvoice', () => {
companyName,
companyWebsite,
senderPolicyTags: undefined,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -704,6 +716,7 @@ describe('actions/SendInvoice', () => {
transaction,
policyRecentlyUsedCurrencies: initialCurrencies,
senderPolicyTags: undefined,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -745,6 +758,7 @@ describe('actions/SendInvoice', () => {
policyRecentlyUsedCurrencies: [],
policyRecentlyUsedCategories,
senderPolicyTags: undefined,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down Expand Up @@ -787,6 +801,7 @@ describe('actions/SendInvoice', () => {
orderWeight: 0,
},
},
formatPhoneNumber,
delegateAccountID: undefined,
});
await waitForBatchedUpdates();
Expand Down Expand Up @@ -823,6 +838,7 @@ describe('actions/SendInvoice', () => {
policyRecentlyUsedCurrencies: [],
invoiceChatReportID: preGeneratedReportID,
senderPolicyTags: undefined,
formatPhoneNumber,
delegateAccountID: undefined,
});

Expand Down
Loading