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

Offline and error patterns in NetSuite integration #46667

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9907ba5
fix error placement in subsidiary selection
war-in Jul 30, 2024
3135e77
fix error in mappings
war-in Jul 30, 2024
f21036f
fix error in mappings
war-in Jul 30, 2024
a457a37
fix errors in import page
war-in Jul 30, 2024
1b4b9fc
update export page
war-in Jul 30, 2024
d112600
update invoice config pages
war-in Jul 30, 2024
9bfabdc
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Jul 31, 2024
9776986
add errors in export -> tax posting account
war-in Jul 31, 2024
cf2d602
move sync options errors and pending fields to the top
war-in Jul 31, 2024
7df165c
use universal pending action function on advanced page
war-in Jul 31, 2024
6c587e5
use proper function
war-in Jul 31, 2024
f7a0e06
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 1, 2024
622b168
after-merge fixes
war-in Aug 1, 2024
c3ee944
show list empty component in the middle
war-in Aug 1, 2024
79277ec
show list empty component in the middle
war-in Aug 1, 2024
22c2b86
propagate errors from (non)reimbursable expenses
war-in Aug 1, 2024
0582270
propagate errors from entire export page
war-in Aug 1, 2024
8219f29
update import mappings
war-in Aug 2, 2024
0f0b941
show RBR for import tax toggle
war-in Aug 2, 2024
3c16601
fix lint
war-in Aug 2, 2024
5a3419a
add errors to custom fields
war-in Aug 5, 2024
1724a48
fix pending action for custom fields
war-in Aug 5, 2024
e925a95
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 5, 2024
3112a48
unify netsuite commands
war-in Aug 5, 2024
bd14365
use correct pending field in custom field edit
war-in Aug 6, 2024
df2bfa0
propagate custom fields settings to PolicyAccountingPage
war-in Aug 6, 2024
43778fd
add errorRowStyles to remaining screens
war-in Aug 6, 2024
401707c
revert max request retries
war-in Aug 6, 2024
a3199e5
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 6, 2024
edfd75c
use unique keys for custom field page
war-in Aug 6, 2024
e773aca
address review comments
war-in Aug 7, 2024
86a6af3
fix remaining pendingActions
war-in Aug 7, 2024
fd6c017
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 7, 2024
dfcc016
remove checking pending action for optimistic data
war-in Aug 12, 2024
b44022a
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 20, 2024
1db511e
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 21, 2024
2c9e2e0
post-merge fixes
war-in Aug 21, 2024
5e64fc5
fix prettier
war-in Aug 21, 2024
2b1acad
fix strikethrough
war-in Aug 21, 2024
44cb1ff
fix sync options onyx data
war-in Aug 21, 2024
ce8b057
do not optimistically remove segment/list field
war-in Aug 21, 2024
da772ec
fix disabled custom field edit
war-in Aug 23, 2024
c10ee9a
fallback to the previous value
war-in Aug 26, 2024
bf7b49a
Merge branch 'refs/heads/main' into war-in/offline-error-patterns-net…
war-in Aug 29, 2024
bdbe3fa
fix not working `Import customers` toggle
war-in Aug 29, 2024
e95b465
fix lint
war-in Aug 30, 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
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ const CONST = {
},
CUSTOM_SEGMENT_FIELDS: ['segmentName', 'internalID', 'scriptID', 'mapping'],
CUSTOM_LIST_FIELDS: ['listName', 'internalID', 'transactionFieldID', 'mapping'],
CUSTOM_FORM_ID_ENABLED: 'enabled',
CUSTOM_FORM_ID_TYPE: {
REIMBURSABLE: 'reimbursable',
NON_REIMBURSABLE: 'nonReimbursable',
Expand Down
26 changes: 25 additions & 1 deletion src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import type {
Transaction,
} from '@src/types/onyx';
import type {Errors} from '@src/types/onyx/OnyxCommon';
import type {Attributes, CompanyAddress, CustomUnit, Rate, TaxRate, Unit} from '@src/types/onyx/Policy';
import type {Attributes, CompanyAddress, CustomUnit, NetSuiteCustomList, NetSuiteCustomSegment, Rate, TaxRate, Unit} from '@src/types/onyx/Policy';
import type {OnyxData} from '@src/types/onyx/Request';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import {buildOptimisticPolicyCategories} from './Category';
Expand Down Expand Up @@ -602,6 +602,28 @@ function clearNetSuiteErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {netsuite: {options: {config: {errorFields: {[fieldName]: null}}}}}});
}

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

function removeNetSuiteCustomFieldByIndex(allRecords: NetSuiteCustomSegment[] | NetSuiteCustomList[], policyID: string, importCustomField: string, valueIndex: number) {
// We allow multiple custom list records with the same internalID. Hence it is safe to remove by index.
const filteredRecords = allRecords.filter((_, index) => index !== Number(valueIndex));
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
connections: {
netsuite: {
options: {
config: {
syncOptions: {
[importCustomField]: filteredRecords,
},
},
},
},
},
});
}

function clearSageIntacctErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {intacct: {config: {errorFields: {[fieldName]: null}}}}});
}
Expand Down Expand Up @@ -3798,7 +3820,9 @@ export {
clearXeroErrorField,
clearSageIntacctErrorField,
clearNetSuiteErrorField,
clearNetSuitePendingField,
clearNetSuiteAutoSyncErrorField,
removeNetSuiteCustomFieldByIndex,
clearWorkspaceReimbursementErrors,
setWorkspaceCurrencyDefault,
setForeignCurrencyDefault,
Expand Down
161 changes: 98 additions & 63 deletions src/libs/actions/connections/NetSuiteCommands.ts

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const styles = useThemeStyles();
const {translate, datetimeToRelative: getDatetimeToRelative} = useLocalize();
const {isOffline} = useNetwork();
const {canUseNetSuiteUSATax} = usePermissions();
const {windowWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
Expand Down Expand Up @@ -232,7 +233,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
}
const shouldShowSynchronizationError = !!synchronizationError;
const shouldHideConfigurationOptions = isConnectionUnverified(policy, connectedIntegration);
const integrationData = getAccountingIntegrationData(connectedIntegration, policyID, translate, policy);
const integrationData = getAccountingIntegrationData(connectedIntegration, policyID, translate, policy, undefined, canUseNetSuiteUSATax);
const iconProps = integrationData?.icon ? {icon: integrationData.icon, iconType: CONST.ICON_TYPE_AVATAR} : {};

const configurationOptions = [
Expand Down Expand Up @@ -342,6 +343,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
isOffline,
startIntegrationFlow,
popoverAnchorRefs,
canUseNetSuiteUSATax,
]);

const otherIntegrationsItems = useMemo(() => {
Expand Down Expand Up @@ -429,6 +431,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
<OfflineWithFeedback
pendingAction={menuItem.pendingAction}
key={menuItem.title}
shouldDisableStrikeThrough
>
<MenuItem
brickRoadIndicator={menuItem.brickRoadIndicator}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useMemo} from 'react';
import {View} from 'react-native';
import BlockingView from '@components/BlockingViews/BlockingView';
import * as Illustrations from '@components/Icon/Illustrations';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import RadioListItem from '@components/SelectionList/RadioListItem';
import SelectionScreen from '@components/SelectionScreen';
import type {SelectorType} from '@components/SelectionScreen';
Expand All @@ -11,6 +11,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {updateNetSuiteSubsidiary} from '@libs/actions/connections/NetSuiteCommands';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import {settingsPendingAction} from '@libs/PolicyUtils';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import variables from '@styles/variables';
Expand Down Expand Up @@ -70,15 +71,11 @@ function NetSuiteSubsidiarySelector({policy}: WithPolicyConnectionsProps) {

const listHeaderComponent = useMemo(
() => (
<OfflineWithFeedback
errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SUBSIDIARY)}
errorRowStyles={[styles.ph5, styles.mt2, styles.mb4]}
onClose={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SUBSIDIARY)}
>
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.netsuite.subsidiarySelectDescription')}</Text>
</OfflineWithFeedback>
<View style={[styles.pb2, styles.ph5]}>
<Text style={[styles.pb2, styles.textNormal]}>{translate('workspace.netsuite.subsidiarySelectDescription')}</Text>
</View>
),
[netsuiteConfig, styles.ph5, styles.mt2, styles.pb5, styles.mb4, translate, policyID],
[styles.pb2, styles.ph5, styles.textNormal, translate],
);

return (
Expand All @@ -96,6 +93,10 @@ function NetSuiteSubsidiarySelector({policy}: WithPolicyConnectionsProps) {
onBackButtonPress={() => Navigation.goBack()}
title="workspace.netsuite.subsidiary"
listEmptyContent={listEmptyContent}
pendingAction={settingsPendingAction([CONST.NETSUITE_CONFIG.SUBSIDIARY], netsuiteConfig?.pendingFields)}
errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SUBSIDIARY)}
errorRowStyles={[styles.ph5, styles.pv3]}
onClose={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SUBSIDIARY)}
/>
);
}
Expand Down
Loading
Loading