From bbbd2d80a4fe19f7903c1863f7b35ad7d1079b03 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 13:32:01 +0530 Subject: [PATCH 1/9] add syncTax type --- src/types/onyx/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 54d6198f4078..748ad06aaef3 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -235,6 +235,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ importCustomers: boolean; importTaxRates: boolean; importTrackingCategories: boolean; + syncTaxes: IntegrationEntityMap; isConfigured: boolean; mappings: { customer: string; From 56fabcdb5be69b47ff4c6346d1e68910923a594d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 13:32:17 +0530 Subject: [PATCH 2/9] add default page --- .../xero/XeroTaxesConfigurationPage.tsx | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx diff --git a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx new file mode 100644 index 000000000000..9a4f604e760f --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx @@ -0,0 +1,67 @@ +import React from 'react'; +import {View} from 'react-native'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Switch from '@components/Switch'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; + +function XeroTaxesConfigurationPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + const {syncTaxes, pendingFields} = policy?.connections?.xero?.config ?? {}; + const isSwitchOn = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + return ( + + + + + {translate('workspace.qbo.taxesDescription')} + + + {translate('workspace.accounting.import')} + + + + + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.XERO, + CONST.QUICK_BOOKS_CONFIG.SYNC_TAXES, + isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + ) + } + /> + + + + + + + ); +} + +XeroTaxesConfigurationPage.displayName = 'XeroTaxesConfigurationPage'; + +export default withPolicyConnections(XeroTaxesConfigurationPage); From e3b1317cebcf0d1f20bffe22a65ac62f4904d2dc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 13:40:50 +0530 Subject: [PATCH 3/9] route to taxes page --- src/ROUTES.ts | 4 ++++ src/SCREENS.ts | 1 + .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/pages/workspace/accounting/xero/XeroImportPage.tsx | 4 +++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index aba59e1a94ac..0015da51f287 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -770,6 +770,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/xero/organization/:currentOrganizationID', getRoute: (policyID: string, currentOrganizationID: string) => `settings/workspaces/${policyID}/accounting/xero/organization/${currentOrganizationID}` as const, }, + POLICY_ACCOUNTING_XERO_TAXES: { + route: 'settings/workspaces/:policyID/accounting/xero/import/taxes', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/taxes` as const, + }, POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_IMPORT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 09d1a27e37fc..40c9cbb6ed1d 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -236,6 +236,7 @@ const SCREENS = { QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Invoice_Account_Selector', XERO_IMPORT: 'Policy_Accounting_Xero_Import', XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', + XERO_TAXES: 'Policy_Accounting_Xero_Taxes', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 2ae41e493a8f..9f578277b3c3 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -294,6 +294,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/XeroImportPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: () => require('../../../../pages/workspace/accounting/xero/XeroOrganizationConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 7eac94db834b..28904841a583 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -323,6 +323,7 @@ const config: LinkingOptions['config'] = { }, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TAXES.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/pages/workspace/accounting/xero/XeroImportPage.tsx b/src/pages/workspace/accounting/xero/XeroImportPage.tsx index 3c1455e9ee65..131dac3e2997 100644 --- a/src/pages/workspace/accounting/xero/XeroImportPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroImportPage.tsx @@ -7,10 +7,12 @@ import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; import type {Tenant} from '@src/types/onyx/Policy'; function XeroImportPage({policy}: WithPolicyProps) { @@ -48,7 +50,7 @@ function XeroImportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.accounting.taxes'), - action: () => {}, + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TAXES.getRoute(policyID)), hasError: !!policy?.errors?.importTaxes, title: importTaxRates ? translate('workspace.accounting.imported') : '', pendingAction: pendingFields?.importTaxRates, From d4bd1b0f6bfe3077080589e82217c6f85e76abb9 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 14:15:06 +0530 Subject: [PATCH 4/9] add full screen map --- src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + 1 file changed, 1 insertion(+) 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 a4c3a399f869..51652e942a52 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -41,6 +41,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, + SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, From cec722418c92ddcda22c4d68cd9aecef5963bae5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 14:24:30 +0530 Subject: [PATCH 5/9] add policyid type to navigation --- src/libs/Navigation/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 0b5119072a95..8db2fbbecf92 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -314,6 +314,9 @@ type SettingsNavigatorParamList = { policyID: string; organizationID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; From 84520f4bb6ea3ca4898d338a755d51554f904dbb Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 16:55:20 +0530 Subject: [PATCH 6/9] add lang --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../workspace/accounting/xero/XeroTaxesConfigurationPage.tsx | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 53735624d14f..5188c884810c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1994,6 +1994,7 @@ export default { importDescription: 'Choose which coding configurations are imported from Xero to Expensify.', trackingCategories: 'Tracking categories', customers: 'Re-bill customers', + taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index e916772ef984..2363340666cf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2021,6 +2021,7 @@ export default { importDescription: 'Elija qué configuraciones de codificación se importan de Xero a Expensify.', trackingCategories: 'Categorías de seguimiento', customers: 'Volver a facturar a los clientes', + taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', }, type: { free: 'Gratis', diff --git a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx index 9a4f604e760f..f8ea7788025e 100644 --- a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx @@ -34,7 +34,7 @@ function XeroTaxesConfigurationPage({policy}: WithPolicyProps) { > - {translate('workspace.qbo.taxesDescription')} + {translate('workspace.xero.taxesDescription')} {translate('workspace.accounting.import')} From 5a3d2d40aff10573c38aa76829a3c7e935049d34 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 16:56:41 +0530 Subject: [PATCH 7/9] add xero config --- src/CONST.ts | 4 ++++ .../workspace/accounting/xero/XeroTaxesConfigurationPage.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index e33ba5a1b7b8..eee23a534234 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1265,6 +1265,10 @@ const CONST = { COLLECTION_ACCOUNT_ID: 'collectionAccountID', }, + XERO_CONFIG: { + SYNC_TAXES: 'syncTaxes', + }, + QUICKBOOKS_EXPORT_ENTITY: { VENDOR_BILL: 'vendorBill', CHECK: 'check', diff --git a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx index f8ea7788025e..ac06f25832c1 100644 --- a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx @@ -48,7 +48,7 @@ function XeroTaxesConfigurationPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, - CONST.QUICK_BOOKS_CONFIG.SYNC_TAXES, + CONST.XERO_CONFIG.SYNC_TAXES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } From 0899c18576abc42cc086bcb78d4d3942d7ed3d1a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 17:40:50 +0530 Subject: [PATCH 8/9] use correct setting name: importTaxRates --- src/CONST.ts | 2 +- .../accounting/xero/XeroTaxesConfigurationPage.tsx | 13 ++++--------- src/types/onyx/Policy.ts | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index eee23a534234..4f49e21f5338 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1266,7 +1266,7 @@ const CONST = { }, XERO_CONFIG: { - SYNC_TAXES: 'syncTaxes', + IMPORT_TAX_RATES: 'importTaxRates', }, QUICKBOOKS_EXPORT_ENTITY: { diff --git a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx index ac06f25832c1..47910760eb40 100644 --- a/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTaxesConfigurationPage.tsx @@ -19,8 +19,8 @@ function XeroTaxesConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {syncTaxes, pendingFields} = policy?.connections?.xero?.config ?? {}; - const isSwitchOn = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + const {importTaxRates, pendingFields} = policy?.connections?.xero?.config ?? {}; + const isSwitchOn = Boolean(importTaxRates); return ( {translate('workspace.accounting.import')} - + - Connections.updatePolicyConnectionConfig( - policyID, - CONST.POLICY.CONNECTIONS.NAME.XERO, - CONST.XERO_CONFIG.SYNC_TAXES, - isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, - ) + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.IMPORT_TAX_RATES, !importTaxRates) } /> diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 748ad06aaef3..54d6198f4078 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -235,7 +235,6 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ importCustomers: boolean; importTaxRates: boolean; importTrackingCategories: boolean; - syncTaxes: IntegrationEntityMap; isConfigured: boolean; mappings: { customer: string; From eee7de6b2d6c48e3386f5995970059dfd822ef47 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 1 May 2024 17:48:42 +0530 Subject: [PATCH 9/9] fix lint --- src/pages/workspace/accounting/xero/XeroImportPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/xero/XeroImportPage.tsx b/src/pages/workspace/accounting/xero/XeroImportPage.tsx index 131dac3e2997..4c83f8dea501 100644 --- a/src/pages/workspace/accounting/xero/XeroImportPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroImportPage.tsx @@ -69,6 +69,7 @@ function XeroImportPage({policy}: WithPolicyProps) { policy?.errors?.importCustomers, policy?.errors?.importTaxes, translate, + policyID, ], );