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

[#Wave-Control: Add NetSuite]: Settings Configuration in NewDot: Import List #44663

Merged
merged 22 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,7 @@ const CONST = {
REPORT_FIELD: 'REPORT_FIELD',
NOT_IMPORTED: 'NOT_IMPORTED',
IMPORTED: 'IMPORTED',
NETSUITE_DEFAULT: 'NETSUITE_DEFAULT',
},
QUICKBOOKS_ONLINE: 'quickbooksOnline',

Expand Down Expand Up @@ -1367,6 +1368,9 @@ const CONST = {
PROVINCIAL_TAX_POSTING_ACCOUNT: 'provincialTaxPostingAccount',
ALLOW_FOREIGN_CURRENCY: 'allowForeignCurrency',
EXPORT_TO_NEXT_OPEN_PERIOD: 'exportToNextOpenPeriod',
IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'],
IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'],
SYNC_TAX: 'syncTax',
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
},

NETSUITE_EXPORT_DATE: {
Expand Down
12 changes: 8 additions & 4 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,18 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const,
},
RESTRICTED_ACTION: {
route: 'restricted-action/workspace/:policyID',
getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const,
},
POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR: {
route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector',
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: We should update these to be consistent at some point:

Suggested change
route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector',
route: 'settings/workspaces/:policyID/accounting/netsuite/subsidiary-selector',

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/net-suite/subsidiary-selector` as const,
},
POLICY_ACCOUNTING_NETSUITE_IMPORT: {
route: 'settings/workspaces/:policyID/accounting/netsuite/import',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import` as const,
},
RESTRICTED_ACTION: {
route: 'restricted-action/workspace/:policyID',
getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const,
},
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
POLICY_ACCOUNTING_NETSUITE_EXPORT: {
route: 'settings/workspaces/:policyID/connections/netsuite/export/',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/export/` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ const SCREENS = {
XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector',
XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select',
NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_Net_Suite_Subsidiary_Selector',
NETSUITE_IMPORT: 'Policy_Accounting_Net_Suite_Import',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NETSUITE_IMPORT: 'Policy_Accounting_Net_Suite_Import',
NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import',

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export',
NETSUITE_PREFERRED_EXPORTER_SELECT: 'Policy_Accounting_NetSuite_Preferred_Exporter_Select',
NETSUITE_DATE_SELECT: 'Policy_Accounting_NetSuite_Date_Select',
Expand Down
17 changes: 17 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,22 @@ export default {
noItemsFoundDescription: 'Add invoice items in NetSuite and sync the connection again.',
noSubsidiariesFound: 'No subsidiaries found',
noSubsidiariesFoundDescription: 'Add the subsidiary in NetSuite and sync the connection again.',
import: {
expenseCategories: `Expense categories`,
expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expenseCategories: `Expense categories`,
expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`,
expenseCategories: 'Expense categories',
expenseCategoriesDescription: 'NetSuite expense categories import into Expensify as categories.',

importFields: {
departments: 'Departments',
classes: 'Classes',
locations: 'Locations',
customers: 'Customers',
jobs: 'Projects (jobs)',
},
importTaxDescription: 'Import tax groups from NetSuite',
importCustomFields: {
customSegments: 'Custom segments/records',
customLists: 'Custom lists',
},
},
},
intacct: {
sageIntacctSetup: 'Sage Intacct setup',
Expand Down Expand Up @@ -2609,6 +2625,7 @@ export default {
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'Not imported',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported as report fields',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default',
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
},
disconnectPrompt: (currentIntegration?: ConnectionName): string => {
const integrationName =
Expand Down
17 changes: 17 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,22 @@ export default {
noItemsFoundDescription: 'Añade artículos de factura en NetSuite y sincroniza la conexión de nuevo.',
noSubsidiariesFound: 'No se ha encontrado subsidiarias',
noSubsidiariesFoundDescription: 'Añade la subsidiaria en NetSuite y sincroniza de nuevo la conexión.',
import: {
expenseCategories: 'Categorías de gastos',
expenseCategoriesDescription: 'Las categorías de gastos de NetSuite se importan a Expensify como categorías.',
importFields: {
departments: 'Departamentos',
classes: 'Clases',
locations: 'Ubicaciones',
customers: 'Clientes',
jobs: 'Proyectos (trabajos)',
},
importTaxDescription: 'Importar grupos de impuestos desde NetSuite',
importCustomFields: {
customSegments: 'Segmentos/registros personalizado',
customLists: 'Listas personalizado',
},
},
},
intacct: {
sageIntacctSetup: 'Sage Intacct configuración',
Expand Down Expand Up @@ -2581,6 +2597,7 @@ export default {
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'No importado',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'No importado',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default',
},
disconnectPrompt: (currentIntegration?: ConnectionName): string => {
const integrationName =
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ const WRITE_COMMANDS = {
UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY: 'UpdateSubscriptionAddNewUsersAutomatically',
UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize',
UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary',
UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION: 'UpdateNetSuiteSyncTaxConfiguration',
UPDATE_NETSUITE_EXPORTER: 'UpdateNetSuiteExporter',
UPDATE_NETSUITE_EXPORT_DATE: 'UpdateNetSuiteExportDate',
UPDATE_NETSUITE_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateNetSuiteReimbursableExpensesExportDestination',
Expand Down Expand Up @@ -479,6 +480,7 @@ type WriteCommandParameters = {

// Netsuite parameters
[WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams;
[WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteGenericTypeParams<'enabled', boolean>;
[WRITE_COMMANDS.UPDATE_NETSUITE_EXPORTER]: Parameters.UpdateNetSuiteGenericTypeParams<'email', string>;
[WRITE_COMMANDS.UPDATE_NETSUITE_EXPORT_DATE]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf<typeof CONST.NETSUITE_EXPORT_DATE>>;
[WRITE_COMMANDS.UPDATE_NETSUITE_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf<typeof CONST.NETSUITE_EXPORT_DESTINATION>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
require<ReactComponentModule>('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default,

[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/export/NetSuitePreferredExporterSelectPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR,
SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_DATE_SELECT,
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_PREFERRED_EXPORTER_SELECT.route},
[SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_BILL_PAYMENT_ACCOUNT_SELECTOR.route},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.route},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: {
path: ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.route,
},
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: {
policyID: string;
};
Expand Down
12 changes: 12 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,17 @@ function getNetSuiteTaxAccountOptions(policy: Policy | undefined, subsidiaryCoun
}));
}

function isSyncTaxEnabled(policy: Policy | undefined): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is trying to do the same thing as canUseTaxNetSuite below - can we just reuse that method instead? Also the name is misleading here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay I received the same feedback from @shubham1206agra. This method is not dependent on canUseNetSuiteUSATax (!!betas?.includes(CONST.BETAS.NETSUITE_USA_TAX)). Hence I created a new one. If the logic is the same I'll use that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated to use canUseNetSuiteUSATax

const netSuiteConfg = policy?.connections?.netsuite?.options?.config;
const {subsidiaryList} = policy?.connections?.netsuite?.options?.data ?? {};
if (!netSuiteConfg || !subsidiaryList) {
return false;
}

const selectedSubsidiary = (subsidiaryList ?? []).find((subsidiary) => subsidiary.internalID === netSuiteConfg?.subsidiaryID);
return !!selectedSubsidiary?.country && CONST.NETSUITE_TAX_COUNTRIES.includes(selectedSubsidiary?.country);
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
}

function canUseTaxNetSuite(canUseNetSuiteUSATax?: boolean, subsidiaryCountry?: string) {
return !!canUseNetSuiteUSATax || CONST.NETSUITE_TAX_COUNTRIES.includes(subsidiaryCountry ?? '');
}
Expand Down Expand Up @@ -652,6 +663,7 @@ export {
navigateWhenEnableFeature,
getIntegrationLastSuccessfulDate,
getCurrentConnectionName,
isSyncTaxEnabled,
};

export type {MemberEmailsToAccountIDs};
87 changes: 87 additions & 0 deletions src/libs/actions/connections/NetSuiteCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,92 @@ function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryPar
API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY, params, onyxData);
}

function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: boolean) {
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
syncOptions: {
syncTax: isSyncTaxEnabled,
},
// pendingFields: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is throwing type errors due to nesting. Will fix this in upcoming PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, but then can we make the comment more descriptive than simply "Fixing in the future PR"?

// syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
// },
errorFields: {
syncTax: null,
},
},
},
},
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
syncOptions: {
syncTax: isSyncTaxEnabled,
},
// pendingFields: {
// syncTax: null
// },
errorFields: {
syncTax: null,
},
},
},
},
},
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
syncOptions: {
syncTax: !isSyncTaxEnabled,
},
// pendingFields: {
// syncTax: null,
// },
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
errorFields: {
syncTax: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
},
},
},
},
],
};

const params = {
policyID,
enabled: isSyncTaxEnabled,
};
API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION, params, onyxData);
}

function updateNetSuiteExporter(policyID: string, exporter: string, oldExporter: string) {
const onyxData = updateNetSuiteOnyxData(policyID, CONST.NETSUITE_CONFIG.EXPORTER, exporter, oldExporter);

Expand Down Expand Up @@ -345,6 +431,7 @@ function updateNetSuiteExportToNextOpenPeriod(policyID: string, value: boolean,

export {
updateNetSuiteSubsidiary,
updateNetSuiteSyncTaxConfiguration,
updateNetSuiteExporter,
updateNetSuiteExportDate,
updateNetSuiteReimbursableExpensesExportDestination,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
const {translate} = useLocalize();
const {canUseReportFieldsFeature, canUseWorkspaceFeeds} = usePermissions();
const hasAccountingConnection = !!policy?.areConnectionsEnabled && !isEmptyObject(policy?.connections);
const isSyncTaxEnabled = !!policy?.connections?.quickbooksOnline?.config?.syncTax || !!policy?.connections?.xero?.config?.importTaxRates;
const isSyncTaxEnabled =
!!policy?.connections?.quickbooksOnline?.config?.syncTax ||
!!policy?.connections?.xero?.config?.importTaxRates ||
!!policy?.connections?.netsuite?.options?.config?.syncOptions?.syncTax;
const policyID = policy?.id ?? '';
// @ts-expect-error a new props will be added during feed api implementation
const workspaceAccountID = policy?.workspaceAccountID ?? '';
Expand Down
6 changes: 3 additions & 3 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ function accountingIntegrationData(
integrationToDisconnect={integrationToDisconnect}
/>
),
onImportPagePress: () => {},
onExportPagePress: () => {},
onImportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID)),
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)),
onAdvancedPagePress: () => {},
};
case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT:
Expand All @@ -129,7 +129,7 @@ function accountingIntegrationData(
/>
),
onImportPagePress: () => {},
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.getRoute(policyID)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think during one of the merges this navigate got messed up. The current main code redirects Sage Export link to NetSuite. Added a fix here.

onExportPagePress: () => {},
onAdvancedPagePress: () => {},
};
default:
Expand Down
Loading
Loading