diff --git a/src/libs/actions/connections/QuickbooksOnline.ts b/src/libs/actions/connections/QuickbooksOnline.ts index d758b6f3b073..92f3723bff7f 100644 --- a/src/libs/actions/connections/QuickbooksOnline.ts +++ b/src/libs/actions/connections/QuickbooksOnline.ts @@ -9,9 +9,7 @@ import {getCommandURL} from '@libs/ApiUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {ConnectionName, Connections, IntegrationEntityMap} from '@src/types/onyx/Policy'; - -type ConnectionNameExceptNetSuite = Exclude; +import type {Connections} from '@src/types/onyx/Policy'; function getQuickbooksOnlineSetupLink(policyID: string) { const params: ConnectPolicyToAccountingIntegrationParams = {policyID}; @@ -92,6 +90,7 @@ function buildOnyxDataForQuickbooksConfiguration, + oldSettingValue?: Partial, ) { const optimisticData: OnyxUpdate[] = [ { @@ -123,7 +122,7 @@ function buildOnyxDataForQuickbooksConfiguration(policyID: string, settingValue: TSettingValue) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES, settingValue, !settingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, @@ -193,11 +192,12 @@ function updateQuickbooksOnlineAutoCreateVendor( +function updateQuickbooksOnlineReimbursableExpensesAccount( policyID: string, - settingValue: Partial, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, ) { - const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT, settingValue); + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT, settingValue, oldSettingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, @@ -207,8 +207,12 @@ function updateQuickbooksOnlineReimbursableExpensesAccount( + policyID: string, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, +) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_LOCATIONS, settingValue, oldSettingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, @@ -218,8 +222,12 @@ function updateQuickbooksOnlineSyncLocations(policyID: string, settingValue: Int API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_SYNC_LOCATIONS, parameters, onyxData); } -function updateQuickbooksOnlineSyncCustomers(policyID: string, settingValue: IntegrationEntityMap) { - const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_CUSTOMERS, settingValue); +function updateQuickbooksOnlineSyncCustomers( + policyID: string, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, +) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_CUSTOMERS, settingValue, oldSettingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, @@ -229,8 +237,12 @@ function updateQuickbooksOnlineSyncCustomers(policyID: string, settingValue: Int API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_SYNC_CUSTOMERS, parameters, onyxData); } -function updateQuickbooksOnlineSyncClasses(policyID: string, settingValue: IntegrationEntityMap) { - const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_CLASSES, settingValue); +function updateQuickbooksOnlineSyncClasses( + policyID: string, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, +) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_CLASSES, settingValue, oldSettingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, settingValue: JSON.stringify(settingValue), @@ -239,8 +251,12 @@ function updateQuickbooksOnlineSyncClasses(policyID: string, settingValue: Integ API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_SYNC_CLASSES, parameters, onyxData); } -function updateQuickbooksOnlineNonReimbursableBillDefaultVendor(policyID: string, settingValue: string) { - const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.NON_REIMBURSABLE_BILL_DEFAULT_VENDOR, settingValue); +function updateQuickbooksOnlineNonReimbursableBillDefaultVendor( + policyID: string, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, +) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.NON_REIMBURSABLE_BILL_DEFAULT_VENDOR, settingValue, oldSettingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, @@ -250,8 +266,8 @@ function updateQuickbooksOnlineNonReimbursableBillDefaultVendor(policyID: string API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_NON_REIMBURSABLE_BILL_DEFAULT_VENDOR, parameters, onyxData); } -function updateQuickbooksOnlineSyncTax(policyID: string, settingValue: boolean) { - const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_TAX, settingValue); +function updateQuickbooksOnlineSyncTax(policyID: string, settingValue: TSettingValue) { + const onyxData = buildOnyxDataForQuickbooksConfiguration(policyID, CONST.QUICK_BOOKS_CONFIG.SYNC_TAX, settingValue, !settingValue); const parameters: UpdateQuickbooksOnlineGenericTypeParams = { policyID, diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx index 368cecc5de3b..a77046b6d7bf 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksNonReimbursableDefaultVendorSelectPage.tsx @@ -42,7 +42,7 @@ function QuickbooksNonReimbursableDefaultVendorSelectPage({policy}: WithPolicyCo const selectVendor = useCallback( (row: CardListItem) => { if (row.value !== nonReimbursableBillDefaultVendor) { - QuickbooksOnline.updateQuickbooksOnlineNonReimbursableBillDefaultVendor(policyID, row.value); + QuickbooksOnline.updateQuickbooksOnlineNonReimbursableBillDefaultVendor(policyID, row.value, nonReimbursableBillDefaultVendor); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 1e50464d3b06..e83e8c59c0b2 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -82,7 +82,7 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyConne const selectExportAccount = useCallback( (row: CardListItem) => { if (row.value.id !== reimbursableExpensesAccount?.id) { - QuickbooksOnline.updateQuickbooksOnlineReimbursableExpensesAccount(policyID, row.value); + QuickbooksOnline.updateQuickbooksOnlineReimbursableExpensesAccount(policyID, row.value, reimbursableExpensesAccount); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); }, diff --git a/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx index af2d8da42216..ed915beeb47b 100644 --- a/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx @@ -51,6 +51,7 @@ function QuickbooksClassesPage({policy}: WithPolicyProps) { QuickbooksOnline.updateQuickbooksOnlineSyncClasses( policyID, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + syncClasses, ) } /> diff --git a/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx index 949978492dc9..a4b795ad3125 100644 --- a/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx @@ -50,6 +50,7 @@ function QuickbooksCustomersPage({policy}: WithPolicyProps) { QuickbooksOnline.updateQuickbooksOnlineSyncCustomers( policyID, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + syncCustomers, ) } /> diff --git a/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx index 5368d2ff8fb2..0a0397db1db1 100644 --- a/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx @@ -55,6 +55,7 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) { QuickbooksOnline.updateQuickbooksOnlineSyncLocations( policyID, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + syncLocations, ) } disabled={shouldBeDisabled}