From a73a5071c6bd5035fb4835a3642f77c744d77934 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 13:18:27 +0530 Subject: [PATCH 001/149] add routes --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index df87daf52b57..5ddaab6a7420 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -790,6 +790,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/xero/advanced', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/advanced` as const, }, + POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/xero/advanced/purchase-bill-status-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/advanced/purchase-bill-status-selector` 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, From e266c3eaa3081b66f7810003bd065ccad4f47ea7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 13:18:39 +0530 Subject: [PATCH 002/149] add screen map --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 1129a86a4e92..988ba28d18fa 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -240,6 +240,7 @@ const SCREENS = { XERO_CUSTOMER: 'Policy_Acounting_Xero_Import_Customer', XERO_TAXES: 'Policy_Accounting_Xero_Taxes', XERO_ADVANCED: 'Policy_Accounting_Xero_Advanced', + XERO_BILL_STATUS_SELECTOR: 'Policy_Accounting_Xero_Advanced_Bill_Status', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', From 102d949c2f9cc4ed88e425deafb0257505d3bca2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 13:18:50 +0530 Subject: [PATCH 003/149] add navigation map --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 2 ++ .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 +++ 4 files changed, 7 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index fad3ce072b06..5d6f85b6e705 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -300,6 +300,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/import/XeroCustomerConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: () => require('../../../../pages/workspace/accounting/xero/advanced/XeroAdvancedPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_STATUS_SELECTOR]: () => + require('../../../../pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage').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/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index f5a45b2ece19..bca304044505 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -45,6 +45,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER, SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES, SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED, + SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_STATUS_SELECTOR, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 1fdd575364f3..2313c1782902 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -332,6 +332,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER]: {path: ROUTES.POLICY_ACCOUNTING_XERO_CUSTOMER.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TAXES.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_STATUS_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 40427bf8cbbd..3d9f86ea384f 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -327,6 +327,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_STATUS_SELECTOR]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; From 37df48a3bde44b89629157a9a244a58836ec6a0d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 13:19:13 +0530 Subject: [PATCH 004/149] link to bill status page and add default page --- .../xero/advanced/XeroAdvancedPage.tsx | 4 +- .../XeroPurchaseBillStatusSelectorPage.tsx | 83 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx diff --git a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx index f781769adabf..4038678f214b 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx @@ -6,11 +6,13 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { const styles = useThemeStyles(); @@ -52,7 +54,7 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { description={translate('workspace.xero.advancedConfig.purchaseBillStatusTitle')} key={translate('workspace.xero.advancedConfig.purchaseBillStatusTitle')} wrapperStyle={[styles.sectionMenuItemTopDescription]} - onPress={() => {}} + onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID))} /> [...(bankAccounts ?? []), ...(creditCards ?? [])], [bankAccounts, creditCards]); + + const qboOnlineSelectorOptions = useMemo( + () => + accountOptions?.map(({id, name}) => ({ + value: id, + text: name, + keyForList: id, + isSelected: reimbursementAccountID === id, + })), + [reimbursementAccountID, accountOptions], + ); + const listHeaderComponent = useMemo( + () => ( + + {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], + ); + + const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + + const saveSelection = useCallback( + ({value}: SelectorType) => { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID)); + }, + [policyID], + ); + + return ( + + + + ); +} + +XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillStatusSelectorPage'; + +export default withPolicyConnections(XeroPurchaseBillStatusSelectorPage); From 7562b7ffe70e6ae55f63432b80cb10e4a6ac5478 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 13:28:10 +0530 Subject: [PATCH 005/149] add selection screen --- src/components/SelectionScreen.tsx | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/components/SelectionScreen.tsx diff --git a/src/components/SelectionScreen.tsx b/src/components/SelectionScreen.tsx new file mode 100644 index 000000000000..df650dffd40e --- /dev/null +++ b/src/components/SelectionScreen.tsx @@ -0,0 +1,81 @@ +import React from 'react'; +import useLocalize from '@hooks/useLocalize'; +import type {PolicyAccessVariant} from '@pages/workspace/AccessOrNotFoundWrapper'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {TranslationPaths} from '@src/languages/types'; +import type {PolicyFeatureName} from '@src/types/onyx/Policy'; +import HeaderWithBackButton from './HeaderWithBackButton'; +import ScreenWrapper from './ScreenWrapper'; +import SelectionList from './SelectionList'; +import type RadioListItem from './SelectionList/RadioListItem'; +import type TableListItem from './SelectionList/TableListItem'; +import type {ListItem, SectionListDataType} from './SelectionList/types'; +import type UserListItem from './SelectionList/UserListItem'; + +type SelectorType = ListItem & { + value: string; +}; + +type SelectionScreenProps = { + displayName: string; + title: TranslationPaths; + headerContent?: React.ReactNode; + sections: Array>; + listItem: typeof RadioListItem | typeof UserListItem | typeof TableListItem; + initiallyFocusedOptionKey?: string | null | undefined; + onSelectRow: (selection: SelectorType) => void; + onBackButtonPress: () => void; + /** The current policyID */ + policyID: string; + /** Defines which types of access should be verified */ + accessVariants?: PolicyAccessVariant[]; + /** The current feature name that the user tries to get access to */ + featureName?: PolicyFeatureName; +}; + +function SelectionScreen({ + displayName, + title, + headerContent, + sections, + listItem, + initiallyFocusedOptionKey, + onSelectRow, + onBackButtonPress, + policyID, + accessVariants, + featureName, +}: SelectionScreenProps) { + const {translate} = useLocalize(); + return ( + + + + + + + ); +} + +export type {SelectorType}; + +SelectionScreen.displayName = 'SelectionScreen'; +export default SelectionScreen; From 189c4f4df13f15db503fb45f8bf2b54c489dd8d0 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 3 May 2024 14:19:58 +0530 Subject: [PATCH 006/149] Add sync functionality in Xero connection --- .../actions/connections/QuickBooksOnline.ts | 39 +++---------------- src/libs/actions/connections/index.ts | 35 ++++++++++++++++- .../accounting/PolicyAccountingPage.tsx | 4 +- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/libs/actions/connections/QuickBooksOnline.ts b/src/libs/actions/connections/QuickBooksOnline.ts index f507758e8d38..3bf4bb4b6a36 100644 --- a/src/libs/actions/connections/QuickBooksOnline.ts +++ b/src/libs/actions/connections/QuickBooksOnline.ts @@ -1,41 +1,14 @@ -import type {OnyxUpdate} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; -import * as API from '@libs/API'; -import type {ConnectPolicyToAccountingIntegrationParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters'; +import type {ConnectPolicyToAccountingIntegrationParams} from '@libs/API/parameters'; import {READ_COMMANDS} from '@libs/API/types'; import {getCommandURL} from '@libs/ApiUtils'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; function getQuickBooksOnlineSetupLink(policyID: string) { const params: ConnectPolicyToAccountingIntegrationParams = {policyID}; - const commandURL = getCommandURL({command: READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE, shouldSkipWebProxy: true}); + const commandURL = getCommandURL({ + command: READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE, + shouldSkipWebProxy: true, + }); return commandURL + new URLSearchParams(params).toString(); } -function syncConnection(policyID: string) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, - value: { - stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.STARTING_IMPORT, - connectionName: CONST.POLICY.CONNECTIONS.NAME.QBO, - }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`, - value: null, - }, - ]; - const parameters: SyncPolicyToQuickbooksOnlineParams = { - policyID, - idempotencyKey: policyID, - }; - API.read(READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE, parameters, {optimisticData, failureData}); -} - -export {getQuickBooksOnlineSetupLink, syncConnection}; +export {getQuickBooksOnlineSetupLink}; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 5ce806c7d4be..ca09f1069b72 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -2,7 +2,8 @@ import Onyx from 'react-native-onyx'; import type {OnyxUpdate} from 'react-native-onyx'; import * as API from '@libs/API'; import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; -import {WRITE_COMMANDS} from '@libs/API/types'; +import {SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters'; +import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -124,4 +125,34 @@ function updatePolicyConnectionConfig syncConnection(policyID), + onSelected: () => syncConnection(policyID, connectedIntegration), disabled: isOffline, }, { From fe9b69b9c49c24c052ccd2309ef539dd97e38327 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 3 May 2024 15:29:58 +0530 Subject: [PATCH 007/149] add selection screen --- .../XeroPurchaseBillStatusSelectorPage.tsx | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx index b369a8008e52..bffe9eecb73b 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -26,55 +27,56 @@ function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; - const {reimbursementAccountID} = policy?.connections?.quickbooksOnline?.config ?? {}; - const accountOptions = useMemo(() => [...(bankAccounts ?? []), ...(creditCards ?? [])], [bankAccounts, creditCards]); + const {bankAccounts} = policy?.connections?.xero?.data ?? {}; - const qboOnlineSelectorOptions = useMemo( + const {invoiceCollectionsAccountID} = policy?.connections?.xero?.config.sync ?? {}; + + const xeroSelectorOptions = useMemo( () => - accountOptions?.map(({id, name}) => ({ + (bankAccounts ?? []).map(({id, name}) => ({ value: id, text: name, keyForList: id, - isSelected: reimbursementAccountID === id, + isSelected: invoiceCollectionsAccountID === id, })), - [reimbursementAccountID, accountOptions], + [invoiceCollectionsAccountID, bankAccounts], ); + const listHeaderComponent = useMemo( () => ( - {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} + {translate('workspace.xero.advancedConfig.invoiceAccountSelectDescription')} ), [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); - const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + const initiallyFocusedOptionKey = useMemo(() => xeroSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [xeroSelectorOptions]); - const saveSelection = useCallback( + const updateMode = useCallback( ({value}: SelectorType) => { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID)); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.SYNC, { + invoiceCollectionsAccountID: value, + }); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID)); }, [policyID], ); return ( - - - + displayName={XeroPurchaseBillStatusSelectorPage.displayName} + sections={[{data: xeroSelectorOptions}]} + listItem={RadioListItem} + onSelectRow={updateMode} + initiallyFocusedOptionKey={initiallyFocusedOptionKey} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack()} + title="workspace.xero.advancedConfig.xeroInvoiceCollectionAccount" + /> ); } From a362c38c92af0a5af95be66f5c22ab0df149037c Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 3 May 2024 17:36:18 +0530 Subject: [PATCH 008/149] Update --- .../ConnectToQuickbooksOnlineButton/index.native.tsx | 2 +- src/components/ConnectToQuickbooksOnlineButton/index.tsx | 2 +- src/libs/actions/connections/QuickBooksOnline.ts | 2 +- src/libs/actions/connections/index.ts | 7 +++---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx b/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx index 3a5e545cce88..50f71ea5a1ae 100644 --- a/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx +++ b/src/components/ConnectToQuickbooksOnlineButton/index.native.tsx @@ -10,7 +10,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import Modal from '@components/Modal'; import useLocalize from '@hooks/useLocalize'; import {removePolicyConnection} from '@libs/actions/connections'; -import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline'; +import getQuickBooksOnlineSetupLink from '@libs/actions/connections/QuickBooksOnline'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Session} from '@src/types/onyx'; diff --git a/src/components/ConnectToQuickbooksOnlineButton/index.tsx b/src/components/ConnectToQuickbooksOnlineButton/index.tsx index 7de2ba55fb84..b17ff374d3a6 100644 --- a/src/components/ConnectToQuickbooksOnlineButton/index.tsx +++ b/src/components/ConnectToQuickbooksOnlineButton/index.tsx @@ -5,7 +5,7 @@ import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {removePolicyConnection} from '@libs/actions/connections'; -import {getQuickBooksOnlineSetupLink} from '@libs/actions/connections/QuickBooksOnline'; +import getQuickBooksOnlineSetupLink from '@libs/actions/connections/QuickBooksOnline'; import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import type {ConnectToQuickbooksOnlineButtonProps} from './types'; diff --git a/src/libs/actions/connections/QuickBooksOnline.ts b/src/libs/actions/connections/QuickBooksOnline.ts index 3bf4bb4b6a36..2642ad4056a9 100644 --- a/src/libs/actions/connections/QuickBooksOnline.ts +++ b/src/libs/actions/connections/QuickBooksOnline.ts @@ -11,4 +11,4 @@ function getQuickBooksOnlineSetupLink(policyID: string) { return commandURL + new URLSearchParams(params).toString(); } -export {getQuickBooksOnlineSetupLink}; +export default getQuickBooksOnlineSetupLink; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index ca09f1069b72..2296ae28df60 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,8 +1,7 @@ import Onyx from 'react-native-onyx'; import type {OnyxUpdate} from 'react-native-onyx'; import * as API from '@libs/API'; -import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; -import {SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -125,14 +124,14 @@ function updatePolicyConnectionConfig Date: Fri, 3 May 2024 17:54:54 +0530 Subject: [PATCH 009/149] Update PolicyAccountingPage.tsx --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 50deefdf94b8..51d9bb493728 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -23,8 +23,7 @@ import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import {removePolicyConnection} from '@libs/actions/connections'; -import {syncConnection} from '@libs/actions/connections'; +import {removePolicyConnection, syncConnection} from '@libs/actions/connections'; import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; From ff31b5350e3b2f06368fe96e26189a1432dac295 Mon Sep 17 00:00:00 2001 From: Shridhar Goel <35566748+ShridharGoel@users.noreply.github.com> Date: Fri, 3 May 2024 17:55:24 +0530 Subject: [PATCH 010/149] Update PolicyAccountingPage.tsx --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 51d9bb493728..9541021c79cb 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -136,7 +136,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting onSelected: () => setIsDisconnectModalOpen(true), }, ], - [translate, policyID, isOffline], + [translate, policyID, isOffline, connectedIntegration], ); const connectionsMenuItems: MenuItemProps[] = useMemo(() => { From 1ddad046d5340f77b254c8c827687c8299cc537f Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 8 May 2024 18:37:05 +0530 Subject: [PATCH 011/149] Add new command and JSdoc --- .../SyncPolicyToIntegratedConnectionParams.ts | 6 +++++ .../SyncPolicyToQuickbooksOnlineParams.ts | 6 ----- src/libs/API/parameters/index.ts | 2 +- src/libs/API/types.ts | 4 ++- src/libs/actions/connections/index.ts | 26 +++++++++++++------ 5 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts delete mode 100644 src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts diff --git a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts new file mode 100644 index 000000000000..ad3a926c6b3e --- /dev/null +++ b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts @@ -0,0 +1,6 @@ +type SyncPolicyToIntegratedConnectionParams = { + policyID: string; + idempotencyKey: string; +}; + +export default SyncPolicyToIntegratedConnectionParams; diff --git a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts deleted file mode 100644 index b5782c150b9f..000000000000 --- a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type SyncPolicyToQuickbooksOnlineParams = { - policyID: string; - idempotencyKey: string; -}; - -export default SyncPolicyToQuickbooksOnlineParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 30261051c0e5..6fa8cf510eb0 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -12,7 +12,7 @@ export type {default as BeginSignInParams} from './BeginSignInParams'; export type {default as CloseAccountParams} from './CloseAccountParams'; export type {default as ConnectBankAccountParams} from './ConnectBankAccountParams'; export type {default as ConnectPolicyToAccountingIntegrationParams} from './ConnectPolicyToAccountingIntegrationParams'; -export type {default as SyncPolicyToQuickbooksOnlineParams} from './SyncPolicyToQuickbooksOnlineParams'; +export type {default as SyncPolicyToIntegratedConnectionParams} from './SyncPolicyToIntegratedConnectionParams'; export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams'; export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams'; export type {default as DeletePaymentCardParams} from './DeletePaymentCardParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index cd85cdfbe401..ee2639284883 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -434,6 +434,7 @@ const READ_COMMANDS = { CONNECT_POLICY_TO_QUICKBOOKS_ONLINE: 'ConnectPolicyToQuickbooksOnline', CONNECT_POLICY_TO_XERO: 'ConnectPolicyToXero', SYNC_POLICY_TO_QUICKBOOKS_ONLINE: 'SyncPolicyToQuickbooksOnline', + SYNC_POLICY_TO_XERO: 'SyncPolicyToXero', OPEN_REIMBURSEMENT_ACCOUNT_PAGE: 'OpenReimbursementAccountPage', OPEN_WORKSPACE_VIEW: 'OpenWorkspaceView', GET_MAPBOX_ACCESS_TOKEN: 'GetMapboxAccessToken', @@ -479,7 +480,8 @@ type ReadCommand = ValueOf; type ReadCommandParameters = { [READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.ConnectPolicyToAccountingIntegrationParams; [READ_COMMANDS.CONNECT_POLICY_TO_XERO]: Parameters.ConnectPolicyToAccountingIntegrationParams; - [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToQuickbooksOnlineParams; + [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToIntegratedConnectionParams; + [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToIntegratedConnectionParams; [READ_COMMANDS.OPEN_REIMBURSEMENT_ACCOUNT_PAGE]: Parameters.OpenReimbursementAccountPageParams; [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: Parameters.OpenWorkspaceViewParams; [READ_COMMANDS.GET_MAPBOX_ACCESS_TOKEN]: EmptyObject; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 2296ae28df60..10d07599c374 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,7 +1,11 @@ -import Onyx from 'react-native-onyx'; import type {OnyxUpdate} from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams, SyncPolicyToQuickbooksOnlineParams} from '@libs/API/parameters'; +import type { + RemovePolicyConnectionParams, + SyncPolicyToIntegratedConnectionParams, + UpdatePolicyConnectionConfigParams +} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -42,6 +46,7 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti }; API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, failureData}); } + function updatePolicyConnectionConfig( policyID: string, connectionName: TConnectionName, @@ -124,6 +129,12 @@ function updatePolicyConnectionConfig Date: Fri, 10 May 2024 01:52:47 +0530 Subject: [PATCH 012/149] Update --- src/libs/actions/connections/index.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 7b77f785bb6a..95495b19d7c7 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,11 +1,7 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import type { - RemovePolicyConnectionParams, - SyncPolicyToIntegratedConnectionParams, - UpdatePolicyConnectionConfigParams -} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams, SyncPolicyToIntegratedConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -150,7 +146,7 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName | API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, { optimisticData, - failureData + failureData, }); } From 66142428d257665e1aa57c0e37e8f6574237ce61 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 05:47:49 +0530 Subject: [PATCH 013/149] unlink from advanced --- .../workspace/accounting/xero/advanced/XeroAdvancedPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx index 8c48840352c1..154f5f8a97f9 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroAdvancedPage.tsx @@ -62,7 +62,7 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) { description={translate('workspace.xero.advancedConfig.purchaseBillStatusTitle')} key={translate('workspace.xero.advancedConfig.purchaseBillStatusTitle')} wrapperStyle={[styles.sectionMenuItemTopDescription]} - onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID))} + onPress={() => {}} /> Date: Fri, 10 May 2024 05:52:41 +0530 Subject: [PATCH 014/149] link export page --- .../accounting/xero/export/XeroExportConfigurationPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx index 934c41dab614..e951afff922f 100644 --- a/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroExportConfigurationPage.tsx @@ -6,9 +6,11 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; type MenuItem = MenuItemProps & {pendingAction?: OfflineWithFeedbackProps['pendingAction']}; @@ -44,7 +46,7 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) { }, { description: translate('workspace.xero.advancedConfig.purchaseBillStatusTitle'), - onPress: () => {}, + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID)), title: exportConfiguration?.billStatus?.purchase, pendingAction: pendingFields?.export, error: errorFields?.purchase ? translate('common.genericErrorMessage') : undefined, From 6ad88e37c701ed59d7d67abdab5234ecae8dfe8b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 06:02:31 +0530 Subject: [PATCH 015/149] update route to export --- src/ROUTES.ts | 4 +- src/SCREENS.ts | 2 +- .../XeroPurchaseBillStatusSelectorPage.tsx | 85 ------------------- .../XeroPurchaseBillStatusSelectorPage.tsx | 73 ++++++++++++++++ 4 files changed, 76 insertions(+), 88 deletions(-) delete mode 100644 src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx create mode 100644 src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 60d8cce94e35..445a7497b65f 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -817,8 +817,8 @@ const ROUTES = { getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/advanced` as const, }, POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR: { - route: 'settings/workspaces/:policyID/accounting/xero/advanced/purchase-bill-status-selector', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/advanced/purchase-bill-status-selector` as const, + route: 'settings/workspaces/:policyID/accounting/xero/export/purchase-bill-status-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/export/purchase-bill-status-selector` as const, }, POLICY_ACCOUNTING_XERO_INVOICE_SELECTOR: { route: 'settings/workspaces/:policyID/accounting/xero/advanced/invoice-account-selector', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 1f04484e0f64..5c1589626cc4 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -250,7 +250,7 @@ const SCREENS = { XERO_EXPORT: 'Policy_Accounting_Xero_Export', XERO_EXPORT_PURCHASE_BILL_DATE_SELECT: 'Policy_Accounting_Xero_Export_Purchase_Bill_Date_Select', XERO_ADVANCED: 'Policy_Accounting_Xero_Advanced', - XERO_BILL_STATUS_SELECTOR: 'Policy_Accounting_Xero_Advanced_Bill_Status', + XERO_BILL_STATUS_SELECTOR: 'Policy_Accounting_Xero_Export_Bill_Status', XERO_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Invoice_Account_Selector', XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select', XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', diff --git a/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx deleted file mode 100644 index bffe9eecb73b..000000000000 --- a/src/pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import React, {useCallback, useMemo} from 'react'; -import {View} from 'react-native'; -import ConnectionLayout from '@components/ConnectionLayout'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionList'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import type {ListItem} from '@components/SelectionList/types'; -import SelectionScreen from '@components/SelectionScreen'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as Connections from '@libs/actions/connections'; -import Navigation from '@libs/Navigation/Navigation'; -import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; -import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; -import withPolicyConnections from '@pages/workspace/withPolicyConnections'; -import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; - -type SelectorType = ListItem & { - value: string; -}; - -function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const policyID = policy?.id ?? ''; - const {bankAccounts} = policy?.connections?.xero?.data ?? {}; - - const {invoiceCollectionsAccountID} = policy?.connections?.xero?.config.sync ?? {}; - - const xeroSelectorOptions = useMemo( - () => - (bankAccounts ?? []).map(({id, name}) => ({ - value: id, - text: name, - keyForList: id, - isSelected: invoiceCollectionsAccountID === id, - })), - [invoiceCollectionsAccountID, bankAccounts], - ); - - const listHeaderComponent = useMemo( - () => ( - - {translate('workspace.xero.advancedConfig.invoiceAccountSelectDescription')} - - ), - [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], - ); - - const initiallyFocusedOptionKey = useMemo(() => xeroSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [xeroSelectorOptions]); - - const updateMode = useCallback( - ({value}: SelectorType) => { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.SYNC, { - invoiceCollectionsAccountID: value, - }); - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID)); - }, - [policyID], - ); - - return ( - Navigation.goBack()} - title="workspace.xero.advancedConfig.xeroInvoiceCollectionAccount" - /> - ); -} - -XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillStatusSelectorPage'; - -export default withPolicyConnections(XeroPurchaseBillStatusSelectorPage); diff --git a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx new file mode 100644 index 000000000000..8c652325312b --- /dev/null +++ b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx @@ -0,0 +1,73 @@ +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; +import type {SelectorType} from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type MenuListItem = ListItem & { + value: ValueOf; +}; + +function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps) { + const {translate} = useLocalize(); + const policyID = policy?.id ?? ''; + const styles = useThemeStyles(); + const {billDate} = policy?.connections?.xero?.config?.export ?? {}; + const data: MenuListItem[] = Object.values(CONST.XERO_EXPORT_DATE).map((dateType) => ({ + value: dateType, + text: translate(`workspace.xero.exportDate.values.${dateType}.label`), + alternateText: translate(`workspace.xero.exportDate.values.${dateType}.description`), + keyForList: dateType, + isSelected: billDate === dateType, + })); + + const headerContent = useMemo( + () => ( + + {translate('workspace.xero.exportDate.description')} + + ), + [translate, styles.pb5, styles.ph5], + ); + + const selectExportDate = useCallback( + (row: MenuListItem) => { + if (row.value !== billDate) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billDate: row.value}); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID)); + }, + [billDate, policyID], + ); + + return ( + selectExportDate(selection as MenuListItem)} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + policyID={policyID} + accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} + featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID))} + /> + ); +} + +XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillDateSelectPage'; + +export default withPolicyConnections(XeroPurchaseBillStatusSelectorPage); From db7f63ec9b5879f3b90055e5e46d691ca43c0615 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:05:12 +0530 Subject: [PATCH 016/149] add lang --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index d51d142696cc..d2dab5746e11 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2082,6 +2082,8 @@ export default { }, }, invoiceStatus: { + label: 'Purchase bill status', + description: 'When exported to Xero what state should purchase bills have.', values: { [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Authorised', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Draft', diff --git a/src/languages/es.ts b/src/languages/es.ts index a19342d04ea3..a83e2f55931d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2117,6 +2117,8 @@ export default { }, }, invoiceStatus: { + label: 'Estado de la factura de compra', + description: 'When exported to Xero what state should purchase bills have.', values: { [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Autorizado', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Borrador', From c4fcf6d11703fdfcb3feb5ded79ee36682a1e724 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:05:29 +0530 Subject: [PATCH 017/149] fix nav --- src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 1a179ec9a733..330de469d0a7 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -314,7 +314,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/advanced/XeroAdvancedPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_STATUS_SELECTOR]: () => - require('../../../../pages/workspace/accounting/xero/advanced/XeroPurchaseBillStatusSelectorPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_INVOICE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT]: () => From d75c75674ca4e144ab62c5b4d76d774cba92c4f5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:05:46 +0530 Subject: [PATCH 018/149] use updated routes and lang --- .../XeroPurchaseBillStatusSelectorPage.tsx | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx index 8c652325312b..dc2119c49d93 100644 --- a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx @@ -16,49 +16,50 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; type MenuListItem = ListItem & { - value: ValueOf; + value: ValueOf; }; function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; const styles = useThemeStyles(); - const {billDate} = policy?.connections?.xero?.config?.export ?? {}; - const data: MenuListItem[] = Object.values(CONST.XERO_EXPORT_DATE).map((dateType) => ({ - value: dateType, - text: translate(`workspace.xero.exportDate.values.${dateType}.label`), - alternateText: translate(`workspace.xero.exportDate.values.${dateType}.description`), - keyForList: dateType, - isSelected: billDate === dateType, + const {billStatus} = policy?.connections?.xero?.config?.export ?? {}; + const invoiceStatus = billStatus?.purchase; + + const data: MenuListItem[] = Object.values(CONST.XERO_CONFIG.INVOICE_STATUS).map((status) => ({ + value: status, + text: translate(`workspace.xero.invoiceStatus.values.${status}`), + keyForList: status, + isSelected: invoiceStatus === status, })); const headerContent = useMemo( () => ( - {translate('workspace.xero.exportDate.description')} + {translate('workspace.xero.invoiceStatus.description')} ), [translate, styles.pb5, styles.ph5], ); - const selectExportDate = useCallback( + const selectPurchaseBillStatus = useCallback( (row: MenuListItem) => { - if (row.value !== billDate) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billDate: row.value}); + if (row.value !== invoiceStatus) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billStatus: {sales: row.value, purchase: row.value}}); } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID)); }, - [billDate, policyID], + [invoiceStatus, policyID], ); return ( selectExportDate(selection as MenuListItem)} + onSelectRow={(selection: SelectorType) => selectPurchaseBillStatus(selection as MenuListItem)} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} policyID={policyID} accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} From 6de73ea9e4a761f1b217e37fc0fc18f7fb1bd5c3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:09:16 +0530 Subject: [PATCH 019/149] update status name --- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index d2dab5746e11..4d9903af11ee 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2085,9 +2085,9 @@ export default { label: 'Purchase bill status', description: 'When exported to Xero what state should purchase bills have.', values: { - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Authorised', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Draft', - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Submitted', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Awaiting approval', }, }, exportPreferredExporterNote: 'This can be any workspace admin, but must be a domain admin if you set different export accounts for individual company cards in domain settings.', diff --git a/src/languages/es.ts b/src/languages/es.ts index a83e2f55931d..851ba1528203 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2120,9 +2120,9 @@ export default { label: 'Estado de la factura de compra', description: 'When exported to Xero what state should purchase bills have.', values: { - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Autorizado', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Borrador', - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Enviado', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Awaiting approval', }, }, exportPreferredExporterNote: From 19b1c8c934d025237db5c075593b2824ff7ea226 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:10:00 +0530 Subject: [PATCH 020/149] change order --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4d9903af11ee..eb5c0a031740 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2085,9 +2085,9 @@ export default { label: 'Purchase bill status', description: 'When exported to Xero what state should purchase bills have.', values: { - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Draft', [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Awaiting approval', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', }, }, exportPreferredExporterNote: 'This can be any workspace admin, but must be a domain admin if you set different export accounts for individual company cards in domain settings.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 851ba1528203..9f3bf41dc255 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2120,9 +2120,9 @@ export default { label: 'Estado de la factura de compra', description: 'When exported to Xero what state should purchase bills have.', values: { - [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', [CONST.XERO_CONFIG.INVOICE_STATUS.DRAFT]: 'Borrador', [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_APPROVAL]: 'Awaiting approval', + [CONST.XERO_CONFIG.INVOICE_STATUS.AWAITING_PAYMENT]: 'Awaiting payment', }, }, exportPreferredExporterNote: From c7eb413e1883ebdafb4594edb166e46b146f220d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:10:46 +0530 Subject: [PATCH 021/149] change order --- src/CONST.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index bd1c61c907d7..6f18b3b7b5c9 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1303,9 +1303,9 @@ const CONST = { IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', INVOICE_STATUS: { - AWAITING_PAYMENT: 'AWT_PAYMENT', DRAFT: 'DRAFT', AWAITING_APPROVAL: 'AWT_APPROVAL', + AWAITING_PAYMENT: 'AWT_PAYMENT', }, IMPORT_TRACKING_CATEGORIES: 'importTrackingCategories', MAPPINGS: 'mappings', From 2380eb77fbb47f010bd8d404da58a55cf9fde12d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 14:16:52 +0530 Subject: [PATCH 022/149] handle undefined --- .../xero/export/XeroPurchaseBillStatusSelectorPage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx index dc2119c49d93..52634712220f 100644 --- a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx @@ -1,3 +1,4 @@ +import _ from 'lodash'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; @@ -44,12 +45,15 @@ function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps const selectPurchaseBillStatus = useCallback( (row: MenuListItem) => { + if (_.isEmpty(billStatus)) { + return; + } if (row.value !== invoiceStatus) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billStatus: {sales: row.value, purchase: row.value}}); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.EXPORT, {billStatus: {...billStatus, purchase: row.value}}); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID)); }, - [invoiceStatus, policyID], + [billStatus, invoiceStatus, policyID], ); return ( From 4d1a0e0e77406920d7d422ce5447d3413c7eb393 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:18:26 +0530 Subject: [PATCH 023/149] Update src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx Co-authored-by: Manan --- .../xero/export/XeroPurchaseBillStatusSelectorPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx index 52634712220f..b2406d0a3bc2 100644 --- a/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/export/XeroPurchaseBillStatusSelectorPage.tsx @@ -73,6 +73,6 @@ function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps ); } -XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillDateSelectPage'; +XeroPurchaseBillStatusSelectorPage.displayName = 'XeroPurchaseBillStatusSelectorPage'; export default withPolicyConnections(XeroPurchaseBillStatusSelectorPage); From bf670dcdd0cb8519d5e861a3f7216e48cf8c9fdd Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 10 May 2024 16:19:07 +0530 Subject: [PATCH 024/149] Update src/SCREENS.ts Co-authored-by: Manan --- src/SCREENS.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 5c1589626cc4..67362b29c506 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -250,7 +250,7 @@ const SCREENS = { XERO_EXPORT: 'Policy_Accounting_Xero_Export', XERO_EXPORT_PURCHASE_BILL_DATE_SELECT: 'Policy_Accounting_Xero_Export_Purchase_Bill_Date_Select', XERO_ADVANCED: 'Policy_Accounting_Xero_Advanced', - XERO_BILL_STATUS_SELECTOR: 'Policy_Accounting_Xero_Export_Bill_Status', + XERO_BILL_STATUS_SELECTOR: 'Policy_Accounting_Xero_Export_Bill_Status_Selector', XERO_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Invoice_Account_Selector', XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select', XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', From 1fce4d03095b85069c24f736b29c730e5b32f18f Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Fri, 10 May 2024 16:36:54 +0200 Subject: [PATCH 025/149] add offline support for XeroOrganizationConfiguration --- .../accounting/PolicyAccountingPage.tsx | 23 ++++++++++++++---- .../XeroOrganizationConfigurationPage.tsx | 24 +++++++++++++------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index fbd5b669fa62..26638b92224e 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -11,7 +11,10 @@ import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {MenuItemProps} from '@components/MenuItem'; +import MenuItem from '@components/MenuItem'; import MenuItemList from '@components/MenuItemList'; +import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; @@ -39,6 +42,8 @@ import type {PolicyConnectionName} from '@src/types/onyx/Policy'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; +type MenuItemData = MenuItemProps & {pendingAction?: OfflineWithFeedbackProps['pendingAction']}; + type PolicyAccountingPageOnyxProps = { connectionSyncProgress: OnyxEntry; }; @@ -140,7 +145,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting [translate, policyID, isOffline], ); - const connectionsMenuItems: MenuItemProps[] = useMemo(() => { + const connectionsMenuItems: MenuItemData[] = useMemo(() => { if (isEmptyObject(policy?.connections) && !isSyncInProgress) { return accountingIntegrations.map((integration) => { const integrationData = accountingIntegrationData(integration, policyID, translate); @@ -211,6 +216,8 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting } Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.getRoute(policyID, currentXeroOrganization?.id ?? '')); }, + pendingAction: policy?.connections?.xero?.config?.pendingFields?.tenantID, + brickRoadIndicator: policy?.connections?.xero?.config?.errorFields?.tenantID ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, }, ] : []), @@ -334,10 +341,16 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting titleStyles={styles.accountSettingsSectionTitle} childrenStyles={styles.pt5} > - + {connectionsMenuItems.map((menuItem) => ( + + + + ))} {otherIntegrationsItems && ( + - {translate('workspace.xero.organizationDescription')} - + + {translate('workspace.xero.organizationDescription')} + + From 1cf8b940be10727d8ca6f43536a63a7d4ae8430f Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 13 May 2024 18:12:43 +0200 Subject: [PATCH 026/149] fix PR comments --- src/CONST.ts | 1 + .../xero/XeroOrganizationConfigurationPage.tsx | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 8a380188d05e..6e5616eee662 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1299,6 +1299,7 @@ const CONST = { XERO_CONFIG: { AUTO_SYNC: 'autoSync', SYNC: 'sync', + TENANT_ID: 'tenantID', IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', IMPORT_TRACKING_CATEGORIES: 'importTrackingCategories', diff --git a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx index e525f82994ff..20a1447ff9a6 100644 --- a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx @@ -18,6 +18,7 @@ import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -32,7 +33,8 @@ function XeroOrganizationConfigurationPage({ const {translate} = useLocalize(); const styles = useThemeStyles(); const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]); - const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID); + const xeroConfig = policy?.connections?.xero?.config; + const currentXeroOrganization = findCurrentXeroOrganization(tenants, xeroConfig?.tenantID); const policyID = policy?.id ?? ''; @@ -48,7 +50,7 @@ function XeroOrganizationConfigurationPage({ return; } - updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, 'tenantID', keyForList); + updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.TENANT_ID, keyForList); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING.getRoute(policyID)); }; @@ -67,10 +69,9 @@ function XeroOrganizationConfigurationPage({ Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.IMPORT_TAX_RATES)} > {translate('workspace.xero.organizationDescription')} Date: Mon, 13 May 2024 18:38:29 +0200 Subject: [PATCH 027/149] fix XeroOrganization bug --- .../accounting/xero/XeroOrganizationConfigurationPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx index 20a1447ff9a6..582aeac07416 100644 --- a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx @@ -71,7 +71,7 @@ function XeroOrganizationConfigurationPage({ Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.IMPORT_TAX_RATES)} + onClose={() => Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.TENANT_ID)} > {translate('workspace.xero.organizationDescription')} Date: Mon, 13 May 2024 18:48:10 +0200 Subject: [PATCH 028/149] use ConnectionLayout in XeroOrganizationConfigurationPage --- .../XeroOrganizationConfigurationPage.tsx | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx index 582aeac07416..09281a7d477c 100644 --- a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx @@ -1,9 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useMemo} from 'react'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ConnectionLayout from '@components/ConnectionLayout'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; @@ -15,7 +13,6 @@ import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils'; -import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Policy from '@userActions/Policy'; @@ -55,35 +52,27 @@ function XeroOrganizationConfigurationPage({ }; return ( - - Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.TENANT_ID)} > - - - - Policy.clearXeroErrorField(policyID, CONST.XERO_CONFIG.TENANT_ID)} - > - {translate('workspace.xero.organizationDescription')} - - - - - + {translate('workspace.xero.organizationDescription')} + + + ); } From 8e391e06200d4dfdbb712b6ad1fc9d036652de4e Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 14 May 2024 14:48:57 +0200 Subject: [PATCH 029/149] fix padding on XeroOrganizationList --- .../accounting/xero/XeroOrganizationConfigurationPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx index 09281a7d477c..9e7a142327c2 100644 --- a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx @@ -66,6 +66,7 @@ function XeroOrganizationConfigurationPage({ > {translate('workspace.xero.organizationDescription')} Date: Tue, 14 May 2024 15:07:33 +0200 Subject: [PATCH 030/149] fix safe area insets --- src/components/ConnectionLayout.tsx | 6 +++++- .../accounting/xero/XeroOrganizationConfigurationPage.tsx | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/ConnectionLayout.tsx b/src/components/ConnectionLayout.tsx index 8abe0e5759fc..6d17b84bfffa 100644 --- a/src/components/ConnectionLayout.tsx +++ b/src/components/ConnectionLayout.tsx @@ -44,6 +44,9 @@ type ConnectionLayoutProps = { /** Style of the title text */ titleStyle?: StyleProp | undefined; + /** Whether to include safe area padding bottom or not */ + shouldIncludeSafeAreaPaddingBottom?: boolean; + /** Whether to use ScrollView or not */ shouldUseScrollView?: boolean; }; @@ -72,6 +75,7 @@ function ConnectionLayout({ featureName, contentContainerStyle, titleStyle, + shouldIncludeSafeAreaPaddingBottom, shouldUseScrollView = true, }: ConnectionLayoutProps) { const {translate} = useLocalize(); @@ -95,7 +99,7 @@ function ConnectionLayout({ featureName={featureName} > diff --git a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx index 9e7a142327c2..0a331ad4938d 100644 --- a/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroOrganizationConfigurationPage.tsx @@ -58,6 +58,7 @@ function XeroOrganizationConfigurationPage({ accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} policyID={policyID} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + shouldIncludeSafeAreaPaddingBottom > Date: Tue, 14 May 2024 20:06:41 +0530 Subject: [PATCH 031/149] Updates --- .../SyncPolicyToIntegratedConnectionParams.ts | 6 ------ .../SyncPolicyToQuickbooksOnlineParams.ts | 6 ++++++ src/libs/API/parameters/index.ts | 3 ++- src/libs/API/types.ts | 4 ++-- src/libs/actions/connections/index.ts | 17 ++++++++++++----- 5 files changed, 22 insertions(+), 14 deletions(-) delete mode 100644 src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts create mode 100644 src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts diff --git a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts b/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts deleted file mode 100644 index ad3a926c6b3e..000000000000 --- a/src/libs/API/parameters/SyncPolicyToIntegratedConnectionParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -type SyncPolicyToIntegratedConnectionParams = { - policyID: string; - idempotencyKey: string; -}; - -export default SyncPolicyToIntegratedConnectionParams; diff --git a/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts new file mode 100644 index 000000000000..b5782c150b9f --- /dev/null +++ b/src/libs/API/parameters/SyncPolicyToQuickbooksOnlineParams.ts @@ -0,0 +1,6 @@ +type SyncPolicyToQuickbooksOnlineParams = { + policyID: string; + idempotencyKey: string; +}; + +export default SyncPolicyToQuickbooksOnlineParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 34609b6a40ec..55acc24f3ed3 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -12,7 +12,8 @@ export type {default as BeginSignInParams} from './BeginSignInParams'; export type {default as CloseAccountParams} from './CloseAccountParams'; export type {default as ConnectBankAccountParams} from './ConnectBankAccountParams'; export type {default as ConnectPolicyToAccountingIntegrationParams} from './ConnectPolicyToAccountingIntegrationParams'; -export type {default as SyncPolicyToIntegratedConnectionParams} from './SyncPolicyToIntegratedConnectionParams'; +export type {default as SyncPolicyToQuickbooksOnlineParams} from './SyncPolicyToQuickbooksOnlineParams'; +export type {default as SyncPolicyToXeroParams} from './SyncPolicyToXeroParams'; export type {default as DeleteContactMethodParams} from './DeleteContactMethodParams'; export type {default as DeletePaymentBankAccountParams} from './DeletePaymentBankAccountParams'; export type {default as DeletePaymentCardParams} from './DeletePaymentCardParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 329ac4294b96..e6c3644f7278 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -486,8 +486,8 @@ type ReadCommand = ValueOf; type ReadCommandParameters = { [READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.ConnectPolicyToAccountingIntegrationParams; [READ_COMMANDS.CONNECT_POLICY_TO_XERO]: Parameters.ConnectPolicyToAccountingIntegrationParams; - [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToIntegratedConnectionParams; - [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToIntegratedConnectionParams; + [READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE]: Parameters.SyncPolicyToQuickbooksOnlineParams; + [READ_COMMANDS.SYNC_POLICY_TO_XERO]: Parameters.SyncPolicyToXeroParams; [READ_COMMANDS.OPEN_REIMBURSEMENT_ACCOUNT_PAGE]: Parameters.OpenReimbursementAccountPageParams; [READ_COMMANDS.OPEN_WORKSPACE_VIEW]: Parameters.OpenWorkspaceViewParams; [READ_COMMANDS.GET_MAPBOX_ACCESS_TOKEN]: EmptyObject; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 95495b19d7c7..8bbdd557bb4d 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,7 +1,7 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import type {RemovePolicyConnectionParams, SyncPolicyToIntegratedConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams, SyncPolicyToQuickbooksOnlineParams, SyncPolicyToXeroParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; @@ -139,10 +139,17 @@ function syncConnection(policyID: string, connectionName: PolicyConnectionName | value: null, }, ]; - const parameters: SyncPolicyToIntegratedConnectionParams = { - policyID, - idempotencyKey: policyID, - }; + + const parameters: SyncPolicyToQuickbooksOnlineParams | SyncPolicyToXeroParams = + connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO + ? ({ + policyID, + idempotencyKey: policyID, + } as SyncPolicyToQuickbooksOnlineParams) + : ({ + policyID, + idempotencyKey: policyID, + } as SyncPolicyToXeroParams); API.read(connectionName === CONST.POLICY.CONNECTIONS.NAME.QBO ? READ_COMMANDS.SYNC_POLICY_TO_QUICKBOOKS_ONLINE : READ_COMMANDS.SYNC_POLICY_TO_XERO, parameters, { optimisticData, From b5e0200be63cea66fe657bde0b6deae9a69190aa Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 15 May 2024 11:14:06 +0200 Subject: [PATCH 032/149] fix typescript errors --- src/pages/workspace/accounting/PolicyAccountingPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index d6b47a0dd662..948120d9d2da 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -2,7 +2,6 @@ import React, {useMemo, useRef, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; -import AccountingListSkeletonView from '@components/AccountingListSkeletonView'; import CollapsibleSection from '@components/CollapsibleSection'; import ConfirmModal from '@components/ConfirmModal'; import ConnectToQuickbooksOnlineButton from '@components/ConnectToQuickbooksOnlineButton'; @@ -106,7 +105,7 @@ function accountingIntegrationData( } } -function PolicyAccountingPage({policy, connectionSyncProgress, isConnectionDataFetchNeeded}: PolicyAccountingPageProps) { +function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccountingPageProps) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); From ef91552914dba19f23d1fd7597f5a4860be7d896 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 15 May 2024 14:29:31 +0200 Subject: [PATCH 033/149] make taxes read only --- .../workspace/taxes/WorkspaceEditTaxPage.tsx | 2 +- .../workspace/taxes/WorkspaceTaxesPage.tsx | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx b/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx index 8ccff7b4e126..c7f3c50489e7 100644 --- a/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx +++ b/src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx @@ -86,7 +86,7 @@ function WorkspaceEditTaxPage({ { const isMultiple = selectedTaxesIDs.length > 1; - const options: Array> = [ - { + const options: Array> = []; + if (!PolicyUtils.hasAccountingConnections(policy)) { + options.push({ icon: Expensicons.Trashcan, text: isMultiple ? translate('workspace.taxes.actions.deleteMultiple') : translate('workspace.taxes.actions.delete'), value: CONST.POLICY.TAX_RATES_BULK_ACTION_TYPES.DELETE, onSelected: () => setIsDeleteModalVisible(true), - }, - ]; + }); + } // `Disable rates` when at least one enabled rate is selected. if (selectedTaxesIDs.some((taxID) => !policy?.taxRates?.taxes[taxID]?.isDisabled)) { @@ -201,18 +202,20 @@ function WorkspaceTaxesPage({ }); } return options; - }, [policy?.taxRates?.taxes, selectedTaxesIDs, toggleTaxes, translate]); + }, [policy, selectedTaxesIDs, toggleTaxes, translate]); const headerButtons = !selectedTaxesIDs.length ? ( -