From 3566460ccd2aa92e0f78a9b82d31a21f2eb62016 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Wed, 20 Mar 2024 00:45:01 +0100 Subject: [PATCH 001/423] add multitag regex --- src/CONST.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 3c53f083abac..a3fd483255a4 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1655,6 +1655,10 @@ const CONST = { MERGED_ACCOUNT_PREFIX: /^(MERGED_\d+@)/, + get MULTI_LEVEL_TAG() { + return new RegExp("/\\{1,2}:/g"); + }, + ROUTES: { VALIDATE_LOGIN: /\/v($|(\/\/*))/, UNLINK_LOGIN: /\/u($|(\/\/*))/, From 04d2b5962b3d77bc25b65dc0053585427163658e Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Wed, 20 Mar 2024 00:59:48 +0100 Subject: [PATCH 002/423] introducted a new boolean agrument, defaulted to false, callled excludeMultiLevelTags for the getTagLists function --- src/libs/PolicyUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 39e6c8932aad..45e5aa03760f 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -188,13 +188,15 @@ function getTagListName(policyTagList: OnyxEntry, tagIndex: numbe /** * Gets all tag lists of a policy */ -function getTagLists(policyTagList: OnyxEntry): Array { +function getTagLists(policyTagList: OnyxEntry, excludeMultiLevelTags = false): Array { if (isEmptyObject(policyTagList)) { return []; } + const regex = new RegExp(CONST.REGEX.MULTI_LEVEL_TAG, `/\\{1,2}:/g`); + return Object.values(policyTagList) - .filter((policyTagListValue) => policyTagListValue !== null) + .filter((policyTagListValue) => policyTagListValue !== null && (!excludeMultiLevelTags || regex.test(policyTagListValue.name))) .sort((tagA, tagB) => tagA.orderWeight - tagB.orderWeight); } From cbd67a509ec7230569bf924dec7a47bea45647bf Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Wed, 20 Mar 2024 01:31:18 +0100 Subject: [PATCH 003/423] introducted a new boolean agrument, defaulted to false, callled excludeMultiLevelTags for the getTagLists function --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 45e5aa03760f..7a34ae22f023 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -196,7 +196,7 @@ function getTagLists(policyTagList: OnyxEntry, excludeMultiLevelT const regex = new RegExp(CONST.REGEX.MULTI_LEVEL_TAG, `/\\{1,2}:/g`); return Object.values(policyTagList) - .filter((policyTagListValue) => policyTagListValue !== null && (!excludeMultiLevelTags || regex.test(policyTagListValue.name))) + .filter((policyTagListValue) => !(!policyTagListValue || excludeMultiLevelTags || regex.test(policyTagListValue.name))) .sort((tagA, tagB) => tagA.orderWeight - tagB.orderWeight); } From 3dc48b4e97f9427f0d459a6da5fdce76df758e77 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 21 Mar 2024 15:55:25 +0300 Subject: [PATCH 004/423] Removing multitags --- src/pages/workspace/tags/WorkspaceTagsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 392d392c55ef..860b47d615ec 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -76,6 +76,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { policyTagLists .map((policyTagList) => Object.values(policyTagList.tags || []) + .filter((value) => value.name == getCleanTagName(value.name)) .sort((a, b) => localeCompare(a.name, b.name)) .map((value) => ({ value: value.name, From 3c73312640b3fe60b3d050a98ab76d60754b7b5f Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 21 Mar 2024 14:15:47 +0100 Subject: [PATCH 005/423] fix --- src/libs/PolicyUtils.ts | 34 +++---------------- .../workspace/tags/WorkspaceTagsPage.tsx | 2 +- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 7a34ae22f023..f7f83f1cfbcb 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -4,8 +4,7 @@ import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {PersonalDetailsList, Policy, PolicyCategories, PolicyMembers, PolicyTagList, PolicyTags, TaxRate} from '@src/types/onyx'; -import type {PolicyFeatureName} from '@src/types/onyx/Policy'; +import type {PersonalDetailsList, Policy, PolicyCategories, PolicyMembers, PolicyTagList, PolicyTags} from '@src/types/onyx'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import Navigation from './Navigation/Navigation'; @@ -35,7 +34,7 @@ function hasPolicyMemberError(policyMembers: OnyxEntry): boolean * Check if the policy has any tax rate errors. */ function hasTaxRateError(policy: OnyxEntry): boolean { - return Object.values(policy?.taxRates?.taxes ?? {}).some((taxRate) => Object.keys(taxRate?.errors ?? {}).length > 0 || Object.values(taxRate?.errorFields ?? {}).some(Boolean)); + return Object.values(policy?.taxRates?.taxes ?? {}).some((taxRate) => Object.keys(taxRate?.errors ?? {}).length > 0); } /** @@ -188,15 +187,13 @@ function getTagListName(policyTagList: OnyxEntry, tagIndex: numbe /** * Gets all tag lists of a policy */ -function getTagLists(policyTagList: OnyxEntry, excludeMultiLevelTags = false): Array { +function getTagLists(policyTagList: OnyxEntry ): Array { if (isEmptyObject(policyTagList)) { return []; } - const regex = new RegExp(CONST.REGEX.MULTI_LEVEL_TAG, `/\\{1,2}:/g`); - return Object.values(policyTagList) - .filter((policyTagListValue) => !(!policyTagListValue || excludeMultiLevelTags || regex.test(policyTagListValue.name))) + .filter((policyTagListValue) => policyTagListValue !== null) .sort((tagA, tagB) => tagA.orderWeight - tagB.orderWeight); } @@ -279,26 +276,6 @@ function goBackFromInvalidPolicy() { Navigation.navigate(ROUTES.SETTINGS_WORKSPACES); } -/** Get a tax with given ID from policy */ -function getTaxByID(policy: OnyxEntry, taxID: string): TaxRate | undefined { - return policy?.taxRates?.taxes?.[taxID]; -} - -/** - * Whether the tax rate can be deleted and disabled - */ -function canEditTaxRate(policy: Policy, taxID: string): boolean { - return policy.taxRates?.defaultExternalID !== taxID; -} - -function isPolicyFeatureEnabled(policy: OnyxEntry | EmptyObject, featureName: PolicyFeatureName): boolean { - if (featureName === CONST.POLICY.MORE_FEATURES.ARE_TAXES_ENABLED) { - return Boolean(policy?.tax?.trackingEnabled); - } - - return Boolean(policy?.[featureName]); -} - export { getActivePolicies, hasAccountingConnections, @@ -319,7 +296,6 @@ export { getIneligibleInvitees, getTagLists, getTagListName, - canEditTaxRate, getTagList, getCleanedTagName, getCountOfEnabledTagsOfList, @@ -330,9 +306,7 @@ export { getPathWithoutPolicyID, getPolicyMembersByIdWithoutCurrentUser, goBackFromInvalidPolicy, - isPolicyFeatureEnabled, hasTaxRateError, - getTaxByID, hasPolicyCategoriesError, }; diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index d19604608bbb..0b0758affd93 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -84,7 +84,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { policyTagLists .map((policyTagList) => Object.values(policyTagList.tags || []) - .filter((value) => value.name == getCleanTagName(value.name)) + .filter((value) => value.name === PolicyUtils.getCleanedTagName(value.name)) .sort((a, b) => localeCompare(a.name, b.name)) .map((value) => ({ value: value.name, From 6dbefcfad1a8b0189754aaee634b87d51cb59a51 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 21 Mar 2024 15:31:28 +0100 Subject: [PATCH 006/423] fix --- src/libs/PolicyUtils.ts | 2 +- src/pages/workspace/tags/WorkspaceTagsPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index f7f83f1cfbcb..675e268045c1 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -187,7 +187,7 @@ function getTagListName(policyTagList: OnyxEntry, tagIndex: numbe /** * Gets all tag lists of a policy */ -function getTagLists(policyTagList: OnyxEntry ): Array { +function getTagLists(policyTagList: OnyxEntry): Array { if (isEmptyObject(policyTagList)) { return []; } diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 0b0758affd93..46417f445bf8 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -84,8 +84,8 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { policyTagLists .map((policyTagList) => Object.values(policyTagList.tags || []) - .filter((value) => value.name === PolicyUtils.getCleanedTagName(value.name)) .sort((a, b) => localeCompare(a.name, b.name)) + .filter((value) => PolicyUtils.getCleanedTagName(value.name) === value.name) .map((value) => ({ value: value.name, text: value.name, From cb96df9e670a724043bafa8b39e2c585b1ef37e8 Mon Sep 17 00:00:00 2001 From: Antony Kithinzi Date: Thu, 21 Mar 2024 15:39:20 +0100 Subject: [PATCH 007/423] Refactoring ... --- src/pages/workspace/tags/WorkspaceTagsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index a355cc062f3d..46417f445bf8 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -85,6 +85,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { .map((policyTagList) => Object.values(policyTagList.tags || []) .sort((a, b) => localeCompare(a.name, b.name)) + .filter((value) => PolicyUtils.getCleanedTagName(value.name) === value.name) .map((value) => ({ value: value.name, text: value.name, From 82a0f8ca8db65414ac19260582853c9f085b54a1 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 12:39:18 +0100 Subject: [PATCH 008/423] set skip confirmation flag --- src/libs/actions/IOU.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 85ab98bb7819..bae3dc7e39d4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -325,6 +325,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState, reportID: string, requestType?: ValueOf) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); + setSkipConfirmation(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4985,6 +4986,10 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } +function setSkipConfirmation(transactionID: string) { + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); +} + function setMoneyRequestBillable(billable: boolean) { Onyx.merge(ONYXKEYS.IOU, {billable}); } From a37611633bf3eb376bf38640139b6c6abadffcf0 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 12:54:03 +0100 Subject: [PATCH 009/423] add new params to handle skip --- src/libs/actions/IOU.ts | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 11 ++++++++++- src/pages/iou/steps/NewRequestAmountPage.js | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bae3dc7e39d4..53ac13c4e363 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4987,7 +4987,7 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { } function setSkipConfirmation(transactionID: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); + Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); } function setMoneyRequestBillable(billable: boolean) { diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index aec2f4765fd4..1b17c14296a4 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -34,6 +34,12 @@ type MoneyRequestAmountFormProps = { /** Whether the amount is being edited or not */ isEditing?: boolean; + /** Whether the confirmation screen should be skipped */ + skipConfirmation?: boolean; + + /** Type of the IOU */ + iouType?: ValueOf; + /** Fired when back button pressed, navigates to currency selection page */ onCurrencyButtonPress: () => void; @@ -261,7 +267,10 @@ function MoneyRequestAmountForm( }; const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); - const buttonText = isEditing ? translate('common.save') : translate('common.next'); + let buttonText = isEditing ? translate('common.save') : translate('common.next'); + if (props.skipConfirmation) { + buttonText = props.iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); useEffect(() => { diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 1df74569e4c3..85881503f2de 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -146,6 +146,8 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { isEditing={isEditing} currency={currency} amount={iou.amount} + skipConfirmation={iou.skipConfirmation} + iouType={iouType} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} From b08993e1494652422d777afc8c1d9be058418ca2 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 14:09:26 +0100 Subject: [PATCH 010/423] changing branch --- src/components/transactionPropTypes.js | 2 ++ src/libs/actions/IOU.ts | 5 +++-- src/pages/iou/request/IOURequestStartPage.js | 1 + src/pages/iou/request/step/IOURequestStepAmount.js | 2 ++ src/pages/iou/steps/MoneyRequestAmountForm.tsx | 6 ++++-- src/pages/iou/steps/NewRequestAmountPage.js | 2 ++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js index 7eb1b776358c..db0842e0c83a 100644 --- a/src/components/transactionPropTypes.js +++ b/src/components/transactionPropTypes.js @@ -93,4 +93,6 @@ export default PropTypes.shape({ /** Server side errors keyed by microtime */ errorFields: PropTypes.objectOf(PropTypes.objectOf(translatableTextPropTypes)), + + skipConfirmation: PropTypes.bool, }); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 53ac13c4e363..8946f442490a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -325,7 +325,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState, reportID: string, requestType?: ValueOf) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); - setSkipConfirmation(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); + setSkipConfirmation(); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4986,7 +4986,7 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } -function setSkipConfirmation(transactionID: string) { +function setSkipConfirmation() { Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); } @@ -5219,6 +5219,7 @@ export { setMoneyRequestTaxAmount, setMoneyRequestTaxRate, setShownHoldUseExplanation, + setSkipConfirmation, navigateToNextPage, updateMoneyRequestDate, updateMoneyRequestBillable, diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index cb078fac133c..b87db2579553 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -70,6 +70,7 @@ function IOURequestStartPage({ selectedTab, transaction, }) { + console.log(transaction); const styles = useThemeStyles(); const {translate} = useLocalize(); const navigation = useNavigation(); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 9fdd2bea24f4..931f33e19175 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -166,6 +166,8 @@ function IOURequestStepAmount({ isEditing={Boolean(backTo)} currency={currency} amount={transaction.amount} + skipConfirmation={transaction.skipConfirmation} + iouType={iouType} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 1b17c14296a4..46da8715bd85 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -77,6 +77,8 @@ function MoneyRequestAmountForm( taxAmount = 0, currency = CONST.CURRENCY.USD, isEditing = false, + skipConfirmation = false, + iouType = CONST.IOU.TYPE.REQUEST, onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -268,8 +270,8 @@ function MoneyRequestAmountForm( const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); let buttonText = isEditing ? translate('common.save') : translate('common.next'); - if (props.skipConfirmation) { - buttonText = props.iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + if (skipConfirmation) { + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 85881503f2de..11a9260c4cf8 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -154,6 +154,8 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { selectedTab={selectedTab} /> ); + console.log(iou); + console.log(iouType); // ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage). // The rest of the cases this component is rendered through which has it's own ScreenWrapper From 90f96dafea8d8c312acef6a7af78073e0cd880da Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 17:16:16 +0100 Subject: [PATCH 011/423] Correctly set flag --- src/libs/actions/IOU.ts | 21 ++++++++++---------- src/pages/iou/request/IOURequestStartPage.js | 5 ++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8946f442490a..b55a57cf13aa 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -258,8 +258,10 @@ Onyx.connect({ * @param policy * @param isFromGlobalCreate * @param iouRequestType one of manual/scan/distance + * @param skipConfirmation if true, skip confirmation step */ -function initMoneyRequest(reportID: string, policy: OnyxEntry, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL) { +function initMoneyRequest(reportID: string, policy: OnyxEntry, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, skipConfirmation = false) { + console.log('this'); // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string @@ -292,12 +294,17 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry, reportID, transactionID: newTransactionID, isFromGlobalCreate, + skipConfirmation, merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, }); } -function clearMoneyRequest(transactionID: string) { - Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); +function clearMoneyRequest(transactionID: string, skipConfirmation = false) { + if (skipConfirmation) { + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {skipConfirmation: true}); + } else { + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); + } } /** @@ -324,8 +331,7 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState, reportID: string, requestType?: ValueOf) { - clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID); - setSkipConfirmation(); + clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, true); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); @@ -4986,10 +4992,6 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxAmount}); } -function setSkipConfirmation() { - Onyx.merge(ONYXKEYS.IOU, {skipConfirmation: true}); -} - function setMoneyRequestBillable(billable: boolean) { Onyx.merge(ONYXKEYS.IOU, {billable}); } @@ -5219,7 +5221,6 @@ export { setMoneyRequestTaxAmount, setMoneyRequestTaxRate, setShownHoldUseExplanation, - setSkipConfirmation, navigateToNextPage, updateMoneyRequestDate, updateMoneyRequestBillable, diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index b87db2579553..0add953b7b50 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -70,7 +70,6 @@ function IOURequestStartPage({ selectedTab, transaction, }) { - console.log(transaction); const styles = useThemeStyles(); const {translate} = useLocalize(); const navigation = useNavigation(); @@ -106,7 +105,7 @@ function IOURequestStartPage({ if (transaction.reportID === reportID) { return; } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, transactionRequestType.current, lodashGet(transaction, 'skipConfirmation', false)); }, [transaction, policy, reportID, iouType, isFromGlobalCreate]); const isExpenseChat = ReportUtils.isPolicyExpenseChat(report); @@ -128,7 +127,7 @@ function IOURequestStartPage({ if (iouType === CONST.IOU.TYPE.SPLIT && transaction.isFromGlobalCreate) { IOU.updateMoneyRequestTypeParams(navigation.getState().routes, CONST.IOU.TYPE.REQUEST, newIouType); } - IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType); + IOU.initMoneyRequest(reportID, policy, isFromGlobalCreate, newIouType, lodashGet(transaction, 'skipConfirmation', false)); transactionRequestType.current = newIouType; }, [policy, previousIOURequestType, reportID, isFromGlobalCreate, iouType, navigation, transaction.isFromGlobalCreate], From d24012da390531107bb5d39cba1971b2d96cee9f Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Mar 2024 11:55:48 +0100 Subject: [PATCH 012/423] handle split --- src/libs/actions/IOU.ts | 5 +-- .../iou/request/step/IOURequestStepAmount.js | 31 +++++++++++++++++-- .../iou/steps/MoneyRequestAmountForm.tsx | 2 +- src/pages/iou/steps/NewRequestAmountPage.js | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b55a57cf13aa..c896f030f015 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -261,7 +261,6 @@ Onyx.connect({ * @param skipConfirmation if true, skip confirmation step */ function initMoneyRequest(reportID: string, policy: OnyxEntry, isFromGlobalCreate: boolean, iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, skipConfirmation = false) { - console.log('this'); // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; // Disabling this line since currentDate can be an empty string @@ -4959,7 +4958,7 @@ function replaceReceipt(transactionID: string, file: File, source: string) { * @param transactionID of the transaction to set the participants of * @param report attached to the transaction */ -function setMoneyRequestParticipantsFromReport(transactionID: string, report: OnyxTypes.Report) { +function setMoneyRequestParticipantsFromReport(transactionID: string, report: OnyxTypes.Report): Participant[] { // If the report is iou or expense report, we should get the chat report to set participant for request money const chatReport = ReportUtils.isMoneyRequestReport(report) ? ReportUtils.getReport(report.chatReportID) : report; const currentUserAccountID = currentUserPersonalDetails.accountID; @@ -4970,6 +4969,8 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants, participantsAutoAssigned: true}); + + return participants; } function setMoneyRequestId(id: string) { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 931f33e19175..1e5edf805be8 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -22,6 +22,10 @@ import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import withWritableReportOrNotFound from './withWritableReportOrNotFound'; +import { + withCurrentUserPersonalDetailsDefaultProps, + withCurrentUserPersonalDetailsPropTypes +} from "@components/withCurrentUserPersonalDetails"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -51,12 +55,15 @@ const propTypes = { /** Collection of tax rates attached to a policy */ taxRates: taxPropTypes, }), + + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { report: {}, transaction: {}, policy: {}, + ...withCurrentUserPersonalDetailsDefaultProps, }; const getTaxAmount = (transaction, defaultTaxValue, amount) => { @@ -72,6 +79,7 @@ function IOURequestStepAmount({ transaction, transaction: {currency}, policy, + currentUserPersonalDetails, }) { const {translate} = useLocalize(); const textInput = useRef(null); @@ -144,8 +152,27 @@ function IOURequestStepAmount({ // inside a report. In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. if (report.reportID) { - IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); + const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + + if (transaction.skipConfirmation) { + if (iouType === CONST.IOU.TYPE.SPLIT) { + IOU.splitBillAndOpenReport( + selectedParticipants, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + transaction.amount, + lodashGet(transaction, 'comment', '').trim(), + transaction.currency, + transaction.category, + transaction.tag, + transaction.merchant, + ); + return; + } + + } else { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); + } return; } diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 46da8715bd85..d9c76c9f02fe 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -271,7 +271,7 @@ function MoneyRequestAmountForm( const formattedAmount = MoneyRequestUtils.replaceAllDigits(currentAmount, toLocaleDigit); let buttonText = isEditing ? translate('common.save') : translate('common.next'); if (skipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? 'Split' : 'Request'; + buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.request'); } const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 11a9260c4cf8..296624a4c232 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -138,6 +138,7 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { return; } + if () IOU.navigateToNextPage(iou, iouType, report); }; From bd1f325e8a114741f48145f803a2a1d04b154301 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Mar 2024 12:17:49 +0100 Subject: [PATCH 013/423] correctly set flag --- src/libs/actions/IOU.ts | 4 ++-- .../SidebarScreen/FloatingActionButtonAndPopover.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c896f030f015..4e5158cf7b20 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -329,8 +329,8 @@ function updateMoneyRequestTypeParams(routes: StackNavigationState, reportID: string, requestType?: ValueOf) { - clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, true); +function startMoneyRequest(iouType: ValueOf, reportID: string, requestType?: ValueOf, skipConfirmation = false) { + clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation); switch (requestType) { case CONST.IOU.REQUEST_TYPE.MANUAL: Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID)); diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 117083293b5d..33d199f6aa4f 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -157,22 +157,22 @@ function FloatingActionButtonAndPopover(props) { const navigateToQuickAction = () => { switch (props.quickAction.action) { case CONST.QUICK_ACTIONS.REQUEST_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.REQUEST_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN, true); return; case CONST.QUICK_ACTIONS.REQUEST_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SPLIT_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.SPLIT_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.SCAN, true); return; case CONST.QUICK_ACTIONS.SPLIT_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, props.quickAction.chatReportID, CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SEND_MONEY: IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, props.quickAction.chatReportID); From 33cba717b2f9a2a92f18992cc004b97697c76074 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Mar 2024 12:18:08 +0100 Subject: [PATCH 014/423] handle money request --- .../iou/request/step/IOURequestStepAmount.js | 39 ++++++++++++++++++- src/pages/iou/steps/NewRequestAmountPage.js | 2 - 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 1e5edf805be8..7fa10b80096e 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -26,6 +26,8 @@ import { withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes } from "@components/withCurrentUserPersonalDetails"; +import tagPropTypes from "@components/tagPropTypes"; +import categoryPropTypes from "@components/categoryPropTypes"; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -56,6 +58,10 @@ const propTypes = { taxRates: taxPropTypes, }), + policyTags: tagPropTypes, + + policyCategories: PropTypes.objectOf(categoryPropTypes), + ...withCurrentUserPersonalDetailsPropTypes, }; @@ -63,6 +69,8 @@ const defaultProps = { report: {}, transaction: {}, policy: {}, + policyCategories: {}, + policyTags: {}, ...withCurrentUserPersonalDetailsDefaultProps, }; @@ -79,6 +87,8 @@ function IOURequestStepAmount({ transaction, transaction: {currency}, policy, + policyCategories, + policyTags, currentUserPersonalDetails, }) { const {translate} = useLocalize(); @@ -153,6 +163,7 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const comment = lodashGet(transaction, 'comment.comment', ''); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -161,15 +172,33 @@ function IOURequestStepAmount({ currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, transaction.amount, - lodashGet(transaction, 'comment', '').trim(), + comment.trim(), transaction.currency, transaction.category, transaction.tag, transaction.merchant, ); return; + } else { + IOU.requestMoney( + report, + transaction.amount, + transaction.currency, + transaction.created, + transaction.merchant, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + selectedParticipants[0], + comment.trim(), + null, + transaction.category, + transaction.tag, + transaction.billable, + policy, + policyTags, + policyCategories, + ); } - } else { Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); } @@ -215,5 +244,11 @@ export default compose( policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, + policyCategories: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, + }, + policyTags: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, + }, }), )(IOURequestStepAmount); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 296624a4c232..bbd0051f7fa0 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -137,8 +137,6 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); return; } - - if () IOU.navigateToNextPage(iou, iouType, report); }; From 63414c1b868b5faf221641d27ab0dc1a7de4c4ce Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Mar 2024 12:34:40 +0100 Subject: [PATCH 015/423] cleanup params --- .../iou/request/step/IOURequestStepAmount.js | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 7fa10b80096e..87913ccebfab 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -163,7 +163,6 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - const comment = lodashGet(transaction, 'comment.comment', ''); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -171,32 +170,26 @@ function IOURequestStepAmount({ selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - transaction.amount, - comment.trim(), + amount, + '', transaction.currency, - transaction.category, - transaction.tag, - transaction.merchant, + '', + '', + '', ); return; } else { IOU.requestMoney( report, - transaction.amount, + amount, transaction.currency, transaction.created, - transaction.merchant, + '', currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, selectedParticipants[0], - comment.trim(), + '', null, - transaction.category, - transaction.tag, - transaction.billable, - policy, - policyTags, - policyCategories, ); } } else { From e9643692c227e2dc52bb61a93fac0a74c754b2c5 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Mar 2024 13:46:02 +0100 Subject: [PATCH 016/423] change branches --- .../iou/request/step/IOURequestStepAmount.js | 21 +++++++---- .../iou/steps/MoneyRequestAmountForm.tsx | 35 ++++++++++++++++++- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 87913ccebfab..afea223e1c7c 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -141,8 +141,9 @@ function IOURequestStepAmount({ /** * @param {Number} amount */ - const navigateToNextPage = ({amount}) => { + const navigateToNextPage = ({amount, paymentMethod}) => { isSaveButtonPressed.current = true; + console.log(paymentMethod); const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if ((iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || backTo) && isTaxTrackingEnabled) { @@ -163,6 +164,7 @@ function IOURequestStepAmount({ // to the confirm step. if (report.reportID) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); + const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if (transaction.skipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -170,7 +172,7 @@ function IOURequestStepAmount({ selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, - amount, + backendAmount, '', transaction.currency, '', @@ -178,10 +180,15 @@ function IOURequestStepAmount({ '', ); return; - } else { + } + if (iouType === CONST.IOU.TYPE.SEND) { + + return; + } + if (iouType === CONST.IOU.TYPE.REQUEST) { IOU.requestMoney( report, - amount, + backendAmount, transaction.currency, transaction.created, '', @@ -191,10 +198,10 @@ function IOURequestStepAmount({ '', null, ); + return; } - } else { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); } + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)); return; } @@ -217,6 +224,8 @@ function IOURequestStepAmount({ amount={transaction.amount} skipConfirmation={transaction.skipConfirmation} iouType={iouType} + policyID={policy.policyID} + bankAccountRoute={ReportUtils.getBankAccountRoute(report)} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} onSubmitButtonPress={navigateToNextPage} diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index d9c76c9f02fe..0685273c628f 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -20,6 +20,8 @@ import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types'; import CONST from '@src/CONST'; +import SettlementButton from "@components/SettlementButton"; +import ROUTES, {AllRoutes} from "@src/ROUTES"; type MoneyRequestAmountFormProps = { /** IOU amount saved in Onyx */ @@ -40,6 +42,12 @@ type MoneyRequestAmountFormProps = { /** Type of the IOU */ iouType?: ValueOf; + /** The policyID of the request */ + policyID?: string; + + /** Depending on expense report or personal IOU report, respective bank account route */ + bankAccountRoute?: AllRoutes; + /** Fired when back button pressed, navigates to currency selection page */ onCurrencyButtonPress: () => void; @@ -79,6 +87,8 @@ function MoneyRequestAmountForm( isEditing = false, skipConfirmation = false, iouType = CONST.IOU.TYPE.REQUEST, + policyID = '', + bankAccountRoute = '', onCurrencyButtonPress, onSubmitButtonPress, selectedTab = CONST.TAB_REQUEST.MANUAL, @@ -248,7 +258,7 @@ function MoneyRequestAmountForm( const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)); initializeAmount(backendAmount); - onSubmitButtonPress({amount: currentAmount, currency}); + onSubmitButtonPress({amount: currentAmount, currency, paymentMethod}); }, [onSubmitButtonPress, currentAmount, taxAmount, currency, isTaxAmountForm, formattedTaxAmount, initializeAmount]); /** @@ -334,6 +344,28 @@ function MoneyRequestAmountForm( longPressHandlerStateChanged={updateLongPressHandlerState} /> ) : null} + {iouType === CONST.IOU.TYPE.SEND && skipConfirmation ? ( + + ) : (