Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal QA]: Fixes for Sage connection and Xero #54411

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
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
Loading