From 1a19a65ef8d039f3418cd761edf1bca44e503481 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 30 Jul 2024 12:19:43 +0200 Subject: [PATCH 01/19] feat: add new write command - ConfigureExpensifyCardForPolicy --- .../parameters/ConfigureExpensifyCardsForPolicyParams.ts | 6 ++++++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 src/libs/API/parameters/ConfigureExpensifyCardsForPolicyParams.ts diff --git a/src/libs/API/parameters/ConfigureExpensifyCardsForPolicyParams.ts b/src/libs/API/parameters/ConfigureExpensifyCardsForPolicyParams.ts new file mode 100644 index 000000000000..dea6b2705188 --- /dev/null +++ b/src/libs/API/parameters/ConfigureExpensifyCardsForPolicyParams.ts @@ -0,0 +1,6 @@ +type ConfigureExpensifyCardsForPolicyParams = { + policyID: string; + bankAccountID: number; +}; + +export default ConfigureExpensifyCardsForPolicyParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 6b95190cd1ed..a76ec0b9fae6 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -269,3 +269,4 @@ export type {default as ExportSearchItemsToCSVParams} from './ExportSearchItemsT export type {default as UpdateExpensifyCardLimitParams} from './UpdateExpensifyCardLimitParams'; export type {CreateWorkspaceApprovalParams, UpdateWorkspaceApprovalParams, RemoveWorkspaceApprovalParams} from './WorkspaceApprovalParams'; export type {default as StartIssueNewCardFlowParams} from './StartIssueNewCardFlowParams'; +export type {default as ConfigureExpensifyCardsForPolicyParams} from './ConfigureExpensifyCardsForPolicyParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index f15fba20bc98..7933ff839d22 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -322,6 +322,7 @@ const WRITE_COMMANDS = { CREATE_WORKSPACE_APPROVAL: 'CreateWorkspaceApproval', UPDATE_WORKSPACE_APPROVAL: 'UpdateWorkspaceApproval', REMOVE_WORKSPACE_APPROVAL: 'RemoveWorkspaceApproval', + CONFIGURE_EXPENSIFY_CARDS_FOR_POLICY: 'ConfigureExpensifyCardsForPolicy', } as const; type WriteCommand = ValueOf; @@ -650,6 +651,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.CREATE_WORKSPACE_APPROVAL]: Parameters.CreateWorkspaceApprovalParams; [WRITE_COMMANDS.UPDATE_WORKSPACE_APPROVAL]: Parameters.UpdateWorkspaceApprovalParams; [WRITE_COMMANDS.REMOVE_WORKSPACE_APPROVAL]: Parameters.RemoveWorkspaceApprovalParams; + [WRITE_COMMANDS.CONFIGURE_EXPENSIFY_CARDS_FOR_POLICY]: Parameters.ConfigureExpensifyCardsForPolicyParams; }; const READ_COMMANDS = { From 3abc929210d43393a3e00a0fbcaf92c6be54e38f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 31 Jul 2024 10:32:34 +0200 Subject: [PATCH 02/19] feat: use new api call in WorkspaceExpensifyCardBankAccounts page --- src/libs/actions/Card.ts | 10 ++++++++++ .../WorkspaceExpensifyCardBankAccounts.tsx | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 205a8dc41bba..c0b9969e2e5a 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -381,6 +381,15 @@ function startIssueNewCardFlow(policyID: string) { API.read(READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW, parameters); } +function configureExpensifyCardsForPolicy(policyID: string, bankAccountID: number) { + const parameters = { + policyID, + bankAccountID, + }; + + API.write(WRITE_COMMANDS.CONFIGURE_EXPENSIFY_CARDS_FOR_POLICY, parameters); +} + export { requestReplacementExpensifyCard, activatePhysicalExpensifyCard, @@ -393,5 +402,6 @@ export { updateExpensifyCardLimit, updateSettlementAccount, startIssueNewCardFlow, + configureExpensifyCardsForPolicy, }; export type {ReplacementReason}; diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx index 470b2c683e70..b1416f140ae6 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx @@ -31,12 +31,11 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA const policyID = route?.params?.policyID ?? '-1'; const handleAddBankAccount = () => { - // TODO: call to API - UpdateCardSettlementAccount Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('new', policyID, ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID))); }; const handleSelectBankAccount = (value: number) => { - Card.updateSettlementAccount(policyID, value); + Card.configureExpensifyCardsForPolicy(policyID, value); Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW.getRoute(policyID)); }; @@ -45,7 +44,6 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA return null; } - // const eligibleBankAccounts = Object.values(bankAccountsList).filter((bankAccount) => bankAccount.accountData.allowDebit || bankAccount.accountData.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS); const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountsList); return eligibleBankAccounts.map((bankAccount) => { From 8cc9256b70fbe7be317ac072a227b9846626a45d Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 31 Jul 2024 11:32:47 +0200 Subject: [PATCH 03/19] fix: replace policyID for workspaceAccountID --- src/libs/PolicyUtils.ts | 10 ++++++ src/libs/actions/Card.ts | 34 +++++++++---------- .../reconciliation/CardReconciliationPage.tsx | 6 ++-- .../ReconciliationAccountSettingsPage.tsx | 9 +++-- .../WorkspaceCardSettingsPage.tsx | 4 ++- .../WorkspaceExpensifyCardPage.tsx | 4 ++- .../WorkspaceSettlementAccountPage.tsx | 9 +++-- .../WorkspaceSettlementFrequencyPage.tsx | 4 ++- src/types/onyx/Policy.ts | 3 ++ 9 files changed, 55 insertions(+), 28 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 2f27f0185759..59fe8fed0d46 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -868,6 +868,15 @@ function getCurrentTaxID(policy: OnyxEntry, taxID: string): string | und return Object.keys(policy?.taxRates?.taxes ?? {}).find((taxIDKey) => policy?.taxRates?.taxes?.[taxIDKey].previousTaxCode === taxID || taxIDKey === taxID); } +function getWorkspaceAccountID(policyID: string) { + const policy = getPolicy(policyID); + + if (!policy) { + return ''; + } + return policy.workspaceAccountID ?? ''; +} + export { canEditTaxRate, extractPolicyIDFromPath, @@ -963,6 +972,7 @@ export { getCurrentTaxID, areXeroSettingsInErrorFields, xeroSettingsPendingAction, + getWorkspaceAccountID, }; export type {MemberEmailsToAccountIDs, XeroSettings}; diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index c0b9969e2e5a..1e5437ce39ef 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -206,14 +206,14 @@ function revealVirtualCardDetails(cardID: number): Promise }); } -function updateSettlementFrequency(policyID: string, frequency: ValueOf) { +function updateSettlementFrequency(workspaceAccountID: string, frequency: ValueOf) { // TODO: remove this code when the API is ready if (frequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY) { - Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { monthlySettlementDate: null, }); } else { - Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { monthlySettlementDate: new Date(), }); } @@ -222,7 +222,7 @@ function updateSettlementFrequency(policyID: string, frequency: ValueOf bankAccountList?.[paymentBankAccountID], [paymentBankAccountID, bankAccountList]); + const bankAccountNumber = useMemo(() => selectedBankAccount?.accountData?.accountNumber ?? '', [selectedBankAccount]); + const settlementAccountEnding = getLastFourDigits(bankAccountNumber); const sections = useMemo(() => { const data = Object.values(bankAccountList ?? {}).map((bankAccount) => ({ diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx index 399ff41d945b..9e73b2c9b738 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx @@ -11,6 +11,7 @@ import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {getLastFourDigits} from '@libs/BankAccountUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; @@ -25,9 +26,10 @@ function WorkspaceCardSettingsPage({route}: WorkspaceCardSettingsPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const policyID = route.params?.policyID; + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policyID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? ''; // const isMonthlySettlementAllowed = cardSettings?.isMonthlySettlementAllowed ?? true; diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx index b6df6b662eb9..afea8d30e7fe 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx @@ -2,6 +2,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; import {useOnyx} from 'react-native-onyx'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; +import * as PolicyUtils from '@libs/PolicyUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -13,8 +14,9 @@ type WorkspaceExpensifyCardPageProps = StackScreenProps, 'generalSettings' | 'addWorkspaceRoom' | keyof ACHAccount >; From ed8ac0c43d3c3f420e5517670fc91ebb50b83dac Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 31 Jul 2024 12:21:22 +0200 Subject: [PATCH 04/19] fix: lint --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 24a5f782a469..417487a2c653 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -91,8 +91,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro !!policy?.connections?.xero?.config?.importTaxRates || !!policy?.connections?.netsuite?.options?.config?.syncOptions?.syncTax; const policyID = policy?.id ?? ''; - // @ts-expect-error a new props will be added during feed api implementation - const workspaceAccountID = (policy?.workspaceAccountID as string) ?? ''; + const workspaceAccountID = policy?.workspaceAccountID ?? ''; const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}${CONST.EXPENSIFY_CARD.BANK}`); // Uncomment this line for testing disabled toggle feature - for c+ // const [cardsList = mockedCardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); From e2b5d8eb5e9214c5daf810dde32af403df00f978 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 7 Aug 2024 09:21:37 +0200 Subject: [PATCH 05/19] fix: remove sharedNvp prefix --- src/ONYXKEYS.ts | 8 ++++---- .../accounting/reconciliation/CardReconciliationPage.tsx | 4 ++-- .../expensifyCard/WorkspaceSettlementAccountPage.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 979bafcdab6d..5e999d17c0b8 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -466,10 +466,10 @@ const ONYXKEYS = { WORKSPACE_CARDS_LIST: 'card_', /** Stores which connection is set up to use Continuous Reconciliation */ - SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'sharedNVP_expensifyCard_continuousReconciliationConnection_', + EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'expensifyCard_continuousReconciliationConnection_', /** The value that indicates whether Continuous Reconciliation should be used on the domain */ - SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'sharedNVP_expensifyCard_useContinuousReconciliation_', + EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'expensifyCard_useContinuousReconciliation_', }, /** List of Form ids */ @@ -733,8 +733,8 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END]: OnyxTypes.BillingGraceEndPeriod; [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS]: OnyxTypes.ExpensifyCardSettings; [ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST]: OnyxTypes.WorkspaceCardsList; - [ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; - [ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; + [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; + [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; }; type OnyxValuesMapping = { diff --git a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx index 839b0f5db1f7..ef7fcb094205 100644 --- a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx @@ -26,8 +26,8 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); - const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); + const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); + const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID}`); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index ba494cbc1f89..857f40db4bc1 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -37,8 +37,8 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); // TODO: uncomment after integration with the BE - // const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); - // const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); + // const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); + // const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); // TODO: remove after integration with the BE const isUsedContinuousReconciliation = true; From 03a18c70e3a3d35508bea8402bf7627057bad88d Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 7 Aug 2024 09:56:22 +0200 Subject: [PATCH 06/19] fix: lint --- .../reconciliation/ReconciliationAccountSettingsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx index 44c247b434e0..39828b3b0a4a 100644 --- a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx @@ -8,9 +8,9 @@ import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; import {getLastFourDigits} from '@libs/BankAccountUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From abfb9cf01b59e29c49b5e6c117e3d36854fbb991 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 7 Aug 2024 10:04:07 +0200 Subject: [PATCH 07/19] fix: minor fix --- .../expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx index b1416f140ae6..1e458d0b0826 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx @@ -49,8 +49,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA return eligibleBankAccounts.map((bankAccount) => { const bankName = (bankAccount.accountData?.addressName ?? '') as BankName; const bankAccountNumber = bankAccount.accountData?.accountNumber ?? ''; - // TODO: change 1 to 0 - applied for testing purposes, as sometimes accountData lacks fundID - const bankAccountID = bankAccount.accountData?.fundID ?? 1; + const bankAccountID = bankAccount.accountData?.bankAccountID ?? 0; const {icon, iconSize, iconStyles} = getBankIcon({bankName, styles}); From 8c040fb14850c4fa48fab0d19f4e315daae8876e Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 7 Aug 2024 17:49:03 +0200 Subject: [PATCH 08/19] fix: change workspaceAccountID type --- src/libs/PolicyUtils.ts | 2 +- src/types/onyx/Policy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 975857f513ff..71ffbe2c4339 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -895,7 +895,7 @@ function getWorkspaceAccountID(policyID: string) { if (!policy) { return ''; } - return policy.workspaceAccountID ?? ''; + return policy.workspaceAccountID ?? 0; } export { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index f6d18bfd9ed7..dc4925c28f5a 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1538,7 +1538,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< glCodes?: boolean; /** Workspace account ID configured for Expensify Card */ - workspaceAccountID?: string; + workspaceAccountID?: number; } & Partial, 'generalSettings' | 'addWorkspaceRoom' | keyof ACHAccount >; From bd89ae2e92606f1ca5d302af5c97d66fa8c4b39c Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 8 Aug 2024 11:22:20 +0200 Subject: [PATCH 09/19] fix: typecheck --- src/ROUTES.ts | 5 ++--- .../reconciliation/CardReconciliationPage.tsx | 2 +- .../ReconciliationAccountSettingsPage.tsx | 4 ++-- .../expensifyCard/WorkspaceSettlementAccountPage.tsx | 11 ++++++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 9650d323d676..0c772ddb685d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -715,12 +715,11 @@ const ROUTES = { }, WORKSPACE_ACCOUNTING_CARD_RECONCILIATION: { route: 'settings/workspaces/:policyID/accounting/:connection/card-reconciliation', - getRoute: (policyID: string, connection: ValueOf) => `settings/workspaces/${policyID}/accounting/${connection}/card-reconciliation` as const, + getRoute: (policyID: string, connection?: ConnectionName) => `settings/workspaces/${policyID}/accounting/${connection}/card-reconciliation` as const, }, WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS: { route: 'settings/workspaces/:policyID/accounting/:connection/card-reconciliation/account', - getRoute: (policyID: string, connection?: ValueOf) => - `settings/workspaces/${policyID}/accounting/${connection}/card-reconciliation/account` as const, + getRoute: (policyID: string, connection?: ConnectionName) => `settings/workspaces/${policyID}/accounting/${connection}/card-reconciliation/account` as const, }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', diff --git a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx index 9dde340ef059..c0765eb7c934 100644 --- a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx @@ -31,7 +31,7 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID}`); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? -1; + const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const bankAccountTitle = bankAccountList?.[paymentBankAccountID]?.title ?? ''; const policyID = policy?.id ?? '-1'; diff --git a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx index dd730180d310..b17068d5c4cb 100644 --- a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx @@ -29,9 +29,9 @@ function ReconciliationAccountSettingsPage({route}: ReconciliationAccountSetting const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? ''; + const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; - const selectedBankAccount = useMemo(() => bankAccountList?.[paymentBankAccountID], [paymentBankAccountID, bankAccountList]); + const selectedBankAccount = useMemo(() => bankAccountList?.[paymentBankAccountID.toString()], [paymentBankAccountID, bankAccountList]); const bankAccountNumber = useMemo(() => selectedBankAccount?.accountData?.accountNumber ?? '', [selectedBankAccount]); const settlementAccountEnding = getLastFourDigits(bankAccountNumber); diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index 8f15ac6493bd..f8bb0b5e4851 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -25,6 +25,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {BankName} from '@src/types/onyx/Bank'; +import type {ConnectionName} from '@src/types/onyx/Policy'; type WorkspaceSettlementAccountPageProps = StackScreenProps; @@ -39,8 +40,8 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); - const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? ''; - const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID]?.accountData?.accountNumber ?? ''; + const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; + const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID.toString()]?.accountData?.accountNumber ?? ''; const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountsList ?? {}); @@ -97,7 +98,11 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP {isUsedContinuousReconciliation && ( {translate('workspace.expensifyCard.settlementAccountInfoPt1')}{' '} - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, reconciliationConnection))}> + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, reconciliationConnection as ConnectionName)) + } + > {translate('workspace.expensifyCard.reconciliationAccount')} {' '} {`(${CONST.MASKED_PAN_PREFIX}${getLastFourDigits(paymentBankAccountNumber)}) `} From e883b68b3c6022ed43f9602c1499c48b61d308d8 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 8 Aug 2024 14:49:37 +0200 Subject: [PATCH 10/19] fix: lint and typecheck --- .../reconciliation/ReconciliationAccountSettingsPage.tsx | 2 +- .../workspace/expensifyCard/WorkspaceCardSettingsPage.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx index b17068d5c4cb..c0205e292cb5 100644 --- a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx @@ -29,7 +29,7 @@ function ReconciliationAccountSettingsPage({route}: ReconciliationAccountSetting const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; + const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; const selectedBankAccount = useMemo(() => bankAccountList?.[paymentBankAccountID.toString()], [paymentBankAccountID, bankAccountList]); const bankAccountNumber = useMemo(() => selectedBankAccount?.accountData?.accountNumber ?? '', [selectedBankAccount]); diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx index 33c8b40f92cd..613e9ba77f1e 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx @@ -31,13 +31,13 @@ function WorkspaceCardSettingsPage({route}: WorkspaceCardSettingsPageProps) { const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? ''; + const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; // const isMonthlySettlementAllowed = cardSettings?.isMonthlySettlementAllowed ?? true; const settlementFrequency = cardSettings?.monthlySettlementDate ? CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.MONTHLY : CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY; // TODO: replace this line with the following line and uncomment the previous comment const isSettlementFrequencyBlocked = settlementFrequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY; // const isSettlementFrequencyBlocked = !isMonthlySettlementAllowed && settlementFrequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY; - const bankAccountNumber = bankAccountList?.[paymentBankAccountID]?.accountData?.accountNumber ?? ''; + const bankAccountNumber = bankAccountList?.[paymentBankAccountID.toString()]?.accountData?.accountNumber ?? ''; return ( Date: Thu, 8 Aug 2024 16:10:37 +0200 Subject: [PATCH 11/19] fix: minor fix --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index f1b0b59c3e68..871e7e5f4e53 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -901,7 +901,7 @@ function getWorkspaceAccountID(policyID: string) { const policy = getPolicy(policyID); if (!policy) { - return ''; + return 0; } return policy.workspaceAccountID ?? 0; } From c4bf48d1260d2103b16d180c6ee9b0fc281969bc Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Aug 2024 11:13:09 +0200 Subject: [PATCH 12/19] fix: minor improvements --- src/libs/actions/Card.ts | 6 +++--- .../reconciliation/ReconciliationAccountSettingsPage.tsx | 2 +- .../workspace/expensifyCard/WorkspaceCardSettingsPage.tsx | 2 +- .../workspace/expensifyCard/WorkspaceEditCardLimitPage.tsx | 4 +++- .../expensifyCard/WorkspaceSettlementAccountPage.tsx | 4 ++-- .../expensifyCard/WorkspaceSettlementFrequencyPage.tsx | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 0454d50466ef..9f5fa3a011f2 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -206,7 +206,7 @@ function revealVirtualCardDetails(cardID: number): Promise }); } -function updateSettlementFrequency(workspaceAccountID: string, frequency: ValueOf) { +function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueOf) { // TODO: remove this code when the API is ready if (frequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY) { Onyx.merge(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { @@ -257,7 +257,7 @@ function updateSettlementFrequency(workspaceAccountID: string, frequency: ValueO // API.write(WRITE_COMMANDS.UPDATE_CARD_SETTLEMENT_FREQUENCY, parameters, {optimisticData, successData, failureData}); } -function updateSettlementAccount(workspaceAccountID: string, accountID: number) { +function updateSettlementAccount(workspaceAccountID: number, accountID: number) { // TODO: remove this code when the API is ready Onyx.merge(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { paymentBankAccountID: accountID, @@ -313,7 +313,7 @@ function clearIssueNewCardFlow() { }); } -function updateExpensifyCardLimit(workspaceAccountID: string, cardID: number, newLimit: number, oldLimit?: number) { +function updateExpensifyCardLimit(workspaceAccountID: number, cardID: number, newLimit: number, oldLimit?: number) { const authToken = NetworkStore.getAuthToken(); if (!authToken) { diff --git a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx index c0205e292cb5..b17068d5c4cb 100644 --- a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx @@ -29,7 +29,7 @@ function ReconciliationAccountSettingsPage({route}: ReconciliationAccountSetting const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; + const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const selectedBankAccount = useMemo(() => bankAccountList?.[paymentBankAccountID.toString()], [paymentBankAccountID, bankAccountList]); const bankAccountNumber = useMemo(() => selectedBankAccount?.accountData?.accountNumber ?? '', [selectedBankAccount]); diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx index 613e9ba77f1e..563c06a1b834 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx @@ -31,7 +31,7 @@ function WorkspaceCardSettingsPage({route}: WorkspaceCardSettingsPageProps) { const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; + const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; // const isMonthlySettlementAllowed = cardSettings?.isMonthlySettlementAllowed ?? true; const settlementFrequency = cardSettings?.monthlySettlementDate ? CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.MONTHLY : CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY; // TODO: replace this line with the following line and uncomment the previous comment diff --git a/src/pages/workspace/expensifyCard/WorkspaceEditCardLimitPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceEditCardLimitPage.tsx index 30808b32e478..4ab790843fdb 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceEditCardLimitPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceEditCardLimitPage.tsx @@ -12,6 +12,7 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CurrencyUtils from '@libs/CurrencyUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; @@ -46,6 +47,7 @@ function WorkspaceEditCardLimitPage({route}: WorkspaceEditCardLimitPageProps) { const {inputCallbackRef} = useAutoFocusInput(); const styles = useThemeStyles(); const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false); + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${policyID}_${CONST.EXPENSIFY_CARD.BANK}`); const card = cardsList?.[cardID] ?? mockedCard; @@ -66,7 +68,7 @@ function WorkspaceEditCardLimitPage({route}: WorkspaceEditCardLimitPageProps) { const updateCardLimit = (newLimit: string) => { setIsConfirmModalVisible(false); - Card.updateExpensifyCardLimit(policyID, Number(cardID), Number(newLimit) * 100, card.nameValuePairs?.limit); + Card.updateExpensifyCardLimit(workspaceAccountID, Number(cardID), Number(newLimit) * 100, card.nameValuePairs?.limit); Navigation.goBack(); }; diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index f8bb0b5e4851..6576c37b87de 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -40,7 +40,7 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); - const paymentBankAccountID = (cardSettings?.paymentBankAccountID as number) ?? 0; + const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID.toString()]?.accountData?.accountNumber ?? ''; const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountsList ?? {}); @@ -74,7 +74,7 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP }, [eligibleBankAccounts, paymentBankAccountID, styles, translate]); const updateSettlementAccount = (value: number) => { - Card.updateSettlementAccount(policyID, value); + Card.updateSettlementAccount(workspaceAccountID, value); Navigation.goBack(); }; diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx index cccc3a370982..608bf9bde00a 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx @@ -56,7 +56,7 @@ function WorkspaceSettlementFrequencyPage({route}: WorkspaceSettlementFrequencyP }, [translate, shouldShowMonthlyOption, selectedFrequency]); const updateSettlementFrequency = (value: ValueOf) => { - Card.updateSettlementFrequency(policyID, value); + Card.updateSettlementFrequency(workspaceAccountID, value); }; return ( From 8c66efd194e9c85758e2c5370b3cfeca877c9875 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Aug 2024 11:47:52 +0200 Subject: [PATCH 13/19] fix: minor fix --- .../expensifyCard/WorkspaceSettlementAccountPage.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index 6576c37b87de..aef3349b8ff3 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -98,11 +98,7 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP {isUsedContinuousReconciliation && ( {translate('workspace.expensifyCard.settlementAccountInfoPt1')}{' '} - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, reconciliationConnection as ConnectionName)) - } - > + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.getRoute(policyID, reconciliationConnection))}> {translate('workspace.expensifyCard.reconciliationAccount')} {' '} {`(${CONST.MASKED_PAN_PREFIX}${getLastFourDigits(paymentBankAccountNumber)}) `} From 4620f699bb50aff61b9a99e8aeff1ac69ededc8b Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Aug 2024 13:27:46 +0200 Subject: [PATCH 14/19] fix: redirect to a proper page when no elligible bank account --- .../WorkspaceExpensifyCardPageEmptyState.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx index ee0ab87af72e..15ad69b3ba13 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx @@ -9,6 +9,7 @@ import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as CardUtils from '@libs/CardUtils'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; import Navigation from '@navigation/Navigation'; import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; @@ -46,20 +47,18 @@ function WorkspaceExpensifyCardPageEmptyState({route, policy}: WorkspaceExpensif const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountList ?? {}); + const reimbursementAccountStatus = reimbursementAccount?.achData?.state ?? ''; - const isSetupUnfinished = - isEmptyObject(bankAccountList) && - (reimbursementAccountStatus === CONST.BANK_ACCOUNT.STATE.VERIFYING || - reimbursementAccountStatus === CONST.BANK_ACCOUNT.STATE.SETUP || - reimbursementAccountStatus === CONST.BANK_ACCOUNT.STATE.VALIDATING); + const isSetupUnfinished = isEmptyObject(bankAccountList) && reimbursementAccountStatus !== CONST.BANK_ACCOUNT.STATE.OPEN; const startFlow = useCallback(() => { - if (isEmptyObject(bankAccountList) || isSetupUnfinished) { + if (!eligibleBankAccounts.length || isSetupUnfinished) { Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('', policy?.id, ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policy?.id ?? '-1'))); } else { Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_BANK_ACCOUNT.getRoute(policy?.id ?? '-1')); } - }, [isSetupUnfinished, bankAccountList, policy?.id]); + }, [eligibleBankAccounts.length, isSetupUnfinished, policy?.id]); return ( Date: Mon, 12 Aug 2024 09:59:55 +0200 Subject: [PATCH 15/19] fix: typecheck --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index d69a2ed95e4b..5b97efb450af 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -69,8 +69,8 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro !!policy?.connections?.xero?.config?.importTaxRates || !!policy?.connections?.netsuite?.options?.config?.syncOptions?.syncTax; const policyID = policy?.id; - const workspaceAccountID = (policy?.workspaceAccountID as string) ?? ''; - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}${CONST.EXPENSIFY_CARD.BANK}`); + const workspaceAccountID = policy?.workspaceAccountID ?? -1; + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID.toString()}${CONST.EXPENSIFY_CARD.BANK}`); const [isOrganizeWarningModalOpen, setIsOrganizeWarningModalOpen] = useState(false); const [isIntegrateWarningModalOpen, setIsIntegrateWarningModalOpen] = useState(false); const [isReportFieldsWarningModalOpen, setIsReportFieldsWarningModalOpen] = useState(false); From ee6562527cd785e8f381ff36b816195ab51f5c1f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 12 Aug 2024 11:05:01 +0200 Subject: [PATCH 16/19] fix: lint --- .../workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index aef3349b8ff3..d2b44e748bbc 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -25,7 +25,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {BankName} from '@src/types/onyx/Bank'; -import type {ConnectionName} from '@src/types/onyx/Policy'; type WorkspaceSettlementAccountPageProps = StackScreenProps; From b76ab11eb87e2b79c44df37a0c759d0b1f095d51 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 12 Aug 2024 18:01:10 +0200 Subject: [PATCH 17/19] fix: minor fix --- src/libs/actions/Card.ts | 6 +++++- .../expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 9f5fa3a011f2..961d4b68d683 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -381,7 +381,11 @@ function startIssueNewCardFlow(policyID: string) { API.read(READ_COMMANDS.START_ISSUE_NEW_CARD_FLOW, parameters); } -function configureExpensifyCardsForPolicy(policyID: string, bankAccountID: number) { +function configureExpensifyCardsForPolicy(policyID: string, bankAccountID?: number) { + if (!bankAccountID) { + return; + } + const parameters = { policyID, bankAccountID, diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx index 1e458d0b0826..b96d86d06582 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx @@ -34,7 +34,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('new', policyID, ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID))); }; - const handleSelectBankAccount = (value: number) => { + const handleSelectBankAccount = (value?: number) => { Card.configureExpensifyCardsForPolicy(policyID, value); Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW.getRoute(policyID)); }; @@ -49,7 +49,7 @@ function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankA return eligibleBankAccounts.map((bankAccount) => { const bankName = (bankAccount.accountData?.addressName ?? '') as BankName; const bankAccountNumber = bankAccount.accountData?.accountNumber ?? ''; - const bankAccountID = bankAccount.accountData?.bankAccountID ?? 0; + const bankAccountID = bankAccount.accountData?.bankAccountID; const {icon, iconSize, iconStyles} = getBankIcon({bankName, styles}); From 39545cdb4651a539777d30c3d648d2b3431be3b6 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 12 Aug 2024 19:04:52 +0200 Subject: [PATCH 18/19] fix: rename to private --- src/ONYXKEYS.ts | 12 ++++++------ src/libs/actions/Card.ts | 18 +++++++++--------- .../reconciliation/CardReconciliationPage.tsx | 6 +++--- .../ReconciliationAccountSettingsPage.tsx | 2 +- .../expensifyCard/WorkspaceCardListHeader.tsx | 2 +- .../WorkspaceCardSettingsPage.tsx | 2 +- .../WorkspaceExpensifyCardPage.tsx | 2 +- .../WorkspaceSettlementAccountPage.tsx | 6 +++--- .../WorkspaceSettlementFrequencyPage.tsx | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index e2bd7898b567..b4eeba7f9c4a 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -466,13 +466,13 @@ const ONYXKEYS = { WORKSPACE_CARDS_LIST: 'card_', /** Expensify cards settings */ - EXPENSIFY_CARD_SETTINGS: 'expensifyCardSettings_', + PRIVATE_EXPENSIFY_CARD_SETTINGS: 'private_expensifyCardSettings_', /** Stores which connection is set up to use Continuous Reconciliation */ - EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'expensifyCard_continuousReconciliationConnection_', + PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'private_expensifyCard_continuousReconciliationConnection_', /** The value that indicates whether Continuous Reconciliation should be used on the domain */ - EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'expensifyCard_useContinuousReconciliation_', + PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'private_expensifyCard_useContinuousReconciliation_', }, /** List of Form ids */ @@ -737,10 +737,10 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS]: OnyxTypes.PolicyConnectionSyncProgress; [ONYXKEYS.COLLECTION.SNAPSHOT]: OnyxTypes.SearchResults; [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END]: OnyxTypes.BillingGraceEndPeriod; - [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS]: OnyxTypes.ExpensifyCardSettings; + [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS]: OnyxTypes.ExpensifyCardSettings; [ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST]: OnyxTypes.WorkspaceCardsList; - [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; - [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; + [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; + [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; }; type OnyxValuesMapping = { diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 961d4b68d683..916ffd07a82a 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -209,11 +209,11 @@ function revealVirtualCardDetails(cardID: number): Promise function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueOf) { // TODO: remove this code when the API is ready if (frequency === CONST.EXPENSIFY_CARD.FREQUENCY_SETTING.DAILY) { - Onyx.merge(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { monthlySettlementDate: null, }); } else { - Onyx.merge(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { monthlySettlementDate: new Date(), }); } @@ -222,7 +222,7 @@ function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueO // const optimisticData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // monthlySettlementDate: '', // }, @@ -232,7 +232,7 @@ function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueO // const successData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // monthlySettlementDate: '', // }, @@ -242,7 +242,7 @@ function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueO // const failureData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // monthlySettlementDate: null, // }, @@ -259,7 +259,7 @@ function updateSettlementFrequency(workspaceAccountID: number, frequency: ValueO function updateSettlementAccount(workspaceAccountID: number, accountID: number) { // TODO: remove this code when the API is ready - Onyx.merge(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { + Onyx.merge(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, { paymentBankAccountID: accountID, }); @@ -267,7 +267,7 @@ function updateSettlementAccount(workspaceAccountID: number, accountID: number) // const optimisticData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // paymentBankAccountID: accountID, // }, @@ -277,7 +277,7 @@ function updateSettlementAccount(workspaceAccountID: number, accountID: number) // const successData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // paymentBankAccountID: accountID, // }, @@ -287,7 +287,7 @@ function updateSettlementAccount(workspaceAccountID: number, accountID: number) // const failureData: OnyxUpdate[] = [ // { // onyxMethod: Onyx.METHOD.MERGE, - // key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, + // key: `${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, // value: { // paymentBankAccountID: null, // }, diff --git a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx index c0765eb7c934..09ea56c54cb2 100644 --- a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx @@ -26,9 +26,9 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); - const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID}`); + const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); + const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID}`); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; diff --git a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx index b17068d5c4cb..58b4107779f8 100644 --- a/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage.tsx @@ -28,7 +28,7 @@ function ReconciliationAccountSettingsPage({route}: ReconciliationAccountSetting const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const selectedBankAccount = useMemo(() => bankAccountList?.[paymentBankAccountID.toString()], [paymentBankAccountID, bankAccountList]); diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardListHeader.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardListHeader.tsx index 97a5dafa7b14..cff89628db6e 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardListHeader.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardListHeader.tsx @@ -22,7 +22,7 @@ function WorkspaceCardListHeader() { const isLessThanMediumScreen = isMediumScreenWidth || isSmallScreenWidth; // TODO: uncomment the code line below to use cardSettings data from Onyx when it's supported - // const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${policyID}`); + // const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); const cardSettings = mockedSettings; return ( diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx index 563c06a1b834..4e295c66060a 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardSettingsPage.tsx @@ -29,7 +29,7 @@ function WorkspaceCardSettingsPage({route}: WorkspaceCardSettingsPageProps) { const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; // const isMonthlySettlementAllowed = cardSettings?.isMonthlySettlementAllowed ?? true; diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx index 457188143409..156889273aa9 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPage.tsx @@ -16,7 +16,7 @@ function WorkspaceExpensifyCardPage({route}: WorkspaceExpensifyCardPageProps) { const policyID = route.params.policyID ?? '-1'; const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; return ( diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index d2b44e748bbc..a762710669d8 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -35,9 +35,9 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); - const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); + const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); + const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID.toString()]?.accountData?.accountNumber ?? ''; diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx index 608bf9bde00a..8e837c5a8456 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementFrequencyPage.tsx @@ -27,7 +27,7 @@ function WorkspaceSettlementFrequencyPage({route}: WorkspaceSettlementFrequencyP const policyID = route.params?.policyID ?? '-1'; const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); - const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); + const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); // TODO: change true for false after API is ready - true is for testing purposes const shouldShowMonthlyOption = cardSettings?.isMonthlySettlementAllowed ?? true; From c25fba0d3aeae4d4f8ae535b683f0e4bcedb2512 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Mon, 12 Aug 2024 19:12:41 +0200 Subject: [PATCH 19/19] fix: revert naming for reconciliation connection keys --- src/ONYXKEYS.ts | 8 ++++---- .../accounting/reconciliation/CardReconciliationPage.tsx | 4 ++-- .../expensifyCard/WorkspaceSettlementAccountPage.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b4eeba7f9c4a..e06a2413bb4a 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -469,10 +469,10 @@ const ONYXKEYS = { PRIVATE_EXPENSIFY_CARD_SETTINGS: 'private_expensifyCardSettings_', /** Stores which connection is set up to use Continuous Reconciliation */ - PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'private_expensifyCard_continuousReconciliationConnection_', + EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION: 'expensifyCard_continuousReconciliationConnection_', /** The value that indicates whether Continuous Reconciliation should be used on the domain */ - PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'private_expensifyCard_useContinuousReconciliation_', + EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'expensifyCard_useContinuousReconciliation_', }, /** List of Form ids */ @@ -739,8 +739,8 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END]: OnyxTypes.BillingGraceEndPeriod; [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS]: OnyxTypes.ExpensifyCardSettings; [ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST]: OnyxTypes.WorkspaceCardsList; - [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; - [ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; + [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName; + [ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean; }; type OnyxValuesMapping = { diff --git a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx index 09ea56c54cb2..5d469baa11ca 100644 --- a/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx +++ b/src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx @@ -26,8 +26,8 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); - const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); + const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${policy?.workspaceAccountID}`); + const [isContinuousReconciliationOn] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${policy?.workspaceAccountID}`); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID}`); const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); diff --git a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx index a762710669d8..815c3dedeb1b 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceSettlementAccountPage.tsx @@ -36,8 +36,8 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); - const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); - const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); + const [isUsedContinuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`); + const [reconciliationConnection] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${workspaceAccountID}`); const paymentBankAccountID = cardSettings?.paymentBankAccountID ?? 0; const paymentBankAccountNumber = bankAccountsList?.[paymentBankAccountID.toString()]?.accountData?.accountNumber ?? '';