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

[QBD] Restrict QBD to Control plans #50890

Merged
merged 8 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5765,6 +5765,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
8 changes: 6 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2462,8 +2462,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.",
lakchote marked this conversation as resolved.
Show resolved Hide resolved
},
},
qbo: {
Expand Down Expand Up @@ -3961,6 +3960,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 @@ -2486,7 +2486,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.',
},
},
qbo: {
Expand Down Expand Up @@ -4006,6 +4006,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.`,
Copy link
Contributor Author

@ZhenjaHorbach ZhenjaHorbach Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used JamesGPT
And I'm waiting for confirmation [here]
(https://expensify.slack.com/archives/C01GTK53T8Q/p1729083871002409?thread_ts=1729070840.273779&cid=C01GTK53T8Q)

Status: Confirmed

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
8 changes: 7 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,9 +69,13 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
undefined,
newActiveIntegration.integrationToDisconnect,
newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting,
undefined,
isSmallScreenWidth,
);
const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails;
if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) {
workspaceUpgradeNavigationDetails.eventBeforeNavigation?.();

Navigation.navigate(
ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, workspaceUpgradeNavigationDetails.integrationAlias, workspaceUpgradeNavigationDetails.backToAfterWorkspaceUpgradeRoute),
);
Expand All @@ -80,7 +86,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
key: Math.random(),
});
},
[policy, policyID, translate],
[isSmallScreenWidth, policy, policyID, translate],
);

const closeConfirmationModal = () => {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspace/accounting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type WorkspaceUpgradeNavigationDetails = {
integrationAlias: string;
/** Route to redirect to after upgrading the workspace */
backToAfterWorkspaceUpgradeRoute: string;
/** Function to call after upgrading the workspace */
eventBeforeNavigation?: () => void;
};

type AccountingIntegration = {
Expand Down
23 changes: 23 additions & 0 deletions src/pages/workspace/accounting/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {canUseTaxNetSuite} from '@libs/PolicyUtils';
import Navigation from '@navigation/Navigation';
import type {ThemeStyles} from '@styles/index';
import {getTrackingCategories} from '@userActions/connections/Xero';
import * as PolicyAction from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {Policy} from '@src/types/onyx';
Expand Down Expand Up @@ -47,11 +48,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 @@ -270,6 +282,17 @@ function getAccountingIntegrationData(
CONST.QUICKBOOKS_DESKTOP_CONFIG.MARK_CHECKS_TO_BE_PRINTED,
],
subscribedAdvancedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC],
workspaceUpgradeNavigationDetails: {
integrationAlias: CONST.UPGRADE_FEATURE_INTRO_MAPPING.quickbooksDesktop.alias,
eventBeforeNavigation: () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (isSmallScreenWidth || integrationToDisconnect) {
return;
}
PolicyAction.enablePolicyTaxes(policyID, false);
ZhenjaHorbach marked this conversation as resolved.
Show resolved Hide resolved
},
backToAfterWorkspaceUpgradeRoute: getBackToAfterWorkspaceUpgradeRouteForQBD(),
},
};
default:
return undefined;
Expand Down
Loading