WEB-674: Write-Off reason on product level duplicated (#3101)

Co-authored-by: Jose Alberto Hernandez <alberto@black-box.local>
This commit is contained in:
Jose Alberto Hernandez
2026-02-06 23:17:15 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent be588d2496
commit 782410d57e
@@ -89,16 +89,19 @@ export class AdvancedAccountingMappingRuleComponent implements OnInit {
this.sendParentData(); this.sendParentData();
} }
add() { fillCurrentFormValues(): void {
this.currentFormValues = []; this.currentFormValues = [];
if (this.formType == 'ChargeOffReasonExpense') { this.allowAddAccountingMapping = true;
this.allowAddAccountingMapping = true; this.tableData.forEach((item: any) => this.currentFormValues.push(item.value.id));
this.tableData.forEach((item: any) => this.currentFormValues.push(item.chargeOffReasonCodeValueId)); this.allowAddAccountingMapping = !(this.accountingMappingOptions.length == this.currentFormValues.length);
if (this.accountingMappingOptions.length == this.currentFormValues.length) { }
this.allowAddAccountingMapping = false;
return; add() {
} this.fillCurrentFormValues();
if (!this.allowAddAccountingMapping) {
return;
} }
const data = { ...this.getData(this.formType), pristine: false }; const data = { ...this.getData(this.formType), pristine: false };
const dialogRef = this.dialog.open(FormDialogComponent, { data }); const dialogRef = this.dialog.open(FormDialogComponent, { data });
dialogRef.afterClosed().subscribe((response: any) => { dialogRef.afterClosed().subscribe((response: any) => {
@@ -123,6 +126,7 @@ export class AdvancedAccountingMappingRuleComponent implements OnInit {
this.addTableData(addData); this.addTableData(addData);
} }
this.sendParentData(); this.sendParentData();
this.fillCurrentFormValues();
if (this.formType == 'ChargeOffReasonExpense') { if (this.formType == 'ChargeOffReasonExpense') {
this.allowAddAccountingMapping = this.tableData.length < this.accountingMappingOptions.length; this.allowAddAccountingMapping = this.tableData.length < this.accountingMappingOptions.length;
@@ -156,6 +160,7 @@ export class AdvancedAccountingMappingRuleComponent implements OnInit {
if (response.delete) { if (response.delete) {
this.tableData = this.tableData.filter((_, i) => i !== index); this.tableData = this.tableData.filter((_, i) => i !== index);
this.sendParentData(); this.sendParentData();
this.fillCurrentFormValues();
} }
}); });
} }