refractor(df/locale):savings module (#1301)
This commit is contained in:
+10
-9
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from '../../savings.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
/**
|
||||
* Add Savings Charge component.
|
||||
@@ -37,14 +38,14 @@ export class AddChargeSavingsAccountComponent implements OnInit {
|
||||
* @param {Router} router Router
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private savingsService: SavingsService
|
||||
) {
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private savingsService: SavingsService,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
|
||||
this.savingsChargeOptions = data.savingsAccountActionData.chargeOptions;
|
||||
});
|
||||
@@ -111,7 +112,7 @@ export class AddChargeSavingsAccountComponent implements OnInit {
|
||||
*/
|
||||
submit() {
|
||||
const savingsCharge = this.savingsChargeForm.value;
|
||||
savingsCharge.locale = 'en';
|
||||
savingsCharge.locale = this.settingsService.language.code;
|
||||
if (!savingsCharge.feeInterval) {
|
||||
savingsCharge.feeInterval = this.chargeDetails.feeInterval;
|
||||
}
|
||||
@@ -124,7 +125,7 @@ export class AddChargeSavingsAccountComponent implements OnInit {
|
||||
savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
|
||||
}
|
||||
} else {
|
||||
const dateFormat = 'yyyy-MM-dd';
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
savingsCharge.dateFormat = dateFormat;
|
||||
if (savingsCharge.dueDate) {
|
||||
const prevDate = this.savingsChargeForm.value.dueDate;
|
||||
|
||||
+6
-3
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from '../../savings.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
/**
|
||||
* Create savings account transactions component.
|
||||
@@ -47,12 +48,14 @@ export class SavingsAccountTransactionsComponent implements OnInit {
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {DatePipe} datePipe DatePipe.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private savingsService: SavingsService) {
|
||||
private savingsService: SavingsService,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
|
||||
this.paymentTypeOptions = data.savingsAccountActionData.paymentTypeOptions;
|
||||
});
|
||||
@@ -106,12 +109,12 @@ export class SavingsAccountTransactionsComponent implements OnInit {
|
||||
submit() {
|
||||
const prevTransactionDate: Date = this.savingAccountTransactionForm.value.transactionDate;
|
||||
// TODO: Update once language and date settings are setup
|
||||
const dateFormat = 'dd-MM-yyyy';
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
this.savingAccountTransactionForm.patchValue({
|
||||
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
|
||||
});
|
||||
const transactionData = this.savingAccountTransactionForm.value;
|
||||
transactionData.locale = 'en';
|
||||
transactionData.locale = this.settingsService.language.code;
|
||||
transactionData.dateFormat = dateFormat;
|
||||
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, transactionData).subscribe(res => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
|
||||
Reference in New Issue
Block a user