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 2 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 @@ -769,4 +781,5 @@ export {
updateSageIntacctSyncReimbursedReports,
updateSageIntacctSyncReimbursementAccountID,
updateSageIntacctEntity,
changeMappingsValueFromDefaultToTag,
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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 @@ -49,10 +49,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 @@ -23,33 +23,44 @@ function SageIntacctMappingsTypePage({route}: SageIntacctMappingsTypePageProps)
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID ?? '-1'}`);
const policyID = policy?.id ?? '-1';
const mappings = policy?.connections?.intacct?.config?.mappings;
const exportConfig = policy?.connections?.intacct?.config?.export;

const selectionOptions = useMemo<SelectorType[]>(
() => [
{
const selectionOptions = useMemo<SelectorType[]>(() => {
const mappingOptions: SelectorType[] = [];
if (
mappingName !== CONST.SAGE_INTACCT_CONFIG.MAPPINGS.CUSTOMERS &&
mappingName !== CONST.SAGE_INTACCT_CONFIG.MAPPINGS.PROJECTS &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe we could build an array with those consts and check if it includes mapping 🤔
But there are only two of them so it's up to you :)

Suggested change
mappingName !== CONST.SAGE_INTACCT_CONFIG.MAPPINGS.CUSTOMERS &&
mappingName !== CONST.SAGE_INTACCT_CONFIG.MAPPINGS.PROJECTS &&
![CONST.SAGE_INTACCT_CONFIG.MAPPINGS.CUSTOMERS,
CONST.SAGE_INTACCT_CONFIG.MAPPINGS.PROJECTS
].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 @@ -92,7 +92,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);
}
}}
/>
Expand Down
Loading