/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; import { DatePipe } from '@angular/common' ; import { ActivatedRoute , Router } from '@angular/router' ; /** Custom Services */ import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service' ; import { SettingsService } from 'app/settings/settings.service' ; /**
 * Withdraw By Client Fixed Deposits Account Component
 */ @ Component ( { selector : 'mifosx-withdraw-by-client-fixed-deposits-account' , templateUrl : './withdraw-by-client-fixed-deposits-account.component.html' , styleUrls : [ './withdraw-by-client-fixed-deposits-account.component.scss' ] } ) export class WithdrawByClientFixedDepositsAccountComponent implements OnInit { /** Minimum date allowed. */ minDate = new Date ( 2000 , 0 , 1 ) ; /** Maximum date allowed. */ maxDate = new Date ( ) ; /** Withdraw Fixed Deposits Account form. */ withdrawFixedDepositsAccountForm : FormGroup ; /** Fixed Deposits Account Id */ accountId : any ; param { FormBuilder } formBuilder param { FixedDepositsService } fixedDepositsService param { DatePipe } datePipe param { ActivatedRoute } route param { Router } router param { SettingsService } settingsService constructor ( private formBuilder , private fixedDepositsService , private datePipe , private route , private router , private settingsService ) { this . accountId = this . route . parent . snapshot . params [ 'fixedDepositAccountId' ] ; } /**
     * Creates the withdraw fixed deposits form.
     */ ngOnInit ( ) { this . createWithdrawFixedDepositsAccountForm ( ) ; } /**
     * Creates the withdraw fixed deposits account form.
     */ createWithdrawFixedDepositsAccountForm ( ) { this . withdrawFixedDepositsAccountForm = this . formBuilder . group ( { 'withdrawnOnDate' : [ '' , Validators . required ] , 'note' : [ '' ] } ) ; } /**
     * Submits the form and withdraws the fixed deposit account by client,
     * if successful redirects to the fixed deposit account.
     */ submit ( ) { const locale = this . settingsService . language . code ; const dateFormat = this . settingsService . dateFormat ; const prevWithdrawnOnDate = this . withdrawFixedDepositsAccountForm . value . withdrawnOnDate ; this . withdrawFixedDepositsAccountForm . patchValue ( { withdrawnOnDate : this . datePipe . transform ( prevWithdrawnOnDate , dateFormat ) , } ) ; const data = { ... this . withdrawFixedDepositsAccountForm . value , dateFormat , locale } ; this . fixedDepositsService . executeFixedDepositsAccountCommand ( this . accountId , 'withdrawnByApplicant' , data ) . subscribe ( ( ) => { this . router . navigate ( [ '../../' ] , { relativeTo : this . route } ) ; } ) ; } }