refactor (df/locale): loans module (#1264)

See: #1213
This commit is contained in:
Shubhankar Bhadra
2020-10-25 13:06:23 +05:30
committed by GitHub
parent 2b5341aa2c
commit 9d438b140e
26 changed files with 179 additions and 84 deletions
@@ -4,6 +4,9 @@ import { LoansService } from 'app/loans/loans.service';
import { ActivatedRoute, Router } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SettingsService } from 'app/settings/settings.service';
@Component({
selector: 'mifosx-foreclosure',
templateUrl: './foreclosure.component.html',
@@ -27,12 +30,14 @@ export class ForeclosureComponent implements OnInit {
* @param {LoansService} systemService Loan Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private loanService: LoansService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private datePipe: DatePipe,
private settingsService: SettingsService) {
this.loanId = this.route.parent.snapshot.params['loanId'];
}
@@ -62,12 +67,12 @@ export class ForeclosureComponent implements OnInit {
}
retrieveLoanForeclosureTemplate(val: any) {
const dateFormat = 'dd MMMM yyyy';
const dateFormat = this.settingsService.dateFormat;
const transactionDateFormatted = this.datePipe.transform(val, dateFormat);
const data = {
command: 'foreclosure',
dateFormat: 'dd MMMM yyyy',
locale: 'en',
dateFormat: this.settingsService.dateFormat,
locale: this.settingsService.language.code,
transactionDate: transactionDateFormatted
};
this.loanService.getForeclosureData(this.loanId, data)
@@ -104,13 +109,13 @@ export class ForeclosureComponent implements OnInit {
submit() {
const transactionDate = this.foreclosureForm.value.transactionDate;
const dateFormat = 'yyyy-MM-dd';
const dateFormat = this.settingsService.dateFormat;
this.foreclosureForm.patchValue({
transactionDate: this.datePipe.transform(transactionDate, dateFormat)
});
const formData = {
transactionDate: this.foreclosureForm.value.transactionDate,
locale: 'en',
locale: this.settingsService.language.code,
dateFormat: dateFormat,
note: this.foreclosureForm.value.note
};