diff --git a/src/languages/en.ts b/src/languages/en.ts index f5ef8279a878..eaa81be2a711 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -653,6 +653,7 @@ export default { nextStep: 'Next Steps', finished: 'Finished', submitAmount: ({amount}: RequestAmountParams) => `submit ${amount}`, + trackAmount: ({amount}: RequestAmountParams) => `track ${amount}`, submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `submitted ${formattedAmount}${comment ? ` for ${comment}` : ''}`, trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `tracking ${formattedAmount}${comment ? ` for ${comment}` : ''}`, splitAmount: ({amount}: SplitAmountParams) => `split ${amount}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index cda0ef862fda..688083270fbb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -646,6 +646,7 @@ export default { nextStep: 'Pasos Siguientes', finished: 'Finalizado', submitAmount: ({amount}: RequestAmountParams) => `solicitar ${amount}`, + trackAmount: ({amount}: RequestAmountParams) => `seguimiento de ${amount}`, submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `solicitó ${formattedAmount}${comment ? ` para ${comment}` : ''}`, trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `realizó un seguimiento de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, splitAmount: ({amount}: SplitAmountParams) => `dividir ${amount}`, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 73059dac3b1b..ed83267e11e7 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -835,29 +835,31 @@ function buildOnyxDataForTrackExpense( } else if (isDistanceRequest) { newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE; } - optimisticData.push({ - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value: { - action: newQuickAction, - chatReportID: chatReport?.reportID, - isFirstQuickAction: isEmptyObject(quickAction), - }, - }); const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null; if (chatReport) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, - value: { - ...chatReport, - lastMessageText: iouAction.message?.[0]?.text, - lastMessageHtml: iouAction.message?.[0]?.html, - lastReadTime: DateUtils.getDBTime(), - iouReportID: iouReport?.reportID, + optimisticData.push( + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, + value: { + ...chatReport, + lastMessageText: iouAction.message?.[0]?.text, + lastMessageHtml: iouAction.message?.[0]?.html, + lastReadTime: DateUtils.getDBTime(), + iouReportID: iouReport?.reportID, + }, }, - }); + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: { + action: newQuickAction, + chatReportID: chatReport.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }, + ); } if (iouReport) { diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 70c1f28fae22..1519ab987919 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -193,13 +193,13 @@ function FloatingActionButtonAndPopover( Task.clearOutTaskInfoAndNavigate(quickAction?.chatReportID ?? '', quickActionReport, quickAction.targetAccountID ?? 0, true); break; case CONST.QUICK_ACTIONS.TRACK_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); break; case CONST.QUICK_ACTIONS.TRACK_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN, true); break; case CONST.QUICK_ACTIONS.TRACK_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE, true); break; default: } diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 4470b3f5b5c7..79b7b13e4fde 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -85,12 +85,12 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { + if (!skipConfirmation || !report?.reportID) { return false; } return !(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report)); - }, [report, skipConfirmation, iouType]); + }, [report, skipConfirmation]); useFocusEffect( useCallback(() => { @@ -186,7 +186,7 @@ function IOURequestStepAmount({ IOU.splitBillAndOpenReport({ participants, currentUserLogin: currentUserPersonalDetails.login ?? '', - currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, + currentUserAccountID: currentUserPersonalDetails.accountID, amount: backendAmount, comment: '', currency, @@ -215,14 +215,28 @@ function IOURequestStepAmount({ currency, transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', {}, ); return; } + if (iouType === CONST.IOU.TYPE.TRACK) { + IOU.trackExpense( + report, + backendAmount, + currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + ); + return; + } } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); navigateToConfirmationPage(); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index d64c0b19d925..264b4b80d985 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -105,15 +105,21 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { + if (!skipConfirmation || !report?.reportID) { return false; } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.submitExpense'); + if (iouType === CONST.IOU.TYPE.SPLIT) { + buttonText = translate('iou.split'); + } else if (iouType === CONST.IOU.TYPE.TRACK) { + buttonText = translate('iou.trackExpense'); + } else { + buttonText = translate('iou.submitExpense'); + } } useEffect(() => { @@ -228,7 +234,7 @@ function IOURequestStepDistance({ IOU.splitBillAndOpenReport({ participants, currentUserLogin: currentUserPersonalDetails.login ?? '', - currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, + currentUserAccountID: currentUserPersonalDetails.accountID, amount: 0, comment: '', currency: transaction?.currency ?? 'USD', @@ -243,6 +249,32 @@ function IOURequestStepDistance({ } IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); IOU.setMoneyRequestMerchant(transactionID, translate('iou.fieldPending'), false); + if (iouType === CONST.IOU.TYPE.TRACK) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + translate('iou.fieldPending'), + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + {}, + '', + '', + '', + 0, + false, + policy, + undefined, + undefined, + undefined, + TransactionUtils.getValidWaypoints(waypoints, true), + ); + return; + } + IOU.createDistanceRequest( report, participants[0], @@ -279,6 +311,7 @@ function IOURequestStepDistance({ translate, navigateToParticipantPage, navigateToConfirmationPage, + policy, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index dc6985874321..5a95b78779e5 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -65,12 +65,12 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { + if (!skipConfirmation || !report?.reportID) { return false; } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); const {translate} = useLocalize(); @@ -245,6 +245,21 @@ function IOURequestStepScan({ }); return; } + if (iouType === CONST.IOU.TYPE.TRACK && report) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + receipt, + ); + return; + } IOU.requestMoney( report, 0, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index fc4e8c254500..c391d87e23be 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -80,12 +80,12 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { + if (!skipConfirmation || !report?.reportID) { return false; } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. @@ -285,6 +285,21 @@ function IOURequestStepScan({ }); return; } + if (iouType === CONST.IOU.TYPE.TRACK && report) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + participants[0], + '', + receipt, + ); + return; + } IOU.requestMoney( report, 0, diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 466619f71e26..9233835ea434 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -232,10 +232,22 @@ function MoneyRequestAmountForm( if (skipConfirmation) { if (currentAmount !== '') { const currencyAmount = CurrencyUtils.convertToDisplayString(CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)), currency) ?? ''; - const text = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitAmount', {amount: currencyAmount}) : translate('iou.submitAmount', {amount: currencyAmount}); + let text = translate('iou.submitAmount', {amount: currencyAmount}); + if (iouType === CONST.IOU.TYPE.SPLIT) { + text = translate('iou.splitAmount', {amount: currencyAmount}); + } else if (iouType === CONST.IOU.TYPE.TRACK) { + text = translate('iou.trackAmount', {amount: currencyAmount}); + } return text[0].toUpperCase() + text.slice(1); } - return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); + + if (iouType === CONST.IOU.TYPE.SPLIT) { + return translate('iou.splitExpense'); + } + if (iouType === CONST.IOU.TYPE.TRACK) { + return translate('iou.trackExpense'); + } + return translate('iou.submitExpense'); } return isEditing ? translate('common.save') : translate('common.next'); }, [skipConfirmation, iouType, currency, isEditing, translate]);