diff --git a/src/CONST.ts b/src/CONST.ts index ac72000c5c0a..40f3c541b0f7 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1492,6 +1492,7 @@ const CONST = { MARK_CHECKS_TO_BE_PRINTED: 'markChecksToBePrinted', REIMBURSABLE_ACCOUNT: 'reimbursableAccount', REIMBURSABLE: 'reimbursable', + ENABLE_NEW_CATEGORIES: 'enableNewCategories', MAPPINGS: { CLASSES: 'classes', }, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7936d3115900..7751ce7be4b6 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -710,6 +710,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import` as const, }, + POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/accounts', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/accounts` as const, + }, POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES: { route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/classes', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/classes` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 4fd1a8857461..3da0f86d651e 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -327,6 +327,7 @@ const SCREENS = { QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL: 'Policy_Accouting_Quickbooks_Desktop_Setup_Required_Device_Modal', QUICKBOOKS_DESKTOP_TRIGGER_FIRST_SYNC: 'Policy_Accouting_Quickbooks_Desktop_Trigger_First_Sync', QUICKBOOKS_DESKTOP_IMPORT: 'Policy_Accounting_Quickbooks_Desktop_Import', + QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS: 'Policy_Accounting_Quickbooks_Desktop_Import_Chart_Of_Accounts', QUICKBOOKS_DESKTOP_CLASSES: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes', QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes_Dipslayed_As', XERO_IMPORT: 'Policy_Accounting_Xero_Import', diff --git a/src/languages/en.ts b/src/languages/en.ts index 287f36b8b040..58ac38d1856c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2452,6 +2452,9 @@ const translations = { classes: 'Classes', items: 'Items', customers: 'Customers/projects', + accountsDescription: 'Your QuickBooks Desktop chart of accounts will import into Expensify as categories.', + accountsSwitchTitle: 'Choose to import new accounts as enabled or disabled categories.', + accountsSwitchDescription: 'Enabled categories will be available for members to select when creating their expenses.', classesDescription: 'Choose how to handle QuickBooks Desktop classes in Expensify.', tagsDisplayedAsDescription: 'Line item level', reportFieldsDisplayedAsDescription: 'Report level', diff --git a/src/languages/es.ts b/src/languages/es.ts index 6e6b7fa9d1d6..650ccdf5e660 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2476,6 +2476,9 @@ const translations = { classes: 'Clases', items: 'Artículos', customers: 'Clientes/proyectos', + accountsDescription: 'Tu plan de cuentas de QuickBooks Desktop se importará a Expensify como categorías.', + accountsSwitchTitle: 'Elige importar cuentas nuevas como categorías activadas o desactivadas.', + accountsSwitchDescription: 'Las categorías activas estarán disponibles para ser escogidas cuando se crea un gasto.', classesDescription: 'Elige cómo gestionar las clases de QuickBooks Desktop en Expensify.', tagsDisplayedAsDescription: 'Nivel de partida', reportFieldsDisplayedAsDescription: 'Nivel de informe', diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index a031d37fa085..2463fc1cdc0c 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -263,6 +263,7 @@ const WRITE_COMMANDS = { UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_ACCOUNT: 'UpdateQuickbooksDesktopReimbursableExpensesAccount', UPDATE_QUICKBOOKS_DESKTOP_MARK_CHECKS_TO_BE_PRINTED: 'UpdateQuickbooksDesktopMarkChecksToBePrinted', UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateQuickbooksDesktopReimbursableExpensesExportDestination', + UPDATE_QUICKBOOKS_DESKTOP_ENABLE_NEW_CATEGORIES: 'UpdateQuickbooksDesktopEnableNewCategories', UPDATE_QUICKBOOKS_DESKTOP_SYNC_CLASSES: 'UpdateQuickbooksDesktopSyncClasses', REMOVE_POLICY_CONNECTION: 'RemovePolicyConnection', SET_POLICY_TAXES_ENABLED: 'SetPolicyTaxesEnabled', @@ -699,6 +700,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_MARK_CHECKS_TO_BE_PRINTED]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_ACCOUNT]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateQuickbooksDesktopExpensesExportDestinationTypeParams; + [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_ENABLE_NEW_CATEGORIES]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CLASSES]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_EXPORT]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index cea6c7987e47..c32f63906443 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -329,6 +329,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbd/QuickBooksDesktopSetupFlowSyncPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_IMPORT]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS]: () => + require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesDisplayedAsPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 357018f9583c..552310dceae4 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -55,6 +55,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_TRIGGER_FIRST_SYNC, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_IMPORT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS, SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 0a36f06ad43a..8f152e2d35de 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -415,6 +415,7 @@ const config: LinkingOptions['config'] = { path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_TRIGGER_FIRST_SYNC.route, }, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 75fc2a9336bc..f1d5b38b6f44 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -463,6 +463,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_IMPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES]: { policyID: string; }; diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index 46ce978e1bbb..80f50dce7b8a 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -370,6 +370,17 @@ function updateQuickbooksDesktopReimbursableExpensesAccount(policyID: string, settingValue: TSettingValue) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES, settingValue, !settingValue); + + const parameters: UpdateQuickbooksDesktopGenericTypeParams = { + policyID, + settingValue: JSON.stringify(settingValue), + idempotencyKey: String(CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES), + }; + API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_ENABLE_NEW_CATEGORIES, parameters, onyxData); +} + function updateQuickbooksDesktopSyncClasses( policyID: string, settingValue: TSettingValue, @@ -420,6 +431,7 @@ export { updateQuickbooksDesktopExpensesExportDestination, updateQuickbooksDesktopReimbursableExpensesAccount, getQuickbooksDesktopCodatSetupLink, + updateQuickbooksDesktopEnableNewCategories, updateQuickbooksDesktopExportDate, updateQuickbooksDesktopSyncClasses, }; diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx new file mode 100644 index 000000000000..8e6cd895c435 --- /dev/null +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import ConnectionLayout from '@components/ConnectionLayout'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import {settingsPendingAction} from '@libs/PolicyUtils'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import {clearQBDErrorField} from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? '-1'; + const {canUseNewDotQBD} = usePermissions(); + const qbdConfig = policy?.connections?.quickbooksDesktop?.config; + + return ( + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.getRoute(policyID))} + > + {}} + disabled + showLockIcon + /> + + {translate('workspace.qbd.accountsSwitchTitle')} + QuickbooksDesktop.updateQuickbooksDesktopEnableNewCategories(policyID, !qbdConfig?.enableNewCategories)} + pendingAction={settingsPendingAction([CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES], qbdConfig?.pendingFields)} + errors={ErrorUtils.getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES)} + onCloseError={() => clearQBDErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES)} + /> + + ); +} + +QuickbooksDesktopChartOfAccountsPage.displayName = 'QuickbooksDesktopChartOfAccountsPage'; + +export default withPolicyConnections(QuickbooksDesktopChartOfAccountsPage); diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx index f9849659e039..8aa21ebccdd8 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx @@ -29,9 +29,9 @@ function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { const sections: QBDSectionType[] = [ { description: translate('workspace.accounting.accounts'), - action: () => {}, // TODO: [QBD] will be implemented in https://github.com/Expensify/App/issues/49703 + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS.getRoute(policyID)), title: translate('workspace.accounting.importAsCategory'), - subscribedSettings: [CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES], + subscribedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES], }, { description: translate('workspace.qbd.classes'), diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index aab7a42dc1d5..7e694babdd5c 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -261,7 +261,7 @@ function getAccountingIntegrationData( onCardReconciliationPagePress: () => {}, onAdvancedPagePress: () => {}, // TODO: [QBD] Make sure all values are passed to subscribedSettings - subscribedImportSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CLASSES], + subscribedImportSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CLASSES], subscribedExportSettings: [ CONST.QUICKBOOKS_DESKTOP_CONFIG.EXPORT_DATE, CONST.QUICKBOOKS_DESKTOP_CONFIG.EXPORTER, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index f914c88a912b..5ecf9ad8d84f 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1293,6 +1293,9 @@ type QBDConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ customers: IntegrationEntityMap; }; + /** Whether new categories are enabled in chart of accounts */ + enableNewCategories: boolean; + /** Collections of form field errors */ errorFields?: OnyxCommon.ErrorFields; }>;