/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormBuilder , Validators } from '@angular/forms' ; import { ActivatedRoute , Router } from '@angular/router' ; import { DatePipe } from '@angular/common' ; /** Custom Services. */ import { ClientsService } from 'app/clients/clients.service' ; import { SettingsService } from 'app/settings/settings.service' ; /**
 * Client Pay Charge component.
 */ @ Component ( { selector : 'mifosx-client-pay-charges' , templateUrl : './client-pay-charges.component.html' , styleUrls : [ './client-pay-charges.component.scss' ] } ) export class ClientPayChargesComponent implements OnInit { /** Transaction Form. */ transactionForm : any ; /** Transaction Data. */ transactionData : any ; /** Minimum Date allowed. */ minDate = new Date ( 2000 , 0 , 1 ) ; param { ClientService } clientService param { FormBuilder } formBuilder param { ActivatedRoute } route param { Router } router param { SettingsService } settingsService constructor ( private clientsService , private formBuilder , private route , private router , private datePipe , private settingsService ) { this . route . data . subscribe ( ( data ) => { this . transactionData = data . transactionData ; } ) ; } ngOnInit ( ) { this . setTransactionForm ( ) ; } /**
     * Set Transaction Form.
     */ setTransactionForm ( ) { this . transactionForm = this . formBuilder . group ( { 'amount' : [ this . transactionData . amount , Validators . required ] , 'transactionDate' : [ new Date ( ) , Validators . required ] } ) ; } /**
     * Submits Transaction form.
     */ submit ( ) { const transactionDate = this . transactionForm . value . transactionDate ; const dateFormat = 'yyyy-MM-dd' ; this . transactionForm . patchValue ( { transactionDate : this . datePipe . transform ( transactionDate , dateFormat ) } ) ; const transactions = this . transactionForm . value ; transactions . locale = this . settingsService . language . code ; transactions . dateFormat = dateFormat ; this . clientsService . payClientCharge ( this . transactionData . clientId , this . transactionData . id , transactions ) . subscribe ( ( ) => { this . router . navigate ( [ '../' , 'general' ] ) ; } ) ; } }