refractor(df/locale):savings module (#1301)

This commit is contained in:
Abhishek Kumar
2021-08-08 13:16:30 +05:30
committed by GitHub
parent 997611a9f3
commit 88ee1b4fcd
4 changed files with 28 additions and 18 deletions
@@ -7,6 +7,7 @@ import { Observable } from 'rxjs';
/** Custom Services */ /** Custom Services */
import { ReportsService } from 'app/reports/reports.service'; import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Savings Transaction Reciept resolver. * Savings Transaction Reciept resolver.
@@ -16,8 +17,10 @@ export class SavingsTransactionRecieptResolver implements Resolve<Object> {
/** /**
* @param {ReportsService} reportsService Reports service. * @param {ReportsService} reportsService Reports service.
* @param {SettingsService} settingsService Settings Service.
*/ */
constructor(private reportsService: ReportsService) { } constructor(private reportsService: ReportsService,
private settingsService: SettingsService) { }
/** /**
* Returns the Savings Transaction Reciept * Returns the Savings Transaction Reciept
@@ -30,7 +33,7 @@ export class SavingsTransactionRecieptResolver implements Resolve<Object> {
'output-type': 'PDF', 'output-type': 'PDF',
R_transactionId: transactionId R_transactionId: transactionId
}; };
return this.reportsService.getPentahoRunReportData('Savings Transaction Receipt', data, 'default', 'en', 'dd MMMM yyyy'); return this.reportsService.getPentahoRunReportData('Savings Transaction Receipt', data, 'default', this.settingsService.language.code, this.settingsService.dateFormat);
} }
} }
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { SavingsService } from '../../savings.service'; import { SavingsService } from '../../savings.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Add Savings Charge component. * Add Savings Charge component.
@@ -37,14 +38,14 @@ export class AddChargeSavingsAccountComponent implements OnInit {
* @param {Router} router Router * @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {SavingsService} savingsService Savings Service * @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/ */
constructor( constructor(private formBuilder: FormBuilder,
private formBuilder: FormBuilder, private route: ActivatedRoute,
private route: ActivatedRoute, private router: Router,
private router: Router, private datePipe: DatePipe,
private datePipe: DatePipe, private savingsService: SavingsService,
private savingsService: SavingsService private settingsService: SettingsService) {
) {
this.route.data.subscribe((data: { savingsAccountActionData: any }) => { this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
this.savingsChargeOptions = data.savingsAccountActionData.chargeOptions; this.savingsChargeOptions = data.savingsAccountActionData.chargeOptions;
}); });
@@ -111,7 +112,7 @@ export class AddChargeSavingsAccountComponent implements OnInit {
*/ */
submit() { submit() {
const savingsCharge = this.savingsChargeForm.value; const savingsCharge = this.savingsChargeForm.value;
savingsCharge.locale = 'en'; savingsCharge.locale = this.settingsService.language.code;
if (!savingsCharge.feeInterval) { if (!savingsCharge.feeInterval) {
savingsCharge.feeInterval = this.chargeDetails.feeInterval; savingsCharge.feeInterval = this.chargeDetails.feeInterval;
} }
@@ -124,7 +125,7 @@ export class AddChargeSavingsAccountComponent implements OnInit {
savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat); savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
} }
} else { } else {
const dateFormat = 'yyyy-MM-dd'; const dateFormat = this.settingsService.dateFormat;
savingsCharge.dateFormat = dateFormat; savingsCharge.dateFormat = dateFormat;
if (savingsCharge.dueDate) { if (savingsCharge.dueDate) {
const prevDate = this.savingsChargeForm.value.dueDate; const prevDate = this.savingsChargeForm.value.dueDate;
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */ /** Custom Services */
import { SavingsService } from '../../savings.service'; import { SavingsService } from '../../savings.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Create savings account transactions component. * Create savings account transactions component.
@@ -47,12 +48,14 @@ export class SavingsAccountTransactionsComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route. * @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe DatePipe. * @param {DatePipe} datePipe DatePipe.
* @param {Router} router Router for navigation. * @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Settings Service
*/ */
constructor(private formBuilder: FormBuilder, constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
private datePipe: DatePipe, private datePipe: DatePipe,
private savingsService: SavingsService) { private savingsService: SavingsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountActionData: any }) => { this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
this.paymentTypeOptions = data.savingsAccountActionData.paymentTypeOptions; this.paymentTypeOptions = data.savingsAccountActionData.paymentTypeOptions;
}); });
@@ -106,12 +109,12 @@ export class SavingsAccountTransactionsComponent implements OnInit {
submit() { submit() {
const prevTransactionDate: Date = this.savingAccountTransactionForm.value.transactionDate; const prevTransactionDate: Date = this.savingAccountTransactionForm.value.transactionDate;
// TODO: Update once language and date settings are setup // TODO: Update once language and date settings are setup
const dateFormat = 'dd-MM-yyyy'; const dateFormat = this.settingsService.dateFormat;
this.savingAccountTransactionForm.patchValue({ this.savingAccountTransactionForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat) transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
}); });
const transactionData = this.savingAccountTransactionForm.value; const transactionData = this.savingAccountTransactionForm.value;
transactionData.locale = 'en'; transactionData.locale = this.settingsService.language.code;
transactionData.dateFormat = dateFormat; transactionData.dateFormat = dateFormat;
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, transactionData).subscribe(res => { this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, transactionData).subscribe(res => {
this.router.navigate(['../../'], { relativeTo: this.route }); this.router.navigate(['../../'], { relativeTo: this.route });
@@ -7,6 +7,7 @@ import { ActivatedRoute } from '@angular/router';
/** Custom Services */ /** Custom Services */
import { ReportsService } from 'app/reports/reports.service'; import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
/** /**
* Export Client Savings Transactions Component * Export Client Savings Transactions Component
@@ -38,12 +39,14 @@ export class ExportTransactionsComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder * @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe * @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route * @param {ActivatedRoute} route Activated Route
* @param {SettingsService} settingsService Settings Service
*/ */
constructor(private sanitizer: DomSanitizer, constructor(private sanitizer: DomSanitizer,
private reportsService: ReportsService, private reportsService: ReportsService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private datePipe: DatePipe, private datePipe: DatePipe,
private route: ActivatedRoute) { private route: ActivatedRoute,
private settingsService: SettingsService) {
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => { this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
this.savingsAccountId = data.savingsAccountData.accountNo; this.savingsAccountId = data.savingsAccountData.accountNo;
}); });
@@ -70,11 +73,11 @@ export class ExportTransactionsComponent implements OnInit {
generate() { generate() {
const data = { const data = {
'output-type': 'PDF', 'output-type': 'PDF',
R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'), R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, this.settingsService.dateFormat),
R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'), R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, this.settingsService.dateFormat),
R_savingsAccountId: this.savingsAccountId R_savingsAccountId: this.savingsAccountId
}; };
this.reportsService.getPentahoRunReportData('Client Saving Transactions', data, 'default', 'en', 'dd MMMM yyyy') this.reportsService.getPentahoRunReportData('Client Saving Transactions', data, 'default', this.settingsService.language.code, this.settingsService.dateFormat)
.subscribe( (res: any) => { .subscribe( (res: any) => {
const contentType = res.headers.get('Content-Type'); const contentType = res.headers.get('Content-Type');
const file = new Blob([res.body], {type: contentType}); const file = new Blob([res.body], {type: contentType});