diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 4eb625affacd..f223bb173a2c 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1163,6 +1163,7 @@ const CONST = { REQUEST_MANUAL: 'requestManual', REQUEST_SCAN: 'requestScan', REQUEST_DISTANCE: 'requestDistance', + REQUEST_TIME: 'requestTime', PER_DIEM: 'perDiem', SPLIT_MANUAL: 'splitManual', SPLIT_SCAN: 'splitScan', diff --git a/src/languages/de.ts b/src/languages/de.ts index 35a758b8b897..1cd1fba4a6e4 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -1138,6 +1138,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Sie haben keinen Zugriff mehr auf Ihr bisheriges Ziel für Schnellaktionen. Wählen Sie unten ein neues aus.', updateDestination: 'Ziel aktualisieren', createReport: 'Bericht erstellen', + createTimeExpense: 'Zeitaufwand erstellen', }, iou: { amount: 'Betrag', diff --git a/src/languages/en.ts b/src/languages/en.ts index 86de05f1f00a..adf23b0b05a5 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1153,6 +1153,7 @@ const translations = { noLongerHaveReportAccess: 'You no longer have access to your previous quick action destination. Pick a new one below.', updateDestination: 'Update destination', createReport: 'Create report', + createTimeExpense: 'Create time expense', }, iou: { amount: 'Amount', diff --git a/src/languages/es.ts b/src/languages/es.ts index cfbd934aa1dd..f9ba4f04768e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -923,6 +923,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Ya no tienes acceso al destino previo de esta acción rápida. Escoge uno nuevo a continuación.', updateDestination: 'Actualiza el destino', createReport: 'Crear informe', + createTimeExpense: 'Crear gasto de tiempo', }, iou: { amount: 'Importe', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index fa05ed6c5fb8..93194a202b16 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -1143,6 +1143,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Vous n’avez plus accès à votre précédente destination d’action rapide. Choisissez-en une nouvelle ci-dessous.', updateDestination: 'Mettre à jour la destination', createReport: 'Créer une note de frais', + createTimeExpense: 'Créer une dépense de temps', }, iou: { amount: 'Montant', diff --git a/src/languages/it.ts b/src/languages/it.ts index 62414a798278..55197eb1497b 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Non hai più accesso alla precedente destinazione dell’azione rapida. Selezionane una nuova qui sotto.', updateDestination: 'Aggiorna destinazione', createReport: 'Crea resoconto', + createTimeExpense: 'Crea nota spese tempo', }, iou: { amount: 'Importo', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 5b6847321fab..3777d7be8eb0 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -1132,6 +1132,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: '以前のクイック操作の宛先にはアクセスできなくなりました。下から新しい宛先を選択してください。', updateDestination: '送信先を更新', createReport: 'レポートを作成', + createTimeExpense: '時間経費を作成', }, iou: { amount: '金額', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index a6d424ad4d07..e30f16c636ae 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Je hebt geen toegang meer tot je vorige snelkoppelingsbestemming. Kies hieronder een nieuwe.', updateDestination: 'Bestemming bijwerken', createReport: 'Rapport maken', + createTimeExpense: 'Tijdkosten aanmaken', }, iou: { amount: 'Bedrag', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index c89befddfd28..ae0663a82e6e 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -1136,6 +1136,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Nie masz już dostępu do swojego poprzedniego szybkiego działania. Wybierz poniżej nowe.', updateDestination: 'Zaktualizuj miejsce docelowe', createReport: 'Utwórz raport', + createTimeExpense: 'Utwórz wydatek czasowy', }, iou: { amount: 'Kwota', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index bc9eb8065018..bd08b57c8792 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -1135,6 +1135,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: 'Você não tem mais acesso ao seu destino anterior de ação rápida. Escolha um novo abaixo.', updateDestination: 'Atualizar destino', createReport: 'Criar relatório', + createTimeExpense: 'Criar despesa de tempo', }, iou: { amount: 'Valor', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 94d1d9cccc25..9be564e6b5ef 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -1119,6 +1119,7 @@ const translations: TranslationDeepObject = { noLongerHaveReportAccess: '您已无法访问之前的快捷操作目标。请在下方选择一个新的目标。', updateDestination: '更新目的地', createReport: '创建报表', + createTimeExpense: '创建工时报销', }, iou: { amount: '金额', diff --git a/src/libs/QuickActionUtils.ts b/src/libs/QuickActionUtils.ts index 3df13ecff1ac..f00937ca128b 100644 --- a/src/libs/QuickActionUtils.ts +++ b/src/libs/QuickActionUtils.ts @@ -6,11 +6,11 @@ import type QuickAction from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; import getIconForAction from './getIconForAction'; -import {getPerDiemCustomUnit} from './PolicyUtils'; +import {getPerDiemCustomUnit, isTimeTrackingEnabled} from './PolicyUtils'; import {canCreateRequest} from './ReportUtils'; const getQuickActionIcon = ( - icons: Record<'CalendarSolid' | 'Car' | 'Task' | 'Coins' | 'Receipt' | 'Cash' | 'Transfer' | 'ReceiptScan' | 'MoneyCircle', IconAsset>, + icons: Record<'CalendarSolid' | 'Car' | 'Task' | 'Coins' | 'Receipt' | 'Cash' | 'Transfer' | 'ReceiptScan' | 'MoneyCircle' | 'Clock', IconAsset>, action: QuickActionName, ): IconAsset => { switch (action) { @@ -37,6 +37,8 @@ const getQuickActionIcon = ( return getIconForAction(CONST.IOU.TYPE.TRACK, icons); case CONST.QUICK_ACTIONS.TRACK_SCAN: return icons.ReceiptScan; + case CONST.QUICK_ACTIONS.REQUEST_TIME: + return icons.Clock; default: return icons.MoneyCircle; } @@ -47,6 +49,7 @@ const getIOUType = (action: QuickActionName | undefined) => { case CONST.QUICK_ACTIONS.REQUEST_MANUAL: case CONST.QUICK_ACTIONS.REQUEST_SCAN: case CONST.QUICK_ACTIONS.REQUEST_DISTANCE: + case CONST.QUICK_ACTIONS.REQUEST_TIME: case CONST.QUICK_ACTIONS.PER_DIEM: return CONST.IOU.TYPE.SUBMIT; case CONST.QUICK_ACTIONS.SPLIT_MANUAL: @@ -88,6 +91,8 @@ const getQuickActionTitle = (action: QuickActionName): TranslationPaths => { return 'quickAction.paySomeone'; case CONST.QUICK_ACTIONS.ASSIGN_TASK: return 'quickAction.assignTask'; + case CONST.QUICK_ACTIONS.REQUEST_TIME: + return 'quickAction.createTimeExpense'; default: return '' as TranslationPaths; } @@ -112,6 +117,12 @@ const isQuickActionAllowed = ( return false; } } + if (quickAction?.action === CONST.QUICK_ACTIONS.REQUEST_TIME) { + if (!isTimeTrackingEnabled(quickActionPolicy)) { + return false; + } + } + const iouType = getIOUType(quickAction?.action); if (iouType) { // We're disabling QAB for Manager McTest reports to prevent confusion when submitting real data for Manager McTest diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 33ecdb4d8063..137252e07ee3 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -224,6 +224,7 @@ import { isPerDiemRequest as isPerDiemRequestTransactionUtils, isScanning, isScanRequest as isScanRequestTransactionUtils, + isTimeRequest as isTimeRequestTransactionUtils, removeTransactionFromDuplicateTransactionViolation, } from '@libs/TransactionUtils'; import ViolationsUtils from '@libs/Violations/ViolationsUtils'; @@ -1938,6 +1939,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR const isScanRequest = isScanRequestTransactionUtils(transaction); const isPerDiemRequest = isPerDiemRequestTransactionUtils(transaction); + const isTimeRequest = isTimeRequestTransactionUtils(transaction); const outstandingChildRequest = getOutstandingChildRequest(iou.report); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const isMoneyRequestToManagerMcTest = isTestTransactionReport(iou.report); @@ -1953,6 +1955,8 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR newQuickAction = CONST.QUICK_ACTIONS.REQUEST_SCAN; } else if (isPerDiemRequest) { newQuickAction = CONST.QUICK_ACTIONS.PER_DIEM; + } else if (isTimeRequest) { + newQuickAction = CONST.QUICK_ACTIONS.REQUEST_TIME; } else { newQuickAction = CONST.QUICK_ACTIONS.REQUEST_MANUAL; } diff --git a/src/libs/actions/QuickActionNavigation.ts b/src/libs/actions/QuickActionNavigation.ts index 575b399c7626..d662b5a12f04 100644 --- a/src/libs/actions/QuickActionNavigation.ts +++ b/src/libs/actions/QuickActionNavigation.ts @@ -32,6 +32,8 @@ function getQuickActionRequestType(action: QuickActionName | undefined, lastDist requestType = lastDistanceExpenseType ?? CONST.IOU.REQUEST_TYPE.DISTANCE_MAP; } else if (action === CONST.QUICK_ACTIONS.PER_DIEM) { requestType = CONST.IOU.REQUEST_TYPE.PER_DIEM; + } else if (action === CONST.QUICK_ACTIONS.REQUEST_TIME) { + requestType = CONST.IOU.REQUEST_TYPE.TIME; } return requestType; @@ -70,6 +72,9 @@ function navigateToQuickAction(params: NavigateToQuickActionParams) { case CONST.QUICK_ACTIONS.TRACK_DISTANCE: selectOption(() => startDistanceRequest(CONST.IOU.TYPE.TRACK, reportID, requestType, true, undefined, isFromFloatingActionButton), false); break; + case CONST.QUICK_ACTIONS.REQUEST_TIME: + selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportID, requestType, false, undefined, undefined, isFromFloatingActionButton), true); + break; default: } } diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index 304779cc63ff..769104084cd9 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -130,6 +130,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref 'Cash', 'Transfer', 'MoneyCircle', + 'Clock', ] as const); const styles = useThemeStyles(); const theme = useTheme(); diff --git a/tests/unit/QuickActionNavigationTest.ts b/tests/unit/QuickActionNavigationTest.ts index 6b379775d395..7ae0d1c991fe 100644 --- a/tests/unit/QuickActionNavigationTest.ts +++ b/tests/unit/QuickActionNavigationTest.ts @@ -117,6 +117,22 @@ describe('IOU Utils', () => { // Then we should start per diem request flow expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.SUBMIT, reportID, CONST.IOU.REQUEST_TYPE.PER_DIEM, true, undefined, undefined, undefined); }); + + it('should be navigated to Time Expense', () => { + // When the quick action is REQUEST_TIME + navigateToQuickAction({ + isValidReport: true, + quickAction: {action: CONST.QUICK_ACTIONS.REQUEST_TIME, chatReportID: reportID}, + selectOption: (onSelected: () => void) => { + onSelected(); + }, + targetAccountPersonalDetails: createPersonalDetails(1), + currentUserAccountID: CONST.DEFAULT_NUMBER_ID, + }); + + // Then we should start time request flow + expect(startMoneyRequest).toHaveBeenCalledWith(CONST.IOU.TYPE.SUBMIT, reportID, CONST.IOU.REQUEST_TYPE.TIME, false, undefined, undefined, undefined); + }); }); }); diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index cb5bb3f317ea..08ededf3e7d0 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -205,5 +205,50 @@ describe('QuickActionUtils', () => { expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false); }); }); + + describe('Policy with time tracking', () => { + it('should allow requestTime action when policy has time tracking enabled', () => { + mockedPolicyUtils.isTimeTrackingEnabled.mockReturnValue(true); + expect( + isQuickActionAllowed( + {action: CONST.QUICK_ACTIONS.REQUEST_TIME}, + { + reportID: '1', + isOwnPolicyExpenseChat: true, + type: CONST.REPORT.TYPE.EXPENSE, + policyID: '1', + ownerAccountID: 1, + }, + { + id: '1', + units: {time: {enabled: true, rate: 1}}, + } as Policy, + false, + false, + ), + ).toBe(true); + }); + + it('should not allow requestTime action when policy has time tracking disabled', () => { + mockedPolicyUtils.isTimeTrackingEnabled.mockReturnValue(false); + expect( + isQuickActionAllowed( + {action: CONST.QUICK_ACTIONS.REQUEST_TIME}, + { + reportID: '1', + isOwnPolicyExpenseChat: true, + type: CONST.REPORT.TYPE.EXPENSE, + policyID: '1', + ownerAccountID: 1, + }, + { + id: '1', + } as Policy, + false, + false, + ), + ).toBe(false); + }); + }); }); });