From 936f903e205c505fdb9b2d415fdb79eb65408309 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 20 Dec 2024 15:07:43 +0200 Subject: [PATCH 1/2] Fixes for Sage connection and Xero --- src/languages/en.ts | 3 +- src/languages/es.ts | 4 +-- ...kspaceCompanyCardAccountSelectCardPage.tsx | 20 ++++++----- src/pages/workspace/companyCards/utils.tsx | 33 +++++++++++-------- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 904ab4cac128..5d22d0febbc7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3588,7 +3588,8 @@ const translations = { cardholder: 'Cardholder', cardName: 'Card name', integrationExport: ({integration, type}: IntegrationExportParams) => (integration && type ? `${integration} ${type.toLowerCase()} export` : `${integration} export`), - integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Choose the ${integration} account where transactions should be exported. Select a different`, + integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Choose the ${integration} account where transactions should be exported.`, + integrationExportTitlePart: 'Select a different', integrationExportTitleLinkPart: 'export option', integrationExportTitleSecondPart: 'to change the available accounts.', lastUpdated: 'Last updated', diff --git a/src/languages/es.ts b/src/languages/es.ts index 47163eaff018..53c4adf7b2cb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3631,9 +3631,9 @@ const translations = { cardName: 'Nombre de la tarjeta', integrationExport: ({integration, type}: IntegrationExportParams) => integration && type ? `Exportación a ${integration} ${type.toLowerCase()}` : `Exportación a ${integration}`, - integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => - `Seleccione la cuenta ${integration} donde se deben exportar las transacciones. Seleccione una cuenta diferente`, + integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Seleccione la cuenta ${integration} donde se deben exportar las transacciones.`, integrationExportTitleLinkPart: 'opción de exportación', + integrationExportTitlePart: 'Seleccione una cuenta diferente', integrationExportTitleSecondPart: 'para cambiar las cuentas disponibles.', lastUpdated: 'Última actualización', transactionStartDate: 'Fecha de inicio de transacciones', diff --git a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx index bb7d3249aad8..88aeb2557b03 100644 --- a/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx +++ b/src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx @@ -40,6 +40,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy); const shouldShowTextInput = (exportMenuItem?.data?.length ?? 0) >= CONST.STANDARD_LIST_ITEM_LIMIT; const defaultCard = translate('workspace.moreFeatures.companyCards.defaultCard'); + const isXeroConnection = connectedIntegration === CONST.POLICY.CONNECTIONS.NAME.XERO; const searchedListOptions = useMemo(() => { return exportMenuItem?.data.filter((option) => option.value.toLowerCase().includes(searchText)); @@ -81,15 +82,18 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard {!!exportMenuItem?.description && ( {translate('workspace.moreFeatures.companyCards.integrationExportTitleFirstPart', {integration: exportMenuItem.description})}{' '} - {!!exportMenuItem && ( - - {translate('workspace.moreFeatures.companyCards.integrationExportTitleLinkPart')}{' '} - + {!!exportMenuItem && !isXeroConnection && ( + <> + {translate('workspace.moreFeatures.companyCards.integrationExportTitlePart')}{' '} + + {translate('workspace.moreFeatures.companyCards.integrationExportTitleLinkPart')}{' '} + + {translate('workspace.moreFeatures.companyCards.integrationExportTitleSecondPart')} + )} - {translate('workspace.moreFeatures.companyCards.integrationExportTitleSecondPart')} )} diff --git a/src/pages/workspace/companyCards/utils.tsx b/src/pages/workspace/companyCards/utils.tsx index bc961b6b1c90..1b3c6f1c704a 100644 --- a/src/pages/workspace/companyCards/utils.tsx +++ b/src/pages/workspace/companyCards/utils.tsx @@ -2,6 +2,7 @@ import type {ValueOf} from 'type-fest'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SelectorType} from '@components/SelectionScreen'; import * as PolicyUtils from '@libs/PolicyUtils'; +import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -27,8 +28,9 @@ function getExportMenuItem( const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy); const defaultCard = translate('workspace.moreFeatures.companyCards.defaultCard'); - const defaultMenuItem: Account = { + const defaultMenuItem: Account & {value?: string} = { name: defaultCard, + value: defaultCard, id: defaultCard, currency: '', }; @@ -215,21 +217,20 @@ function getExportMenuItem( case CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL: { const defaultAccount = PolicyUtils.getSageIntacctNonReimbursableActiveDefaultVendor(policy); isDefaultTitle = !!( - defaultAccount && - (!companyCard?.nameValuePairs?.netsuite_export_payable_account || - companyCard?.nameValuePairs?.netsuite_export_payable_account === CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE) + companyCard?.nameValuePairs?.intacct_export_vendor === CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE || + (defaultAccount && !companyCard?.nameValuePairs?.intacct_export_vendor) ); const vendors = policy?.connections?.intacct?.data?.vendors ?? []; - const selectedVendor = PolicyUtils.findSelectedSageVendorWithDefaultSelect(vendors, companyCard?.nameValuePairs?.netsuite_export_payable_account ?? defaultAccount); - title = isDefaultTitle ? defaultCard : selectedVendor?.name; + const selectedVendorID = companyCard?.nameValuePairs?.intacct_export_vendor ?? defaultAccount; + const selectedVendor = (vendors ?? []).find(({id}) => id === selectedVendorID); + title = isDefaultTitle ? defaultCard : selectedVendor?.value; const resultData = (vendors ?? []).length > 0 ? [defaultMenuItem, ...(vendors ?? [])] : vendors; - - data = (resultData ?? []).map(({id, name}) => { + data = (resultData ?? []).map(({id, value}) => { return { value: id, - text: name, + text: value, keyForList: id, - isSelected: isDefaultTitle ? name === defaultCard : selectedVendor?.id === id, + isSelected: isDefaultTitle ? value === defaultCard : selectedVendor?.id === id, }; }); exportType = CONST.COMPANY_CARDS.EXPORT_CARD_TYPES.NVP_INTACCT_EXPORT_VENDOR; @@ -237,13 +238,17 @@ function getExportMenuItem( } case CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE: { const intacctCreditCards = policy?.connections?.intacct?.data?.creditCards ?? []; + const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + + const defaultVendorAccount = (policy?.connections?.intacct?.data?.vendors ?? []).find((vendor) => vendor.id === activeDefaultVendor); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const defaultAccount = exportConfig?.nonReimbursableAccount || intacctCreditCards.at(0)?.id; + const defaultAccount = exportConfig?.nonReimbursableAccount || defaultVendorAccount; isDefaultTitle = !!( - defaultAccount && - (!companyCard?.nameValuePairs?.intacct_export_charge_card || companyCard?.nameValuePairs?.intacct_export_charge_card === CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE) + companyCard?.nameValuePairs?.intacct_export_charge_card === CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE || + (defaultAccount && !companyCard?.nameValuePairs?.intacct_export_charge_card) ); - const selectedCard = PolicyUtils.findSelectedSageVendorWithDefaultSelect(intacctCreditCards, companyCard?.nameValuePairs?.intacct_export_charge_card ?? defaultAccount); + const selectedVendorID = companyCard?.nameValuePairs?.intacct_export_charge_card ?? defaultAccount; + const selectedCard = (intacctCreditCards ?? []).find(({id}) => id === selectedVendorID); title = isDefaultTitle ? defaultCard : selectedCard?.name; const resultData = (intacctCreditCards ?? []).length > 0 ? [defaultMenuItem, ...(intacctCreditCards ?? [])] : intacctCreditCards; From 26011ff4fe44a501fde91bf48261c14afc64dfbc Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 20 Dec 2024 15:14:55 +0200 Subject: [PATCH 2/2] update --- src/pages/workspace/companyCards/utils.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/companyCards/utils.tsx b/src/pages/workspace/companyCards/utils.tsx index 1b3c6f1c704a..634ee5807b6f 100644 --- a/src/pages/workspace/companyCards/utils.tsx +++ b/src/pages/workspace/companyCards/utils.tsx @@ -2,7 +2,6 @@ import type {ValueOf} from 'type-fest'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SelectorType} from '@components/SelectionScreen'; import * as PolicyUtils from '@libs/PolicyUtils'; -import {getSageIntacctNonReimbursableActiveDefaultVendor} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -238,7 +237,7 @@ function getExportMenuItem( } case CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE: { const intacctCreditCards = policy?.connections?.intacct?.data?.creditCards ?? []; - const activeDefaultVendor = getSageIntacctNonReimbursableActiveDefaultVendor(policy); + const activeDefaultVendor = PolicyUtils.getSageIntacctNonReimbursableActiveDefaultVendor(policy); const defaultVendorAccount = (policy?.connections?.intacct?.data?.vendors ?? []).find((vendor) => vendor.id === activeDefaultVendor); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing