From a754ea3f9f6e48428b71294f7f4399c4e99187c1 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 9 Oct 2024 05:59:22 +0700 Subject: [PATCH 1/9] Setup screen & route for QBD import chart of accounts page --- src/ROUTES.ts | 4 +++ src/SCREENS.ts | 1 + .../ModalStackNavigators/index.tsx | 2 ++ .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 +++ .../QuickbooksDesktopChartOfAccountsPage.tsx | 25 +++++++++++++++++++ .../import/QuickbooksDesktopImportPage.tsx | 2 +- 8 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 47fabe3c421c..53a3bfd80696 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -678,6 +678,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, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 6e9efd15e910..0c3f7113ca09 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -320,6 +320,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', XERO_IMPORT: 'Policy_Accounting_Xero_Import', XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', XERO_CHART_OF_ACCOUNTS: 'Policy_Accounting_Xero_Import_Chart_Of_Accounts', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index eed6686d96e7..e22ab660cd1e 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -319,6 +319,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.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').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 b6422494241e..b2287f55349e 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -50,6 +50,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.XERO_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS, SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 57e83d309966..6a173e7ab638 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -388,6 +388,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.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_CHART_OF_ACCOUNTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 0a65d4a91725..c82d2099431a 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -448,6 +448,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_IMPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: { policyID: string; }; 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..eb2cc909f5b7 --- /dev/null +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -0,0 +1,25 @@ +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 QuickbooksOnline from '@libs/actions/connections/QuickbooksOnline'; +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 {clearQBOErrorField} from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { + return undefined; +} + +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 f20975a25648..2e4c32cb39d2 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx @@ -29,7 +29,7 @@ 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], }, From 3e0b83264cacaff2d8cab7a9661f0e812e3b793e Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 9 Oct 2024 07:33:28 +0700 Subject: [PATCH 2/9] Implement QBD chart of accounts page --- src/languages/en.ts | 3 ++ src/languages/es.ts | 3 ++ .../QuickbooksDesktopChartOfAccountsPage.tsx | 51 +++++++++++++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index d2226e1c1290..6d56b32dc60b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2372,6 +2372,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.', }, qbo: { importDescription: 'Choose which coding configurations to import from QuickBooks Online to Expensify.', diff --git a/src/languages/es.ts b/src/languages/es.ts index fd807854e410..c866a82b33ce 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2394,6 +2394,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.', }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index eb2cc909f5b7..56452e9fe9f0 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -5,19 +5,60 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as QuickbooksOnline from '@libs/actions/connections/QuickbooksOnline'; -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 {clearQBOErrorField} from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { - return undefined; + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? '-1'; + const {canUseNewDotQBD} = usePermissions(); + + return ( + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.getRoute(policyID))} + > + {}} + disabled + showLockIcon + /> + + {translate('workspace.qbd.accountsSwitchTitle')} + {}} + disabled + showLockIcon + /> + + ); } QuickbooksDesktopChartOfAccountsPage.displayName = 'QuickbooksDesktopChartOfAccountsPage'; From 94eb5b4caaf60f976e49c8bff32df873c24f7d04 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 11 Oct 2024 15:50:21 +0700 Subject: [PATCH 3/9] Temporary hide enabled button --- .../qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index 56452e9fe9f0..d5da9b7a57c9 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -46,7 +46,9 @@ function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { description={translate('workspace.common.displayedAs')} wrapperStyle={[styles.sectionMenuItemTopDescription, styles.mt2]} /> - {translate('workspace.qbd.accountsSwitchTitle')} + {/* TODO: [QBD] Temporary hide this menu item until BE supports this option + more details: https://github.com/Expensify/App/pull/50545#issuecomment-2406554260 */} + {/* {translate('workspace.qbd.accountsSwitchTitle')} {}} disabled showLockIcon - /> + /> */} ); } From 66ae5086042afbcd8088af8c5ab34ce23da4612c Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 11 Oct 2024 15:55:14 +0700 Subject: [PATCH 4/9] Fix eslint --- .../qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index d5da9b7a57c9..a50fbf4b8839 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -1,7 +1,6 @@ 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'; From 4fd18441561b8241e09c6767f2dbc649b29d504e Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 11 Oct 2024 21:49:38 +0700 Subject: [PATCH 5/9] Add todo comment --- .../qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index a50fbf4b8839..eaad6a9aff29 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -27,7 +27,7 @@ function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} contentContainerStyle={[styles.pb2, styles.ph5]} connectionName={CONST.POLICY.CONNECTIONS.NAME.QBD} - shouldBeBlocked={!canUseNewDotQBD} + shouldBeBlocked={!canUseNewDotQBD} // TODO: [QBD] Will be removed when release onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.getRoute(policyID))} > Date: Fri, 11 Oct 2024 23:42:44 +0700 Subject: [PATCH 6/9] Remove redundant subscribed settings --- .../accounting/qbd/import/QuickbooksDesktopImportPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx index 2e4c32cb39d2..da9815bc1506 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx @@ -16,7 +16,7 @@ type QBDSectionType = { description: string; action: () => void; title?: string; - subscribedSettings: [string]; + subscribedSettings?: [string]; }; function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { @@ -31,7 +31,6 @@ function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { description: translate('workspace.accounting.accounts'), 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], }, { description: translate('workspace.qbd.classes'), From 3f06ba03741dac47486c66714062dc2b9d987841 Mon Sep 17 00:00:00 2001 From: VH Date: Sat, 12 Oct 2024 12:41:53 +0700 Subject: [PATCH 7/9] Update QBD enabled new categories setting --- src/CONST.ts | 1 + src/libs/API/types.ts | 2 ++ .../actions/connections/QuickbooksDesktop.ts | 12 +++++++++++ .../QuickbooksDesktopChartOfAccountsPage.tsx | 21 ++++++++++++------- .../import/QuickbooksDesktopImportPage.tsx | 3 ++- src/pages/workspace/accounting/utils.tsx | 2 +- src/types/onyx/Policy.ts | 3 +++ 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 996354e3d60c..492b409ac01e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1484,6 +1484,7 @@ const CONST = { MARK_CHECKS_TO_BE_PRINTED: 'markChecksToBePrinted', REIMBURSABLE_ACCOUNT: 'reimbursableAccount', REIMBURSABLE: 'reimbursable', + ENABLE_NEW_CATEGORIES: 'enableNewCategories', }, QUICKBOOKS_CONFIG: { diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index ee5b06aba6ab..75b7d447d8b3 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -261,6 +261,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', REMOVE_POLICY_CONNECTION: 'RemovePolicyConnection', SET_POLICY_TAXES_ENABLED: 'SetPolicyTaxesEnabled', DELETE_POLICY_TAXES: 'DeletePolicyTaxes', @@ -695,6 +696,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_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; [WRITE_COMMANDS.UPDATE_MANY_POLICY_CONNECTION_CONFIGS]: Parameters.UpdateManyPolicyConnectionConfigurationsParams; [WRITE_COMMANDS.REMOVE_POLICY_CONNECTION]: Parameters.RemovePolicyConnectionParams; diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index 78f99b5c6106..ac84fda86703 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -289,9 +289,21 @@ 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); +} + export { updateQuickbooksDesktopMarkChecksToBePrinted, updateQuickbooksDesktopExpensesExportDestination, updateQuickbooksDesktopReimbursableExpensesAccount, getQuickbooksDesktopCodatSetupLink, + updateQuickbooksDesktopEnableNewCategories, }; diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index eaad6a9aff29..720a8d557c36 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -1,13 +1,18 @@ 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 {clearQBOErrorField} from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -16,6 +21,7 @@ function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? '-1'; const {canUseNewDotQBD} = usePermissions(); + const qbdConfig = policy?.connections?.quickbooksDesktop?.config; return ( - {/* TODO: [QBD] Temporary hide this menu item until BE supports this option - more details: https://github.com/Expensify/App/pull/50545#issuecomment-2406554260 */} - {/* {translate('workspace.qbd.accountsSwitchTitle')} + {translate('workspace.qbd.accountsSwitchTitle')} {}} - disabled - showLockIcon - /> */} + isActive={!!qbdConfig?.enableNewCategories} + onToggle={() => 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={() => clearQBOErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES)} + /> ); } diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx index da9815bc1506..dd56f0e7f994 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx @@ -16,7 +16,7 @@ type QBDSectionType = { description: string; action: () => void; title?: string; - subscribedSettings?: [string]; + subscribedSettings: [string]; }; function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { @@ -31,6 +31,7 @@ function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { description: translate('workspace.accounting.accounts'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS.getRoute(policyID)), title: translate('workspace.accounting.importAsCategory'), + 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 2afa6ddd282d..8105f02fd6c3 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -260,7 +260,7 @@ function getAccountingIntegrationData( onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_EXPORT.getRoute(policyID)), onCardReconciliationPagePress: () => {}, onAdvancedPagePress: () => {}, - subscribedImportSettings: [], + subscribedImportSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES], subscribedExportSettings: [ CONST.QUICKBOOKS_DESKTOP_CONFIG.REIMBURSABLE, CONST.QUICKBOOKS_DESKTOP_CONFIG.REIMBURSABLE_ACCOUNT, 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; }>; From 6f767e4d2eaaa0bec67286b3be3c314521e64256 Mon Sep 17 00:00:00 2001 From: VH Date: Sat, 12 Oct 2024 12:45:59 +0700 Subject: [PATCH 8/9] Fix clear QBD error field --- .../qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx index 720a8d557c36..8e6cd895c435 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopChartOfAccountsPage.tsx @@ -12,7 +12,7 @@ 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 {clearQBOErrorField} from '@userActions/Policy/Policy'; +import {clearQBDErrorField} from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -61,7 +61,7 @@ function QuickbooksDesktopChartOfAccountsPage({policy}: WithPolicyProps) { onToggle={() => 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={() => clearQBOErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES)} + onCloseError={() => clearQBDErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES)} /> ); From 37dad4ce364e3366652617b89292ea4f53037e4c Mon Sep 17 00:00:00 2001 From: VH Date: Tue, 15 Oct 2024 16:41:29 +0700 Subject: [PATCH 9/9] Fix merge main --- src/ROUTES.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ac444fff6e2c..7751ce7be4b6 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -713,6 +713,7 @@ const ROUTES = { 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,