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

Sage intacct offline error patterns #47079

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
155 changes: 110 additions & 45 deletions src/libs/actions/connections/SageIntacct.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function SageIntacctEntityPage({policy}: WithPolicyProps) {
});

const saveSelection = ({keyForList}: ListItem) => {
updateSageIntacctEntity(policyID, keyForList ?? '');
updateSageIntacctEntity(policyID, keyForList ?? '', entityID);
Navigation.goBack();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function SageIntacctPaymentAccountPage({policy}: WithPolicyConnectionsProps) {
const updateDefaultVendor = useCallback(
({value}: SelectorType) => {
if (value !== config?.sync?.reimbursementAccountID) {
updateSageIntacctSyncReimbursementAccountID(policyID, value);
updateSageIntacctSyncReimbursementAccountID(policyID, value, config?.sync?.reimbursementAccountID);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ADVANCED.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function SageIntacctDatePage({policy}: WithPolicyProps) {
const selectExportDate = useCallback(
(row: MenuListItem) => {
if (row.value !== exportConfig?.exportDate) {
updateSageIntacctExportDate(policyID, row.value);
updateSageIntacctExportDate(policyID, row.value, exportConfig?.exportDate);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function SageIntacctDefaultVendorPage({route}: SageIntacctDefaultVendorPageProps
const updateDefaultVendor = useCallback(
({value}: SelectorType) => {
if (value !== defaultVendor) {
updateSageIntacctDefaultVendor(policyID, settingName, value);
updateSageIntacctDefaultVendor(policyID, settingName, value, defaultVendor);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function SageIntacctNonReimbursableCreditCardAccountPage({policy}: WithPolicyCon
const updateCreditCardAccount = useCallback(
({value}: SelectorType) => {
if (value !== exportConfig?.nonReimbursableAccount) {
updateSageIntacctNonreimbursableExpensesExportAccount(policyID, value);
updateSageIntacctNonreimbursableExpensesExportAccount(policyID, value, exportConfig?.nonReimbursableAccount);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) {
if (row.value === config?.export.nonReimbursable) {
return;
}
updateSageIntacctNonreimbursableExpensesExportDestination(policyID, row.value);
updateSageIntacctNonreimbursableExpensesExportDestination(policyID, row.value, config?.export.nonReimbursable);
},
[config?.export.nonReimbursable, policyID],
);
Expand Down Expand Up @@ -152,7 +152,12 @@ function SageIntacctNonReimbursableExpensesPage({policy}: WithPolicyProps) {
isActive={!!config?.export.nonReimbursableCreditCardChargeDefaultVendor}
onToggle={(enabled) => {
const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : '';
updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR, vendor);
updateSageIntacctDefaultVendor(
policyID,
CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR,
vendor,
config?.export.nonReimbursableCreditCardChargeDefaultVendor,
);
}}
wrapperStyle={[styles.ph5, styles.pv3]}
pendingAction={settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR], config?.pendingFields)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function SageIntacctPreferredExporterPage({policy}: WithPolicyProps) {
const selectExporter = useCallback(
(row: CardListItem) => {
if (row.value !== exportConfiguration?.exporter) {
updateSageIntacctExporter(policyID, row.value);
updateSageIntacctExporter(policyID, row.value, exportConfiguration?.exporter);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) {
const selectReimbursableDestination = useCallback(
(row: MenuListItem) => {
if (row.value !== reimbursable) {
updateSageIntacctReimbursableExpensesExportDestination(policyID, row.value);
updateSageIntacctReimbursableExpensesExportDestination(policyID, row.value, reimbursable);
}
if (row.value === CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL) {
// Employee default mapping value is not allowed when expense type is VENDOR_BILL, so we have to change mapping value to Tag
Expand Down Expand Up @@ -124,7 +124,7 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) {
isActive={!!reimbursableExpenseReportDefaultVendor}
onToggle={(enabled) => {
const vendor = enabled ? policy?.connections?.intacct?.data?.vendors?.[0].id ?? '' : '';
updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor);
updateSageIntacctDefaultVendor(policyID, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR, vendor, reimbursableExpenseReportDefaultVendor);
}}
pendingAction={settingsPendingAction([CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR], config?.pendingFields)}
errors={ErrorUtils.getLatestErrorField(config, CONST.SAGE_INTACCT_CONFIG.REIMBURSABLE_VENDOR)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import TextInput from '@components/TextInput';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import {clearSageIntacctErrorField, editSageIntacctUserDimensions, removeSageIntacctUserDimensions} from '@libs/actions/connections/SageIntacct';
import {
clearSageIntacctErrorField,
clearSageIntacctPendingField,
editSageIntacctUserDimensions,
removeSageIntacctUserDimensions,
removeSageIntacctUserDimensionsByName,
} from '@libs/actions/connections/SageIntacct';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -89,7 +95,15 @@ function SageIntacctEditUserDimensionsPage({route}: SageIntacctEditUserDimension
pendingAction={settingsPendingAction([`${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`], config?.pendingFields)}
errors={ErrorUtils.getLatestErrorField(config ?? {}, `${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`)}
errorRowStyles={[styles.pb3]}
onClose={() => clearSageIntacctErrorField(policyID, `${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`)}
onClose={() => {
clearSageIntacctErrorField(policyID, `${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`);
const pendingAction = settingsPendingAction([`${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`], config?.pendingFields);
if (pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
removeSageIntacctUserDimensionsByName(userDimensions ?? [], policyID, editedUserDimensionName);
Navigation.goBack();
}
clearSageIntacctPendingField(policyID, `${CONST.SAGE_INTACCT_CONFIG.DIMENSION_PREFIX}${editedUserDimensionName}`);
}}
>
<View style={[styles.mb4]}>
<InputWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ function SageIntacctMappingsTypePage({route}: SageIntacctMappingsTypePageProps)

const updateMapping = useCallback(
({value}: SelectorType) => {
updateSageIntacctMappingValue(policyID, mappingName, value as SageIntacctMappingValue);
updateSageIntacctMappingValue(policyID, mappingName, value as SageIntacctMappingValue, mappings?.[mappingName]);
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_TOGGLE_MAPPINGS.getRoute(policyID, mappingName));
},
[mappingName, policyID],
[mappingName, policyID, mappings],
);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {StackScreenProps} from '@react-navigation/stack';
import {Str} from 'expensify-common';
import React, {useState} from 'react';
import React from 'react';
import ConnectionLayout from '@components/ConnectionLayout';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
Expand Down Expand Up @@ -54,8 +54,7 @@ function SageIntacctToggleMappingsPage({route}: SageIntacctToggleMappingsPagePro

const config = policy?.connections?.intacct?.config;
const translationKeys = getDisplayTypeTranslationKeys(config?.mappings?.[mappingName]);
const [importMapping, setImportMapping] = useState(config?.mappings?.[mappingName] && config?.mappings?.[mappingName] !== CONST.SAGE_INTACCT_MAPPING_VALUE.NONE);

const isImportMappingEnable = config?.mappings?.[mappingName] !== CONST.SAGE_INTACCT_MAPPING_VALUE.NONE;
return (
<ConnectionLayout
displayName={SageIntacctToggleMappingsPage.displayName}
Expand All @@ -78,21 +77,16 @@ function SageIntacctToggleMappingsPage({route}: SageIntacctToggleMappingsPagePro
switchAccessibilityLabel={`${translate('workspace.accounting.import')} ${translate('workspace.intacct.mappingTitle', mappingName)}`}
shouldPlaceSubtitleBelowSwitch
wrapperStyle={[styles.mv3, styles.mh5]}
isActive={importMapping ?? false}
onToggle={() => {
if (importMapping) {
setImportMapping(false);
updateSageIntacctMappingValue(policyID, mappingName, CONST.SAGE_INTACCT_MAPPING_VALUE.NONE);
} else {
setImportMapping(true);
updateSageIntacctMappingValue(policyID, mappingName, CONST.SAGE_INTACCT_MAPPING_VALUE.TAG);
}
isActive={isImportMappingEnable}
onToggle={(enabled) => {
const mappingValue = enabled ? CONST.SAGE_INTACCT_MAPPING_VALUE.TAG : CONST.SAGE_INTACCT_MAPPING_VALUE.NONE;
updateSageIntacctMappingValue(policyID, mappingName, mappingValue, config?.mappings?.[mappingName]);
}}
pendingAction={settingsPendingAction([mappingName], config?.pendingFields)}
errors={ErrorUtils.getLatestErrorField(config ?? {}, mappingName)}
onCloseError={() => clearSageIntacctErrorField(policyID, mappingName)}
/>
{importMapping && (
{isImportMappingEnable && (
<OfflineWithFeedback pendingAction={settingsPendingAction([mappingName], config?.pendingFields)}>
<MenuItemWithTopDescription
title={translationKeys?.titleKey ? translate(translationKeys?.titleKey) : undefined}
Expand Down
Loading