Skip to content

Commit

Permalink
Merge pull request #41638 from Expensify/hayata-do-not-allow-invalid-…
Browse files Browse the repository at this point in the history
…location-account-combo

Prevent invalid configuration between location and JE selection
  • Loading branch information
Hayata Suenaga authored May 31, 2024
2 parents 250778d + a3729d4 commit d234079
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 28 deletions.
9 changes: 4 additions & 5 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1938,10 +1938,11 @@ export default {
customersDescription: 'Choose whether to import customers/projects and see where customers/projects are displayed.',
locationsDescription: 'Choose whether to import locations, and see where locations are displayed.',
taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.',
locationsAdditionalDescription: `QuickBooks Online does not support adding a location to vendor bills or checks. Update your export preference to journal entry if you'd like to import locations as tags.`,
outOfPocketLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for locations on vendor bill or check exports. As you have locations enabled on your workspace, this export option is unavailable.',
taxesJournalEntrySwitchNote:
'Note: QuickBooks Online does not support a field for tax on Journal Entry exports. Change your export preference to Vendor Bill or Check to import taxes.',
locationsAdditionalDescription:
'Locations are imported as Tags. This limits exporting expense reports as Vendor Bills or Checks to QuickBooks Online. To unlock these export options, either disable Locations import or upgrade to the Control Plan to export Locations encoded as a Report Field.',
export: 'Export',
exportAs: 'Export as',
exportDescription: 'Configure how data in Expensify gets exported to QuickBooks Online.',
Expand Down Expand Up @@ -1993,13 +1994,11 @@ export default {
bankAccountDescription: 'This is your chosen bank account to write checks from.',
optionBelow: 'Choose an option below:',
companyCardsLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.',
'Note: QuickBooks Online does not support a field for locations on vendor bill exports. As you have locations enabled on your workspace, this export option is unavailable.',
outOfPocketTaxEnabledDescription:
"Note: QuickBooks Online doesn't support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.",
outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.',
outOfPocketLocationEnabledError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.',
outOfPocketLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations as Tags, this export option is unavailable.',
advancedConfig: {
advanced: 'Advanced',
autoSync: 'Auto-sync',
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ export default {
taxesJournalEntrySwitchNote:
'Nota: QuickBooks Online no admite un campo para impuestos al exportar entradas en el libro diario. Cambia tu preferencia de exportación a Factura de Proveedor o Cheque para importar impuestos.',
locationsAdditionalDescription:
'Los lugares son importados como Etiquegas. Esto limita a exportar los informes de gastos como Factura del Proveedor o Cheques a Quicbooks Online. Para desbloquear estas opciones de exportación desactiva la importación de Lugares o cambia al Plan Control para exportar Lugares como Campos de Informes.',
'QuickBooks Online no permite añadir una ubicación a las facturas de proveedores o a los cheques. Actualice su preferencia de exportación a asiento contable si desea importar ubicaciones como etiquetas.',
export: 'Exportar',
exportAs: 'Exportar cómo',
exportExpenses: 'Exportar gastos de bolsillo como',
Expand Down Expand Up @@ -2025,7 +2025,7 @@ export default {
outOfPocketTaxEnabledError: 'La Anotacion en el diario no está disponible cuando los impuestos están activados. Por favor, selecciona una opción de exportación diferente.',
outOfPocketLocationEnabledError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están activadas. Seleccione otra opción de exportación.',
outOfPocketLocationEnabledDescription:
'Nota: QuickBooks Online no admite un campo para Ubicaciones como Etiquetas en las exportaciones de Facturas de Proveedor. Al importar Ubicaciones como Etiquetas, esta opción de exportación no está disponible.',
'Nota: QuickBooks Online no permite añadir una ubicación a las facturas de proveedores o a los cheques. Al importar ubicaciones como etiquetas, esta opción de exportación no está disponible.',

advancedConfig: {
advanced: 'Avanzado',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
const {translate} = useLocalize();
const styles = useThemeStyles();
const policyID = policy?.id ?? '';
const {syncLocations, reimbursableExpensesAccount, reimbursableExpensesExportDestination, errorFields, syncTax, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {};
const {syncLocations, syncTax, reimbursableExpensesAccount, reimbursableExpensesExportDestination, errorFields, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {};
const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE);
const isTaxesEnabled = Boolean(syncTax);
const shouldShowTaxError = isTaxesEnabled && reimbursableExpensesExportDestination === CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY;
Expand Down Expand Up @@ -59,7 +59,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
>
<HeaderWithBackButton title={translate('workspace.qbo.exportExpenses')} />
<ScrollView contentContainerStyle={styles.pb2}>
{!isLocationEnabled && <Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportOutOfPocketExpensesDescription')}</Text>}
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.qbo.exportOutOfPocketExpensesDescription')}</Text>
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesExportDestination}>
<MenuItemWithTopDescription
title={reimbursableExpensesExportDestination ? translate(`workspace.qbo.accounts.${reimbursableExpensesExportDestination}`) : undefined}
Expand All @@ -71,19 +71,16 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyConne
hintText={exportHintText}
/>
</OfflineWithFeedback>
{isLocationEnabled && <Text style={[styles.ph5, styles.mutedNormalTextLabel, styles.pt1]}>{translate('workspace.qbo.outOfPocketLocationEnabledDescription')}</Text>}
{!isLocationEnabled && (
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesAccount}>
<MenuItemWithTopDescription
title={reimbursableExpensesAccount?.name}
description={accountDescription}
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))}
brickRoadIndicator={errorFields?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
shouldShowRightIcon
errorText={errorFields?.exportAccount ? translate('common.genericErrorMessage') : undefined}
/>
</OfflineWithFeedback>
)}
<OfflineWithFeedback pendingAction={pendingFields?.reimbursableExpensesAccount}>
<MenuItemWithTopDescription
title={reimbursableExpensesAccount?.name}
description={accountDescription}
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))}
brickRoadIndicator={errorFields?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
shouldShowRightIcon
errorText={errorFields?.exportAccount ? translate('common.genericErrorMessage') : undefined}
/>
</OfflineWithFeedback>
</ScrollView>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {Account, QBOReimbursableExportAccountType} from '@src/types/onyx/Policy';

function Footer({isTaxEnabled, isLocationsEnabled}: {isTaxEnabled: boolean; isLocationsEnabled: boolean}) {
const styles = useThemeStyles();
const {translate} = useLocalize();

if (!isTaxEnabled && !isLocationsEnabled) {
return null;
}

return (
<View style={[styles.gap2, styles.mt2]}>
{isTaxEnabled && <Text style={styles.mutedNormalTextLabel}>{translate('workspace.qbo.outOfPocketTaxEnabledDescription')}</Text>}
{isLocationsEnabled && <Text style={styles.mutedNormalTextLabel}>{translate('workspace.qbo.outOfPocketLocationEnabledDescription')}</Text>}
</View>
);
}

type CardListItem = ListItem & {
value: QBOReimbursableExportAccountType;
isShown: boolean;
Expand Down Expand Up @@ -107,7 +123,12 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyConnec
onSelectRow={selectExportEntity}
shouldDebounceRowSelect
initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList}
footerContent={isTaxesEnabled && <Text style={[styles.mutedNormalTextLabel, styles.pt2]}>{translate('workspace.qbo.outOfPocketTaxEnabledDescription')}</Text>}
footerContent={
<Footer
isTaxEnabled={isTaxesEnabled}
isLocationsEnabled={isLocationsEnabled}
/>
}
/>
</View>
</ScreenWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const policyID = policy?.id ?? '';
const {syncLocations, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {};
const {syncLocations, pendingFields, reimbursableExpensesExportDestination, nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {};
const isSwitchOn = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE);
const canImportLocation =
reimbursableExpensesExportDestination === CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY &&
nonReimbursableExpensesExportDestination !== CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.VENDOR_BILL;
const shouldBeDisabled = !canImportLocation && !isSwitchOn;
const isReportFieldsSelected = syncLocations === CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD;

return (
Expand Down Expand Up @@ -55,6 +59,7 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) {
isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG,
)
}
disabled={shouldBeDisabled}
/>
</View>
</OfflineWithFeedback>
Expand All @@ -69,9 +74,11 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) {
/>
</OfflineWithFeedback>
)}
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap2, styles.mt1]}>
<Text style={styles.mutedTextLabel}>{translate('workspace.qbo.locationsAdditionalDescription')}</Text>
</View>
{shouldBeDisabled && (
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap2, styles.mt1]}>
<Text style={styles.mutedTextLabel}>{translate('workspace.qbo.locationsAdditionalDescription')}</Text>
</View>
)}
</ScrollView>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function QuickbooksTaxesPage({policy}: WithPolicyProps) {
</View>
</OfflineWithFeedback>
</View>
{isJournalExportEntity && <Text style={[styles.mutedNormalTextLabel, styles.pt2]}>{translate('workspace.qbo.taxesJournalEntrySwitchNote')}</Text>}
{!syncTax && isJournalExportEntity && <Text style={[styles.mutedNormalTextLabel, styles.pt2]}>{translate('workspace.qbo.taxesJournalEntrySwitchNote')}</Text>}
</ScrollView>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down

0 comments on commit d234079

Please sign in to comment.