WEB-306: Allow customer to provide write-off reasons

This commit is contained in:
Jose Alberto Hernandez
2025-09-05 20:31:27 -05:00
parent 9697d90367
commit ee5ee3d66f
15 changed files with 34 additions and 4 deletions
@@ -26,6 +26,15 @@
<input matInput formControlName="amount" />
</mat-form-field>
<mat-form-field>
<mat-label>{{ 'labels.inputs.Reason for Write-Off' | translate }}</mat-label>
<mat-select formControlName="writeoffReasonId">
<mat-option *ngFor="let writeOffReason of writeOffReasonOptions" [value]="writeOffReason.id">
{{ writeOffReason.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<mat-label>{{ 'labels.inputs.Note' | translate }}</mat-label>
<textarea matInput formControlName="note" cdkTextareaAutosize cdkAutosizeMinRows="2"></textarea>
@@ -24,7 +24,8 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
})
export class WriteOffPageComponent implements OnInit {
@Input() dataObject: any;
/** Loan Id */
loanId: string;
/** Minimum Date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum Date allowed. */
@@ -32,6 +33,7 @@ export class WriteOffPageComponent implements OnInit {
/** Write Off form. */
writeOffForm: UntypedFormGroup;
writeOffReasonOptions: any[] = [];
/**
* Get data from `Resolver`.
@@ -49,11 +51,14 @@ export class WriteOffPageComponent implements OnInit {
private dateUtils: Dates,
private router: Router,
private settingsService: SettingsService
) {}
) {
this.loanId = this.route.snapshot.params['loanId'];
}
ngOnInit() {
this.maxDate = this.settingsService.businessDate;
this.setWriteOffForm();
this.writeOffReasonOptions = this.dataObject.writeOffReasonOptions;
}
/**
@@ -66,6 +71,7 @@ export class WriteOffPageComponent implements OnInit {
Validators.required
],
amount: [{ value: this.dataObject.amount, disabled: true }],
writeoffReasonId: [''],
note: ['']
});
}
@@ -81,14 +87,16 @@ export class WriteOffPageComponent implements OnInit {
if (writeOffFormData.transactionDate instanceof Date) {
writeOffFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
if (writeOffFormData.writeoffReasonId === null || writeOffFormData.writeoffReasonId === '') {
delete writeOffFormData.writeoffReasonId;
}
const data = {
...writeOffFormData,
dateFormat,
locale
};
const loanId = this.route.snapshot.params['loanId'];
delete data.amount;
this.loanService.submitLoanActionButton(loanId, data, 'writeoff').subscribe((response: any) => {
this.loanService.submitLoanActionButton(this.loanId, data, 'writeoff').subscribe((response: any) => {
this.router.navigate(['../../general'], { relativeTo: this.route });
});
}