From 5b484ae276133c02f27ff6c3452cfbffd9a3b7b7 Mon Sep 17 00:00:00 2001 From: DhaaraniCIT Date: Thu, 10 Oct 2024 11:32:12 +0530 Subject: [PATCH] intacct prepend code field fix --- .../intacct-import-settings.component.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.ts b/src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.ts index 200f1a4f8..63ac6daac 100644 --- a/src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.ts +++ b/src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.ts @@ -170,7 +170,10 @@ export class IntacctImportSettingsComponent implements OnInit { sourceField = IntacctCategoryDestination.ACCOUNT; } - if (event.checked && this.acceptedImportCodeField.includes(sourceField) && this.intacctImportCodeConfig[sourceField]) { + // Find the index of the FormGroup + const index = importCodeFieldsArray.controls.findIndex(control => control?.get('source_field')?.value === sourceField); + + if (event.checked && this.acceptedImportCodeField.includes(sourceField) && this.intacctImportCodeConfig[sourceField] && index === -1) { // Create a new FormGroup const value = this.formBuilder.group({ source_field: [sourceField], @@ -180,8 +183,6 @@ export class IntacctImportSettingsComponent implements OnInit { // Push the new FormGroup into the FormArray importCodeFieldsArray.push(value); } else { - // Find the index of the FormGroup to be removed - const index = importCodeFieldsArray.controls.findIndex(control => control?.get('source_field')?.value === sourceField); // If found, remove the FormGroup from the FormArray if (index !== -1) {