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

Fix Customers and Projects to not have option as Sage Intacct Employee Default #46505

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
13 changes: 13 additions & 0 deletions src/libs/actions/connections/SageIntacct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ function updateSageIntacctMappingValue(policyID: string, mappingName: SageIntacc
);
}

function changeMappingsValueFromDefaultToTag(policyID: string, mappings?: SageIntacctMappingType) {
if (mappings?.departments === CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT) {
updateSageIntacctMappingValue(policyID, CONST.SAGE_INTACCT_CONFIG.MAPPINGS.DEPARTMENTS, CONST.SAGE_INTACCT_MAPPING_VALUE.TAG);
}
if (mappings?.classes === CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT) {
updateSageIntacctMappingValue(policyID, CONST.SAGE_INTACCT_CONFIG.MAPPINGS.CLASSES, CONST.SAGE_INTACCT_MAPPING_VALUE.TAG);
}
if (mappings?.locations === CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT) {
updateSageIntacctMappingValue(policyID, CONST.SAGE_INTACCT_CONFIG.MAPPINGS.LOCATIONS, CONST.SAGE_INTACCT_MAPPING_VALUE.TAG);
}
}

function updateSageIntacctSyncTaxConfiguration(policyID: string, enabled: boolean) {
const optimisticData: OnyxUpdate[] = [
{
Expand Down Expand Up @@ -771,4 +783,5 @@ export {
updateSageIntacctSyncReimbursedReports,
updateSageIntacctSyncReimbursementAccountID,
updateSageIntacctEntity,
changeMappingsValueFromDefaultToTag,
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Navigation from '@navigation/Navigation';
import type {WithPolicyProps} from '@pages/workspace/withPolicy';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
import {updateSageIntacctDefaultVendor, updateSageIntacctReimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct';
import {changeMappingsValueFromDefaultToTag, updateSageIntacctDefaultVendor, updateSageIntacctReimbursableExpensesExportDestination} from '@userActions/connections/SageIntacct';
import * as Policy from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -50,10 +50,12 @@ function SageIntacctReimbursableExpensesPage({policy}: WithPolicyProps) {
updateSageIntacctReimbursableExpensesExportDestination(policyID, row.value);
}
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
changeMappingsValueFromDefaultToTag(policyID, config?.mappings);
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXPORT.getRoute(policyID));
}
},
[reimbursable, policyID],
[reimbursable, policyID, config?.mappings],
);

const defaultVendor = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,45 @@ function SageIntacctMappingsTypePage({route}: SageIntacctMappingsTypePageProps)
const mappingName: SageIntacctMappingName = route.params.mapping;
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID ?? '-1'}`);
const policyID = policy?.id ?? '-1';

const {config} = policy?.connections?.intacct ?? {};
const {mappings, pendingFields} = config ?? {};
const {mappings, pendingFields, export: exportConfig} = config ?? {};

const selectionOptions = useMemo<SelectorType[]>(
() => [
{
const selectionOptions = useMemo<SelectorType[]>(() => {
const mappingOptions: SelectorType[] = [];
if (
!([CONST.SAGE_INTACCT_CONFIG.MAPPINGS.CUSTOMERS, CONST.SAGE_INTACCT_CONFIG.MAPPINGS.PROJECTS] as string[]).includes(mappingName) &&
exportConfig?.reimbursable !== CONST.SAGE_INTACCT_REIMBURSABLE_EXPENSE_TYPE.VENDOR_BILL
) {
mappingOptions.push({
value: CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT,
text: translate('workspace.intacct.employeeDefault'),
alternateText: translate('workspace.common.appliedOnExport'),
keyForList: CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT,
isSelected: mappings?.[mappingName] === CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT,
},
{
value: CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
text: translate('workspace.common.tags'),
alternateText: translate('workspace.common.lineItemLevel'),
keyForList: CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
isSelected: mappings?.[mappingName] === CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
},
{
value: CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
text: translate('workspace.common.reportFields'),
alternateText: translate('workspace.common.reportLevel'),
keyForList: CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
isSelected: mappings?.[mappingName] === CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
},
],
[mappingName, mappings, translate],
);
});
}
mappingOptions.push(
...[
{
value: CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
text: translate('workspace.common.tags'),
alternateText: translate('workspace.common.lineItemLevel'),
keyForList: CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
isSelected: mappings?.[mappingName] === CONST.SAGE_INTACCT_MAPPING_VALUE.TAG,
},
{
value: CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
text: translate('workspace.common.reportFields'),
alternateText: translate('workspace.common.reportLevel'),
keyForList: CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
isSelected: mappings?.[mappingName] === CONST.SAGE_INTACCT_MAPPING_VALUE.REPORT_FIELD,
},
],
);

return mappingOptions;
}, [exportConfig?.reimbursable, mappingName, mappings, translate]);

const updateMapping = useCallback(
({value}: SelectorType) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function SageIntacctToggleMappingsPage({route}: SageIntacctToggleMappingsPagePro
updateSageIntacctMappingValue(policyID, mappingName, CONST.SAGE_INTACCT_MAPPING_VALUE.NONE);
} else {
setImportMapping(true);
updateSageIntacctMappingValue(policyID, mappingName, CONST.SAGE_INTACCT_MAPPING_VALUE.DEFAULT);
updateSageIntacctMappingValue(policyID, mappingName, CONST.SAGE_INTACCT_MAPPING_VALUE.TAG);
}
}}
pendingAction={settingsPendingAction([mappingName], config?.pendingFields)}
Expand Down
Loading