diff --git a/package-lock.json b/package-lock.json index 9853eb8a..a90c9c90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32665,4 +32665,4 @@ "integrity": "sha512-GkPiJL8jifSrKReKaTZ5jkhrMEgXbXYC+IPo1iquBjayRa0q86w3Dipjn8b415jpitMExe9lV8iTsv8tk3DGag==" } } -} +} \ No newline at end of file diff --git a/src/app/si/dashboard/dashboard.component.ts b/src/app/si/dashboard/dashboard.component.ts index 90d57d01..f15f03c3 100644 --- a/src/app/si/dashboard/dashboard.component.ts +++ b/src/app/si/dashboard/dashboard.component.ts @@ -145,7 +145,7 @@ export class DashboardComponent implements OnInit { getEmployeeMappings() { const that = this; // TODO: remove promises and do with rxjs observables - if (that.configuration && that.configuration.auto_create_destination_entity) { + if (that.configuration && (that.configuration.auto_create_destination_entity || !that.configuration.reimbursable_expenses_object)) { that.currentState = onboardingStates.employeeMappingsDone; return; } else { diff --git a/src/app/si/settings/category-mappings/category-mappings-dialog/category-mappings-dialog.component.ts b/src/app/si/settings/category-mappings/category-mappings-dialog/category-mappings-dialog.component.ts index 497fe040..2dacb519 100644 --- a/src/app/si/settings/category-mappings/category-mappings-dialog/category-mappings-dialog.component.ts +++ b/src/app/si/settings/category-mappings/category-mappings-dialog/category-mappings-dialog.component.ts @@ -194,7 +194,7 @@ export class CategoryMappingsDialogComponent implements OnInit { showSeparateCCCField() { const that = this; const settings = that.configuration; - if (settings.corporate_credit_card_expenses_object && settings.corporate_credit_card_expenses_object !== 'EXPENSE_REPORT' && settings.reimbursable_expenses_object === 'EXPENSE_REPORT') { + if (settings.corporate_credit_card_expenses_object && settings.corporate_credit_card_expenses_object !== 'EXPENSE_REPORT' && !(settings.reimbursable_expenses_object === 'BILL' || settings.reimbursable_expenses_object === 'JOURNAL_ENTRY' )) { return true; } diff --git a/src/app/si/settings/general-mappings/general-mappings.component.ts b/src/app/si/settings/general-mappings/general-mappings.component.ts index 321ef678..67daddb6 100644 --- a/src/app/si/settings/general-mappings/general-mappings.component.ts +++ b/src/app/si/settings/general-mappings/general-mappings.component.ts @@ -57,7 +57,7 @@ export class GeneralMappingsComponent implements OnInit { const that = this; that.route.queryParams.subscribe(params => { - if (params.redirect_to_employee_mappings) { + if (params.redirect_to_employee_mappings && that.configuration.reimbursable_expenses_object) { setTimeout(() => { const destination = that.configuration.employee_field_mapping.toLowerCase().replace(/\b(\w)/g, s => s.toUpperCase()); that.snackBar.open(`To ensure successful export, map Fyle Employees to ${destination}s in SageIntacct`, '', { diff --git a/src/app/si/settings/sage-intacct-configurations/configuration/configuration-dialog/configuration-dialog.component.html b/src/app/si/settings/sage-intacct-configurations/configuration/configuration-dialog/configuration-dialog.component.html index d28c2080..3568e016 100644 --- a/src/app/si/settings/sage-intacct-configurations/configuration/configuration-dialog/configuration-dialog.component.html +++ b/src/app/si/settings/sage-intacct-configurations/configuration/configuration-dialog/configuration-dialog.component.html @@ -34,12 +34,14 @@

- -
+ + +
to
- -
+ + + diff --git a/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.html b/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.html index 731af926..ab71c87b 100644 --- a/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.html +++ b/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.html @@ -14,11 +14,13 @@
Map reimbursable Expenses from Fyle to -
+ + None + {{option.label}} @@ -26,11 +28,11 @@ -
+
Map Employees from Fyle to
- + Vendor diff --git a/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.ts b/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.ts index 357a914f..407846e6 100644 --- a/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.ts +++ b/src/app/si/settings/sage-intacct-configurations/configuration/configuration.component.ts @@ -94,16 +94,13 @@ export class ConfigurationComponent implements OnInit { label: 'Journal Entry', value: 'JOURNAL_ENTRY' }, - ]; - - if (employeesMappedTo === 'VENDOR') { - cccExpenseOptions.push({ - label: 'Bill', - value: 'BILL' - }); + { + label: 'Bill', + value: 'BILL' } + ]; - if (reimburExpenseMappedTo === 'EXPENSE_REPORT' || (reimburExpenseMappedTo === 'JOURNAL_ENTRY' && employeesMappedTo === 'EMPLOYEE')) { + if (reimburExpenseMappedTo === 'EXPENSE_REPORT') { cccExpenseOptions.push({ label: 'Expense Report', value: 'EXPENSE_REPORT' @@ -142,10 +139,52 @@ export class ConfigurationComponent implements OnInit { } } + updateEmployeeFieldMapping(reimbursableExpenseMappedTo, cccExpenseMappedTo, reimburExpenseControl, configurationForm) { + const employeeFieldMappingControl = configurationForm.controls.employeeFieldMapping; + + if (reimbursableExpenseMappedTo === 'JOURNAL_ENTRY' || (cccExpenseMappedTo === 'JOURNAL_ENTRY' && !reimburExpenseControl.value)) { + employeeFieldMappingControl.reset(); + employeeFieldMappingControl.setValidators([Validators.required]); + employeeFieldMappingControl.updateValueAndValidity(); + } else { + employeeFieldMappingControl.reset(); + employeeFieldMappingControl.clearValidators(); + employeeFieldMappingControl.updateValueAndValidity(); + } + } + setupReimbursableFieldWatcher() { const that = this; - that.configurationForm.controls.reimburExpense.valueChanges.subscribe((reimbursableExpenseMappedTo) => { - that.configurationForm.controls.cccExpense.reset(); + const cccExpenseControl = this.configurationForm.controls.cccExpense; + const reimburExpenseControl = this.configurationForm.controls.reimburExpense; + let programmaticChange = false; + + cccExpenseControl.valueChanges.subscribe((cccExpenseMappedTo) => { + if (!programmaticChange) { + programmaticChange = true; + if (!cccExpenseMappedTo && !reimburExpenseControl.value) { + reimburExpenseControl.setValidators([Validators.required]); + } else { + reimburExpenseControl.clearValidators(); + } + reimburExpenseControl.updateValueAndValidity(); + programmaticChange = false; + } + + this.updateEmployeeFieldMapping(reimburExpenseControl.value, cccExpenseMappedTo, reimburExpenseControl, this.configurationForm); + }); + + reimburExpenseControl.valueChanges.subscribe((reimbursableExpenseMappedTo) => { + if (!programmaticChange) { + programmaticChange = true; + if (!reimbursableExpenseMappedTo && !cccExpenseControl.value) { + cccExpenseControl.setValidators([Validators.required]); + } else { + cccExpenseControl.clearValidators(); + } + cccExpenseControl.updateValueAndValidity(); + programmaticChange = false; + } that.cccExpenseOptions = that.getCCCExpenseOptions(reimbursableExpenseMappedTo); if (reimbursableExpenseMappedTo) { @@ -156,22 +195,7 @@ export class ConfigurationComponent implements OnInit { that.showImportCategories = true; } - if (reimbursableExpenseMappedTo === 'JOURNAL_ENTRY') { - that.configurationForm.controls.employeeFieldMapping.reset(); - // Add validators for the 'employeeFieldMapping' form control - that.configurationForm.controls.employeeFieldMapping.setValidators([Validators.required]); - - // Update the form control's value and validation state - that.configurationForm.controls.employeeFieldMapping.updateValueAndValidity(); - } else { - that.configurationForm.controls.employeeFieldMapping.reset(); - - // Clear validators for the 'employeeFieldMapping' form control - that.configurationForm.controls.employeeFieldMapping.clearValidators(); - - // Update the form control's value and validation state - that.configurationForm.controls.employeeFieldMapping.updateValueAndValidity(); - } + this.updateEmployeeFieldMapping(reimbursableExpenseMappedTo, cccExpenseControl.value, reimburExpenseControl, this.configurationForm); if (that.configuration && that.configuration.reimbursable_expenses_object === 'EXPENSE_REPORT' && reimbursableExpenseMappedTo !== 'EXPENSE_REPORT') { // turn off the import categories toggle when the user switches from EXPENSE REPORT to something else @@ -184,7 +208,6 @@ export class ConfigurationComponent implements OnInit { setupEmployeesFieldWatcher(reimbursableExpense) { const that = this; that.configurationForm.controls.employeeFieldMapping.valueChanges.subscribe((employeesMappedTo) => { - that.configurationForm.controls.cccExpense.reset(); that.cccExpenseOptions = that.getCCCExpenseOptions(reimbursableExpense, employeesMappedTo); }); } @@ -255,7 +278,7 @@ export class ConfigurationComponent implements OnInit { } that.configurationForm = that.formBuilder.group({ - reimburExpense: [that.configuration ? that.configuration.reimbursable_expenses_object : '', Validators.required], + reimburExpense: [that.configuration ? that.configuration.reimbursable_expenses_object : ''], employeeFieldMapping: [that.configuration ? that.configuration.employee_field_mapping : ''], cccExpense: [that.configuration ? that.configuration.corporate_credit_card_expenses_object : ''], importProjects: [importProjects], @@ -401,10 +424,10 @@ export class ConfigurationComponent implements OnInit { constructConfigurationsPayload(): Configuration { const that = this; - const reimbursableExpensesObject = that.configurationForm.getRawValue().reimburExpense; + const reimbursableExpensesObject = that.configurationForm.getRawValue().reimburExpense ? that.configurationForm.getRawValue().reimburExpense : null; const cccExpensesObject = that.configurationForm.getRawValue().cccExpense ? that.configurationForm.getRawValue().cccExpense : null; - const categoryMappingObject = that.getCategory(reimbursableExpensesObject)[0].value; - const employeeMappingsObject = that.getEmployee(reimbursableExpensesObject)[0].value; + const categoryMappingObject = reimbursableExpensesObject ? that.getCategory(reimbursableExpensesObject)[0].value : null; + const employeeMappingsObject = reimbursableExpensesObject ? that.getEmployee(reimbursableExpensesObject)[0].value : (cccExpensesObject === 'JOURNAL_ENTRY' ? that.getEmployee(cccExpensesObject)[0].value : null); const importProjects = that.configurationForm.value.importProjects; const importCategories = that.configurationForm.value.importCategories; const autoMapEmployees = that.configurationForm.value.autoMapEmployees ? that.configurationForm.value.autoMapEmployees : null; @@ -442,14 +465,11 @@ export class ConfigurationComponent implements OnInit { constructMappingSettingsPayload(): MappingSetting[] { const that = this; - const reimbursableExpensesObject = that.configurationForm.getRawValue().reimburExpense; - const employeeMappingsObject = that.getEmployee(reimbursableExpensesObject)[0].value; - const categoryMappingObject = that.getCategory(reimbursableExpensesObject)[0].value; + const reimbursableExpensesObject = that.configurationForm.getRawValue().reimburExpense ? that.configurationForm.getRawValue().reimburExpense : null; + const employeeMappingsObject = reimbursableExpensesObject ? that.getEmployee(reimbursableExpensesObject)[0].value : null; + const categoryMappingObject = reimbursableExpensesObject ? that.getCategory(reimbursableExpensesObject)[0].value : null; - const mappingsSettingsPayload: MappingSetting[] = [{ - source_field: 'EMPLOYEE', - destination_field: employeeMappingsObject - }]; + const mappingsSettingsPayload: MappingSetting[] = []; const importProjects = that.configurationForm.value.importProjects ? that.configurationForm.value.importProjects : false; const importTaxCodes = that.configurationForm.value.importTaxCodes ? that.configurationForm.value.importTaxCodes : false; @@ -462,11 +482,6 @@ export class ConfigurationComponent implements OnInit { }); } - mappingsSettingsPayload.push({ - source_field: 'CATEGORY', - destination_field: categoryMappingObject - }); - if (importProjects) { mappingsSettingsPayload.push({ source_field: 'PROJECT', diff --git a/src/app/si/si.component.html b/src/app/si/si.component.html index 8239261a..03237c61 100644 --- a/src/app/si/si.component.html +++ b/src/app/si/si.component.html @@ -37,7 +37,7 @@ routerLink="{{workspace.id}}/settings/general/mappings/" routerLinkActive="active" (click)="onGeneralMappingsPageVisit()"> General Mappings - Employee Mappings diff --git a/src/app/si/si.component.ts b/src/app/si/si.component.ts index 8de3ffcf..b5db5017 100644 --- a/src/app/si/si.component.ts +++ b/src/app/si/si.component.ts @@ -39,6 +39,7 @@ export class SiComponent implements OnInit { windowReference: Window; connectSageIntacct = true; showRefreshIcon: boolean; + showEmployeeMapping = true; constructor( private workspaceService: WorkspaceService, @@ -58,6 +59,7 @@ export class SiComponent implements OnInit { return name.replace(/_/g, ' '); } + refreshDashboardMappingSettings(mappingSettings: MappingSetting[]) { const that = this; @@ -117,15 +119,25 @@ export class SiComponent implements OnInit { setupAccessiblePathWatchers() { const that = this; - that.getConfigurations().subscribe(() => { + that.getConfigurations().subscribe((response) => { that.navDisabled = false; + if (response[0].reimbursable_expenses_object != null || response[0].corporate_credit_card_expenses_object === 'JOURNAL_ENTRY') { + this.showEmployeeMapping = true; + } else { + this.showEmployeeMapping = false; + } }); that.router.events.subscribe(() => { const onboarded = that.storageService.get('onboarded'); if (onboarded !== true) { - that.getConfigurations().subscribe(() => { + that.getConfigurations().subscribe((response) => { that.navDisabled = false; + if (response[0].reimbursable_expenses_object != null || response[0].corporate_credit_card_expenses_object === 'JOURNAL_ENTRY') { + this.showEmployeeMapping = true; + } else { + this.showEmployeeMapping = false; + } }); } });