Skip to content

Commit

Permalink
intacct prepend code field fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DhaaraniCIT committed Oct 10, 2024
1 parent d6035f6 commit 5b484ae
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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) {
Expand Down

0 comments on commit 5b484ae

Please sign in to comment.