Format date fields without patch form

This commit is contained in:
Jose Alberto Hernandez
2022-06-10 10:34:19 +02:00
committed by Arnold Gálovics
parent 9d43181cea
commit 6ea3d97538
191 changed files with 1408 additions and 1173 deletions
@@ -38,7 +38,7 @@ export class CreateSavingsAccountComponent {
* Fetches savings account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
* @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/
@@ -38,7 +38,7 @@ export class EditSavingsAccountComponent {
* Fetches savings account template from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {DatePipe} datePipe Date Utils
* @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class ActivateSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -65,15 +65,15 @@ export class ActivateSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const activateSavingsAccountFormData = this.activateSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevActivatedOnDate: Date = this.activateSavingsAccountForm.value.activatedOnDate;
this.activateSavingsAccountForm.patchValue({
activatedOnDate: this.datePipe.transform(prevActivatedOnDate, dateFormat),
});
if (activateSavingsAccountFormData.activatedOnDate instanceof Date) {
activateSavingsAccountFormData.activatedOnDate = this.dateUtils.formatDate(prevActivatedOnDate, dateFormat);
}
const data = {
...this.activateSavingsAccountForm.value,
...activateSavingsAccountFormData,
dateFormat,
locale
};
@@ -23,7 +23,7 @@
<mat-form-field>
<mat-label>Amount</mat-label>
<input type=number required matInput formControlName="amount" />
<input type="number" required matInput formControlName="amount" />
<mat-error *ngIf="savingsChargeForm.controls.amount.hasError('required')">
Amount is <strong>required</strong>
</mat-error>
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from '../../savings.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Add Savings Charge component.
@@ -36,14 +36,14 @@ export class AddChargeSavingsAccountComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {SavingsService} savingsService Savings Service
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
@@ -122,14 +122,14 @@ export class AddChargeSavingsAccountComponent implements OnInit {
savingsCharge.monthDayFormat = monthDayFormat;
if (savingsCharge.feeOnMonthDay) {
const prevDate = this.savingsChargeForm.value.feeOnMonthDay;
savingsCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
savingsCharge.feeOnMonthDay = this.dateUtils.formatDate(prevDate, monthDayFormat);
}
} else {
const dateFormat = this.settingsService.dateFormat;
savingsCharge.dateFormat = dateFormat;
if (savingsCharge.dueDate) {
const prevDate = this.savingsChargeForm.value.dueDate;
savingsCharge.dueDate = this.datePipe.transform(prevDate, dateFormat);
savingsCharge.dueDate = this.dateUtils.formatDate(prevDate, dateFormat);
}
}
}
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -34,14 +34,14 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -87,15 +87,15 @@ export class ApplyAnnualFeesSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const applyAnnualFeesFormData = this.applyAnnualFeesForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevApprovedOnDate: Date = this.applyAnnualFeesForm.value.dueDate;
this.applyAnnualFeesForm.patchValue({
dueDate: this.datePipe.transform(prevApprovedOnDate, dateFormat),
});
if (applyAnnualFeesFormData.dueDate instanceof Date) {
applyAnnualFeesFormData.dueDate = this.dateUtils.formatDate(prevApprovedOnDate, dateFormat);
}
const data = {
...this.applyAnnualFeesForm.value,
...applyAnnualFeesFormData,
dateFormat,
locale
};
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class ApproveSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class ApproveSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const approveSavingsAccountFormData = this.approveSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevApprovedOnDate: Date = this.approveSavingsAccountForm.value.approvedOnDate;
this.approveSavingsAccountForm.patchValue({
approvedOnDate: this.datePipe.transform(prevApprovedOnDate, dateFormat),
});
if (approveSavingsAccountFormData.approvedOnDate instanceof Date) {
approveSavingsAccountFormData.approvedOnDate = this.dateUtils.formatDate(prevApprovedOnDate, dateFormat);
}
const data = {
...this.approveSavingsAccountForm.value,
...approveSavingsAccountFormData,
dateFormat,
locale
};
@@ -30,7 +30,7 @@
<mat-form-field class="m-t-20" *ngIf="closeSavingsAccountForm.controls['amount']">
<mat-label>Transaction Amount</mat-label>
<input type=number required matInput formControlName="amount"/>
<input type="number" required matInput formControlName="amount"/>
</mat-form-field>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['paymentTypeId']">
@@ -49,27 +49,27 @@
<fa-icon [icon]="!addPaymentDetailsFlag ? 'plus-circle' : 'minus-circle'" size="lg"></fa-icon>
</button>
</div>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['accountNumber']">
<mat-label>Account Number</mat-label>
<input type="number" formControlName="accountNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['checkNumber']">
<mat-label>Cheque</mat-label>
<input type="number" formControlName="checkNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['routingCode']">
<mat-label>Routing Code</mat-label>
<input formControlName="routingCode" matInput />
</mat-form-field>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['receiptNumber']">
<mat-label>Receipt Number</mat-label>
<input formControlName="receiptNumber" matInput />
</mat-form-field>
<mat-form-field *ngIf="closeSavingsAccountForm.controls['bankNumber']">
<mat-label>Bank</mat-label>
<input formControlName="bankNumber" matInput />
@@ -1,8 +1,8 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -36,14 +36,14 @@ export class CloseSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -114,15 +114,15 @@ export class CloseSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const closeSavingsAccountFormData = this.closeSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevClosedOnDate: Date = this.closeSavingsAccountForm.value.closedOnDate;
this.closeSavingsAccountForm.patchValue({
closedOnDate: this.datePipe.transform(prevClosedOnDate, dateFormat),
});
if (closeSavingsAccountFormData.closedOnDate instanceof Date) {
closeSavingsAccountFormData.closedOnDate = this.dateUtils.formatDate(prevClosedOnDate, dateFormat);
}
const data = {
...this.closeSavingsAccountForm.value,
...closeSavingsAccountFormData,
dateFormat,
locale
};
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class PostInterestAsOnSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -65,15 +65,15 @@ export class PostInterestAsOnSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const postInterestSavingsAccountFormData = this.postInterestSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevTransactionDate: Date = this.postInterestSavingsAccountForm.value.transactionDate;
this.postInterestSavingsAccountForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat),
});
if (postInterestSavingsAccountFormData.transactionDate instanceof Date) {
postInterestSavingsAccountFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...this.postInterestSavingsAccountForm.value,
...postInterestSavingsAccountFormData,
IsPostInterestAsOn: true,
dateFormat,
locale
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class RejectSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class RejectSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const rejectSavingsAccountFormData = this.rejectSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevRejectedOnDate: Date = this.rejectSavingsAccountForm.value.rejectedOnDate;
this.rejectSavingsAccountForm.patchValue({
rejectedOnDate: this.datePipe.transform(prevRejectedOnDate, dateFormat),
});
if (rejectSavingsAccountFormData.rejectedOnDate instanceof Date) {
rejectSavingsAccountFormData.rejectedOnDate = this.dateUtils.formatDate(prevRejectedOnDate, dateFormat);
}
const data = {
...this.rejectSavingsAccountForm.value,
...rejectSavingsAccountFormData,
dateFormat,
locale
};
@@ -1,8 +1,8 @@
/** Angular Imports */
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -34,14 +34,14 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -74,15 +74,15 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const savingsAssignStaffFormData = this.savingsAssignStaffForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevAssignmentDate: Date = this.savingsAssignStaffForm.value.assignmentDate;
this.savingsAssignStaffForm.patchValue({
assignmentDate: this.datePipe.transform(prevAssignmentDate, dateFormat),
});
if (savingsAssignStaffFormData.assignmentDate instanceof Date) {
savingsAssignStaffFormData.assignmentDate = this.dateUtils.formatDate(prevAssignmentDate, dateFormat);
}
const data = {
...this.savingsAssignStaffForm.value,
...savingsAssignStaffFormData,
fromSavingsOfficerId: '',
dateFormat,
locale
@@ -2,11 +2,11 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { SavingsService } from '../../savings.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create savings account transactions component.
@@ -46,14 +46,14 @@ export class SavingsAccountTransactionsComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {SavingsService} savingsService Savings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @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 dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
@@ -107,16 +107,19 @@ export class SavingsAccountTransactionsComponent implements OnInit {
* Method to submit the transaction details.
*/
submit() {
const prevTransactionDate: Date = this.savingAccountTransactionForm.value.transactionDate;
// TODO: Update once language and date settings are setup
const savingAccountTransactionFormData = this.savingAccountTransactionForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.savingAccountTransactionForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
});
const transactionData = this.savingAccountTransactionForm.value;
transactionData.locale = this.settingsService.language.code;
transactionData.dateFormat = dateFormat;
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, transactionData).subscribe(res => {
const prevTransactionDate: Date = this.savingAccountTransactionForm.value.transactionDate;
if (savingAccountTransactionFormData.transactionDate instanceof Date) {
savingAccountTransactionFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...savingAccountTransactionFormData,
dateFormat,
locale
};
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, this.transactionCommand, data).subscribe(res => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
@@ -1,8 +1,8 @@
/** Angular Imports */
import { Component, OnInit, Input } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class SavingsAccountUnassignStaffComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -65,15 +65,15 @@ export class SavingsAccountUnassignStaffComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const savingsUnassignStaffFormData = this.savingsUnassignStaffForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevUnassignmentDate: Date = this.savingsUnassignStaffForm.value.unassignedDate;
this.savingsUnassignStaffForm.patchValue({
unassignedDate: this.datePipe.transform(prevUnassignmentDate, dateFormat),
});
if (savingsUnassignStaffFormData.unassignedDate instanceof Date) {
savingsUnassignStaffFormData.unassignedDate = this.dateUtils.formatDate(prevUnassignmentDate, dateFormat);
}
const data = {
...this.savingsUnassignStaffForm.value,
...savingsUnassignStaffFormData,
dateFormat,
locale
};
@@ -1,8 +1,8 @@
/** 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';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -30,14 +30,14 @@ export class WithdrawByClientSavingsAccountComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private savingsService: SavingsService,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router,
private settingsService: SettingsService) {
@@ -66,15 +66,15 @@ export class WithdrawByClientSavingsAccountComponent implements OnInit {
* if successful redirects to the saving account.
*/
submit() {
// TODO: Update once language and date settings are setup
const withdrawSavingsAccountFormData = this.withdrawSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevWithdrawnOnDate: Date = this.withdrawSavingsAccountForm.value.withdrawnOnDate;
this.withdrawSavingsAccountForm.patchValue({
withdrawnOnDate: this.datePipe.transform(prevWithdrawnOnDate, dateFormat),
});
if (withdrawSavingsAccountFormData.withdrawnOnDate instanceof Date) {
withdrawSavingsAccountFormData.withdrawnOnDate = this.dateUtils.formatDate(prevWithdrawnOnDate, dateFormat);
}
const data = {
...this.withdrawSavingsAccountForm.value,
...withdrawSavingsAccountFormData,
dateFormat,
locale
};
@@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
@@ -41,7 +41,7 @@ export class SingleRowComponent implements OnInit {
/**
* Fetches savings account Id from parent route params.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe Date Pipe.
* @param {DatePipe} datePipe Date Utils.
* @param {SavingsService} savingsService Savingss Service.
* @param {MatDialog} dialog Mat Dialog.
* @param {SettingsService} settingsService Setting service
@@ -151,7 +151,7 @@ export class SingleRowComponent implements OnInit {
/**
* Maps API response to data table form fields.
* @param {any} columns Data Table Columns.
* @param {string[]} dateTransformColumns Columns transformed with date pipe.
* @param {string[]} dateTransformColumns Columns transformed with Date Utils.
* @param {any} dataTableEntryObject Additional data table details.
*/
getFormfields(columns: any, dateTransformColumns: string[], dataTableEntryObject: any) {
@@ -32,4 +32,4 @@
</form>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width=100% height="750px;"></iframe>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width="100%" height="750px;"></iframe>
@@ -2,12 +2,12 @@
import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { FormBuilder, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
/** Custom Services */
import { ReportsService } from 'app/reports/reports.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Export Client Savings Transactions Component
@@ -37,14 +37,14 @@ export class ExportTransactionsComponent implements OnInit {
* @param {DomSanitizer} sanitizer DOM Sanitizer
* @param {ReportsService} reportsService Reports Service
* @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe Date Pipe
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {SettingsService} settingsService Settings Service
*/
constructor(private sanitizer: DomSanitizer,
private reportsService: ReportsService,
private formBuilder: FormBuilder,
private datePipe: DatePipe,
private dateUtils: Dates,
private route: ActivatedRoute,
private settingsService: SettingsService) {
this.route.parent.parent.data.subscribe((data: { savingsAccountData: any }) => {
@@ -73,8 +73,8 @@ export class ExportTransactionsComponent implements OnInit {
generate() {
const data = {
'output-type': 'PDF',
R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, this.settingsService.dateFormat),
R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, this.settingsService.dateFormat),
R_startDate: this.dateUtils.formatDate(this.transactionsReportForm.value.fromDate, this.settingsService.dateFormat),
R_endDate: this.dateUtils.formatDate(this.transactionsReportForm.value.toDate, this.settingsService.dateFormat),
R_savingsAccountId: this.savingsAccountId
};
this.reportsService.getPentahoRunReportData('Client Saving Transactions', data, 'default', this.settingsService.language.code, this.settingsService.dateFormat)
@@ -2,7 +2,7 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
@@ -44,14 +44,14 @@ export class EditTransactionComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {SavingsService} savingsService Savings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {DatePipe} datePipe DatePipe.
* @param {Dates} dateUtils Date Utils.
* @param {Router} router Router for navigation.
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private dateUtils: Dates,
private savingsService: SavingsService,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { savingsAccountTransactionTemplate: any }) => {
@@ -108,16 +108,19 @@ export class EditTransactionComponent implements OnInit {
* Method to submit the transaction details.
*/
submit() {
const prevTransactionDate: Date = this.editTransactionForm.value.transactionDate;
// TODO: Update once language and date settings are setup
const editTransactionFormData = this.editTransactionForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.editTransactionForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
});
const transactionData = this.editTransactionForm.value;
transactionData.locale = this.settingsService.language.code;
transactionData.dateFormat = dateFormat;
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, 'modify', transactionData, this.transactionTemplateData.id)
const prevTransactionDate: Date = this.editTransactionForm.value.transactionDate;
if (editTransactionFormData.transactionDate instanceof Date) {
editTransactionFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...editTransactionFormData,
dateFormat,
locale
};
this.savingsService.executeSavingsAccountTransactionsCommand(this.savingAccountId, 'modify', data, this.transactionTemplateData.id)
.subscribe(res => {
this.router.navigate(['../'], { relativeTo: this.route });
});