From 82a0f8ca8db65414ac19260582853c9f085b54a1 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 12:39:18 +0100 Subject: [PATCH 001/283] 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 002/283] 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 003/283] 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 004/283] 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 005/283] 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 006/283] 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 007/283] 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 008/283] 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 009/283] 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 ? ( + + ) : (