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

QBO import main page #38400

Merged
merged 39 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
96635ab
QBO import main page
narefyev91 Mar 15, 2024
b9670c9
lock
narefyev91 Mar 15, 2024
ef23460
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 18, 2024
c863078
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 18, 2024
8e78317
Add Chart of account sub page + new routes and Policy api
narefyev91 Mar 19, 2024
c0fe32b
prettier
narefyev91 Mar 19, 2024
f85ce0d
resolve suggested comments
narefyev91 Mar 20, 2024
1b8bfb9
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 20, 2024
7b90e68
update naming, add mock pages, and correct routing
narefyev91 Mar 20, 2024
758a77b
fix ts
narefyev91 Mar 20, 2024
441bbf0
add 2 more screen - classes and customer + pending actions, clean up …
narefyev91 Mar 21, 2024
56c728f
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 21, 2024
6bc7a25
update after merge conflicts
narefyev91 Mar 21, 2024
3a6113b
remove line
narefyev91 Mar 21, 2024
bcfa12a
lint
narefyev91 Mar 21, 2024
3477c63
Taxes and Locations pages
narefyev91 Mar 22, 2024
ded9218
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 22, 2024
9c170b4
translations
narefyev91 Mar 22, 2024
b4d845f
updated booleans and rename methods to function execution
narefyev91 Mar 25, 2024
8fdf373
fix native ui and warning
narefyev91 Mar 25, 2024
95a844e
prettier
narefyev91 Mar 25, 2024
83fa595
updates after design review
narefyev91 Mar 26, 2024
40b55eb
design review updates
narefyev91 Mar 26, 2024
3286d8b
Merge branch 'main' into qbo-import-main-page
narefyev91 Mar 27, 2024
0a5e35e
Merge branch 'main' into qbo-import-main-page
narefyev91 Apr 2, 2024
5ee4227
updates based on new stack implementation
narefyev91 Apr 2, 2024
9717dfb
prettier
narefyev91 Apr 2, 2024
6694dc2
Export date page - initial
narefyev91 Apr 3, 2024
d8e225e
add wrappers for not showing page
narefyev91 Apr 4, 2024
2d37315
resolve c+ comments
narefyev91 Apr 4, 2024
1e59910
remove color
narefyev91 Apr 4, 2024
3ca396f
resolve comments
narefyev91 Apr 8, 2024
b4d73c1
remove true false from types
narefyev91 Apr 9, 2024
fb31fb1
resolve c+ comments
narefyev91 Apr 9, 2024
6355d8c
Update src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPa…
narefyev91 Apr 9, 2024
08bbde1
Update src/pages/workspace/accounting/WorkspaceAccountingPage.tsx
narefyev91 Apr 9, 2024
1a94706
Merge branch 'main' into qbo-import-main-page
narefyev91 Apr 9, 2024
79b9198
merge updates
narefyev91 Apr 9, 2024
03c7452
prettier
narefyev91 Apr 9, 2024
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
24 changes: 24 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ const ROUTES = {
route: 'r/:reportID/transaction/:transactionID/receipt',
getRoute: (reportID: string, transactionID: string) => `r/${reportID}/transaction/${transactionID}/receipt` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_IMPORT: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_CHART_OF_ACCOUNTS: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/accounts',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import/accounts` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_CLASSES: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/classes',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import/classes` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_CUSTOMER: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/customers',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import/customers` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_LOCATIONS: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/locations',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import/locations` as const,
},
POLICY_ACCOUNTING_QUICKBOOKSONLINE_TAXES: {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes',
getRoute: (policyID: string) => `workspace/${policyID}/connections/quickbooks-online/import/taxes` as const,
},
} as const;

/**
Expand Down
7 changes: 7 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ const SCREENS = {
MEMBER_DETAILS_ROLE_SELECTION: 'Workspace_Member_Details_Role_Selection',
DISTANCE_RATES: 'Distance_Rates',
CREATE_DISTANCE_RATE: 'Create_Distance_Rate',
ACCOUNTING: 'Policy_Accounting',
QUICKBOOKSONLINE_IMPORT: 'Policy_Accounting_QuickbooksOnline_Import',
QUICKBOOKSONLINE_CHART_OF_ACCOUNTS: 'Policy_Accounting_QuickbooksOnline_Import_Chart_Of_Accounts',
QUICKBOOKSONLINE_CLASSES: 'Policy_Accounting_QuickbooksOnline_Import_Classes',
QUICKBOOKSONLINE_CUSTOMER: 'Policy_Accounting_QuickbooksOnline_Import_Customer',
QUICKBOOKSONLINE_LOCATIONS: 'Policy_Accounting_QuickbooksOnline_Import_Locations',
QUICKBOOKSONLINE_TAXES: 'Policy_Accounting_QuickbooksOnline_Import_Taxes',
},

EDIT_REQUEST: {
Expand Down
16 changes: 16 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,22 @@ export default {
requested: 'Requested',
distanceRates: 'Distance rates',
},
qbo: {
import: 'Import',
importDescription: 'Choose which coding configurations are imported from QuickBooks Online to Expensify',
classes: 'Classes',
accounts: 'Chart of Accounts',
locations: 'Locations',
taxes: 'Taxes',
customers: 'Customers/Projects',
imported: 'Imported',
notImported: 'Not imported',
importedAsTags: 'Imported, displayed as tags',
importedAsReportFields: 'Imported, displayed as categories',
accountsDescription: 'Chart of Accounts import as categories when connected to an accounting integration, this cannot be disabled.',
accountsSwitchTitle: 'Enable newly imported Chart of Accounts.',
accountsSwitchDescription: 'New categories imported from QuickBooks Online to Expensify will be either enabled or disabled by default.',
},
type: {
free: 'Free',
control: 'Control',
Expand Down
16 changes: 16 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,22 @@ export default {
requested: 'Solicitado',
distanceRates: 'Tasas de distancia',
},
qbo: {
import: 'Importación',
importDescription: 'Elija qué configuraciones de codificación se importan de QuickBooks Online a Expensify',
classes: 'Clases',
locations: 'Ubicaciones',
accounts: 'Catálogo de cuentas',
customers: 'Clientes/Proyectos',
imported: 'Importado',
taxes: 'Impuestos',
notImported: 'No importado',
importedAsTags: 'Importado, mostrado como etiquetas',
importedAsReportFields: 'Importado, mostrado como categorías',
accountsDescription: 'El plan de cuentas se importa como categorías cuando se conecta a una integración contable; esto no se puede desactivar.',
accountsSwitchTitle: 'Habilite el plan de cuentas recién importado.',
accountsSwitchDescription: 'Las nuevas categorías importadas de QuickBooks Online a Expensify estarán habilitadas o deshabilitadas de forma predeterminada.',
},
type: {
free: 'Gratis',
control: 'Control',
Expand Down
1 change: 1 addition & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const WRITE_COMMANDS = {
ACCEPT_JOIN_REQUEST: 'AcceptJoinRequest',
DECLINE_JOIN_REQUEST: 'DeclineJoinRequest',
CREATE_POLICY_TAX: 'CreatePolicyTax',
UPDATE_POLICY_CONNECTIONS_CONFIGURATION: 'UpdatePolicyConnectionsConfiguration',
CREATE_POLICY_DISTANCE_RATE: 'CreatePolicyDistanceRate',
} as const;

Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.TAXES_SETTINGS_CUSTOM_TAX_NAME]: () => require('../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType,
[SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType,
[SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType,
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_IMPORT]: () => require('../../../pages/workspace/qbo/PolicyQuickbooksImportPage').default as React.ComponentType,
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_CHART_OF_ACCOUNTS]: () => require('../../../pages/workspace/qbo/QuickbooksChartOfAccountsConfigurationPage').default as React.ComponentType,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType,
[SCREENS.GET_ASSISTANCE]: () => require('../../../pages/GetAssistancePage').default as React.ComponentType,
[SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType,
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.CURRENCY]: {
path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route,
},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_IMPORT.route},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CHART_OF_ACCOUNTS.route},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_CLASSES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CLASSES.route},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_CUSTOMER]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CUSTOMER.route},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_LOCATIONS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_LOCATIONS.route},
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_TAXES.route},
[SCREENS.WORKSPACE.DESCRIPTION]: {
path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route,
},
Expand Down
9 changes: 9 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.CREATE_DISTANCE_RATE]: {
policyID: string;
};
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_IMPORT]: {
policyID: string;
};
[SCREENS.GET_ASSISTANCE]: {
backTo: Routes;
};
Expand Down Expand Up @@ -571,6 +574,12 @@ type WorkspacesCentralPaneNavigatorParamList = {
[SCREENS.WORKSPACE.DISTANCE_RATES]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING]: {
policyID: string;
};
[SCREENS.WORKSPACE.QUICKBOOKSONLINE_IMPORT]: {
policyID: string;
};
};

type FullScreenNavigatorParamList = {
Expand Down
65 changes: 65 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,70 @@ function openPolicyDistanceRatesPage(policyID?: string) {
API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params);
}

function updatePolicyConnectionConfig(policyID: string, connectionName: string, settingName: string, settingValue: string | boolean) {
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
const parameters = {policyID, connectionName, settingName, settingValue, idempotencyKey: settingName};
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
pendingFields: {
[settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
connections: {
quickbooksOnline: {
config: {
[settingName]: settingValue,
},
},
},
},
},
];
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
errorFields: {
[settingName]: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage'),
},
pendingFields: {
[settingName]: null,
},
connections: {
quickbooksOnline: {
config: {
[settingName]: settingValue,
},
},
},
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
pendingFields: {
[settingName]: null,
},
connections: {
quickbooksOnline: {
config: {
[settingName]: settingValue,
},
},
},
},
},
];

API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTIONS_CONFIGURATION, parameters, {optimisticData, failureData, successData});
}

function navigateWhenEnableFeature(policyID: string, featureRoute: Route) {
const isNarrowLayout = getIsNarrowLayout();

Expand Down Expand Up @@ -4066,5 +4130,6 @@ export {
setWorkspaceTagEnabled,
setWorkspaceCurrencyDefault,
setForeignCurrencyDefault,
updatePolicyConnectionConfig,
setPolicyCustomTaxName,
};
126 changes: 126 additions & 0 deletions src/pages/workspace/qbo/PolicyQuickbooksImportPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import React, {useCallback} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import withPolicy from '@pages/workspace/withPolicy';
import type {WithPolicyProps} from '@pages/workspace/withPolicy';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

const NAVIGATION_KEYS = {
ACCOUNTS: 'accounts',
CLASSES: 'classes',
CUSTOMERS: 'customers',
LOCATIONS: 'locations',
TAXES: 'taxes',
};

function PolicyQuickbooksImportPage({policy}: WithPolicyProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const quickbooksOnlineConfigTitles = {
DEFAULT: translate('workspace.qbo.imported'),
true: translate('workspace.qbo.imported'),
false: translate('workspace.qbo.notImported'),
NONE: translate('workspace.qbo.notImported'),
TAG: translate('workspace.qbo.importedAsTags'),
REPORT_FIELD: translate('workspace.qbo.importedAsReportFields'),
};
const {syncClasses, syncCustomers, syncLocations, syncTaxes, syncAccounts} = policy?.connections?.quickbooksOnline?.config ?? {};

const onPressConfigOption = useCallback(
(option: string) => {
const policyID = policy?.id ?? '';
switch (option) {
case NAVIGATION_KEYS.ACCOUNTS:
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CHART_OF_ACCOUNTS.getRoute(policyID));
break;
case NAVIGATION_KEYS.CLASSES:
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CLASSES.getRoute(policyID));
break;
case NAVIGATION_KEYS.CUSTOMERS:
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_CUSTOMER.getRoute(policyID));
break;
case NAVIGATION_KEYS.LOCATIONS:
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_LOCATIONS.getRoute(policyID));
break;
case NAVIGATION_KEYS.TAXES:
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKSONLINE_TAXES.getRoute(policyID));
break;
default:
break;
}
},
[policy?.id],
);

const sections = [
{
description: translate('workspace.qbo.accounts'),
navigationKey: NAVIGATION_KEYS.ACCOUNTS,
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
errorIndicator: !!policy?.errors?.syncAccounts,
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
title: syncAccounts,
},
{
description: translate('workspace.qbo.classes'),
navigationKey: NAVIGATION_KEYS.CLASSES,
errorIndicator: !!policy?.errors?.syncClasses,
title: syncClasses,
},
{
description: translate('workspace.qbo.customers'),
navigationKey: NAVIGATION_KEYS.CUSTOMERS,
errorIndicator: !!policy?.errors?.syncCustomers,
title: syncCustomers,
},
{
description: translate('workspace.qbo.locations'),
navigationKey: NAVIGATION_KEYS.LOCATIONS,
errorIndicator: !!policy?.errors?.syncLocations,
title: syncLocations,
},
{
description: translate('workspace.qbo.taxes'),
navigationKey: NAVIGATION_KEYS.TAXES,
errorIndicator: !!policy?.errors?.syncTaxes,
title: syncTaxes,
},
];

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableMaxHeight
testID={PolicyQuickbooksImportPage.displayName}
>
<HeaderWithBackButton
title={translate('workspace.qbo.import')}
onBackButtonPress={Navigation.goBack}
/>
<ScrollView contentContainerStyle={styles.pb2}>
<Text style={[styles.pl5, styles.pb5]}>{translate('workspace.qbo.importDescription')}</Text>
{sections.map((section) => (
<OfflineWithFeedback>
<MenuItemWithTopDescription
title={quickbooksOnlineConfigTitles[`${section.title ?? 'NONE'}`]}
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
description={section.description}
shouldShowRightIcon
onPress={() => onPressConfigOption(section.navigationKey)}
brickRoadIndicator={section.errorIndicator ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
narefyev91 marked this conversation as resolved.
Show resolved Hide resolved
/>
</OfflineWithFeedback>
))}
</ScrollView>
</ScreenWrapper>
);
}

PolicyQuickbooksImportPage.displayName = 'PolicyQuickbooksImportPage';

export default withPolicy(PolicyQuickbooksImportPage);
Loading
Loading