@@ -163,35 +163,77 @@ export class ViewTransactionComponent implements OnInit {
163163 * Undo the loans transaction
164164 */
165165 undoTransaction ( ) {
166+ console . log ( this . transactionData ) ;
166167 const accountId = this . route . snapshot . params [ 'loanId' ] ;
167- const undoTransactionAccountDialogRef = this . dialog . open ( ConfirmationDialogComponent , {
168- data : {
169- heading : this . translateService . instant ( 'labels.heading.Undo Transaction' ) ,
170- dialogContext :
171- this . translateService . instant ( 'labels.dialogContext.Are you sure you want undo the transaction' ) +
172- `${ this . transactionData . id } `
173- }
174- } ) ;
175- undoTransactionAccountDialogRef . afterClosed ( ) . subscribe ( ( response : { confirm : any } ) => {
176- if ( response . confirm ) {
177- const locale = this . settingsService . language . code ;
178- const dateFormat = this . settingsService . dateFormat ;
179- const data = {
180- transactionDate : this . dateUtils . formatDate (
181- this . transactionData . date && new Date ( this . transactionData . date ) ,
182- dateFormat
183- ) ,
184- transactionAmount : 0 ,
185- dateFormat,
186- locale
187- } ;
188- this . loansService
189- . executeLoansAccountTransactionsCommand ( accountId , 'undo' , data , this . transactionData . id )
190- . subscribe ( ( ) => {
168+
169+ if ( this . transactionType . contractTermination ) {
170+ const formfields : FormfieldBase [ ] = [
171+ new InputBase ( {
172+ controlName : 'note' ,
173+ label : 'Note' ,
174+ value : '' ,
175+ type : 'text' ,
176+ required : false ,
177+ order : 1
178+ } ) ,
179+ new InputBase ( {
180+ controlName : 'reversalExternalId' ,
181+ label : 'externalId' ,
182+ value : '' ,
183+ type : 'text' ,
184+ required : false ,
185+ order : 2
186+ } )
187+
188+ ] ;
189+ const data = {
190+ title : this . translateService . instant ( 'labels.heading.Undo Transaction' ) ,
191+ layout : { addButtonText : 'Undo' } ,
192+ formfields : formfields
193+ } ;
194+ const undoTransactionAccountDialogRef = this . dialog . open ( FormDialogComponent , { data, width : '50rem' } ) ;
195+ undoTransactionAccountDialogRef . afterClosed ( ) . subscribe ( ( response : any ) => {
196+ if ( response . data ) {
197+ const payload = {
198+ note : response . data . value . note ,
199+ reversalExternalId : response . data . value . reversalExternalId
200+ } ;
201+
202+ this . loansService . loanActionButtons ( accountId , 'undoContractTermination' , payload ) . subscribe ( ( ) => {
191203 this . router . navigate ( [ '../' ] , { relativeTo : this . route } ) ;
192204 } ) ;
193- }
194- } ) ;
205+ }
206+ } ) ;
207+ } else {
208+ const undoTransactionAccountDialogRef = this . dialog . open ( ConfirmationDialogComponent , {
209+ data : {
210+ heading : this . translateService . instant ( 'labels.heading.Undo Transaction' ) ,
211+ dialogContext :
212+ this . translateService . instant ( 'labels.dialogContext.Are you sure you want undo the transaction' ) +
213+ `${ this . transactionData . id } `
214+ }
215+ } ) ;
216+ undoTransactionAccountDialogRef . afterClosed ( ) . subscribe ( ( response : { confirm : any } ) => {
217+ if ( response . confirm ) {
218+ const locale = this . settingsService . language . code ;
219+ const dateFormat = this . settingsService . dateFormat ;
220+ const data = {
221+ transactionDate : this . dateUtils . formatDate (
222+ this . transactionData . date && new Date ( this . transactionData . date ) ,
223+ dateFormat
224+ ) ,
225+ transactionAmount : 0 ,
226+ dateFormat,
227+ locale
228+ } ;
229+ this . loansService
230+ . executeLoansAccountTransactionsCommand ( accountId , 'undo' , data , this . transactionData . id )
231+ . subscribe ( ( ) => {
232+ this . router . navigate ( [ '../' ] , { relativeTo : this . route } ) ;
233+ } ) ;
234+ }
235+ } ) ;
236+ }
195237 }
196238
197239 chargebackTransaction ( ) {
0 commit comments