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]: Top-level Subsidiary selection #44038

Merged
merged 59 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
747fe19
Revert "Merge pull request #42965 from suneox/40767-handle-edit-last-…
mananjadhav Jun 6, 2024
8c0912a
Reapply "Merge pull request #42965 from suneox/40767-handle-edit-last…
mananjadhav Jun 6, 2024
2ab267e
Merge branch 'main' of github.com:mananjadhav/App
mananjadhav Jun 6, 2024
b335e64
Merge branch 'main' of github.com:mananjadhav/App
mananjadhav Jun 11, 2024
e8c4fb5
Merge branch 'main' of github.com:mananjadhav/App
mananjadhav Jun 19, 2024
5224cb9
feat: net suite setup
mananjadhav Jun 19, 2024
f288173
feat: navigation types
mananjadhav Jun 19, 2024
b51c85a
feat: page setup with options
mananjadhav Jun 19, 2024
95089ff
fix: default selection
mananjadhav Jun 19, 2024
424495d
fix: routing
mananjadhav Jun 19, 2024
c8185c8
feat: show selected subsidiary
mananjadhav Jun 19, 2024
007d762
style: lint fixes
mananjadhav Jun 19, 2024
577dc58
refactor: remove console.log
mananjadhav Jun 19, 2024
68c865c
feat: added write command
mananjadhav Jun 19, 2024
855c930
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 20, 2024
2a4add9
refactor: rename type
mananjadhav Jun 20, 2024
4461ff2
refactor: lint fixes
mananjadhav Jun 20, 2024
6fc7b09
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 20, 2024
88ec924
feat: added icon and es content
mananjadhav Jun 20, 2024
d563a73
fix: added fallback
mananjadhav Jun 20, 2024
208b4b9
refactor: rename net_suite identifier
mananjadhav Jun 20, 2024
bd7973a
feat: added api types
mananjadhav Jun 20, 2024
0faf015
feat: modify optimistic data
mananjadhav Jun 20, 2024
d66f59d
feat: added api call
mananjadhav Jun 20, 2024
0664aa6
fix: param name
mananjadhav Jun 20, 2024
8fa3a78
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 20, 2024
8c1c8d6
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 20, 2024
f7252bb
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 21, 2024
c47d6de
refactor: update id handling
mananjadhav Jun 21, 2024
ada6d00
fix: added id in params
mananjadhav Jun 21, 2024
a172a5b
fix: added comment
mananjadhav Jun 21, 2024
f81860b
fix: added pending action
mananjadhav Jun 21, 2024
bc1365d
fix: added error handling
mananjadhav Jun 21, 2024
26903ce
style: lint fixes
mananjadhav Jun 21, 2024
5a6bf06
feat: nested scrollview handling
mananjadhav Jun 21, 2024
521b93e
style: lint fixes
mananjadhav Jun 21, 2024
dd3d8a5
refactor: error handling
mananjadhav Jun 21, 2024
f8865bf
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 21, 2024
aeba073
style: lint fixes
mananjadhav Jun 22, 2024
9b77ae8
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 22, 2024
baf05f2
refactor: use withpolicyconnections
mananjadhav Jun 22, 2024
c71d566
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 24, 2024
0116857
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 24, 2024
66159f1
refactor: update args for error field
mananjadhav Jun 24, 2024
414b116
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-su…
mananjadhav Jun 25, 2024
d2666d8
refactor: rename imports and files
mananjadhav Jun 25, 2024
1132bb0
fix: go back
mananjadhav Jun 25, 2024
16ee3e2
refactor: run prettier
mananjadhav Jun 25, 2024
0bb8d5a
refactor: use selectionscreen
mananjadhav Jun 25, 2024
a977826
refactor: api call fixes
mananjadhav Jun 25, 2024
0fe7e06
refactor: import lint error
mananjadhav Jun 25, 2024
ac62d2f
refactor: rename methods and error conditions
mananjadhav Jun 25, 2024
e1f9e11
fix: Spanish translation
mananjadhav Jun 25, 2024
e0b782a
refactor: added fallback
mananjadhav Jun 25, 2024
bb8f94b
fix: rollback unwanted prop
mananjadhav Jun 25, 2024
2a9b743
fix: remove extra space
mananjadhav Jun 25, 2024
6be111f
fix: netsuite name
mananjadhav Jun 25, 2024
01cac87
refactor: remove unwanted types
mananjadhav Jun 25, 2024
fc16c01
fix: lint errors
mananjadhav Jun 25, 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
57 changes: 57 additions & 0 deletions assets/images/integrationicons/netsuite-icon-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,10 @@ const CONST = {
},
},

NETSUITE_CONFIG: {
SUBSIDIARY: 'subsidiary',
},

QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: {
VENDOR_BILL: 'bill',
CHECK: 'check',
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const,
},
POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR: {
route: 'settings/workspaces/:policyID/accounting/net-suite/subsidiary-selector',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/net-suite/subsidiary-selector` as const,
},
RESTRICTED_ACTION: {
route: 'restricted-action/workspace/:policyID',
getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` 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 @@ -269,6 +269,7 @@ const SCREENS = {
XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select',
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',
},
INITIAL: 'Workspace_Initial',
PROFILE: 'Workspace_Profile',
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import ImageCropCircleMask from '@assets/images/image-crop-circle-mask.svg';
import ImageCropSquareMask from '@assets/images/image-crop-square-mask.svg';
import Inbox from '@assets/images/inbox.svg';
import Info from '@assets/images/info.svg';
import NetSuiteSquare from '@assets/images/integrationicons/netsuite-icon-square.svg';
import QBOSquare from '@assets/images/integrationicons/qbo-icon-square.svg';
import XeroSquare from '@assets/images/integrationicons/xero-icon-square.svg';
import InvoiceGeneric from '@assets/images/invoice-generic.svg';
Expand Down Expand Up @@ -366,4 +367,5 @@ export {
Clear,
CheckCircle,
CheckmarkCircle,
NetSuiteSquare,
};
7 changes: 7 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,12 @@ export default {
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: 'Add the account in Xero and sync the connection again.',
},
netsuite: {
subsidiary: 'Subsidiary',
subsidiarySelectDescription: "Choose the subsidiary in NetSuite that you'd like to import data from.",
noSubsidiariesFound: 'No subsidiaries found',
noSubsidiariesFoundDescription: 'Add the subsidiary in NetSuite and sync the connection again.',
},
type: {
free: 'Free',
control: 'Control',
Expand Down Expand Up @@ -2409,6 +2415,7 @@ export default {
subtitle: 'Connect to your accounting system to code transactions with your chart of accounts, auto-match payments, and keep your finances in sync.',
qbo: 'Quickbooks Online',
xero: 'Xero',
netsuite: 'NetSuite',
setup: 'Connect',
lastSync: 'Last synced just now',
import: 'Import',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,12 @@ export default {
noAccountsFound: 'No se ha encontrado ninguna cuenta',
noAccountsFoundDescription: 'Añade la cuenta en Xero y sincroniza de nuevo la conexión.',
},
netsuite: {
subsidiary: 'Subsidiaria',
subsidiarySelectDescription: 'Elige la subsidiaria de NetSuite de la que deseas importar datos.',
noSubsidiariesFound: 'No se ha encontrado subsidiarias',
noSubsidiariesFoundDescription: 'Añade la subsidiaria en NetSuite y sincroniza de nuevo la conexión.',
},
type: {
free: 'Gratis',
control: 'Control',
Expand Down Expand Up @@ -2413,6 +2419,7 @@ export default {
subtitle: 'Conecta a tu sistema de contabilidad para codificar transacciones con tu plan de cuentas, auto-cotejar pagos, y mantener tus finanzas sincronizadas.',
qbo: 'Quickbooks Online',
xero: 'Xero',
netsuite: 'NetSuite',
setup: 'Configurar',
lastSync: 'Recién sincronizado',
import: 'Importar',
Expand Down
7 changes: 7 additions & 0 deletions src/libs/API/parameters/UpdateNetSuiteSubsidiaryParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type UpdateNetSuiteSubsidiaryParams = {
policyID: string;
subsidiary: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to pass authToken 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.

I don't think it's necessary to pass authToken.

subsidiaryID: string;
};

export default UpdateNetSuiteSubsidiaryParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,4 @@ export type {default as UpdateSubscriptionAutoRenewParams} from './UpdateSubscri
export type {default as UpdateSubscriptionAddNewUsersAutomaticallyParams} from './UpdateSubscriptionAddNewUsersAutomaticallyParams';
export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams';
export type {default as UpdateSubscriptionSizeParams} from './UpdateSubscriptionSizeParams';
export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams';
4 changes: 4 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ const WRITE_COMMANDS = {
UPDATE_SUBSCRIPTION_AUTO_RENEW: 'UpdateSubscriptionAutoRenew',
UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY: 'UpdateSubscriptionAddNewUsersAutomatically',
UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize',
UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary',
} as const;

type WriteCommand = ValueOf<typeof WRITE_COMMANDS>;
Expand Down Expand Up @@ -455,6 +456,9 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_AUTO_RENEW]: Parameters.UpdateSubscriptionAutoRenewParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_ADD_NEW_USERS_AUTOMATICALLY]: Parameters.UpdateSubscriptionAddNewUsersAutomaticallyParams;
[WRITE_COMMANDS.UPDATE_SUBSCRIPTION_SIZE]: Parameters.UpdateSubscriptionSizeParams;

// Netsuite parameters
[WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams;
};

const READ_COMMANDS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
require<ReactComponentModule>('../../../../pages/workspace/accounting/xero/export/XeroPreferredExporterSelectPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: () =>
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.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require<ReactComponentModule>('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default,
[SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require<ReactComponentModule>('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default,
[SCREENS.WORKSPACE.TAX_EDIT]: () => require<ReactComponentModule>('../../../../pages/workspace/taxes/WorkspaceEditTaxPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR,
SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR,
],
[SCREENS.WORKSPACE.TAXES]: [
SCREENS.WORKSPACE.TAXES_SETTINGS,
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 @@ -333,6 +333,7 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.ACCOUNTING.XERO_INVOICE_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_INVOICE_SELECTOR.route},
[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.DESCRIPTION]: {
path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.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 @@ -385,6 +385,9 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {
policyID: string;
};
[SCREENS.GET_ASSISTANCE]: {
backTo: Routes;
};
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ function clearXeroErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {xero: {config: {errorFields: {[fieldName]: null}}}}});
}

function clearNetSuiteErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {netsuite: {options: {config: {errorFields: {[fieldName]: null}}}}}});
}

function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>, reimburserEmail: string) {
const policy = getPolicy(policyID);

Expand Down Expand Up @@ -3002,6 +3006,7 @@ export {
createDraftWorkspace,
buildPolicyData,
createPolicyExpenseChats,
clearNetSuiteErrorField,
};

export type {NewCustomUnit};
99 changes: 99 additions & 0 deletions src/libs/actions/connections/NetSuiteCommands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import {WRITE_COMMANDS} from '@libs/API/types';
import * as ErrorUtils from '@libs/ErrorUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxData} from '@src/types/onyx/Request';

type SubsidiaryParam = {
subsidiaryID: string;
subsidiary: string;
};

function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryParam, oldSubsidiary: SubsidiaryParam) {
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
subsidiary: newSubsidiary.subsidiary,
subsidiaryID: newSubsidiary.subsidiaryID,
pendingFields: {
subsidiary: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
subsidiary: null,
},
},
},
},
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
subsidiary: newSubsidiary.subsidiary,
subsidiaryID: newSubsidiary.subsidiaryID,
errorFields: {
subsidiary: null,
},
pendingFields: {
subsidiary: null,
},
},
},
},
},
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
netsuite: {
options: {
config: {
subsidiary: oldSubsidiary.subsidiary,
subsidiaryID: oldSubsidiary.subsidiaryID,
errorFields: {
subsidiary: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
pendingFields: {
subsidiary: null,
},
},
},
},
},
},
},
],
};

const params = {
policyID,
...newSubsidiary,
};
API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY, params, onyxData);
}

// We'll have more API calls in upcoming PRs
// eslint-disable-next-line import/prefer-default-export
export {updateNetSuiteSubsidiary};
Loading
Loading