/** Angular Imports */ import { Component } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { MatDialog } from '@angular/material/dialog' ; import { DatePipe } from '@angular/common' ; /** Custom Services */ import { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service' ; import { SettingsService } from 'app/settings/settings.service' ; /** Custom Dialogs */ import { RecurringDepositConfirmationDialogComponent } from '../../custom-dialogs/recurring-deposit-confirmation-dialog/recurring-deposit-confirmation-dialog.component' ; /**
 * View Transaction Component.
 * TODO: Add support for account transfers.
 */ @ Component ( { selector : 'mifosx-view-transaction' , templateUrl : './view-transaction.component.html' , styleUrls : [ './view-transaction.component.scss' ] } ) export class ViewTransactionComponent { /** Transaction data. */ transactionData : any ; param { RecurringDepositsService } recurringDepositsService param { ActivatedRoute } route param { Router } router param { MatDialog } dialog param { DatePipe } datePipe param { SettingsService } settingsService constructor ( private recurringDepositsService , private route , private datePipe , private router , public dialog , private settingsService ) { this . route . data . subscribe ( ( data ) => { this . transactionData = data . recurringDepositsAccountTransaction ; } ) ; } /**
     * Undo the recurring deposits transaction
     */ undoTransaction ( ) { const accountId = this . route . parent . snapshot . params [ 'recurringDepositAccountId' ] ; const undoTransactionAccountDialogRef = this . dialog . open ( RecurringDepositConfirmationDialogComponent , { data : { heading : 'Undo Transaction' , dialogContext : 'Are you sure you want to undo this transaction ?' } } ) ; undoTransactionAccountDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . confirm ) { const locale = this . settingsService . language . code ; const dateFormat = this . settingsService . dateFormat ; const data = { transactionDate : this . datePipe . transform ( this . transactionData . date && new Date ( this . transactionData . date ) , dateFormat ) , transactionAmount : 0 , dateFormat , locale } ; this . recurringDepositsService . executeRecurringDepositsAccountTransactionsCommand ( accountId , 'undo' , data , this . transactionData . id ) . subscribe ( ( ) => { this . router . navigate ( [ '../' ] , { relativeTo : this . route } ) ; } ) ; } } ) ; } }