Skip to content

Commit

Permalink
Add new page for auto-config
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
twilight2294 authored Nov 5, 2024
1 parent 210db71 commit fc05e8f
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,11 @@ const CONST = {
NETSUITE_ADD_CUSTOM_SEGMENT_STEP_NAMES: ['1', '2,', '3', '4', '5', '6,'],
},

NETSUITE_ACCOUNTING_METHODS: {
ACCRUAL: 'ACCRUAL',
CASH: 'CASH',
},

NETSUITE_CUSTOM_FIELD_SUBSTEP_INDEXES: {
CUSTOM_LISTS: {
CUSTOM_LIST_PICKER: 0,
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,14 @@ const ROUTES = {
getRoute: (policyID: string, expenseType: ValueOf<typeof CONST.NETSUITE_EXPENSE_TYPE>) =>
`settings/workspaces/${policyID}/connections/netsuite/advanced/custom-form-id/${expenseType}` as const,
},
POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC: {
route: 'settings/workspaces/:policyID/connections/netsuite/advanced/autosync',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/advanced/autosync` as const,
},
POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD: {
route: 'settings/workspaces/:policyID/connections/netsuite/advanced/autosync/accounting-method',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/advanced/autosync/accounting-method` as const,
},
POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES: {
route: 'settings/workspaces/:policyID/accounting/sage-intacct/prerequisites',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/prerequisites` as const,
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ const SCREENS = {
NETSUITE_JOURNAL_ENTRY_APPROVAL_LEVEL_SELECT: 'Policy_Accounting_NetSuite_Journal_Entry_Approval_Level_Select',
NETSUITE_APPROVAL_ACCOUNT_SELECT: 'Policy_Accounting_NetSuite_Approval_Account_Select',
NETSUITE_CUSTOM_FORM_ID: 'Policy_Accounting_NetSuite_Custom_Form_ID',
NETSUITE_AUTO_SYNC: 'Policy_Accounting_NetSuite_Auto_Sync',
NETSUITE_ACCOUNTING_METHOD: 'Policy_Accounting_NetSuite_Accounting_Method',
SAGE_INTACCT_PREREQUISITES: 'Policy_Accounting_Sage_Intacct_Prerequisites',
ENTER_SAGE_INTACCT_CREDENTIALS: 'Policy_Enter_Sage_Intacct_Credentials',
EXISTING_SAGE_INTACCT_CONNECTIONS: 'Policy_Existing_Sage_Intacct_Connections',
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function SelectionScreen<T = string>({
sectionListStyle={!!sections.length && [styles.flexGrow0]}
shouldSingleExecuteRowSelect={shouldSingleExecuteRowSelect}
shouldUpdateFocusedIndex={shouldUpdateFocusedIndex}
isAlternateTextMultilineSupported
>
<ErrorMessageRow
errors={errors}
Expand Down
14 changes: 14 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ const translations = {
dropMessage: 'Drop your file here',
ignore: 'Ignore',
enabled: 'Enabled',
disabled: 'Disabled',
import: 'Import',
offlinePrompt: "You can't take this action right now.",
outstanding: 'Outstanding',
Expand Down Expand Up @@ -2834,6 +2835,18 @@ const translations = {
[CONST.NETSUITE_REPORTS_APPROVAL_LEVEL.REPORTS_APPROVED_BOTH]: 'Supervisor and accounting approved',
},
},
accountingMethods: {
label: 'When to Export',
description: 'Choose when to export the expenses:',
values: {
[CONST.NETSUITE_ACCOUNTING_METHODS.ACCRUAL]: 'Accrual',
[CONST.NETSUITE_ACCOUNTING_METHODS.CASH]: 'Cash',
},
alternateText: {
[CONST.NETSUITE_ACCOUNTING_METHODS.ACCRUAL]: 'Out of pocket expenses will export when final approved',
[CONST.NETSUITE_ACCOUNTING_METHODS.CASH]: 'Out of pocket expenses will export when paid',
},
},
exportVendorBillsTo: {
label: 'Vendor bill approval level',
description: 'Once a vendor bill is approved in Expensify and exported to NetSuite, you can set an additional level of approval in NetSuite prior to posting.',
Expand Down Expand Up @@ -3829,6 +3842,7 @@ const translations = {
exportDate: 'Export date',
defaultVendor: 'Default vendor',
autoSync: 'Auto-sync',
autoSyncDescription: 'Sync NetSuite and Expensify automatically, every day. Export finalized report in realtime',
reimbursedReports: 'Sync reimbursed reports',
cardReconciliation: 'Card reconciliation',
reconciliationAccount: 'Reconciliation account',
Expand Down
14 changes: 14 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ const translations = {
dropTitle: 'Suéltalo',
dropMessage: 'Suelta tu archivo aquí',
enabled: 'Habilitado',
disabled: 'Desactivada',
ignore: 'Ignorar',
import: 'Importar',
offlinePrompt: 'No puedes realizar esta acción ahora mismo.',
Expand Down Expand Up @@ -2871,6 +2872,18 @@ const translations = {
[CONST.NETSUITE_REPORTS_APPROVAL_LEVEL.REPORTS_APPROVED_BOTH]: 'Aprobado por supervisor y contabilidad',
},
},
accountingMethods: {
label: 'Cuándo Exportar',
description: 'Elige cuándo exportar los gastos:',
values: {
[CONST.NETSUITE_ACCOUNTING_METHODS.ACCRUAL]: 'Devengo',
[CONST.NETSUITE_ACCOUNTING_METHODS.CASH]: 'Efectivo',
},
alternateText: {
[CONST.NETSUITE_ACCOUNTING_METHODS.ACCRUAL]: 'Los gastos personales se exportarán cuando sean aprobados definitivamente',
[CONST.NETSUITE_ACCOUNTING_METHODS.CASH]: 'Los gastos personales se exportarán cuando sean pagados',
},
},
exportVendorBillsTo: {
label: 'Nivel de aprobación de facturas de proveedores',
description:
Expand Down Expand Up @@ -3834,6 +3847,7 @@ const translations = {
exportDate: 'Fecha de exportación',
defaultVendor: 'Proveedor predeterminado',
autoSync: 'Autosincronización',
autoSyncDescription: 'Sincroniza NetSuite y Expensify automáticamente, todos los días. Exporta el informe finalizado en tiempo real',
reimbursedReports: 'Sincronizar informes reembolsados',
cardReconciliation: 'Conciliación de tarjetas',
reconciliationAccount: 'Cuenta de conciliación',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_APPROVAL_ACCOUNT_SELECT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteApprovalAccountSelectPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteCustomFormIDPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/SageIntacctPrerequisitesPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_JOURNAL_ENTRY_APPROVAL_LEVEL_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_APPROVAL_ACCOUNT_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD,
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES,
SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS,
SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS,
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 @@ -529,6 +529,12 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID]: {
path: ROUTES.POLICY_ACCOUNTING_NETSUITE_CUSTOM_FORM_ID.route,
},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC]: {
path: ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.route,
},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: {
path: ROUTES.POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD.route,
},
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.route},
[SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTER_CREDENTIALS.route},
[SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXISTING_CONNECTIONS.route},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';
import type {ValueOf} from 'type-fest';
import RadioListItem from '@components/SelectionList/RadioListItem';
import type {ListItem} from '@components/SelectionList/types';
import SelectionScreen from '@components/SelectionScreen';
import type {SelectorType} from '@components/SelectionScreen';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@navigation/Navigation';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

type MenuListItem = ListItem & {
value: ValueOf<typeof CONST.NETSUITE_ACCOUNTING_METHODS>;
};

function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) {
const {translate} = useLocalize();
const policyID = policy?.id ?? '-1';
const styles = useThemeStyles();
const config = policy?.connections?.netsuite.options.config;
const accountingMehtod = config?.accountingMehtod ?? CONST.NETSUITE_ACCOUNTING_METHODS.CASH;
const data: MenuListItem[] = Object.values(CONST.NETSUITE_ACCOUNTING_METHODS).map((accountingMehtodType) => ({
value: accountingMehtodType,
text: translate(`workspace.netsuite.advancedConfig.accountingMethods.values.${accountingMehtodType}`),
alternateText: translate(`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMehtodType}`),
keyForList: accountingMehtodType,
isSelected: accountingMehtod === accountingMehtodType,
}));

const headerContent = useMemo(
() => (
<View>
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.netsuite.advancedConfig.accountingMethods.description')}</Text>
</View>
),
[translate, styles.pb5, styles.ph5],
);

const selectExpenseReportApprovalLevel = useCallback(
(row: MenuListItem) => {

Check failure on line 45 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'row' is defined but never used

Check failure on line 45 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'row' is defined but never used
// if (row.value !== config?.syncOptions.exportReportsTo) {
// Connections.updateNetSuiteExportReportsTo(policyID, row.value, config?.syncOptions.exportReportsTo ?? CONST.NETSUITE_REPORTS_APPROVAL_LEVEL.REPORTS_APPROVED_NONE);
// }
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID));
},
[config?.syncOptions.exportReportsTo, policyID],

Check warning on line 51 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'config.syncOptions.exportReportsTo'. Either exclude it or remove the dependency array

Check warning on line 51 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has an unnecessary dependency: 'config.syncOptions.exportReportsTo'. Either exclude it or remove the dependency array
);

return (
<SelectionScreen
displayName={NetSuiteAccountingMethodPage.displayName}
title="workspace.netsuite.advancedConfig.accountingMethods.label"
headerContent={headerContent}
sections={[{data}]}
listItem={RadioListItem}
onSelectRow={(selection: SelectorType) => selectExpenseReportApprovalLevel(selection as MenuListItem)}
initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList}
policyID={policyID}
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]}
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID))}
connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE}
/>
);
}

NetSuiteAccountingMethodPage.displayName = 'NetSuiteExpenseReportApprovalLevelSelectPage';

export default withPolicyConnections(NetSuiteAccountingMethodPage);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import * as Policy from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

type MenuItemWithSubscribedSettings = Pick<MenuItem, 'type' | 'description' | 'title' | 'onPress' | 'shouldHide'> & {subscribedSettings?: string[]};
type MenuItemWithSubscribedSettings = Pick<MenuItem, 'type' | 'description' | 'title' | 'onPress' | 'shouldHide' | 'hintText'> & {subscribedSettings?: string[]};

function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {
const {translate} = useLocalize();
Expand All @@ -40,7 +40,7 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {

const config = policy?.connections?.netsuite?.options.config;
const autoSyncConfig = policy?.connections?.netsuite?.config;

const accountingMehtod = policy?.connections?.netsuite?.options.config.accountingMehtod;
const {payableList} = policy?.connections?.netsuite?.options?.data ?? {};

const selectedReimbursementAccount = useMemo(
Expand All @@ -63,16 +63,14 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {

const menuItems: Array<MenuItemWithSubscribedSettings | ToggleItem | DividerLineItem> = [
{
type: 'toggle',
title: translate('workspace.accounting.autoSync'),
subtitle: translate('workspace.netsuite.advancedConfig.autoSyncDescription'),
isActive: !!autoSyncConfig?.autoSync.enabled,
switchAccessibilityLabel: translate('workspace.netsuite.advancedConfig.autoSyncDescription'),
shouldPlaceSubtitleBelowSwitch: true,
onCloseError: () => Policy.clearNetSuiteAutoSyncErrorField(policyID),
onToggle: (isEnabled) => Connections.updateNetSuiteAutoSync(policyID, isEnabled),
pendingAction: settingsPendingAction([CONST.NETSUITE_CONFIG.AUTO_SYNC], autoSyncConfig?.pendingFields),
errors: ErrorUtils.getLatestErrorField(autoSyncConfig, CONST.NETSUITE_CONFIG.AUTO_SYNC),
type: 'menuitem',
title: autoSyncConfig?.autoSync.enabled ? translate('common.enabled') : translate('common.disabled'),
description: translate('workspace.accounting.autoSync'),
onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID)),
hintText: (() => {
if (!autoSyncConfig?.autoSync.enabled) return undefined;

Check failure on line 71 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Expected { after 'if' condition

Check failure on line 71 in src/pages/workspace/accounting/netsuite/advanced/NetSuiteAdvancedPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Expected { after 'if' condition
return translate(`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMehtod ?? CONST.NETSUITE_ACCOUNTING_METHODS.CASH}`);
})(),
},
{
type: 'divider',
Expand Down Expand Up @@ -264,6 +262,7 @@ function NetSuiteAdvancedPage({policy}: WithPolicyConnectionsProps) {
shouldShowRightIcon
onPress={item?.onPress}
brickRoadIndicator={areSettingsInErrorFields(item.subscribedSettings, config?.errorFields) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
hintText={item.hintText}
/>
</OfflineWithFeedback>
);
Expand Down
Loading

0 comments on commit fc05e8f

Please sign in to comment.