Skip to content

Commit be243d3

Browse files
authored
intacct prepend code field fix (#1011)
1 parent d6035f6 commit be243d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ export class IntacctImportSettingsComponent implements OnInit {
170170
sourceField = IntacctCategoryDestination.ACCOUNT;
171171
}
172172

173-
if (event.checked && this.acceptedImportCodeField.includes(sourceField) && this.intacctImportCodeConfig[sourceField]) {
173+
// Find the index of the FormGroup
174+
const index = importCodeFieldsArray.controls.findIndex(control => control?.get('source_field')?.value === sourceField);
175+
176+
if (event.checked && this.acceptedImportCodeField.includes(sourceField) && this.intacctImportCodeConfig[sourceField] && index === -1) {
174177
// Create a new FormGroup
175178
const value = this.formBuilder.group({
176179
source_field: [sourceField],
@@ -180,8 +183,6 @@ export class IntacctImportSettingsComponent implements OnInit {
180183
// Push the new FormGroup into the FormArray
181184
importCodeFieldsArray.push(value);
182185
} else {
183-
// Find the index of the FormGroup to be removed
184-
const index = importCodeFieldsArray.controls.findIndex(control => control?.get('source_field')?.value === sourceField);
185186

186187
// If found, remove the FormGroup from the FormArray
187188
if (index !== -1) {

0 commit comments

Comments
 (0)