@@ -24,14 +24,16 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
2424} )
2525export class WriteOffPageComponent implements OnInit {
2626 @Input ( ) dataObject : any ;
27-
27+ /** Loan Id */
28+ loanId : string ;
2829 /** Minimum Date allowed. */
2930 minDate = new Date ( 2000 , 0 , 1 ) ;
3031 /** Maximum Date allowed. */
3132 maxDate = new Date ( ) ;
3233
3334 /** Write Off form. */
3435 writeOffForm : UntypedFormGroup ;
36+ writeOffReasonOptions : any [ ] = [ ] ;
3537
3638 /**
3739 * Get data from `Resolver`.
@@ -49,11 +51,14 @@ export class WriteOffPageComponent implements OnInit {
4951 private dateUtils : Dates ,
5052 private router : Router ,
5153 private settingsService : SettingsService
52- ) { }
54+ ) {
55+ this . loanId = this . route . snapshot . params [ 'loanId' ] ;
56+ }
5357
5458 ngOnInit ( ) {
5559 this . maxDate = this . settingsService . businessDate ;
5660 this . setWriteOffForm ( ) ;
61+ this . writeOffReasonOptions = this . dataObject . writeOffReasonOptions ;
5762 }
5863
5964 /**
@@ -66,6 +71,7 @@ export class WriteOffPageComponent implements OnInit {
6671 Validators . required
6772 ] ,
6873 amount : [ { value : this . dataObject . amount , disabled : true } ] ,
74+ writeoffReasonId : [ '' ] ,
6975 note : [ '' ]
7076 } ) ;
7177 }
@@ -81,14 +87,16 @@ export class WriteOffPageComponent implements OnInit {
8187 if ( writeOffFormData . transactionDate instanceof Date ) {
8288 writeOffFormData . transactionDate = this . dateUtils . formatDate ( prevTransactionDate , dateFormat ) ;
8389 }
90+ if ( writeOffFormData . writeoffReasonId === null || writeOffFormData . writeoffReasonId === '' ) {
91+ delete writeOffFormData . writeoffReasonId ;
92+ }
8493 const data = {
8594 ...writeOffFormData ,
8695 dateFormat,
8796 locale
8897 } ;
89- const loanId = this . route . snapshot . params [ 'loanId' ] ;
9098 delete data . amount ;
91- this . loanService . submitLoanActionButton ( loanId , data , 'writeoff' ) . subscribe ( ( response : any ) => {
99+ this . loanService . submitLoanActionButton ( this . loanId , data , 'writeoff' ) . subscribe ( ( response : any ) => {
92100 this . router . navigate ( [ '../../general' ] , { relativeTo : this . route } ) ;
93101 } ) ;
94102 }
0 commit comments