Skip to content

Commit

Permalink
Merge pull request #54411 from callstack-internal/fixes-for-export-types
Browse files Browse the repository at this point in the history
  • Loading branch information
mountiny authored Dec 22, 2024
2 parents 006a1df + 26011ff commit 7078986
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3581,7 +3581,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',
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3624,9 +3624,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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -81,15 +82,18 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard
{!!exportMenuItem?.description && (
<Text style={[styles.textNormal]}>
{translate('workspace.moreFeatures.companyCards.integrationExportTitleFirstPart', {integration: exportMenuItem.description})}{' '}
{!!exportMenuItem && (
<TextLink
style={styles.link}
onPress={exportMenuItem.onExportPagePress}
>
{translate('workspace.moreFeatures.companyCards.integrationExportTitleLinkPart')}{' '}
</TextLink>
{!!exportMenuItem && !isXeroConnection && (
<>
{translate('workspace.moreFeatures.companyCards.integrationExportTitlePart')}{' '}
<TextLink
style={styles.link}
onPress={exportMenuItem.onExportPagePress}
>
{translate('workspace.moreFeatures.companyCards.integrationExportTitleLinkPart')}{' '}
</TextLink>
{translate('workspace.moreFeatures.companyCards.integrationExportTitleSecondPart')}
</>
)}
{translate('workspace.moreFeatures.companyCards.integrationExportTitleSecondPart')}
</Text>
)}
</View>
Expand Down
32 changes: 18 additions & 14 deletions src/pages/workspace/companyCards/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,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: '',
};
Expand Down Expand Up @@ -215,35 +216,38 @@ 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;
break;
}
case CONST.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSE_TYPE.CREDIT_CARD_CHARGE: {
const intacctCreditCards = policy?.connections?.intacct?.data?.creditCards ?? [];
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
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;

Expand Down

0 comments on commit 7078986

Please sign in to comment.