Skip to content

Commit 8c4661d

Browse files
authored
Merge pull request #52575 from callstack-internal/fix-default-card-with-export-type
[Internal QA]: Fix default card with export type
2 parents 787d804 + 33806c3 commit 8c4661d

File tree

6 files changed

+180
-35
lines changed

6 files changed

+180
-35
lines changed

src/CONST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2850,6 +2850,7 @@ const CONST = {
28502850
ALLOW: 'personal',
28512851
},
28522852
CARD_LIST_THRESHOLD: 8,
2853+
DEFAULT_EXPORT_TYPE: 'default',
28532854
EXPORT_CARD_TYPES: {
28542855
/**
28552856
* Name of Card NVP for QBO custom export accounts

src/languages/en.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ const translations = {
34893489
cardNumber: 'Card number',
34903490
cardholder: 'Cardholder',
34913491
cardName: 'Card name',
3492-
integrationExport: ({integration, type}: IntegrationExportParams) => `${integration} ${type?.toLowerCase()} export`,
3492+
integrationExport: ({integration, type}: IntegrationExportParams) => (integration && type ? `${integration} ${type.toLowerCase()} export` : `${integration} export`),
34933493
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) => `Choose the ${integration} account where transactions should be exported. Select a different`,
34943494
integrationExportTitleLinkPart: 'export option',
34953495
integrationExportTitleSecondPart: 'to change the available accounts.',
@@ -3526,6 +3526,7 @@ const translations = {
35263526
giveItNameInstruction: 'Give the card a name that sets it apart from the others.',
35273527
updating: 'Updating...',
35283528
noAccountsFound: 'No accounts found',
3529+
defaultCard: 'Default card',
35293530
noAccountsFoundDescription: ({connection}: ConnectionParams) => `Please add the account in ${connection} and sync the connection again.`,
35303531
},
35313532
workflows: {

src/languages/es.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3531,7 +3531,8 @@ const translations = {
35313531
cardNumber: 'Número de la tarjeta',
35323532
cardholder: 'Titular de la tarjeta',
35333533
cardName: 'Nombre de la tarjeta',
3534-
integrationExport: ({integration, type}: IntegrationExportParams) => `Exportación a ${integration} ${type?.toLowerCase()}`,
3534+
integrationExport: ({integration, type}: IntegrationExportParams) =>
3535+
integration && type ? `Exportación a ${integration} ${type.toLowerCase()}` : `Exportación a ${integration}`,
35353536
integrationExportTitleFirstPart: ({integration}: IntegrationExportParams) =>
35363537
`Seleccione la cuenta ${integration} donde se deben exportar las transacciones. Seleccione una cuenta diferente`,
35373538
integrationExportTitleLinkPart: 'opción de exportación',
@@ -3570,6 +3571,7 @@ const translations = {
35703571
giveItNameInstruction: 'Nombra la tarjeta para distingirla de las demás.',
35713572
updating: 'Actualizando...',
35723573
noAccountsFound: 'No se han encontrado cuentas',
3574+
defaultCard: 'Tarjeta predeterminada',
35733575
noAccountsFoundDescription: ({connection}: ConnectionParams) => `Añade la cuenta en ${connection} y sincroniza la conexión de nuevo.`,
35743576
},
35753577
workflows: {

src/libs/PolicyUtils.ts

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import type {
2626
PolicyConnectionSyncProgress,
2727
PolicyFeatureName,
2828
Rate,
29+
SageIntacctDataElement,
30+
SageIntacctDataElementWithValue,
2931
Tenant,
3032
} from '@src/types/onyx/Policy';
3133
import type PolicyEmployee from '@src/types/onyx/PolicyEmployee';
@@ -711,6 +713,11 @@ function findSelectedVendorWithDefaultSelect(vendors: NetSuiteVendor[] | undefin
711713
return selectedVendor ?? vendors?.[0] ?? undefined;
712714
}
713715

716+
function findSelectedSageVendorWithDefaultSelect(vendors: SageIntacctDataElementWithValue[] | SageIntacctDataElement[] | undefined, selectedVendorID: string | undefined) {
717+
const selectedVendor = (vendors ?? []).find(({id}) => id === selectedVendorID);
718+
return selectedVendor ?? vendors?.[0] ?? undefined;
719+
}
720+
714721
function findSelectedBankAccountWithDefaultSelect(accounts: NetSuiteAccount[] | undefined, selectedBankAccountId: string | undefined) {
715722
const selectedBankAccount = (accounts ?? []).find(({id}) => id === selectedBankAccountId);
716723
return selectedBankAccount ?? accounts?.[0] ?? undefined;
@@ -1185,6 +1192,7 @@ export {
11851192
findSelectedBankAccountWithDefaultSelect,
11861193
findSelectedInvoiceItemWithDefaultSelect,
11871194
findSelectedTaxAccountWithDefaultSelect,
1195+
findSelectedSageVendorWithDefaultSelect,
11881196
getNetSuiteVendorOptions,
11891197
canUseTaxNetSuite,
11901198
canUseProvincialTaxNetSuite,

src/pages/workspace/companyCards/WorkspaceCompanyCardAccountSelectCardPage.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard
3939
const exportMenuItem = getExportMenuItem(connectedIntegration, policyID, translate, policy, card);
4040
const currentConnectionName = PolicyUtils.getCurrentConnectionName(policy);
4141
const shouldShowTextInput = (exportMenuItem?.data?.length ?? 0) >= CONST.STANDARD_LIST_ITEM_LIMIT;
42+
const defaultCard = translate('workspace.moreFeatures.companyCards.defaultCard');
4243

4344
const searchedListOptions = useMemo(() => {
4445
return exportMenuItem?.data.filter((option) => option.value.toLowerCase().includes(searchText));
@@ -63,11 +64,13 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard
6364
if (!exportMenuItem?.exportType) {
6465
return;
6566
}
66-
CompanyCards.setCompanyCardExportAccount(policyID, workspaceAccountID, cardID, exportMenuItem.exportType, value, bank);
67+
const isDefaultCardSelected = value === defaultCard;
68+
const exportValue = isDefaultCardSelected ? CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE : value;
69+
CompanyCards.setCompanyCardExportAccount(policyID, workspaceAccountID, cardID, exportMenuItem.exportType, exportValue, bank);
6770

6871
Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, cardID, bank));
6972
},
70-
[exportMenuItem?.exportType, workspaceAccountID, cardID, policyID, bank],
73+
[exportMenuItem?.exportType, workspaceAccountID, cardID, policyID, bank, defaultCard],
7174
);
7275

7376
return (

0 commit comments

Comments
 (0)