Skip to content

Commit

Permalink
Merge pull request #50890 from ZhenjaHorbach/qbd-restrict-control-plans
Browse files Browse the repository at this point in the history
[QBD] Restrict QBD to Control plans
  • Loading branch information
lakchote authored Oct 18, 2024
2 parents 40e2230 + 5555582 commit 7995e8c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5788,6 +5788,14 @@ const CONST = {
description: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.SAGE_INTACCT}.description` as const,
icon: 'IntacctSquare',
},
[this.POLICY.CONNECTIONS.NAME.QBD]: {
id: this.POLICY.CONNECTIONS.NAME.QBD,
alias: 'qbd',
name: this.POLICY.CONNECTIONS.NAME_USER_FRIENDLY.quickbooksDesktop,
title: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.QBD}.title` as const,
description: `workspace.upgrade.${this.POLICY.CONNECTIONS.NAME.QBD}.description` as const,
icon: 'QBDSquare',
},
approvals: {
id: 'approvals' as const,
alias: 'approvals' as const,
Expand Down
3 changes: 0 additions & 3 deletions src/components/ConnectToQuickbooksDesktopFlow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {useEffect} from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyAction from '@userActions/Policy/Policy';
import ROUTES from '@src/ROUTES';
import type {ConnectToQuickbooksDesktopFlowProps} from './types';

Expand All @@ -12,8 +11,6 @@ function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFl
if (isSmallScreenWidth) {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID));
} else {
// Since QBD doesn't support Taxes, we should disable them from the LHN when connecting to QBD
PolicyAction.enablePolicyTaxes(policyID, false);
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID));
}
}, [isSmallScreenWidth, policyID]);
Expand Down
8 changes: 6 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2467,8 +2467,7 @@ const translations = {
advancedConfig: {
autoSyncDescription: 'Expensify will automatically sync with QuickBooks Desktop every day.',
createEntities: 'Auto-create entities',
createEntitiesDescription:
"Expensify will automatically create vendors in QuickBooks Desktop if they don't exist already, and auto-create customers when exporting invoices.",
createEntitiesDescription: "Expensify will automatically create vendors in QuickBooks Desktop if they don't exist already.",
},
itemsDescription: 'Choose how to handle QuickBooks Desktop items in Expensify.',
},
Expand Down Expand Up @@ -3990,6 +3989,11 @@ const translations = {
description: `Enjoy automated syncing and reduce manual entries with the Expensify + Sage Intacct integration. Gain in-depth, real-time financial insights with user-defined dimensions, as well as expense coding by department, class, location, customer, and project (job).`,
onlyAvailableOnPlan: 'Our Sage Intacct integration is only available on the Control plan, starting at ',
},
[CONST.POLICY.CONNECTIONS.NAME.QBD]: {
title: 'QuickBooks Desktop',
description: `Enjoy automated syncing and reduce manual entries with the Expensify + QuickBooks Desktop integration. Gain ultimate efficiency with a realtime, two-way connection and expense coding by class, item, customer, and project.`,
onlyAvailableOnPlan: 'Our QuickBooks Desktop integration is only available on the Control plan, starting at ',
},
[CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id]: {
title: 'Advanced Approvals',
description: `If you want to add more layers of approval to the mix – or just make sure the largest expenses get another set of eyes – we’ve got you covered. Advanced approvals help you put the right checks in place at every level so you keep your team’s spend under control.`,
Expand Down
7 changes: 6 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ const translations = {
advancedConfig: {
autoSyncDescription: 'Expensify se sincronizará automáticamente con QuickBooks Desktop todos los días.',
createEntities: 'Crear entidades automáticamente',
createEntitiesDescription: 'Expensify creará automáticamente proveedores en QuickBooks Desktop si aún no existen, y creará automáticamente clientes al exportar facturas.',
createEntitiesDescription: 'Expensify creará automáticamente proveedores en QuickBooks Desktop si aún no existen.',
},
itemsDescription: 'Elige cómo gestionar los elementos de QuickBooks Desktop en Expensify.',
},
Expand Down Expand Up @@ -4035,6 +4035,11 @@ const translations = {
description: `Disfruta de una sincronización automatizada y reduce las entradas manuales con la integración Expensify + Sage Intacct. Obtén información financiera en profundidad y en tiempo real con dimensiones definidas por el usuario, así como codificación de gastos por departamento, clase, ubicación, cliente y proyecto (trabajo).`,
onlyAvailableOnPlan: 'Nuestra integración Sage Intacct sólo está disponible en el plan Control, a partir de ',
},
[CONST.POLICY.CONNECTIONS.NAME.QBD]: {
title: 'QuickBooks Desktop',
description: `Disfruta de la sincronización automática y reduce las entradas manuales con la integración de Expensify + QuickBooks Desktop. Obtén la máxima eficiencia con una conexión bidireccional en tiempo real y la codificación de gastos por clase, artículo, cliente y proyecto.`,
onlyAvailableOnPlan: 'Nuestra integración con QuickBooks Desktop solo está disponible en el plan Control, que comienza en ',
},
[CONST.UPGRADE_FEATURE_INTRO_MAPPING.approvals.id]: {
title: 'Aprobaciones anticipadas',
description: `Si quieres añadir más niveles de aprobación, o simplemente asegurarte de que los gastos más importantes reciben otro vistazo, no hay problema. Las aprobaciones avanzadas ayudan a realizar las comprobaciones adecuadas a cada nivel para mantener los gastos de tu equipo bajo control.`,
Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/accounting/AccountingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {removePolicyConnection} from '@libs/actions/connections';
import Navigation from '@libs/Navigation/Navigation';
import {isControlPolicy} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -56,6 +57,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
const [activeIntegration, setActiveIntegration] = useState<ActiveIntegrationState>();
const {translate} = useLocalize();
const policyID = policy?.id ?? '-1';
const {isSmallScreenWidth} = useResponsiveLayout();

const startIntegrationFlow = React.useCallback(
(newActiveIntegration: ActiveIntegration) => {
Expand All @@ -67,6 +69,8 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
undefined,
newActiveIntegration.integrationToDisconnect,
newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting,
undefined,
isSmallScreenWidth,
);
const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails;
if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) {
Expand All @@ -80,7 +84,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
key: Math.random(),
});
},
[policy, policyID, translate],
[isSmallScreenWidth, policy, policyID, translate],
);

const closeConfirmationModal = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import LoadingPage from '@pages/LoadingPage';
import * as PolicyAction from '@userActions/Policy/Policy';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

Expand All @@ -36,6 +37,9 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro
});
};

// Since QBD doesn't support Taxes, we should disable them from the LHN when connecting to QBD
PolicyAction.enablePolicyTaxes(policyID, false);

fetchSetupLink();
// disabling this rule, as we want this to run only on the first render
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
Expand Down
15 changes: 15 additions & 0 deletions src/pages/workspace/accounting/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ function getAccountingIntegrationData(
integrationToDisconnect?: ConnectionName,
shouldDisconnectIntegrationBeforeConnecting?: boolean,
canUseNetSuiteUSATax?: boolean,
isSmallScreenWidth?: boolean,
): AccountingIntegration | undefined {
const qboConfig = policy?.connections?.quickbooksOnline?.config;
const netsuiteConfig = policy?.connections?.netsuite?.options?.config;
const netsuiteSelectedSubsidiary = (policy?.connections?.netsuite?.options?.data?.subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netsuiteConfig?.subsidiaryID);

const getBackToAfterWorkspaceUpgradeRouteForQBD = () => {
if (integrationToDisconnect) {
return ROUTES.POLICY_ACCOUNTING.getRoute(policyID, connectionName, integrationToDisconnect, shouldDisconnectIntegrationBeforeConnecting);
}
if (isSmallScreenWidth) {
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID);
}
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID);
};

switch (connectionName) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
return {
Expand Down Expand Up @@ -279,6 +290,10 @@ function getAccountingIntegrationData(
CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR,
],
subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC],
workspaceUpgradeNavigationDetails: {
integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias,
backToAfterWorkspaceUpgradeRoute: getBackToAfterWorkspaceUpgradeRouteForQBD(),
},
};
default:
return undefined;
Expand Down

0 comments on commit 7995e8c

Please sign in to comment.