@@ -24,14 +24,16 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
24
24
} )
25
25
export class WriteOffPageComponent implements OnInit {
26
26
@Input ( ) dataObject : any ;
27
-
27
+ /** Loan Id */
28
+ loanId : string ;
28
29
/** Minimum Date allowed. */
29
30
minDate = new Date ( 2000 , 0 , 1 ) ;
30
31
/** Maximum Date allowed. */
31
32
maxDate = new Date ( ) ;
32
33
33
34
/** Write Off form. */
34
35
writeOffForm : UntypedFormGroup ;
36
+ writeOffReasonOptions : any [ ] = [ ] ;
35
37
36
38
/**
37
39
* Get data from `Resolver`.
@@ -49,11 +51,14 @@ export class WriteOffPageComponent implements OnInit {
49
51
private dateUtils : Dates ,
50
52
private router : Router ,
51
53
private settingsService : SettingsService
52
- ) { }
54
+ ) {
55
+ this . loanId = this . route . snapshot . params [ 'loanId' ] ;
56
+ }
53
57
54
58
ngOnInit ( ) {
55
59
this . maxDate = this . settingsService . businessDate ;
56
60
this . setWriteOffForm ( ) ;
61
+ this . writeOffReasonOptions = this . dataObject . writeOffReasonOptions ;
57
62
}
58
63
59
64
/**
@@ -66,6 +71,7 @@ export class WriteOffPageComponent implements OnInit {
66
71
Validators . required
67
72
] ,
68
73
amount : [ { value : this . dataObject . amount , disabled : true } ] ,
74
+ writeoffReasonId : [ '' ] ,
69
75
note : [ '' ]
70
76
} ) ;
71
77
}
@@ -81,14 +87,16 @@ export class WriteOffPageComponent implements OnInit {
81
87
if ( writeOffFormData . transactionDate instanceof Date ) {
82
88
writeOffFormData . transactionDate = this . dateUtils . formatDate ( prevTransactionDate , dateFormat ) ;
83
89
}
90
+ if ( writeOffFormData . writeoffReasonId === null || writeOffFormData . writeoffReasonId === '' ) {
91
+ delete writeOffFormData . writeoffReasonId ;
92
+ }
84
93
const data = {
85
94
...writeOffFormData ,
86
95
dateFormat,
87
96
locale
88
97
} ;
89
- const loanId = this . route . snapshot . params [ 'loanId' ] ;
90
98
delete data . amount ;
91
- this . loanService . submitLoanActionButton ( loanId , data , 'writeoff' ) . subscribe ( ( response : any ) => {
99
+ this . loanService . submitLoanActionButton ( this . loanId , data , 'writeoff' ) . subscribe ( ( response : any ) => {
92
100
this . router . navigate ( [ '../../general' ] , { relativeTo : this . route } ) ;
93
101
} ) ;
94
102
}
0 commit comments