From 6ea3d9753860b8fa7b9c6d9141ded5006d6fb4c4 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Thu, 9 Jun 2022 21:59:51 -0500 Subject: [PATCH] Format date fields without patch form --- .../create-standing-instructions.component.ts | 12 ++-- .../edit-standing-instructions.component.ts | 12 ++-- .../make-account-transfers.component.ts | 8 +-- .../activate-center.component.ts | 16 ++--- .../attach-center-meeting.component.ts | 16 ++--- .../center-attendance.component.ts | 2 +- .../close-center/close-center.component.ts | 16 ++--- .../edit-center-meeting-schedule.component.ts | 20 +++--- .../edit-center-meeting.component.ts | 16 ++--- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../create-center/create-center.component.ts | 63 ++++++++++--------- .../edit-center/edit-center.component.ts | 15 ++--- .../client-family-member-dialog.component.ts | 16 ++--- .../client-general-step.component.ts | 21 +++---- .../client-pay-charges.component.ts | 26 ++++---- .../accept-client-transfer.component.ts | 17 ++++- .../activate-client.component.ts | 16 ++--- .../add-client-charge.component.html | 2 +- .../add-client-charge.component.ts | 10 +-- .../close-client/close-client.component.ts | 16 ++--- .../reactivate-client.component.ts | 16 ++--- .../reject-client-transfer.component.ts | 15 ++++- .../reject-client/reject-client.component.ts | 16 ++--- .../transfer-client.component.ts | 18 +++--- .../undo-client-rejection.component.ts | 16 ++--- .../undo-client-transfer.component.ts | 15 ++++- .../withdraw-client.component.ts | 16 ++--- .../add-family-member.component.ts | 27 ++++---- .../edit-family-member.component.ts | 29 +++++---- .../edit-client/edit-client.component.ts | 15 +++-- ...individual-collection-sheet.component.html | 4 +- ...individual-collection-sheet.component.scss | 6 +- .../individual-collection-sheet.component.ts | 14 ++--- .../create-fixed-deposit-account.component.ts | 2 +- .../edit-fixed-deposit-account.component.ts | 2 +- ...-deposit-account-charges-step.component.ts | 2 +- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- ...tivate-fixed-deposits-account.component.ts | 16 ++--- ...arge-fixed-deposits-account.component.html | 2 +- ...charge-fixed-deposits-account.component.ts | 10 +-- ...pprove-fixed-deposits-account.component.ts | 15 ++--- ...lose-fixed-deposits-account.component.html | 2 +- .../close-fixed-deposits-account.component.ts | 15 ++--- ...lose-fixed-deposits-account.component.html | 2 +- ...-close-fixed-deposits-account.component.ts | 17 ++--- ...reject-fixed-deposits-account.component.ts | 15 ++--- ...client-fixed-deposits-account.component.ts | 15 ++--- ...te-recurring-deposits-account.component.ts | 16 ++--- ...-recurring-deposits-account.component.html | 2 +- ...ge-recurring-deposits-account.component.ts | 10 +-- ...ve-recurring-deposits-account.component.ts | 16 ++--- ...-recurring-deposits-account.component.html | 2 +- ...-recurring-deposits-account.component.scss | 2 +- ...se-recurring-deposits-account.component.ts | 15 ++--- ...-recurring-deposits-account.component.html | 4 +- ...-recurring-deposits-account.component.scss | 2 +- ...it-recurring-deposits-account.component.ts | 17 ++--- ...ose-recurring-deposit-account.component.ts | 16 ++--- ...ct-recurring-deposits-account.component.ts | 16 ++--- ...nt-recurring-deposits-account.component.ts | 16 ++--- ...deposits-account-details-step.component.ts | 4 +- ...eposits-account-settings-step.component.ts | 4 +- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../edit-transaction.component.ts | 27 ++++---- .../create-group/create-group.component.ts | 35 ++++++----- .../groups/edit-group/edit-group.component.ts | 31 +++++---- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../activate-group.component.ts | 16 ++--- .../attach-group-meeting.component.ts | 16 ++--- .../close-group/close-group.component.ts | 16 ++--- .../edit-group-meeting-schedule.component.ts | 20 +++--- .../edit-group-meeting.component.ts | 16 ++--- .../group-attendance.component.ts | 2 +- .../client-trends-bar.component.ts | 2 +- .../create-loans-account.component.ts | 2 +- .../edit-loans-account.component.ts | 2 +- .../loans-account-details-step.component.ts | 4 +- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../add-loan-charge.component.html | 2 +- .../add-loan-charge.component.ts | 21 ++++--- .../approve-loan/approve-loan.component.html | 2 +- .../approve-loan/approve-loan.component.ts | 19 +++--- .../assign-loan-officer.component.ts | 23 ++++--- .../close-as-rescheduled.component.ts | 20 +++--- .../create-guarantor.component.html | 8 +-- .../create-guarantor.component.ts | 25 ++++---- .../disburse-loan-account.component.ts | 20 +++--- .../disburse/disburse.component.html | 2 +- .../disburse/disburse.component.scss | 2 +- .../disburse/disburse.component.ts | 21 ++++--- .../foreclosure/foreclosure.component.ts | 24 ++++--- .../loan-reschedule.component.ts | 35 ++++++----- .../loans-account-close.component.ts | 20 +++--- .../make-repayment.component.html | 2 +- .../make-repayment.component.scss | 2 +- .../make-repayment.component.ts | 19 +++--- .../prepay-loan/prepay-loan.component.html | 2 +- .../prepay-loan/prepay-loan.component.scss | 2 +- .../prepay-loan/prepay-loan.component.ts | 22 ++++--- .../recovery-repayment.component.html | 2 +- .../recovery-repayment.component.scss | 2 +- .../recovery-repayment.component.ts | 21 ++++--- .../reject-loan/reject-loan.component.ts | 20 +++--- .../waive-interest.component.ts | 26 ++++---- .../withdrawn-by-client.component.ts | 21 ++++--- .../write-off-page.component.ts | 28 +++++---- .../edit-transaction.component.ts | 27 ++++---- .../export-transactions.component.html | 2 +- .../export-transactions.component.ts | 10 +-- .../bulk-loan-reassignmnet.component.ts | 26 ++++---- .../create-employee.component.ts | 27 ++++---- .../edit-employee/edit-employee.component.ts | 27 ++++---- .../fund-mapping/fund-mapping.component.ts | 26 ++++---- .../create-holiday.component.ts | 32 +++++----- .../edit-holiday/edit-holiday.component.ts | 40 ++++++------ .../create-office/create-office.component.ts | 27 ++++---- .../edit-office/edit-office.component.html | 2 +- .../edit-office/edit-office.component.ts | 26 ++++---- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../create-campaign.component.ts | 2 +- .../edit-campaign/edit-campaign.component.ts | 2 +- ...edit-business-rule-parameters.component.ts | 6 +- .../business-rule-parameters.component.ts | 8 +-- .../view-campaign/view-campaign.component.ts | 41 ++++++------ ...standing-instructions-history.component.ts | 29 ++++++--- .../allocate-cash/allocate-cash.component.ts | 26 ++++---- .../create-cashier.component.html | 2 +- .../create-cashier.component.scss | 3 + .../create-cashier.component.ts | 32 ++++++---- .../edit-cashier/edit-cashier.component.html | 2 +- .../edit-cashier/edit-cashier.component.scss | 3 + .../edit-cashier/edit-cashier.component.ts | 34 +++++----- .../settle-cash/settle-cash.component.ts | 28 +++++---- .../create-teller/create-teller.component.ts | 31 +++++---- .../edit-teller/edit-teller.component.ts | 33 +++++----- .../create-charge/create-charge.component.ts | 40 ++++++------ ...duct-interest-rate-chart-step.component.ts | 10 +-- .../create-floating-rate.component.ts | 2 +- .../edit-floating-rate.component.ts | 2 +- .../loan-product-details-step.component.ts | 20 +++--- .../create-tax-component.component.ts | 27 ++++---- .../edit-tax-component.component.ts | 27 ++++---- .../create-tax-group.component.ts | 2 +- .../edit-tax-group.component.ts | 2 +- ...duct-interest-rate-chart-step.component.ts | 10 +-- .../create-dividend.component.ts | 32 ++++++---- ...are-product-market-price-step.component.ts | 4 +- .../run-report/run-report.component.html | 22 +++---- .../run-report/run-report.component.ts | 8 +-- .../xbrl-report/xbrl-report.component.html | 4 +- .../xbrl-report/xbrl-report.component.ts | 23 +++---- .../create-savings-account.component.ts | 2 +- .../edit-savings-account.component.ts | 2 +- .../activate-savings-account.component.ts | 16 ++--- .../add-charge-savings-account.component.html | 2 +- .../add-charge-savings-account.component.ts | 10 +-- ...y-annual-fees-savings-account.component.ts | 16 ++--- .../approve-savings-account.component.ts | 16 ++--- .../close-savings-account.component.html | 12 ++-- .../close-savings-account.component.ts | 16 ++--- ...nterest-as-on-savings-account.component.ts | 16 ++--- .../reject-savings-account.component.ts | 16 ++--- .../savings-account-assign-staff.component.ts | 16 ++--- .../savings-account-transactions.component.ts | 27 ++++---- ...avings-account-unassign-staff.component.ts | 16 ++--- ...raw-by-client-savings-account.component.ts | 16 ++--- .../multi-row/multi-row.component.ts | 2 +- .../single-row/single-row.component.ts | 4 +- .../export-transactions.component.html | 2 +- .../export-transactions.component.ts | 10 +-- .../edit-transaction.component.ts | 27 ++++---- .../create-shares-account.component.ts | 2 +- .../edit-shares-account.component.ts | 2 +- .../activate-shares-account.component.ts | 16 ++--- .../apply-shares/apply-shares.component.ts | 16 ++--- .../approve-shares-account.component.ts | 16 ++--- .../close-shares-account.component.ts | 16 ++--- .../redeem-shares/redeem-shares.component.ts | 16 ++--- .../reject-shares-account.component.ts | 16 ++--- .../audit-trails/audit-trails.component.ts | 8 +-- .../checker-inbox/checker-inbox.component.ts | 10 +-- .../client-approval.component.ts | 2 +- .../loan-approval/loan-approval.component.ts | 2 +- .../loan-disbursal.component.ts | 2 +- .../reschedule-loan.component.ts | 2 +- 191 files changed, 1408 insertions(+), 1173 deletions(-) diff --git a/src/app/account-transfers/create-standing-instructions/create-standing-instructions.component.ts b/src/app/account-transfers/create-standing-instructions/create-standing-instructions.component.ts index 9810e85e1..1ae1f66da 100644 --- a/src/app/account-transfers/create-standing-instructions/create-standing-instructions.component.ts +++ b/src/app/account-transfers/create-standing-instructions/create-standing-instructions.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { AccountTransfersService } from '../account-transfers.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create Standing Instructions @@ -70,14 +70,14 @@ export class CreateStandingInstructionsComponent implements OnInit { * @param {Router} router Router * @param {AccountTransfersService} accountTransfersService Account Transfers Service * @param {SettingsService} settingsService Settings Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private accountTransfersService: AccountTransfersService, private settingsService: SettingsService, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => { this.standingIntructionsTemplate = data.standingIntructionsTemplate; this.setParams(); @@ -221,9 +221,9 @@ export class CreateStandingInstructionsComponent implements OnInit { monthDayFormat: 'dd MMMM', fromClientId: this.clientId, fromOfficeId: this.officeId, - validFrom: this.datePipe.transform(this.createStandingInstructionsForm.value.validFrom, dateFormat), - validTill: this.datePipe.transform(this.createStandingInstructionsForm.value.validTill, dateFormat), - recurrenceOnMonthDay: this.datePipe.transform(this.createStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), + validFrom: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validFrom, dateFormat), + validTill: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.validTill, dateFormat), + recurrenceOnMonthDay: this.dateUtils.formatDate(this.createStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), }; delete standingInstructionData['destination']; delete standingInstructionData['applicant']; diff --git a/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts b/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts index 6680658c9..341e9fb8b 100644 --- a/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts +++ b/src/app/account-transfers/edit-standing-instructions/edit-standing-instructions.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { AccountTransfersService } from '../account-transfers.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Standing Instructions @@ -48,14 +48,14 @@ export class EditStandingInstructionsComponent implements OnInit { * @param {Router} router Router * @param {AccountTransfersService} accountTransfersService Account Transfers Service * @param {SettingsService} settingsService Settings Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private accountTransfersService: AccountTransfersService, private settingsService: SettingsService, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { standingInstructionsDataAndTemplate: any }) => { this.standingInstructionsData = data.standingInstructionsDataAndTemplate; this.standingInstructionsId = data.standingInstructionsDataAndTemplate.id; @@ -151,11 +151,11 @@ export class EditStandingInstructionsComponent implements OnInit { priority: this.editStandingInstructionsForm.value.priority, recurrenceFrequency: this.editStandingInstructionsForm.value.recurrenceFrequency, recurrenceInterval: this.editStandingInstructionsForm.value.recurrenceInterval, - recurrenceOnMonthDay: this.datePipe.transform(this.editStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), + recurrenceOnMonthDay: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.recurrenceOnMonthDay, 'dd MMMM'), recurrenceType: this.editStandingInstructionsForm.value.recurrenceType, status: this.editStandingInstructionsForm.value.status, - validFrom: this.datePipe.transform(this.editStandingInstructionsForm.value.validFrom, dateFormat), - validTill: this.datePipe.transform(this.editStandingInstructionsForm.value.validTill, dateFormat) + validFrom: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validFrom, dateFormat), + validTill: this.dateUtils.formatDate(this.editStandingInstructionsForm.value.validTill, dateFormat) }; this.accountTransfersService.updateStandingInstructionsData(this.standingInstructionsId, standingInstructionData).subscribe((response: any) => { this.router.navigate(['../view'], { relativeTo: this.route }); diff --git a/src/app/account-transfers/make-account-transfers/make-account-transfers.component.ts b/src/app/account-transfers/make-account-transfers/make-account-transfers.component.ts index 3a2785766..a1bf69871 100644 --- a/src/app/account-transfers/make-account-transfers/make-account-transfers.component.ts +++ b/src/app/account-transfers/make-account-transfers/make-account-transfers.component.ts @@ -2,12 +2,12 @@ import { Component, OnInit, AfterViewInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { AccountTransfersService } from '../account-transfers.service'; import { SettingsService } from 'app/settings/settings.service'; import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; /** @@ -51,7 +51,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit { * @param {FormBuilder} formBuilder Form Builder * @param {Router} router Router * @param {AccountTransfersService} accountTransfersService Account Transfers Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {SettingsService} settingsService Settings Service * @param {ClientsService} clientsService Clients Service */ @@ -59,7 +59,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit { private route: ActivatedRoute, private router: Router, private accountTransfersService: AccountTransfersService, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService, private clientsService: ClientsService) { this.route.data.subscribe((data: { accountTransferTemplate: any }) => { @@ -176,7 +176,7 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit { const locale = this.settingsService.language.code; const makeAccountTransferData = { ... this.makeAccountTransferForm.value, - transferDate: this.datePipe.transform(this.makeAccountTransferForm.value.transferDate, dateFormat), + transferDate: this.dateUtils.formatDate(this.makeAccountTransferForm.value.transferDate, dateFormat), dateFormat, locale, toClientId: this.makeAccountTransferForm.controls.toClientId.value.id, diff --git a/src/app/centers/centers-view/center-actions/activate-center/activate-center.component.ts b/src/app/centers/centers-view/center-actions/activate-center/activate-center.component.ts index d037b12ef..dbb329d34 100644 --- a/src/app/centers/centers-view/center-actions/activate-center/activate-center.component.ts +++ b/src/app/centers/centers-view/center-actions/activate-center/activate-center.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { CentersService } from 'app/centers/centers.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -31,14 +31,14 @@ export class ActivateCenterComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {centersService} CentersService Shares Service * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.centerId = this.route.parent.snapshot.params['centerId']; @@ -65,15 +65,15 @@ export class ActivateCenterComponent implements OnInit { * if successful redirects to the center. */ submit() { - // TODO: Update once language and date settings are setup + const activateCenterData = this.activateCenterForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevactivationDate: Date = this.activateCenterForm.value.activationDate; - this.activateCenterForm.patchValue({ - activationDate: this.datePipe.transform(prevactivationDate, dateFormat), - }); + if (activateCenterData.activationDate instanceof Date) { + activateCenterData.activationDate = this.dateUtils.formatDate(prevactivationDate, dateFormat); + } const data = { - ...this.activateCenterForm.value, + ...activateCenterData, dateFormat, locale }; diff --git a/src/app/centers/centers-view/center-actions/attach-center-meeting/attach-center-meeting.component.ts b/src/app/centers/centers-view/center-actions/attach-center-meeting/attach-center-meeting.component.ts index cfcdf3350..ee07d5d95 100644 --- a/src/app/centers/centers-view/center-actions/attach-center-meeting/attach-center-meeting.component.ts +++ b/src/app/centers/centers-view/center-actions/attach-center-meeting/attach-center-meeting.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { CentersService } from 'app/centers/centers.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -40,14 +40,14 @@ export class AttachCenterMeetingComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {CentersService} centersService Shares Service * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { centersActionData: any }) => { @@ -114,17 +114,17 @@ export class AttachCenterMeetingComponent implements OnInit { * Submits the form and attatches the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const centerMeetingFormData = this.centerMeetingForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const title = `centers_${this.centerId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.centerMeetingForm.value.startDate; - this.centerMeetingForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - }); + if (centerMeetingFormData.startDate instanceof Date) { + centerMeetingFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } const data = { - ...this.centerMeetingForm.value, + ...centerMeetingFormData, title, typeId, dateFormat, diff --git a/src/app/centers/centers-view/center-actions/center-attendance/center-attendance.component.ts b/src/app/centers/centers-view/center-actions/center-attendance/center-attendance.component.ts index f7a47f609..7ff2ce877 100644 --- a/src/app/centers/centers-view/center-actions/center-attendance/center-attendance.component.ts +++ b/src/app/centers/centers-view/center-actions/center-attendance/center-attendance.component.ts @@ -48,7 +48,7 @@ export class CenterAttendanceComponent implements OnInit { /** * Retrieves the center members data from `resolve`. * @param {ActivatedRoute} route Route - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {Router} router Router * @param {CentersService} centersService Centers Service * @param {SettingsService} settingsService Settings Service. diff --git a/src/app/centers/centers-view/center-actions/close-center/close-center.component.ts b/src/app/centers/centers-view/center-actions/close-center/close-center.component.ts index be58d07c2..3d1bc66d5 100644 --- a/src/app/centers/centers-view/center-actions/close-center/close-center.component.ts +++ b/src/app/centers/centers-view/center-actions/close-center/close-center.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { CentersService } from 'app/centers/centers.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -33,14 +33,14 @@ export class CloseCenterComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {CentersService} centersService Shares Service * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { centeractionData: any }) => { @@ -67,15 +67,15 @@ export class CloseCenterComponent implements OnInit { * Submits the form and closes the center. */ submit() { - // TODO: Update once language and date settings are setup + const closeCenterFormData = this.closeCenterForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeCenterForm.value.closureDate; - this.closeCenterForm.patchValue({ - closureDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (closeCenterFormData.closureDate instanceof Date) { + closeCenterFormData.closureDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.closeCenterForm.value, + ...closeCenterFormData, dateFormat, locale }; diff --git a/src/app/centers/centers-view/center-actions/edit-center-meeting-schedule/edit-center-meeting-schedule.component.ts b/src/app/centers/centers-view/center-actions/edit-center-meeting-schedule/edit-center-meeting-schedule.component.ts index 98c1cd168..c4e1f76c1 100644 --- a/src/app/centers/centers-view/center-actions/edit-center-meeting-schedule/edit-center-meeting-schedule.component.ts +++ b/src/app/centers/centers-view/center-actions/edit-center-meeting-schedule/edit-center-meeting-schedule.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { CentersService } from 'app/centers/centers.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -38,14 +38,14 @@ export class EditCenterMeetingScheduleComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {CentersService} centersService Shares Service * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { centersActionData: any }) => { @@ -74,18 +74,20 @@ export class EditCenterMeetingScheduleComponent implements OnInit { * Submits the form and updates the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const centerEditMeetingScheduleFormData = this.centerEditMeetingScheduleForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const reschedulebasedOnMeetingDates = true; const prevOldDate: Date = new Date(this.centerEditMeetingScheduleForm.value.presentMeetingDate); + if (centerEditMeetingScheduleFormData.startDate instanceof Date) { + centerEditMeetingScheduleFormData.presentMeetingDate = this.dateUtils.formatDate(prevOldDate, dateFormat); + } const prevNewDate: Date = this.centerEditMeetingScheduleForm.value.newMeetingDate; - this.centerEditMeetingScheduleForm.patchValue({ - 'presentMeetingDate': this.datePipe.transform(prevOldDate, dateFormat), - 'newMeetingDate': this.datePipe.transform(prevNewDate, dateFormat) - }); + if (centerEditMeetingScheduleFormData.newMeetingDate instanceof Date) { + centerEditMeetingScheduleFormData.newMeetingDate = this.dateUtils.formatDate(prevNewDate, dateFormat); + } const data = { - ...this.centerEditMeetingScheduleForm.value, + ...centerEditMeetingScheduleFormData, reschedulebasedOnMeetingDates, dateFormat, locale diff --git a/src/app/centers/centers-view/center-actions/edit-center-meeting/edit-center-meeting.component.ts b/src/app/centers/centers-view/center-actions/edit-center-meeting/edit-center-meeting.component.ts index 9198b1bf7..7287af4fa 100644 --- a/src/app/centers/centers-view/center-actions/edit-center-meeting/edit-center-meeting.component.ts +++ b/src/app/centers/centers-view/center-actions/edit-center-meeting/edit-center-meeting.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { CentersService } from 'app/centers/centers.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -42,14 +42,14 @@ export class EditCenterMeetingComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {CentersService} centersService Shares Service * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { centersActionData: any }) => { @@ -119,17 +119,17 @@ export class EditCenterMeetingComponent implements OnInit { * Submits the form and updates the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const centerEditMeetingFormData = this.centerEditMeetingForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const title = `centers_${this.centerId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.centerEditMeetingForm.value.startDate; - this.centerEditMeetingForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - }); + if (centerEditMeetingFormData.startDate instanceof Date) { + centerEditMeetingFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } const data = { - ...this.centerEditMeetingForm.value, + ...centerEditMeetingFormData, repeating: true, title, typeId, diff --git a/src/app/centers/centers-view/datatable-tab/multi-row/multi-row.component.ts b/src/app/centers/centers-view/datatable-tab/multi-row/multi-row.component.ts index d3973507a..7c70761a8 100644 --- a/src/app/centers/centers-view/datatable-tab/multi-row/multi-row.component.ts +++ b/src/app/centers/centers-view/datatable-tab/multi-row/multi-row.component.ts @@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges { /** * Fetches center Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {CentersService} centersService Centers Service. * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. diff --git a/src/app/centers/centers-view/datatable-tab/single-row/single-row.component.ts b/src/app/centers/centers-view/datatable-tab/single-row/single-row.component.ts index 0449d8b74..a36f57a02 100644 --- a/src/app/centers/centers-view/datatable-tab/single-row/single-row.component.ts +++ b/src/app/centers/centers-view/datatable-tab/single-row/single-row.component.ts @@ -40,7 +40,7 @@ export class SingleRowComponent implements OnInit { /** * Fetches center Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {CentersService} centersService Centers Service. * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. @@ -150,7 +150,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) { diff --git a/src/app/centers/create-center/create-center.component.ts b/src/app/centers/create-center/create-center.component.ts index 481dfa5bf..daa943fbc 100644 --- a/src/app/centers/create-center/create-center.component.ts +++ b/src/app/centers/create-center/create-center.component.ts @@ -2,12 +2,12 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service'; import { CentersService } from '../centers.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create Center component. @@ -44,16 +44,16 @@ export class CreateCenterComponent implements OnInit { * @param {CentersService} centerService CentersService. * @param {SettingsService} settingsService Settings Service. * @param {GroupsService} groupService GroupsService. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, - private route: ActivatedRoute, - private router: Router, - private centerService: CentersService, - private settingsService: SettingsService, - private groupService: GroupsService, - private datePipe: DatePipe) { - this.route.data.subscribe( (data: { offices: any }) => { + private route: ActivatedRoute, + private router: Router, + private centerService: CentersService, + private settingsService: SettingsService, + private groupService: GroupsService, + private dateUtils: Dates) { + this.route.data.subscribe((data: { offices: any }) => { this.officeData = data.offices; }); } @@ -85,8 +85,8 @@ export class CreateCenterComponent implements OnInit { * Adds form control Activation Date if active. */ buildDependencies() { - this.centerForm.get('officeId').valueChanges.subscribe( (option: any) => { - this.groupService.getGroupsByOfficeId(option).subscribe( (data: any) => { + this.centerForm.get('officeId').valueChanges.subscribe((option: any) => { + this.groupService.getGroupsByOfficeId(option).subscribe((data: any) => { this.groupsData = data; if (!this.groupsData.length) { this.groupChoice.disable(); @@ -94,7 +94,7 @@ export class CreateCenterComponent implements OnInit { this.groupChoice.enable(); } }); - this.centerService.getStaff(option).subscribe( (data: any) => { + this.centerService.getStaff(option).subscribe((data: any) => { this.staffData = data['staffOptions']; if (this.staffData === undefined) { this.centerForm.controls['staffId'].disable(); @@ -103,7 +103,7 @@ export class CreateCenterComponent implements OnInit { } }); }); - this.centerForm.get('active').valueChanges.subscribe( (bool: boolean) => { + this.centerForm.get('active').valueChanges.subscribe((bool: boolean) => { if (bool) { this.centerForm.addControl('activationDate', new FormControl('', Validators.required)); } else { @@ -133,22 +133,27 @@ export class CreateCenterComponent implements OnInit { * if successful redirects to centers. */ submit() { - const prevSubmittedOnDate: Date = this.centerForm.value.submittedOnDate; - const prevActivationDate: Date = this.centerForm.value.activationDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.centerForm.patchValue({ - submittedOnDate: this.datePipe.transform(prevSubmittedOnDate, dateFormat), - activationDate: this.datePipe.transform(prevActivationDate, dateFormat) - }); - const center = this.centerForm.value; - center.locale = this.settingsService.language.code; - center.dateFormat = dateFormat; - center.groupMembers = []; - this.groupMembers.forEach((group: any) => center.groupMembers.push(group.id)); - this.centerService.createCenter(center).subscribe((response: any) => { - this.router.navigate(['../centers']); - }); + const centerFormData = this.centerForm.value; + const prevSubmittedOnDate: Date = this.centerForm.value.submittedOnDate; + const prevActivationDate: Date = this.centerForm.value.activationDate; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + if (centerFormData.submittedOnDate instanceof Date) { + centerFormData.submittedOnDate = this.dateUtils.formatDate(prevSubmittedOnDate, dateFormat); } + if (centerFormData.activationDate instanceof Date) { + centerFormData.activationDate = this.dateUtils.formatDate(prevActivationDate, dateFormat); + } + const data = { + ...centerFormData, + dateFormat, + locale + }; + data.groupMembers = []; + this.groupMembers.forEach((group: any) => data.groupMembers.push(group.id)); + this.centerService.createCenter(data).subscribe((response: any) => { + this.router.navigate(['../centers']); + }); + } } diff --git a/src/app/centers/edit-center/edit-center.component.ts b/src/app/centers/edit-center/edit-center.component.ts index c1906a809..004c3dd60 100644 --- a/src/app/centers/edit-center/edit-center.component.ts +++ b/src/app/centers/edit-center/edit-center.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { CentersService } from '../centers.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Center component. @@ -36,14 +36,14 @@ export class EditCenterComponent implements OnInit { * @param {Router} router Router for navigation. * @param {CentersService} centerService CentersService. * @param {GroupsService} groupService GroupsService. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private centersService: CentersService, private settingsService: SettingsService, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { centerData: any }) => { this.centerData = data.centerData; this.staffs = this.centerData.staffOptions; @@ -77,16 +77,17 @@ export class EditCenterComponent implements OnInit { * if successful redirects to the center. */ submit() { + const editCenterFormData = this.editCenterForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; if (this.centerData.status.value === 'Pending') { const prevactivationDate: Date = this.editCenterForm.value.activationDate; - this.editCenterForm.patchValue({ - activationDate: this.datePipe.transform(prevactivationDate, dateFormat), - }); + if (editCenterFormData.activationDate instanceof Date) { + editCenterFormData.activationDate = this.dateUtils.formatDate(prevactivationDate, dateFormat); + } } const data = { - ...this.editCenterForm.value, + ...editCenterFormData, name: this.centerData.name, dateFormat, locale diff --git a/src/app/clients/client-stepper/client-family-members-step/client-family-member-dialog/client-family-member-dialog.component.ts b/src/app/clients/client-stepper/client-family-members-step/client-family-member-dialog/client-family-member-dialog.component.ts index 60740bb4d..a227b4970 100644 --- a/src/app/clients/client-stepper/client-family-members-step/client-family-member-dialog/client-family-member-dialog.component.ts +++ b/src/app/clients/client-stepper/client-family-members-step/client-family-member-dialog/client-family-member-dialog.component.ts @@ -2,10 +2,10 @@ import { Component, OnInit, Inject } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Client Family Members Dialog @@ -28,13 +28,13 @@ export class ClientFamilyMemberDialogComponent implements OnInit { /** * @param {MatDialogRef} dialogRef Client Family Member Dialog Reference * @param {FormBuilder} formBuilder Form Builder - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {any} data Dialog Data * @param {SettingsService} settingsService Setting service */ constructor(public dialogRef: MatDialogRef, private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, @Inject(MAT_DIALOG_DATA) public data: any, private settingsService: SettingsService) { } @@ -80,11 +80,14 @@ export class ClientFamilyMemberDialogComponent implements OnInit { * Returns Formatted Family Member */ get familyMember() { + const familyMemberFormData = this.familyMemberForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - // TODO: Update once language and date settings are setup + if (familyMemberFormData.dateOfBirth instanceof Date) { + familyMemberFormData.dateOfBirth = this.dateUtils.formatDate(familyMemberFormData.dateOfBirth, dateFormat); + } const familyMember = { - ...this.familyMemberForm.value, + ...familyMemberFormData, dateFormat, locale }; @@ -93,9 +96,6 @@ export class ClientFamilyMemberDialogComponent implements OnInit { delete familyMember[key]; } } - if (familyMember.dateOfBirth) { - familyMember.dateOfBirth = this.datePipe.transform(familyMember.dateOfBirth, dateFormat); - } return familyMember; } diff --git a/src/app/clients/client-stepper/client-general-step/client-general-step.component.ts b/src/app/clients/client-stepper/client-general-step/client-general-step.component.ts index fd5875d00..d779fbe08 100644 --- a/src/app/clients/client-stepper/client-general-step/client-general-step.component.ts +++ b/src/app/clients/client-stepper/client-general-step/client-general-step.component.ts @@ -1,7 +1,7 @@ /** Angular Imports */ import { Component, OnInit, Input } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service'; @@ -47,11 +47,11 @@ export class ClientGeneralStepComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {SettingsService} settingsService Setting service */ constructor(private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.setClientForm(); } @@ -148,26 +148,25 @@ export class ClientGeneralStepComponent implements OnInit { const generalDetails = this.createClientForm.value; const dateFormat = this.settingsService.dateFormat; const locale = this.settingsService.language.code; - // TODO: Update once language and date settings are setup for (const key in generalDetails) { if (generalDetails[key] === '' || key === 'addSavings') { delete generalDetails[key]; } } - if (generalDetails.submittedOnDate) { - generalDetails.submittedOnDate = this.datePipe.transform(generalDetails.submittedOnDate, dateFormat); + if (generalDetails.submittedOnDate instanceof Date) { + generalDetails.submittedOnDate = this.dateUtils.formatDate(generalDetails.submittedOnDate, dateFormat); } - if (generalDetails.activationDate) { - generalDetails.activationDate = this.datePipe.transform(generalDetails.activationDate, dateFormat); + if (generalDetails.activationDate instanceof Date) { + generalDetails.activationDate = this.dateUtils.formatDate(generalDetails.activationDate, dateFormat); } - if (generalDetails.dateOfBirth) { - generalDetails.dateOfBirth = this.datePipe.transform(generalDetails.dateOfBirth, dateFormat); + if (generalDetails.dateOfBirth instanceof Date) { + generalDetails.dateOfBirth = this.dateUtils.formatDate(generalDetails.dateOfBirth, dateFormat); } if (generalDetails.clientNonPersonDetails && generalDetails.clientNonPersonDetails.incorpValidityTillDate) { generalDetails.clientNonPersonDetails = { ...generalDetails.clientNonPersonDetails, - incorpValidityTillDate: this.datePipe.transform(generalDetails.dateOfBirth, dateFormat), + incorpValidityTillDate: this.dateUtils.formatDate(generalDetails.dateOfBirth, dateFormat), dateFormat, locale }; diff --git a/src/app/clients/clients-view/charges/client-pay-charges/client-pay-charges.component.ts b/src/app/clients/clients-view/charges/client-pay-charges/client-pay-charges.component.ts index c80f37b5d..1ca8e6b8f 100644 --- a/src/app/clients/clients-view/charges/client-pay-charges/client-pay-charges.component.ts +++ b/src/app/clients/clients-view/charges/client-pay-charges/client-pay-charges.component.ts @@ -2,10 +2,10 @@ 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 { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -38,7 +38,7 @@ export class ClientPayChargesComponent implements OnInit { private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService ) { this.route.data.subscribe((data: { transactionData: any }) => { @@ -64,15 +64,19 @@ export class ClientPayChargesComponent implements OnInit { * 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(() => { + const transactionFormData = this.transactionForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const prevTransactionDate = this.transactionForm.value.transactionDate; + if (transactionFormData.transactionDate instanceof Date) { + transactionFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...transactionFormData, + dateFormat, + locale + }; + this.clientsService.payClientCharge(this.transactionData.clientId, this.transactionData.id, data).subscribe(() => { this.router.navigate(['../', 'general']); }); } diff --git a/src/app/clients/clients-view/client-actions/accept-client-transfer/accept-client-transfer.component.ts b/src/app/clients/clients-view/client-actions/accept-client-transfer/accept-client-transfer.component.ts index e7d530101..bef4cea1e 100644 --- a/src/app/clients/clients-view/client-actions/accept-client-transfer/accept-client-transfer.component.ts +++ b/src/app/clients/clients-view/client-actions/accept-client-transfer/accept-client-transfer.component.ts @@ -5,6 +5,8 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; +import { SettingsService } from 'app/settings/settings.service'; /** * Accept Client Transfer Component @@ -26,11 +28,15 @@ export class AcceptClientTransferComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {ClientsService} clientsService Clients Service + * @param {SettingsService} settingsService Settings Service. + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, + private settingsService: SettingsService, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { clientActionData: any }) => { @@ -61,8 +67,17 @@ export class AcceptClientTransferComponent implements OnInit { * if successful redirects to the client. */ submit() { + const acceptClientTransferFormData = this.acceptClientTransferForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const prevTransferDate: Date = this.acceptClientTransferForm.value.transferDate; + if (acceptClientTransferFormData.transferDate instanceof Date) { + acceptClientTransferFormData.transferDate = this.dateUtils.formatDate(prevTransferDate, dateFormat); + } const data = { - ...this.acceptClientTransferForm.value, + ...acceptClientTransferFormData, + dateFormat, + locale }; this.clientsService.executeClientCommand(this.clientId, 'acceptTransfer', data).subscribe(() => { this.router.navigate(['../../'], { relativeTo: this.route }); diff --git a/src/app/clients/clients-view/client-actions/activate-client/activate-client.component.ts b/src/app/clients/clients-view/client-actions/activate-client/activate-client.component.ts index f0111394d..10955eca2 100644 --- a/src/app/clients/clients-view/client-actions/activate-client/activate-client.component.ts +++ b/src/app/clients/clients-view/client-actions/activate-client/activate-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -30,14 +30,14 @@ export class ActivateClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {clientsService} clientsService Cliens Service - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -65,15 +65,15 @@ export class ActivateClientComponent implements OnInit { * if successful redirects to the client. */ submit() { - // TODO: Update once language and date settings are setup + const activateClientFormData = this.activateClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevActivationDate: Date = this.activateClientForm.value.activationDate; - this.activateClientForm.patchValue({ - activationDate: this.datePipe.transform(prevActivationDate, dateFormat), - }); + if (activateClientFormData.activationDate instanceof Date) { + activateClientFormData.activationDate = this.dateUtils.formatDate(prevActivationDate, dateFormat); + } const data = { - ...this.activateClientForm.value, + ...activateClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.html b/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.html index 742c4828d..ab0b09d79 100644 --- a/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.html +++ b/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.html @@ -23,7 +23,7 @@ Amount - + Amount is required diff --git a/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.ts b/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.ts index 33b294165..a55c64b3a 100644 --- a/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.ts +++ b/src/app/clients/clients-view/client-actions/add-client-charge/add-client-charge.component.ts @@ -2,10 +2,10 @@ 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 { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -36,7 +36,7 @@ export class AddClientChargeComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {ClientsService} clientsService Clients Service * @param {SettingsService} settingsService Setting service */ @@ -44,7 +44,7 @@ export class AddClientChargeComponent implements OnInit { private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private clientsService: ClientsService, private settingsService: SettingsService ) { @@ -124,14 +124,14 @@ export class AddClientChargeComponent implements OnInit { clientCharge.monthDayFormat = monthDayFormat; if (clientCharge.feeOnMonthDay) { const prevDate = this.clientChargeForm.value.feeOnMonthDay; - clientCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat); + clientCharge.feeOnMonthDay = this.dateUtils.formatDate(prevDate, monthDayFormat); } } else { const dateFormat = this.settingsService.dateFormat; clientCharge.dateFormat = dateFormat; if (clientCharge.dueDate) { const prevDate = this.clientChargeForm.value.dueDate; - clientCharge.dueDate = this.datePipe.transform(prevDate, dateFormat); + clientCharge.dueDate = this.dateUtils.formatDate(prevDate, dateFormat); } } } diff --git a/src/app/clients/clients-view/client-actions/close-client/close-client.component.ts b/src/app/clients/clients-view/client-actions/close-client/close-client.component.ts index 10fe2b300..15df08183 100644 --- a/src/app/clients/clients-view/client-actions/close-client/close-client.component.ts +++ b/src/app/clients/clients-view/client-actions/close-client/close-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -32,14 +32,14 @@ export class CloseClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {ClientsService} clientsService Clients Service - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Setting service */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -67,15 +67,15 @@ export class CloseClientComponent implements OnInit { * Submits the form and closes the client. */ submit() { - // TODO: Update once language and date settings are setup + const closeClientFormData = this.closeClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeClientForm.value.closureDate; - this.closeClientForm.patchValue({ - closureDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (closeClientFormData.closureDate instanceof Date) { + closeClientFormData.closureDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.closeClientForm.value, + ...closeClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/reactivate-client/reactivate-client.component.ts b/src/app/clients/clients-view/client-actions/reactivate-client/reactivate-client.component.ts index f9e8c7289..83018da71 100644 --- a/src/app/clients/clients-view/client-actions/reactivate-client/reactivate-client.component.ts +++ b/src/app/clients/clients-view/client-actions/reactivate-client/reactivate-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -30,14 +30,14 @@ export class ReactivateClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {clientsService} clientsService Clients 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 clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -65,15 +65,15 @@ export class ReactivateClientComponent implements OnInit { * if successful redirects to the client. */ submit() { - // TODO: Update once language and date settings are setup + const reactivateClientFormData = this.reactivateClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevReactivationDate: Date = this.reactivateClientForm.value.reactivationDate; - this.reactivateClientForm.patchValue({ - reactivationDate: this.datePipe.transform(prevReactivationDate, dateFormat), - }); + if (reactivateClientFormData.closureDate instanceof Date) { + reactivateClientFormData.reactivationDate = this.dateUtils.formatDate(prevReactivationDate, dateFormat); + } const data = { - ...this.reactivateClientForm.value, + ...reactivateClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/reject-client-transfer/reject-client-transfer.component.ts b/src/app/clients/clients-view/client-actions/reject-client-transfer/reject-client-transfer.component.ts index 4ed7eb4cc..7876bc03a 100644 --- a/src/app/clients/clients-view/client-actions/reject-client-transfer/reject-client-transfer.component.ts +++ b/src/app/clients/clients-view/client-actions/reject-client-transfer/reject-client-transfer.component.ts @@ -5,6 +5,8 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; +import { SettingsService } from 'app/settings/settings.service'; /** * Reject Client Transfer Component @@ -31,6 +33,8 @@ export class RejectClientTransferComponent implements OnInit { */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, + private settingsService: SettingsService, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { clientActionData: any }) => { @@ -58,8 +62,17 @@ export class RejectClientTransferComponent implements OnInit { * if successful redirects to the client. */ submit() { + const rejectClientTransferFormData = this.rejectClientTransferForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const prevTransferDate: Date = this.rejectClientTransferForm.value.transferDate; + if (rejectClientTransferFormData.transferDate instanceof Date) { + rejectClientTransferFormData.transferDate = this.dateUtils.formatDate(prevTransferDate, dateFormat); + } const data = { - ...this.rejectClientTransferForm.value, + ...rejectClientTransferFormData, + dateFormat, + locale }; this.clientsService.executeClientCommand(this.clientId, 'rejectTransfer', data).subscribe(() => { this.router.navigate(['../../'], { relativeTo: this.route }); diff --git a/src/app/clients/clients-view/client-actions/reject-client/reject-client.component.ts b/src/app/clients/clients-view/client-actions/reject-client/reject-client.component.ts index e8fc6279c..ea0149ca0 100644 --- a/src/app/clients/clients-view/client-actions/reject-client/reject-client.component.ts +++ b/src/app/clients/clients-view/client-actions/reject-client/reject-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -32,14 +32,14 @@ export class RejectClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {ClientsService} clientsService Clients 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 clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -67,15 +67,15 @@ export class RejectClientComponent implements OnInit { * Submits the form and rejects the client. */ submit() { - // TODO: Update once language and date settings are setup + const rejectClientFormData = this.rejectClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRejectedDate: Date = this.rejectClientForm.value.rejectionDate; - this.rejectClientForm.patchValue({ - rejectionDate: this.datePipe.transform(prevRejectedDate, dateFormat), - }); + if (rejectClientFormData.rejectionDate instanceof Date) { + rejectClientFormData.rejectionDate = this.dateUtils.formatDate(prevRejectedDate, dateFormat); + } const data = { - ...this.rejectClientForm.value, + ...rejectClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/transfer-client/transfer-client.component.ts b/src/app/clients/clients-view/client-actions/transfer-client/transfer-client.component.ts index e26efd0b8..f55973c31 100644 --- a/src/app/clients/clients-view/client-actions/transfer-client/transfer-client.component.ts +++ b/src/app/clients/clients-view/client-actions/transfer-client/transfer-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -32,14 +32,14 @@ export class TransferClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {ClientsService} clientsService Clients 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 clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -68,15 +68,15 @@ export class TransferClientComponent implements OnInit { * Submits the form and transfers the client. */ submit() { - // TODO: Update once language and date settings are setup + const transferClientFormData = this.transferClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const prevClosedDate: Date = this.transferClientForm.value.transferDate; - this.transferClientForm.patchValue({ - transferDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + const prevTransferDate: Date = this.transferClientForm.value.transferDate; + if (transferClientFormData.transferDate instanceof Date) { + transferClientFormData.transferDate = this.dateUtils.formatDate(prevTransferDate, dateFormat); + } const data = { - ...this.transferClientForm.value, + ...transferClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/undo-client-rejection/undo-client-rejection.component.ts b/src/app/clients/clients-view/client-actions/undo-client-rejection/undo-client-rejection.component.ts index 9448413f7..89cd58447 100644 --- a/src/app/clients/clients-view/client-actions/undo-client-rejection/undo-client-rejection.component.ts +++ b/src/app/clients/clients-view/client-actions/undo-client-rejection/undo-client-rejection.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -30,13 +30,13 @@ export class UndoClientRejectionComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {clientsService} clientsService Cliens Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -64,15 +64,15 @@ export class UndoClientRejectionComponent implements OnInit { * if successful redirects to the client. */ submit() { - // TODO: Update once language and date settings are setup + const undoClientRejectionFormData = this.undoClientRejectionForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevReopenedDate: Date = this.undoClientRejectionForm.value.reopenedDate; - this.undoClientRejectionForm.patchValue({ - reopenedDate: this.datePipe.transform(prevReopenedDate, dateFormat), - }); + if (undoClientRejectionFormData.reopenedDate instanceof Date) { + undoClientRejectionFormData.reopenedDate = this.dateUtils.formatDate(prevReopenedDate, dateFormat); + } const data = { - ...this.undoClientRejectionForm.value, + ...undoClientRejectionFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/client-actions/undo-client-transfer/undo-client-transfer.component.ts b/src/app/clients/clients-view/client-actions/undo-client-transfer/undo-client-transfer.component.ts index 463df9da3..82f2bc132 100644 --- a/src/app/clients/clients-view/client-actions/undo-client-transfer/undo-client-transfer.component.ts +++ b/src/app/clients/clients-view/client-actions/undo-client-transfer/undo-client-transfer.component.ts @@ -5,6 +5,8 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; +import { SettingsService } from 'app/settings/settings.service'; /** * Undo Client Transfer Component @@ -31,6 +33,8 @@ export class UndoClientTransferComponent implements OnInit { */ constructor(private formBuilder: FormBuilder, private clientsService: ClientsService, + private settingsService: SettingsService, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router) { this.route.data.subscribe((data: { clientActionData: any }) => { @@ -61,8 +65,17 @@ export class UndoClientTransferComponent implements OnInit { * if successful redirects to the client. */ submit() { + const undoClientTransferFormData = this.undoClientTransferForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const prevTransferDate: Date = this.undoClientTransferForm.value.transferDate; + if (undoClientTransferFormData.transferDate instanceof Date) { + undoClientTransferFormData.transferDate = this.dateUtils.formatDate(prevTransferDate, dateFormat); + } const data = { - ...this.undoClientTransferForm.value, + ...undoClientTransferFormData, + dateFormat, + locale }; this.clientsService.executeClientCommand(this.clientId, 'withdrawTransfer', data).subscribe(() => { this.router.navigate(['../../'], { relativeTo: this.route }); diff --git a/src/app/clients/clients-view/client-actions/withdraw-client/withdraw-client.component.ts b/src/app/clients/clients-view/client-actions/withdraw-client/withdraw-client.component.ts index ab5819189..030b1129b 100644 --- a/src/app/clients/clients-view/client-actions/withdraw-client/withdraw-client.component.ts +++ b/src/app/clients/clients-view/client-actions/withdraw-client/withdraw-client.component.ts @@ -1,11 +1,11 @@ /** 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'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +import { Dates } from 'app/core/utils/dates'; import { SettingsService } from 'app/settings/settings.service'; /** @@ -32,14 +32,14 @@ export class WithdrawClientComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {ClientsService} clientsService Clients 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 clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -67,15 +67,15 @@ export class WithdrawClientComponent implements OnInit { * Submits the form and withdraws the client. */ submit() { - // TODO: Update once language and date settings are setup + const withdrawClientFormData = this.withdrawClientForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevWithdrawalDate: Date = this.withdrawClientForm.value.withdrawalDate; - this.withdrawClientForm.patchValue({ - withdrawalDate: this.datePipe.transform(prevWithdrawalDate, dateFormat), - }); + if (withdrawClientFormData.withdrawalDate instanceof Date) { + withdrawClientFormData.withdrawalDate = this.dateUtils.formatDate(prevWithdrawalDate, dateFormat); + } const data = { - ...this.withdrawClientForm.value, + ...withdrawClientFormData, dateFormat, locale }; diff --git a/src/app/clients/clients-view/family-members-tab/add-family-member/add-family-member.component.ts b/src/app/clients/clients-view/family-members-tab/add-family-member/add-family-member.component.ts index 9d1bee81c..045830c3e 100644 --- a/src/app/clients/clients-view/family-members-tab/add-family-member/add-family-member.component.ts +++ b/src/app/clients/clients-view/family-members-tab/add-family-member/add-family-member.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ClientsService } from '../../../clients.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Add Family Member Component @@ -31,14 +31,14 @@ export class AddFamilyMemberComponent implements OnInit { /** * @param {FormBuilder} formBuilder FormBuilder - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {Router} router Router * @param {Route} route Route * @param {ClientsService} clientsService Clients Service * @param {SettingsService} settingsService Setting service */ constructor(private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private router: Router, private route: ActivatedRoute, private clientsService: ClientsService, @@ -77,16 +77,19 @@ export class AddFamilyMemberComponent implements OnInit { * Submits the form and adds the family member */ submit() { - const prevDateOfBirth: Date = this.addFamilyMemberForm.value.dateOfBirth; - // TODO: Update once language and date settings are setup + const addFamilyMemberFormData = this.addFamilyMemberForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.addFamilyMemberForm.patchValue({ - dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat) - }); - const familyMemberData = this.addFamilyMemberForm.value; - familyMemberData.locale = this.settingsService.language.code; - familyMemberData.dateFormat = dateFormat; - this.clientsService.addFamilyMember(this.clientId, familyMemberData).subscribe(res => { + const prevDateOfBirth: Date = this.addFamilyMemberForm.value.dateOfBirth; + if (addFamilyMemberFormData.dateOfBirth instanceof Date) { + addFamilyMemberFormData.dateOfBirth = this.dateUtils.formatDate(prevDateOfBirth, dateFormat); + } + const data = { + ...addFamilyMemberFormData, + dateFormat, + locale + }; + this.clientsService.addFamilyMember(this.clientId, data).subscribe(res => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/clients/clients-view/family-members-tab/edit-family-member/edit-family-member.component.ts b/src/app/clients/clients-view/family-members-tab/edit-family-member/edit-family-member.component.ts index 652513806..0393e77f3 100644 --- a/src/app/clients/clients-view/family-members-tab/edit-family-member/edit-family-member.component.ts +++ b/src/app/clients/clients-view/family-members-tab/edit-family-member/edit-family-member.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ClientsService } from '../../../clients.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Family Member Component @@ -31,14 +31,14 @@ export class EditFamilyMemberComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder - * @param {DatePipe} datePipe DatePipe + * @param {Dates} dateUtils DatePipe * @param {Router} router Router * @param {ActivatedRoute} route Route * @param {ClientsService} clientsService Clients Service * @param {SettingsService} settingsService Setting service */ constructor(private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private router: Router, private route: ActivatedRoute, private clientsService: ClientsService, @@ -69,7 +69,7 @@ export class EditFamilyMemberComponent implements OnInit { 'genderId': [familyMember.genderId, Validators.required], 'professionId': [familyMember.professionId], 'maritalStatusId': [familyMember.maritalStatusId], - 'dateOfBirth': [this.datePipe.transform(familyMember.dateOfBirth, 'yyyy-MM-dd'), Validators.required] + 'dateOfBirth': [this.dateUtils.formatDate(familyMember.dateOfBirth, 'yyyy-MM-dd'), Validators.required] }); } @@ -77,16 +77,19 @@ export class EditFamilyMemberComponent implements OnInit { * Submits the form and updates the client family member. */ submit() { - const prevDateOfBirth: Date = this.editFamilyMemberForm.value.dateOfBirth; - // TODO: Update once language and date settings are setup + const editFamilyMemberFormData = this.editFamilyMemberForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.editFamilyMemberForm.patchValue({ - dateOfBirth: this.datePipe.transform(prevDateOfBirth, dateFormat) - }); - const familyMemberData = this.editFamilyMemberForm.value; - familyMemberData.locale = this.settingsService.language.code; - familyMemberData.dateFormat = dateFormat; - this.clientsService.editFamilyMember(this.familyMemberDetails.clientId, this.familyMemberDetails.id, familyMemberData).subscribe(res => { + const prevDateOfBirth: Date = this.editFamilyMemberForm.value.dateOfBirth; + if (editFamilyMemberFormData.dateOfBirth instanceof Date) { + editFamilyMemberFormData.dateOfBirth = this.dateUtils.formatDate(prevDateOfBirth, dateFormat); + } + const data = { + ...editFamilyMemberFormData, + dateFormat, + locale + }; + this.clientsService.editFamilyMember(this.familyMemberDetails.clientId, this.familyMemberDetails.id, data).subscribe(res => { this.router.navigate(['../../'], { relativeTo: this.route }); }); } diff --git a/src/app/clients/edit-client/edit-client.component.ts b/src/app/clients/edit-client/edit-client.component.ts index 18050bcab..d7294f2ec 100644 --- a/src/app/clients/edit-client/edit-client.component.ts +++ b/src/app/clients/edit-client/edit-client.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ClientsService } from '../clients.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Client Component @@ -51,14 +51,14 @@ export class EditClientComponent implements OnInit { * @param {ActivatedRoute} route ActivatedRoute * @param {Router} router Router * @param {ClientsService} clientsService Clients Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private clientsService: ClientsService, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe((data: { clientDataAndTemplate: any }) => { this.clientDataAndTemplate = data.clientDataAndTemplate; @@ -158,13 +158,12 @@ export class EditClientComponent implements OnInit { submit() { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - // TODO: Update once language and date settings are setup const editClientFormValue: any = this.editClientForm.getRawValue(); const clientData = { ...editClientFormValue, - dateOfBirth: editClientFormValue.dateOfBirth && this.datePipe.transform(editClientFormValue.dateOfBirth, dateFormat), - submittedOnDate: editClientFormValue.submittedOnDate && this.datePipe.transform(editClientFormValue.submittedOnDate, dateFormat), - activationDate: this.datePipe.transform(editClientFormValue.activationDate, dateFormat), + dateOfBirth: editClientFormValue.dateOfBirth && this.dateUtils.formatDate(editClientFormValue.dateOfBirth, dateFormat), + submittedOnDate: editClientFormValue.submittedOnDate && this.dateUtils.formatDate(editClientFormValue.submittedOnDate, dateFormat), + activationDate: this.dateUtils.formatDate(editClientFormValue.activationDate, dateFormat), dateFormat, locale }; @@ -172,7 +171,7 @@ export class EditClientComponent implements OnInit { if (editClientFormValue.clientNonPersonDetails) { clientData.clientNonPersonDetails = { ...editClientFormValue.clientNonPersonDetails, - incorpValidityTillDate: editClientFormValue.clientNonPersonDetails.incorpValidityTillDate && this.datePipe.transform(editClientFormValue.clientNonPersonDetails.incorpValidityTillDate, dateFormat), + incorpValidityTillDate: editClientFormValue.clientNonPersonDetails.incorpValidityTillDate && this.dateUtils.formatDate(editClientFormValue.clientNonPersonDetails.incorpValidityTillDate, dateFormat), dateFormat, locale }; diff --git a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.html b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.html index f7cc51415..4895a1e74 100644 --- a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.html +++ b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.html @@ -28,7 +28,7 @@ Repayment date + formControlName="transactionDate"> @@ -58,7 +58,7 @@ -
+
diff --git a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.scss b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.scss index fb5d3842b..19c570ef4 100644 --- a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.scss +++ b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.scss @@ -5,18 +5,18 @@ .margin-v { margin: 1em 0; } - + .margin-b { margin: 0 0 1em 0; } - + .margin-t { margin-top: 1em; } } -.showCollectionSheet { +.showcollectionsheet { .container { max-width: 73rem; } diff --git a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.ts b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.ts index 2d4554dd5..12af80ac1 100644 --- a/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.ts +++ b/src/app/collections/individual-collection-sheet/individual-collection-sheet.component.ts @@ -6,7 +6,6 @@ import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Services Import */ import { CollectionsService } from '../collections.service'; @@ -21,6 +20,7 @@ import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Individual Collection Sheet @@ -82,7 +82,7 @@ export class IndividualCollectionSheetComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {OrganizationService} collectionsService Organization Service. * @param {Route} route Route. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {Dialog} dialog Dialog component. * @param {Router} router Router for navigation. * @param {SettingsService} settingsService Settings Service @@ -90,7 +90,7 @@ export class IndividualCollectionSheetComponent implements OnInit { constructor(private formBuilder: FormBuilder, private collectionsService: CollectionsService, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, public dialog: MatDialog, private router: Router, private settingsService: SettingsService) { @@ -280,12 +280,11 @@ export class IndividualCollectionSheetComponent implements OnInit { * Searches collection sheet data */ previewCollectionSheet() { - // TODO: Update once language and date settings are setup const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const collectionSheet = { ...this.collectionSheetForm.value, - 'transactionDate': this.datePipe.transform(this.collectionSheetForm.value.transactionDate, dateFormat), + transactionDate: this.dateUtils.formatDate(this.collectionSheetForm.value.transactionDate, dateFormat), dateFormat, locale }; @@ -308,7 +307,6 @@ export class IndividualCollectionSheetComponent implements OnInit { * Submit the data with all the payments data */ submit() { - // TODO: Update once language and date settings are setup const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; this.bulkDisbursementTransactionsData['bulkRepaymentTransactions'] = this.bulkRepaymentTransactions; @@ -316,8 +314,8 @@ export class IndividualCollectionSheetComponent implements OnInit { const finalSubmitData = { dateFormat, locale, - actualDisbursementDate: this.datePipe.transform(this.collectionSheetForm.value.transactionDate, dateFormat), - transactionDate: this.datePipe.transform(this.collectionSheetForm.value.transactionDate, dateFormat), + actualDisbursementDate: this.dateUtils.formatDate(this.collectionSheetForm.value.transactionDate, dateFormat), + transactionDate: this.dateUtils.formatDate(this.collectionSheetForm.value.transactionDate, dateFormat), bulkDisbursementTransactions: this.bulkDisbursementTransactionsData }; this.collectionsService.executeSaveCollectionSheet(finalSubmitData).subscribe(() => { diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts index 5f105da1e..7f4c0db2f 100644 --- a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts @@ -44,7 +44,7 @@ export class CreateFixedDepositAccountComponent { * Fetches FD account template from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts index 5c0389e10..6e9e01b59 100644 --- a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts +++ b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts @@ -44,7 +44,7 @@ export class EditFixedDepositAccountComponent { * Fetches FD account template from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts index 32d81f0bf..22f59f353 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts @@ -45,7 +45,7 @@ export class FixedDepositAccountChargesStepComponent implements OnInit, OnChange /** * @param {MatDialog} dialog Mat Dialog - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {SettingsService} settingsService Settings Service */ constructor(public dialog: MatDialog, diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/multi-row/multi-row.component.ts index 3b7844d0a..5fa34dbef 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/multi-row/multi-row.component.ts @@ -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 Settings Service. diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/single-row/single-row.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/single-row/single-row.component.ts index 1412b78a8..0041745c4 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/datatable-tabs/single-row/single-row.component.ts @@ -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 Settings 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) { diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts index 20d95af04..8e2d5ef8c 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component.ts @@ -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'; @@ -31,14 +31,14 @@ export class ActivateFixedDepositsAccountComponent implements OnInit { * Fixed deposits endpoint is not supported so using Savings endpoint. * @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 Settings 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 ActivateFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fixed deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const activateFixedDepositsAccountFormData = this.activateFixedDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevActivatedOnDate: Date = this.activateFixedDepositsAccountForm.value.activatedOnDate; - this.activateFixedDepositsAccountForm.patchValue({ - activatedOnDate: this.datePipe.transform(prevActivatedOnDate, dateFormat), - }); + if (activateFixedDepositsAccountFormData.activatedOnDate instanceof Date) { + activateFixedDepositsAccountFormData.activatedOnDate = this.dateUtils.formatDate(prevActivatedOnDate, dateFormat); + } const data = { - ...this.activateFixedDepositsAccountForm.value, + ...activateFixedDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.html index 037d17406..620759e0d 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.html @@ -23,7 +23,7 @@ Amount - + Amount is required diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts index 04574e356..9704bfd58 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component.ts @@ -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'; @@ -37,7 +37,7 @@ export class AddChargeFixedDepositsAccountComponent 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 */ @@ -45,7 +45,7 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private savingsService: SavingsService, private settingsService: SettingsService ) { @@ -125,14 +125,14 @@ export class AddChargeFixedDepositsAccountComponent implements OnInit { savingsCharge.monthDayFormat = monthDayFormat; if (savingsCharge.feeOnMonthDay) { const prevDate = this.fixedDepositsChargeForm.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.fixedDepositsChargeForm.value.dueDate; - savingsCharge.dueDate = this.datePipe.transform(prevDate, dateFormat); + savingsCharge.dueDate = this.dateUtils.formatDate(prevDate, dateFormat); } } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts index 87aeabfa7..1a9f0022a 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/approve-fixed-deposits-account/approve-fixed-deposits-account.component.ts @@ -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 { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; @@ -30,14 +30,14 @@ export class ApproveFixedDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private fixedDepositsService: FixedDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,14 +66,15 @@ export class ApproveFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fixed deposit account. */ submit() { + const approveFixedDepositsAccountFormData = this.approveFixedDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevApprovedOnDate: Date = this.approveFixedDepositsAccountForm.value.approvedOnDate; - this.approveFixedDepositsAccountForm.patchValue({ - approvedOnDate: this.datePipe.transform(prevApprovedOnDate, dateFormat), - }); + if (approveFixedDepositsAccountFormData.approvedOnDate instanceof Date) { + approveFixedDepositsAccountFormData.approvedOnDate = this.dateUtils.formatDate(prevApprovedOnDate, dateFormat); + } const data = { - ...this.approveFixedDepositsAccountForm.value, + ...approveFixedDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.html index c7fb1e2cd..42c85aaf7 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.html @@ -20,7 +20,7 @@ Maturity Amount - + diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.ts index c898aa970..863c13597 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { FixedDepositsService } from '../../fixed-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Close On Maturity Fixed Deposits Account Component @@ -37,14 +37,14 @@ export class CloseFixedDepositsAccountComponent implements OnInit { * Fetches close action data from `resolve` * @param {FormBuilder} formBuilder Form Builder * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private fixedDepositsService: FixedDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -96,14 +96,15 @@ export class CloseFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fd account. */ submit() { + const closeOnMaturityAccountFormData = this.closeOnMaturityAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeOnMaturityAccountForm.value.closedOnDate; - this.closeOnMaturityAccountForm.patchValue({ - closedOnDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (closeOnMaturityAccountFormData.closedOnDate instanceof Date) { + closeOnMaturityAccountFormData.closedOnDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.closeOnMaturityAccountForm.value, + ...closeOnMaturityAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html index b18dd6cd1..092516eb4 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.html @@ -20,7 +20,7 @@ Maturity Amount - + diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts index 6df4430fb..a3af00303 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { FixedDepositsService } from '../../fixed-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Premature Close Fixed Deposits Account Component @@ -37,14 +37,14 @@ export class PrematureCloseFixedDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private fixedDepositsService: FixedDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -87,7 +87,7 @@ export class PrematureCloseFixedDepositsAccountComponent implements OnInit { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const data = { - closedOnDate: this.datePipe.transform(date, dateFormat), + closedOnDate: this.dateUtils.formatDate(date, dateFormat), dateFormat, locale }; @@ -124,15 +124,16 @@ export class PrematureCloseFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fd account. */ submit() { + const prematureCloseAccountFormData = this.prematureCloseAccountForm.value; this.isSubmitted = true; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.prematureCloseAccountForm.value.closedOnDate; - this.prematureCloseAccountForm.patchValue({ - closedOnDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (prematureCloseAccountFormData.closedOnDate instanceof Date) { + prematureCloseAccountFormData.closedOnDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.prematureCloseAccountForm.value, + ...prematureCloseAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/reject-fixed-deposits-account/reject-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/reject-fixed-deposits-account/reject-fixed-deposits-account.component.ts index 83c0c5710..61d40223e 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/reject-fixed-deposits-account/reject-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/reject-fixed-deposits-account/reject-fixed-deposits-account.component.ts @@ -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 { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; @@ -30,14 +30,14 @@ export class RejectFixedDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private fixedDepositsService: FixedDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,14 +66,15 @@ export class RejectFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fixed deposit account. */ submit() { + const rejectFixedDepositsAccountFormData = this.rejectFixedDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRejectedOnDate: Date = this.rejectFixedDepositsAccountForm.value.rejectedOnDate; - this.rejectFixedDepositsAccountForm.patchValue({ - rejectedOnDate: this.datePipe.transform(prevRejectedOnDate, dateFormat), - }); + if (rejectFixedDepositsAccountFormData.rejectedOnDate instanceof Date) { + rejectFixedDepositsAccountFormData.rejectedOnDate = this.dateUtils.formatDate(prevRejectedOnDate, dateFormat); + } const data = { - ...this.rejectFixedDepositsAccountForm.value, + ...rejectFixedDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts index 73e25b63a..a91549b79 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component.ts @@ -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 { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; @@ -30,14 +30,14 @@ export class WithdrawByClientFixedDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private fixedDepositsService: FixedDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,14 +66,15 @@ export class WithdrawByClientFixedDepositsAccountComponent implements OnInit { * if successful redirects to the fixed deposit account. */ submit() { + const withdrawFixedDepositsAccountFormData = this.withdrawFixedDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevWithdrawnOnDate: Date = this.withdrawFixedDepositsAccountForm.value.withdrawnOnDate; - this.withdrawFixedDepositsAccountForm.patchValue({ - withdrawnOnDate: this.datePipe.transform(prevWithdrawnOnDate, dateFormat), - }); + if (withdrawFixedDepositsAccountFormData.withdrawnOnDate instanceof Date) { + withdrawFixedDepositsAccountFormData.withdrawnOnDate = this.dateUtils.formatDate(prevWithdrawnOnDate, dateFormat); + } const data = { - ...this.withdrawFixedDepositsAccountForm.value, + ...withdrawFixedDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/activate-recurring-deposits-account/activate-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/activate-recurring-deposits-account/activate-recurring-deposits-account.component.ts index c9de92fe8..81630172b 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/activate-recurring-deposits-account/activate-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/activate-recurring-deposits-account/activate-recurring-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Activate Recurring Deposits Account Component @@ -30,14 +30,14 @@ export class ActivateRecurringDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {recurringDepositsService} recurringDepositsService Recurring Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SavingsService} savingsService Savings Service */ constructor(private formBuilder: FormBuilder, private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -65,15 +65,15 @@ export class ActivateRecurringDepositsAccountComponent implements OnInit { * if successful redirects to the recurring deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const activateRecurringDepositsAccountFormData = this.activateRecurringDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevActivatedOnDate: Date = this.activateRecurringDepositsAccountForm.value.activatedOnDate; - this.activateRecurringDepositsAccountForm.patchValue({ - activatedOnDate: this.datePipe.transform(prevActivatedOnDate, dateFormat), - }); + if (activateRecurringDepositsAccountFormData.activatedOnDate instanceof Date) { + activateRecurringDepositsAccountFormData.activatedOnDate = this.dateUtils.formatDate(prevActivatedOnDate, dateFormat); + } const data = { - ...this.activateRecurringDepositsAccountForm.value, + ...activateRecurringDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.html index ffadc2d06..e9acf785a 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.html @@ -23,7 +23,7 @@ Amount - + Amount is required diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts index 5928417be..5831b6edc 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/add-charge-recurring-deposits-account/add-charge-recurring-deposits-account.component.ts @@ -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'; @@ -37,14 +37,14 @@ export class AddChargeRecurringDepositsAccountComponent 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 */ constructor( private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private savingsService: SavingsService, private settingsService: SettingsService ) { @@ -124,14 +124,14 @@ export class AddChargeRecurringDepositsAccountComponent implements OnInit { savingsCharge.monthDayFormat = monthDayFormat; if (savingsCharge.feeOnMonthDay) { const prevDate = this.recurringDepositsChargeForm.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.recurringDepositsChargeForm.value.dueDate; - savingsCharge.dueDate = this.datePipe.transform(prevDate, dateFormat); + savingsCharge.dueDate = this.dateUtils.formatDate(prevDate, dateFormat); } } } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component.ts index abb27e2c5..f3adbae8c 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/approve-recurring-deposits-account/approve-recurring-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Approve Recurring Deposits Account Component @@ -30,14 +30,14 @@ export class ApproveRecurringDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,15 +66,15 @@ export class ApproveRecurringDepositsAccountComponent implements OnInit { * if successful redirects to the recurring deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const approveRecurringDepositsAccountFormData = this.approveRecurringDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevApprovedOnDate: Date = this.approveRecurringDepositsAccountForm.value.approvedOnDate; - this.approveRecurringDepositsAccountForm.patchValue({ - approvedOnDate: this.datePipe.transform(prevApprovedOnDate, dateFormat), - }); + if (approveRecurringDepositsAccountFormData.approvedOnDate instanceof Date) { + approveRecurringDepositsAccountFormData.approvedOnDate = this.dateUtils.formatDate(prevApprovedOnDate, dateFormat); + } const data = { - ...this.approveRecurringDepositsAccountForm.value, + ...approveRecurringDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.html index 31ac6c826..b9f0f6f41 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.html @@ -56,7 +56,7 @@
Show Payment Details - + diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.scss b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.scss index f76218e04..e5e6a71a3 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.scss +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.scss @@ -2,7 +2,7 @@ max-width: 37rem; } -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; margin-left: 2%; } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.ts index eb8e70f14..4570b6afb 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/close-recurring-deposits-account/close-recurring-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Close Recurring Deposits Account Component @@ -42,14 +42,14 @@ export class CloseRecurringDepositsAccountComponent 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 {SettingsService} settingsService Settings Service */ constructor( private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private recurringDepositsService: RecurringDepositsService, private settingsService: SettingsService ) { @@ -99,14 +99,15 @@ export class CloseRecurringDepositsAccountComponent implements OnInit { * Submits the close recurring deposit form */ submit() { + const closeRecurringDepositFormData = this.closeRecurringDepositForm.value; const closedOnDate = this.closeRecurringDepositForm.value.closedOnDate; const dateFormat = this.settingsService.dateFormat; const locale = this.settingsService.language.code; - this.closeRecurringDepositForm.patchValue({ - closedOnDate: this.datePipe.transform(closedOnDate, dateFormat) - }); + if (closeRecurringDepositFormData.closedOnDate instanceof Date) { + closeRecurringDepositFormData.closedOnDate = this.dateUtils.formatDate(closedOnDate, dateFormat); + } const data = { - ...this.closeRecurringDepositForm.value, + ...closeRecurringDepositFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.html index 028b3959d..094eee8df 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.html @@ -41,7 +41,7 @@
Show Payment Details - + @@ -96,4 +96,4 @@ -
\ No newline at end of file +
diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.scss b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.scss index f76218e04..e5e6a71a3 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.scss +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.scss @@ -2,7 +2,7 @@ max-width: 37rem; } -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; margin-left: 2%; } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.ts index 34e1223dc..390ee33e7 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/deposit-recurring-deposits-account/deposit-recurring-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Deposits Recurring Deposits Account Component @@ -40,14 +40,14 @@ export class DepositRecurringDepositsAccountComponent 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 {SettingsService} settingsService Settings Service */ constructor( private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private recurringDepositsService: RecurringDepositsService, private settingsService: SettingsService ) { @@ -94,14 +94,15 @@ export class DepositRecurringDepositsAccountComponent implements OnInit { * Submits the deposits recurring deposit form */ submit() { - const transactionDate = this.depositRecurringDepositForm.value.transactionDate; + const depositRecurringDepositFormData = this.depositRecurringDepositForm.value; const dateFormat = this.settingsService.dateFormat; const locale = this.settingsService.language.code; - this.depositRecurringDepositForm.patchValue({ - transactionDate: this.datePipe.transform(transactionDate, dateFormat) - }); + const prevTransactionDate = this.depositRecurringDepositForm.value.transactionDate; + if (depositRecurringDepositFormData.transactionDate instanceof Date) { + depositRecurringDepositFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } const data = { - ...this.depositRecurringDepositForm.value, + ...depositRecurringDepositFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/premature-close-recurring-deposit-account/premature-close-recurring-deposit-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/premature-close-recurring-deposit-account/premature-close-recurring-deposit-account.component.ts index ce54c0424..c2700fae8 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/premature-close-recurring-deposit-account/premature-close-recurring-deposit-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/premature-close-recurring-deposit-account/premature-close-recurring-deposit-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Premature Close Recurring Deposits Account Component @@ -31,14 +31,14 @@ export class PrematureCloseRecurringDepositAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService, ) { @@ -66,15 +66,15 @@ export class PrematureCloseRecurringDepositAccountComponent implements OnInit { * if successful redirects to the recurring deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const prematureCloseRecurringDepositsAccountFormData = this.prematureCloseRecurringDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedOnDate: Date = this.prematureCloseRecurringDepositsAccountForm.value.closedOnDate; - this.prematureCloseRecurringDepositsAccountForm.patchValue({ - closedOnDate: this.datePipe.transform(prevClosedOnDate, dateFormat), - }); + if (prematureCloseRecurringDepositsAccountFormData.closedOnDate instanceof Date) { + prematureCloseRecurringDepositsAccountFormData.closedOnDate = this.dateUtils.formatDate(prevClosedOnDate, dateFormat); + } const data = { - ...this.prematureCloseRecurringDepositsAccountForm.value, + ...prematureCloseRecurringDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component.ts index 39204f002..a06acca8d 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/reject-recurring-deposits-account/reject-recurring-deposits-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** @@ -31,14 +31,14 @@ export class RejectRecurringDepositsAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -67,15 +67,15 @@ export class RejectRecurringDepositsAccountComponent implements OnInit { * if successful redirects to the recurring deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const rejectRecurringDepositsAccountFormData = this.rejectRecurringDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRejectedOnDate: Date = this.rejectRecurringDepositsAccountForm.value.rejectedOnDate; - this.rejectRecurringDepositsAccountForm.patchValue({ - rejectedOnDate: this.datePipe.transform(prevRejectedOnDate, dateFormat), - }); + if (rejectRecurringDepositsAccountFormData.rejectedOnDate instanceof Date) { + rejectRecurringDepositsAccountFormData.rejectedOnDate = this.dateUtils.formatDate(prevRejectedOnDate, dateFormat); + } const data = { - ...this.rejectRecurringDepositsAccountForm.value, + ...rejectRecurringDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts index 51fdf2dbb..e3dd8a3aa 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-actions/withdraw-by-client-recurring-deposits-account/withdraw-by-client-recurring-deposits-account.component.ts @@ -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 { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service'; @@ -29,14 +29,14 @@ export class WithdrawByClientRecurringDepositsAccountComponent implements OnInit /** * @param {FormBuilder} formBuilder Form Builder * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService, ) { @@ -65,15 +65,15 @@ export class WithdrawByClientRecurringDepositsAccountComponent implements OnInit * if successful redirects to the recurring deposit account. */ submit() { - // TODO: Update once language and date settings are setup + const withdrawRecurringDepositsAccountFormData = this.withdrawRecurringDepositsAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevWithdrawnOnDate: Date = this.withdrawRecurringDepositsAccountForm.value.withdrawnOnDate; - this.withdrawRecurringDepositsAccountForm.patchValue({ - withdrawnOnDate: this.datePipe.transform(prevWithdrawnOnDate, dateFormat), - }); + if (withdrawRecurringDepositsAccountFormData.withdrawnOnDate instanceof Date) { + withdrawRecurringDepositsAccountFormData.withdrawnOnDate = this.dateUtils.formatDate(prevWithdrawnOnDate, dateFormat); + } const data = { - ...this.withdrawRecurringDepositsAccountForm.value, + ...withdrawRecurringDepositsAccountFormData, dateFormat, locale }; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts index 45e88d345..38dc4f28f 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts @@ -4,7 +4,6 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; /** Custom Services */ import { RecurringDepositsService } from '../../recurring-deposits.service'; -import { DatePipe } from '@angular/common'; /** * Recurring Deposits Account Details Step @@ -41,8 +40,7 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit { * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits Service. */ constructor(private formBuilder: FormBuilder, - private recurringDepositsService: RecurringDepositsService, - private datePipe: DatePipe) { + private recurringDepositsService: RecurringDepositsService) { this.createRecurringDepositsAccountDetailsForm(); } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts index cabdd3ff4..b815012d9 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts @@ -3,7 +3,6 @@ import { Component, OnInit, Input, OnChanges } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; /** Custom Services */ -import { DatePipe } from '@angular/common'; /** * Recurring Deposits Account Settings Step @@ -36,8 +35,7 @@ export class RecurringDepositsAccountSettingsStepComponent implements OnInit, On /** * @param {FormBuilder} formBuilder Form Builder */ - constructor(private formBuilder: FormBuilder, - private datePipe: DatePipe) { + constructor(private formBuilder: FormBuilder) { this.createRecurringDepositAccountSettingsForm(); this.buildDependencies(); } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/multi-row/multi-row.component.ts index 0d0a93bc1..22b0096d3 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/multi-row/multi-row.component.ts @@ -49,7 +49,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. */ diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/single-row/single-row.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/single-row/single-row.component.ts index 079f4295d..8179dd0da 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/datatable-tabs/single-row/single-row.component.ts @@ -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 Settings 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) { diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/transactions-tab/edit-transaction/edit-transaction.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/transactions-tab/edit-transaction/edit-transaction.component.ts index fc187b14b..3361d5cc4 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-view/transactions-tab/edit-transaction/edit-transaction.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-view/transactions-tab/edit-transaction/edit-transaction.component.ts @@ -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 { RecurringDepositsService } from 'app/deposits/recurring-deposits/recurring-deposits.service'; @@ -44,14 +44,14 @@ export class EditTransactionComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {RecurringDepositsService} recurringDepositsService Recurring Deposits 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 recurringDepositsService: RecurringDepositsService, private settingsService: SettingsService, ) { this.route.data.subscribe((data: { recurringDepositsAccountTransactionTemplate: any }) => { @@ -108,16 +108,19 @@ export class EditTransactionComponent implements OnInit { * 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.recurringDepositsService.executeRecurringDepositsAccountTransactionsCommand(this.recurringDepositAccountId, '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.recurringDepositsService.executeRecurringDepositsAccountTransactionsCommand(this.recurringDepositAccountId, 'modify', data, this.transactionTemplateData.id) .subscribe(res => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/groups/create-group/create-group.component.ts b/src/app/groups/create-group/create-group.component.ts index d370da3ff..69a930522 100644 --- a/src/app/groups/create-group/create-group.component.ts +++ b/src/app/groups/create-group/create-group.component.ts @@ -2,12 +2,12 @@ import { Component, OnInit, AfterViewInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { GroupsService } from '../groups.service'; import { ClientsService } from '../../clients/clients.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create Group component. @@ -43,7 +43,7 @@ export class CreateGroupComponent implements OnInit, AfterViewInit { * @param {Router} router Router for navigation. * @param {ClientsService} clientsService CentersService. * @param {GroupsService} groupService GroupsService. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, @@ -51,7 +51,7 @@ export class CreateGroupComponent implements OnInit, AfterViewInit { private router: Router, private clientsService: ClientsService, private groupService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe( (data: {offices: any} ) => { this.officeData = data.offices; @@ -149,20 +149,25 @@ export class CreateGroupComponent implements OnInit, AfterViewInit { * if successful redirects to groups. */ submit() { + const groupFormData = this.groupForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const submittedOnDate: Date = this.groupForm.value.submittedOnDate; const activationDate: Date = this.groupForm.value.activationDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.groupForm.patchValue({ - submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat), - activationDate: this.datePipe.transform(activationDate, dateFormat) - }); - const group = this.groupForm.value; - group.locale = this.settingsService.language.code; - group.dateFormat = dateFormat; - group.clientMembers = []; - this.clientMembers.forEach((client: any) => group.clientMembers.push(client.id)); - this.groupService.createGroup(group).subscribe((response: any) => { + if (groupFormData.submittedOnDate instanceof Date) { + groupFormData.submittedOnDate = this.dateUtils.formatDate(submittedOnDate, dateFormat); + } + if (groupFormData.activationDate instanceof Date) { + groupFormData.activationDate = this.dateUtils.formatDate(activationDate, dateFormat); + } + const data = { + ...groupFormData, + dateFormat, + locale + }; + data.clientMembers = []; + this.clientMembers.forEach((client: any) => data.clientMembers.push(client.id)); + this.groupService.createGroup(data).subscribe((response: any) => { this.router.navigate(['../groups']); }); } diff --git a/src/app/groups/edit-group/edit-group.component.ts b/src/app/groups/edit-group/edit-group.component.ts index 14ace7c94..36686b8ac 100644 --- a/src/app/groups/edit-group/edit-group.component.ts +++ b/src/app/groups/edit-group/edit-group.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { GroupsService } from '../groups.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Group component. @@ -37,14 +37,14 @@ export class EditGroupComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {GroupsService} groupService GroupsService. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, private groupService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe( (data: { groupAndTemplateData: any, groupViewData: any } ) => { this.staffData = data.groupAndTemplateData.staffOptions; @@ -96,18 +96,23 @@ export class EditGroupComponent implements OnInit { * if successful redirects to groups. */ submit() { + const editGroupFormData = this.editGroupForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const submittedOnDate: Date = this.editGroupForm.value.submittedOnDate; const activationDate: Date = this.editGroupForm.value.activationDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.editGroupForm.patchValue({ - submittedOnDate: this.datePipe.transform(submittedOnDate, dateFormat), - activationDate: activationDate && this.datePipe.transform(activationDate, dateFormat) - }); - const group = this.editGroupForm.value; - group.locale = this.settingsService.language.code; - group.dateFormat = dateFormat; - this.groupService.updateGroup(group, this.groupData.id).subscribe((response: any) => { + if (editGroupFormData.submittedOnDate instanceof Date) { + editGroupFormData.submittedOnDate = this.dateUtils.formatDate(submittedOnDate, dateFormat); + } + if (editGroupFormData.activationDate instanceof Date) { + editGroupFormData.activationDate = this.dateUtils.formatDate(activationDate, dateFormat); + } + const data = { + ...editGroupFormData, + dateFormat, + locale + }; + this.groupService.updateGroup(data, this.groupData.id).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts index 353fe5158..b1d42efa8 100644 --- a/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/groups/groups-view/datatable-tabs/multi-row/multi-row.component.ts @@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges { /** * Fetches group Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {GroupsService} groupsService Groups Service. * @param {MatDialog} dialog Mat Dialog. * @param {SettingsService} settingsService SettingsService diff --git a/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts b/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts index 21ee7b7c0..7fca15107 100644 --- a/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/groups/groups-view/datatable-tabs/single-row/single-row.component.ts @@ -40,7 +40,7 @@ export class SingleRowComponent implements OnInit { /** * Fetches group Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {GroupsService} groupsService Groups Service. * @param {MatDialog} dialog Mat Dialog. * @param {SettingsService} settingsService SettingsService @@ -150,7 +150,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) { diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts index 6f2b46d2d..df7a5e825 100644 --- a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts @@ -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 { GroupsService } from 'app/groups/groups.service'; @@ -30,14 +30,14 @@ export class ActivateGroupComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {groupsService} groupsService Groups Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -62,15 +62,15 @@ export class ActivateGroupComponent implements OnInit { * if successful redirects to the group. */ submit() { - // TODO: Update once language and date settings are setup + const activateGroupFormData = this.activateGroupForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevactivationDate: Date = this.activateGroupForm.value.activationDate; - this.activateGroupForm.patchValue({ - activationDate: this.datePipe.transform(prevactivationDate, dateFormat), - }); + if (activateGroupFormData.activationDate instanceof Date) { + activateGroupFormData.activationDate = this.dateUtils.formatDate(prevactivationDate, dateFormat); + } const data = { - ...this.activateGroupForm.value, + ...activateGroupFormData, dateFormat, locale }; diff --git a/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts b/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts index 5ea367dfb..c95c89303 100644 --- a/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts +++ b/src/app/groups/groups-view/group-actions/attach-group-meeting/attach-group-meeting.component.ts @@ -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 { GroupsService } from 'app/groups/groups.service'; @@ -39,14 +39,14 @@ export class AttachGroupMeetingComponent implements OnInit { * Fetches Calendar Template from `resolve` * @param {FormBuilder} formBuilder Form Builder * @param {GroupsService} groupsService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -114,17 +114,17 @@ export class AttachGroupMeetingComponent implements OnInit { * Submits the form and attatches the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const groupMeetingFormData = this.groupMeetingForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const title = `groups_${this.groupId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.groupMeetingForm.value.startDate; - this.groupMeetingForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - }); + if (groupMeetingFormData.startDate instanceof Date) { + groupMeetingFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } const data = { - ...this.groupMeetingForm.value, + ...groupMeetingFormData, title, typeId, dateFormat, diff --git a/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts b/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts index 758dede29..0aa6c744f 100644 --- a/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts +++ b/src/app/groups/groups-view/group-actions/close-group/close-group.component.ts @@ -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 { GroupsService } from 'app/groups/groups.service'; @@ -32,14 +32,14 @@ export class CloseGroupComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {GroupsService} groupsService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -67,15 +67,15 @@ export class CloseGroupComponent implements OnInit { * Submits the form and closes the group. */ submit() { - // TODO: Update once language and date settings are setup + const closeGroupFormData = this.closeGroupForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeGroupForm.value.closureDate; - this.closeGroupForm.patchValue({ - closureDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (closeGroupFormData.closureDate instanceof Date) { + closeGroupFormData.closureDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.closeGroupForm.value, + ...closeGroupFormData, dateFormat, locale }; diff --git a/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts b/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts index 7b0e51e24..9111a0faa 100644 --- a/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts +++ b/src/app/groups/groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component.ts @@ -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 { GroupsService } from 'app/groups/groups.service'; @@ -37,14 +37,14 @@ export class EditGroupMeetingScheduleComponent implements OnInit { * Fetches Calendar Template from `resolve` * @param {FormBuilder} formBuilder Form Builder * @param {GroupsService} groupsService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -74,18 +74,20 @@ export class EditGroupMeetingScheduleComponent implements OnInit { * Submits the form and updates the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const groupEditMeetingScheduleFormData = this.groupEditMeetingScheduleForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const reschedulebasedOnMeetingDates = true; const prevOldDate: Date = new Date(this.groupEditMeetingScheduleForm.value.presentMeetingDate); const prevNewDate: Date = this.groupEditMeetingScheduleForm.value.newMeetingDate; - this.groupEditMeetingScheduleForm.patchValue({ - 'presentMeetingDate': this.datePipe.transform(prevOldDate, dateFormat), - 'newMeetingDate': this.datePipe.transform(prevNewDate, dateFormat) - }); + if (groupEditMeetingScheduleFormData.presentMeetingDate instanceof Date) { + groupEditMeetingScheduleFormData.presentMeetingDate = this.dateUtils.formatDate(prevOldDate, dateFormat); + } + if (groupEditMeetingScheduleFormData.newMeetingDate instanceof Date) { + groupEditMeetingScheduleFormData.newMeetingDate = this.dateUtils.formatDate(prevNewDate, dateFormat); + } const data = { - ...this.groupEditMeetingScheduleForm.value, + ...groupEditMeetingScheduleFormData, reschedulebasedOnMeetingDates, dateFormat, locale diff --git a/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts b/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts index e31105a6b..26d052b99 100644 --- a/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts +++ b/src/app/groups/groups-view/group-actions/edit-group-meeting/edit-group-meeting.component.ts @@ -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 { GroupsService } from 'app/groups/groups.service'; @@ -41,14 +41,14 @@ export class EditGroupMeetingComponent implements OnInit { * Fetches Calendar Template from `resolve` * @param {FormBuilder} formBuilder Form Builder * @param {GroupsService} groupsService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService SettingsService */ constructor(private formBuilder: FormBuilder, private groupsService: GroupsService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -119,17 +119,17 @@ export class EditGroupMeetingComponent implements OnInit { * Submits the form and updates the meeting. */ submit() { - // TODO: Update once language and date settings are setup + const groupEditMeetingFormData = this.groupEditMeetingForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const title = `groups_${this.groupId}_CollectionMeeting`; const typeId = '1'; const prevStartDate: Date = this.groupEditMeetingForm.value.startDate; - this.groupEditMeetingForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - }); + if (groupEditMeetingFormData.startDate instanceof Date) { + groupEditMeetingFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } const data = { - ...this.groupEditMeetingForm.value, + ...groupEditMeetingFormData, repeating: true, title, typeId, diff --git a/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts b/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts index d294faec6..8919fd458 100644 --- a/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts +++ b/src/app/groups/groups-view/group-actions/group-attendance/group-attendance.component.ts @@ -44,7 +44,7 @@ export class GroupAttendanceComponent implements OnInit { /** * Retrieves the group members data from `resolve`. * @param {ActivatedRoute} route Route - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {Router} router Router * @param {GroupsService} groupsService Groups Service * @param {MatDialog} dialog Mat Dialog diff --git a/src/app/home/dashboard/client-trends-bar/client-trends-bar.component.ts b/src/app/home/dashboard/client-trends-bar/client-trends-bar.component.ts index 369f49332..10c3621d5 100644 --- a/src/app/home/dashboard/client-trends-bar/client-trends-bar.component.ts +++ b/src/app/home/dashboard/client-trends-bar/client-trends-bar.component.ts @@ -39,7 +39,7 @@ export class ClientTrendsBarComponent implements OnInit { * Fetches offices data from `resolve` * @param {HomeService} homeService Home Service * @param {ActivatedRoute} route Activated Route - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils */ constructor(private homeService: HomeService, private route: ActivatedRoute, diff --git a/src/app/loans/create-loans-account/create-loans-account.component.ts b/src/app/loans/create-loans-account/create-loans-account.component.ts index 335ae9825..cbb6c1176 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.ts +++ b/src/app/loans/create-loans-account/create-loans-account.component.ts @@ -40,7 +40,7 @@ export class CreateLoansAccountComponent implements OnInit { * Sets loans account create form. * @param {route} ActivatedRoute Activated Route. * @param {router} Router Router. - * @param {datePipe} DatePipe Date Pipe + * @param {datePipe} DatePipe Date Utils * @param {loansService} LoansService Loans Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/loans/edit-loans-account/edit-loans-account.component.ts b/src/app/loans/edit-loans-account/edit-loans-account.component.ts index 8ed564ce4..5b815e0f9 100644 --- a/src/app/loans/edit-loans-account/edit-loans-account.component.ts +++ b/src/app/loans/edit-loans-account/edit-loans-account.component.ts @@ -35,7 +35,7 @@ export class EditLoansAccountComponent implements OnInit { * Sets loans account edit form. * @param {route} ActivatedRoute Activated Route. * @param {router} Router Router. - * @param {datePipe} DatePipe Date Pipe + * @param {datePipe} DatePipe Date Utils * @param {loansService} LoansService Loans Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts index acfba3981..203e96c14 100644 --- a/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-details-step/loans-account-details-step.component.ts @@ -4,7 +4,6 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; /** Custom Services */ import { LoansService } from '../../loans.service'; -import { DatePipe } from '@angular/common'; /** * Loans Account Details Step @@ -46,8 +45,7 @@ export class LoansAccountDetailsStepComponent implements OnInit { * @param {LoansService} loansService Loans Service. */ constructor(private formBuilder: FormBuilder, - private loansService: LoansService, - private datePipe: DatePipe) { + private loansService: LoansService) { this.createLoansAccountDetailsForm(); } diff --git a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts index c22af967d..f9ad709c8 100644 --- a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts +++ b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts @@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges { /** * Fetches loan Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {LoansService} loansService Loans Service. * @param {MatDialog} dialog Mat Dialog. * @param {SettingsService} settingsService Settings Service diff --git a/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.ts b/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.ts index 9c84981fe..f700a79f7 100644 --- a/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.ts +++ b/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.ts @@ -38,7 +38,7 @@ export class SingleRowComponent implements OnInit { /** * Fetches loan Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {LoansService} loansService Loans Service. * @param {MatDialog} dialog Mat Dialog. * @param {SettingsService} settingsService Settings Service @@ -148,7 +148,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) { diff --git a/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.html b/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.html index 637ffdc5b..0cd9c38f9 100644 --- a/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.html +++ b/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.html @@ -21,7 +21,7 @@ Amount - + Amount is required diff --git a/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.ts b/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.ts index d7c768d48..ef78c1768 100644 --- a/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/add-loan-charge/add-loan-charge.component.ts @@ -98,16 +98,19 @@ export class AddLoanChargeComponent implements OnInit { } submit() { - const prevDueDate: Date = this.loanChargeForm.value.dueDate; - // TODO: Update once language and date settings are setup + const loanChargeFormData = this.loanChargeForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.loanChargeForm.patchValue({ - dueDate: this.dateUtils.formatDate(prevDueDate, dateFormat) - }); - const loanCharge = this.loanChargeForm.value; - loanCharge.locale = this.settingsService.language.code; - loanCharge.dateFormat = dateFormat; - this.loansService.createLoanCharge(this.loanId, 'charges', loanCharge).subscribe(res => { + const prevDueDate: Date = this.loanChargeForm.value.dueDate; + if (loanChargeFormData.dueDate instanceof Date) { + loanChargeFormData.dueDate = this.dateUtils.formatDate(prevDueDate, dateFormat); + } + const data = { + ...loanChargeFormData, + dateFormat, + locale + }; + this.loansService.createLoanCharge(this.loanId, 'charges', data).subscribe(res => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); } diff --git a/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html b/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html index f75c85b8f..c28d101ee 100644 --- a/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html +++ b/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html @@ -34,7 +34,7 @@ Transaction Amount - + Transaction Amount is required diff --git a/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts b/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts index 9c71ef8a7..86bc588c3 100644 --- a/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts @@ -33,7 +33,7 @@ export class ApproveLoanComponent implements OnInit { * Retrieve data from `Resolver`. * @param formBuilder Form Builder. * @param route Activated Route. - * @param datePipe Date Pipe. + * @param datePipe Date Utils. * @param loanService Loan Service. * @param router Router. * @param {SettingsService} settingsService Settings Service @@ -76,20 +76,23 @@ export class ApproveLoanComponent implements OnInit { * Submits Approve form. */ submit() { + const approveLoanFormData = this.approveLoanForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const approvedOnDate = this.approveLoanForm.value.approvedOnDate; const expectedDisbursementDate = this.approveLoanForm.value.expectedDisbursementDate; - this.approveLoanForm.patchValue({ - approvedOnDate: this.dateUtils.formatDate(approvedOnDate, dateFormat), - expectedDisbursementDate: this.dateUtils.formatDate(expectedDisbursementDate, dateFormat) - }); - const approveLoanFormData = { - ... this.approveLoanForm.value, + if (approveLoanFormData.approvedOnDate instanceof Date) { + approveLoanFormData.approvedOnDate = this.dateUtils.formatDate(approvedOnDate, dateFormat); + } + if (approveLoanFormData.expectedDisbursementDate instanceof Date) { + approveLoanFormData.expectedDisbursementDate = this.dateUtils.formatDate(expectedDisbursementDate, dateFormat); + } + const data = { + ...approveLoanFormData, dateFormat, locale }; - this.loanService.loanActionButtons(this.loanId, 'approve', approveLoanFormData).subscribe((response: any) => { + this.loanService.loanActionButtons(this.loanId, 'approve', data).subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); } diff --git a/src/app/loans/loans-view/loan-account-actions/assign-loan-officer/assign-loan-officer.component.ts b/src/app/loans/loans-view/loan-account-actions/assign-loan-officer/assign-loan-officer.component.ts index 1f4ed4dc0..4741ef1b5 100644 --- a/src/app/loans/loans-view/loan-account-actions/assign-loan-officer/assign-loan-officer.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/assign-loan-officer/assign-loan-officer.component.ts @@ -60,17 +60,20 @@ export class AssignLoanOfficerComponent implements OnInit { } submit() { - const assignmentDate = this.assignOfficerForm.value.assignmentDate; + const assignOfficerFormData = this.assignOfficerForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.assignOfficerForm.patchValue({ - assignmentDate: this.dateUtils.formatDate(assignmentDate, dateFormat) - }); - const assignForm = this.assignOfficerForm.value; - assignForm.locale = this.settingsService.language.code; - assignForm.dateFormat = dateFormat; - assignForm.fromLoanOfficerId = this.dataObject.loanOfficerId || ''; - - this.loanService.loanActionButtons(this.loanId, 'assignLoanOfficer', assignForm) + const assignmentDate = this.assignOfficerForm.value.assignmentDate; + if (assignOfficerFormData.assignmentDate instanceof Date) { + assignOfficerFormData.assignmentDate = this.dateUtils.formatDate(assignmentDate, dateFormat); + } + const data = { + ...assignOfficerFormData, + dateFormat, + locale + }; + data.fromLoanOfficerId = this.dataObject.loanOfficerId || ''; + this.loanService.loanActionButtons(this.loanId, 'assignLoanOfficer', data) .subscribe((response: any) => { this.router.navigate([`../../general`], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts index 3087c51e8..6f6d99958 100644 --- a/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/close-as-rescheduled/close-as-rescheduled.component.ts @@ -63,15 +63,19 @@ export class CloseAsRescheduledComponent implements OnInit { * if successful redirects to view created close. */ submit() { - const transactionDate = this.closeLoanForm.value.transactionDate; + const closeLoanFormData = this.closeLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.closeLoanForm.patchValue({ - transactionDate: this.dateUtils.formatDate(transactionDate, dateFormat) - }); - const closeForm = this.closeLoanForm.value; - closeForm.locale = this.settingsService.language.code; - closeForm.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(this.loanId, closeForm, 'close-rescheduled') + const transactionDate = this.closeLoanForm.value.transactionDate; + if (closeLoanFormData.transactionDate instanceof Date) { + closeLoanFormData.transactionDate = this.dateUtils.formatDate(transactionDate, dateFormat); + } + const data = { + ...closeLoanFormData, + dateFormat, + locale + }; + this.loanService.submitLoanActionButton(this.loanId, data, 'close-rescheduled') .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.html b/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.html index d66270b11..320edf250 100644 --- a/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.html +++ b/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.html @@ -23,7 +23,7 @@ + (optionSelected)="clientSelected($event.option.value)"> {{ client.displayName }} @@ -51,7 +51,7 @@ Amount - + @@ -71,7 +71,7 @@ First Name - + First Name is required @@ -79,7 +79,7 @@ Last Name - + Last Name is required diff --git a/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.ts b/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.ts index cf6a88d5b..23953bf5a 100644 --- a/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/create-guarantor/create-guarantor.component.ts @@ -149,28 +149,31 @@ export class CreateGuarantorComponent implements OnInit, AfterViewInit { /** Submits the new guarantor details form */ submit() { - const prevdob: Date = this.newGuarantorForm.value.dob; - const guarantorTypeId: number = this.newGuarantorForm.value.existingClient ? this.dataObject.guarantorTypeOptions[0].id : this.dataObject.guarantorTypeOptions[2].id; - // TODO: Update once language and date settings are setup + const newGuarantorFormData = this.newGuarantorForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const newGuarantorData = { - ... this.newGuarantorForm.value, + + const prevdob: Date = this.newGuarantorForm.value.dob; + const guarantorTypeId: number = this.newGuarantorForm.value.existingClient ? this.dataObject.guarantorTypeOptions[0].id : this.dataObject.guarantorTypeOptions[2].id; + const data = { + ...newGuarantorFormData, locale, + dateFormat, guarantorTypeId }; if (this.newGuarantorForm.value.existingClient) { - newGuarantorData['entityId'] = this.newGuarantorForm.controls.name.value.id; + data['entityId'] = this.newGuarantorForm.controls.name.value.id; } else { - newGuarantorData['dob'] = this.dateUtils.formatDate(prevdob, dateFormat), - newGuarantorData['dateFormat'] = dateFormat; + if (newGuarantorFormData.dob instanceof Date) { + data['dob'] = this.dateUtils.formatDate(prevdob, dateFormat); + } } - delete newGuarantorData.existingClient; - delete newGuarantorData.name; + delete data.existingClient; + delete data.name; - this.loanService.createNewGuarantor(this.loanId, newGuarantorData) + this.loanService.createNewGuarantor(this.loanId, data) .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/disburse-loan-account/disburse-loan-account.component.ts b/src/app/loans/loans-view/loan-account-actions/disburse-loan-account/disburse-loan-account.component.ts index f111e7484..3fd8fbed1 100644 --- a/src/app/loans/loans-view/loan-account-actions/disburse-loan-account/disburse-loan-account.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/disburse-loan-account/disburse-loan-account.component.ts @@ -64,16 +64,20 @@ export class DisburseLoanAccountComponent implements OnInit { * Submit Disburse Form. */ submit() { - const actualDisbursementDate = this.disbursementForm.value.actualDisbursementDate; + const disbursementLoanFormData = this.disbursementForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.disbursementForm.patchValue({ - actualDisbursementDate: this.dateUtils.formatDate(actualDisbursementDate, dateFormat) - }); + const prevActualDisbursementDate: Date = this.disbursementForm.value.actualDisbursementDate; + if (disbursementLoanFormData.actualDisbursementDate instanceof Date) { + disbursementLoanFormData.actualDisbursementDate = this.dateUtils.formatDate(prevActualDisbursementDate, dateFormat); + } + const data = { + ...disbursementLoanFormData, + dateFormat, + locale + }; const loanId = this.route.parent.snapshot.params['loanId']; - const disbursementForm = this.disbursementForm.value; - disbursementForm.locale = this.settingsService.language.code; - disbursementForm.dateFormat = dateFormat; - this.loanService.loanActionButtons(loanId, 'disbursetosavings', disbursementForm).subscribe((response: any) => { + this.loanService.loanActionButtons(loanId, 'disbursetosavings', data).subscribe((response: any) => { this.router.navigate(['../../general'], {relativeTo: this.route}); }); } diff --git a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.html b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.html index d68a90843..381250d3f 100644 --- a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.html +++ b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.html @@ -38,7 +38,7 @@
Show Payment Details - + diff --git a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.scss b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.scss index 3b9ed34b0..5aa0bac6f 100644 --- a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.scss +++ b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.scss @@ -1,4 +1,4 @@ -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; } diff --git a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts index 752aad072..6979b5adb 100644 --- a/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/disburse/disburse.component.ts @@ -100,16 +100,19 @@ export class DisburseComponent implements OnInit { /** Submits the disbursement form */ submit() { - const prevActualDisbursementDate: Date = this.disbursementLoanForm.value.actualDisbursementDate; - // TODO: Update once language and date settings are setup + const disbursementLoanFormData = this.disbursementLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.disbursementLoanForm.patchValue({ - actualDisbursementDate: this.dateUtils.formatDate(prevActualDisbursementDate, dateFormat) - }); - const disbursementLoanData = this.disbursementLoanForm.value; - disbursementLoanData.locale = this.settingsService.language.code; - disbursementLoanData.dateFormat = dateFormat; - this.loanService.loanActionButtons(this.loanId, 'disburse', disbursementLoanData ) + const prevActualDisbursementDate: Date = this.disbursementLoanForm.value.actualDisbursementDate; + if (disbursementLoanFormData.actualDisbursementDate instanceof Date) { + disbursementLoanFormData.actualDisbursementDate = this.dateUtils.formatDate(prevActualDisbursementDate, dateFormat); + } + const data = { + ...disbursementLoanFormData, + dateFormat, + locale + }; + this.loanService.loanActionButtons(this.loanId, 'disburse', data ) .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/foreclosure/foreclosure.component.ts b/src/app/loans/loans-view/loan-account-actions/foreclosure/foreclosure.component.ts index 11d3d4507..1d8f4a8c1 100644 --- a/src/app/loans/loans-view/loan-account-actions/foreclosure/foreclosure.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/foreclosure/foreclosure.component.ts @@ -13,8 +13,6 @@ import { Dates } from 'app/core/utils/dates'; styleUrls: ['./foreclosure.component.scss'] }) export class ForeclosureComponent implements OnInit { - - loanId: any; foreclosureForm: FormGroup; /** Minimum Date allowed. */ @@ -24,7 +22,6 @@ export class ForeclosureComponent implements OnInit { foreclosuredata: any; paymentTypes: any; - /** * @param {FormBuilder} formBuilder Form Builder. * @param {LoansService} systemService Loan Service. @@ -108,19 +105,20 @@ export class ForeclosureComponent implements OnInit { } submit() { - const transactionDate = this.foreclosureForm.value.transactionDate; + const foreclosureFormData = this.foreclosureForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.foreclosureForm.patchValue({ - transactionDate: this.dateUtils.formatDate(transactionDate, dateFormat) - }); - const formData = { - transactionDate: this.foreclosureForm.value.transactionDate, - locale: this.settingsService.language.code, - dateFormat: dateFormat, - note: this.foreclosureForm.value.note + const prevTransactionDate = this.foreclosureForm.value.transactionDate; + if (foreclosureFormData.transactionDate instanceof Date) { + foreclosureFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...foreclosureFormData, + dateFormat, + locale }; - this.loanService.loanForclosureData(this.loanId, formData) + this.loanService.loanForclosureData(this.loanId, data) .subscribe((response: any) => { this.router.navigate([`../../general`], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/loan-reschedule/loan-reschedule.component.ts b/src/app/loans/loans-view/loan-account-actions/loan-reschedule/loan-reschedule.component.ts index 35310662e..dc3f1a7fe 100644 --- a/src/app/loans/loans-view/loan-account-actions/loan-reschedule/loan-reschedule.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/loan-reschedule/loan-reschedule.component.ts @@ -66,21 +66,28 @@ export class LoanRescheduleComponent implements OnInit { } submit() { - const rescheduleFromDate = this.rescheduleLoanForm.value.rescheduleFromDate; - const adjustedDueDate = this.rescheduleLoanForm.value.adjustedDueDate; - const submittedOnDate = this.rescheduleLoanForm.value.submittedOnDate; + const rescheduleLoanFormData = this.rescheduleLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - - this.rescheduleLoanForm.patchValue({ - rescheduleFromDate: this.dateUtils.formatDate(rescheduleFromDate, dateFormat), - adjustedDueDate: this.dateUtils.formatDate(adjustedDueDate, dateFormat), - submittedOnDate: this.dateUtils.formatDate(submittedOnDate, dateFormat) - }); - const rescheduleForm = this.rescheduleLoanForm.value; - rescheduleForm.locale = this.settingsService.language.code; - rescheduleForm.dateFormat = dateFormat; - rescheduleForm.loanId = this.loanId; - this.loanService.submitRescheduleData(rescheduleForm).subscribe((response: any) => { + const prevRescheduleFromDate = this.rescheduleLoanForm.value.rescheduleFromDate; + const prevAdjustedDueDate = this.rescheduleLoanForm.value.adjustedDueDate; + const prevSubmittedOnDate = this.rescheduleLoanForm.value.submittedOnDate; + if (rescheduleLoanFormData.rescheduleFromDate instanceof Date) { + rescheduleLoanFormData.rescheduleFromDate = this.dateUtils.formatDate(prevRescheduleFromDate, dateFormat); + } + if (rescheduleLoanFormData.rescheduleFromDate instanceof Date) { + rescheduleLoanFormData.adjustedDueDate = this.dateUtils.formatDate(prevAdjustedDueDate, dateFormat); + } + if (rescheduleLoanFormData.rescheduleFromDate instanceof Date) { + rescheduleLoanFormData.submittedOnDate = this.dateUtils.formatDate(prevSubmittedOnDate, dateFormat); + } + const data = { + ...rescheduleLoanFormData, + dateFormat, + locale + }; + data.loanId = this.loanId; + this.loanService.submitRescheduleData(data).subscribe((response: any) => { // TODO: needs to be updated // mentioned in Community App: diff --git a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts index 0d2e1e556..b345a3f06 100644 --- a/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/loans-account-close/loans-account-close.component.ts @@ -64,15 +64,19 @@ export class LoansAccountCloseComponent implements OnInit { * if successful redirects to view created close. */ submit() { - const transactionDate = this.closeLoanForm.value.transactionDate; + const closeLoanFormData = this.closeLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.closeLoanForm.patchValue({ - transactionDate: this.dateUtils.formatDate(transactionDate, dateFormat) - }); - const closeForm = this.closeLoanForm.value; - closeForm.locale = this.settingsService.language.code; - closeForm.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(this.loanId, closeForm, 'close') + const preTransactionDate = this.closeLoanForm.value.transactionDate; + if (closeLoanFormData.transactionDate instanceof Date) { + closeLoanFormData.transactionDate = this.dateUtils.formatDate(preTransactionDate, dateFormat); + } + const data = { + ...closeLoanFormData, + dateFormat, + locale + }; + this.loanService.submitLoanActionButton(this.loanId, data, 'close') .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.html b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.html index 535f45827..33357e547 100644 --- a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.html +++ b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.html @@ -38,7 +38,7 @@
Show Payment Details - + diff --git a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.scss b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.scss index 3b9ed34b0..5aa0bac6f 100644 --- a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.scss +++ b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.scss @@ -1,4 +1,4 @@ -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; } diff --git a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts index c4594341d..b11065059 100644 --- a/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/make-repayment/make-repayment.component.ts @@ -98,14 +98,19 @@ export class MakeRepaymentComponent implements OnInit { /** Submits the repayment form */ submit() { - const prevTransactionDate: Date = this.repaymentLoanForm.value.transactionDate; - // TODO: Update once language and date settings are setup + const repaymentLoanFormData = this.repaymentLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const repaymentLoanData = this.repaymentLoanForm.value; - repaymentLoanData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); - repaymentLoanData.locale = this.settingsService.language.code; - repaymentLoanData.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(this.loanId, repaymentLoanData, 'repayment') + const prevTransactionDate: Date = this.repaymentLoanForm.value.transactionDate; + if (repaymentLoanFormData.transactionDate instanceof Date) { + repaymentLoanFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...repaymentLoanFormData, + dateFormat, + locale + }; + this.loanService.submitLoanActionButton(this.loanId, data, 'repayment') .subscribe((response: any) => { this.router.navigate(['../../transactions'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.html b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.html index 07389e331..5c543d322 100644 --- a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.html +++ b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.html @@ -51,7 +51,7 @@
Show Payment Details - + diff --git a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.scss b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.scss index 3b9ed34b0..5aa0bac6f 100644 --- a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.scss +++ b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.scss @@ -1,4 +1,4 @@ -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; } diff --git a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.ts b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.ts index 20ece5420..09d80559c 100644 --- a/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/prepay-loan/prepay-loan.component.ts @@ -5,7 +5,6 @@ import { ActivatedRoute, Router } from '@angular/router'; /** Custom Services */ import { LoansService } from 'app/loans/loans.service'; -import { DatePipe } from '@angular/common'; import { SettingsService } from 'app/settings/settings.service'; import { Dates } from 'app/core/utils/dates'; @@ -113,16 +112,19 @@ export class PrepayLoanComponent implements OnInit { * Submits the prepay loan form */ submit() { - const prevTransactionDate: Date = this.prepayLoanForm.value.transactionDate; - // TODO: Update once language and date settings are setup + const prepayLoanFormData = this.prepayLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.prepayLoanForm.patchValue({ - transactionDate: this.dateUtils.formatDate(prevTransactionDate, dateFormat) - }); - const prepayLoanData = this.prepayLoanForm.value; - prepayLoanData.locale = this.settingsService.language.code; - prepayLoanData.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(this.loanId, prepayLoanData, 'repayment') + const prevTransactionDate: Date = this.prepayLoanForm.value.transactionDate; + if (prepayLoanFormData.transactionDate instanceof Date) { + prepayLoanFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...prepayLoanFormData, + dateFormat, + locale + }; + this.loanService.submitLoanActionButton(this.loanId, data, 'repayment') .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.html b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.html index 16e7cbee5..1cf07d98f 100644 --- a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.html +++ b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.html @@ -38,7 +38,7 @@
Show Payment Details - + diff --git a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.scss b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.scss index 3b9ed34b0..5aa0bac6f 100644 --- a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.scss +++ b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.scss @@ -1,4 +1,4 @@ -.expandCollapsebutton { +.expandcollapsebutton { margin-top: -7px; } diff --git a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.ts b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.ts index c8542a113..08b12e201 100644 --- a/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/recovery-repayment/recovery-repayment.component.ts @@ -100,16 +100,19 @@ export class RecoveryRepaymentComponent implements OnInit { /** Submits the recovery payment form */ submit() { - const prevTransactionDate: Date = this.recoveryRepaymentLoanForm.value.transactionDate; - // TODO: Update once language and date settings are setup + const recoveryRepaymentLoanFormData = this.recoveryRepaymentLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.recoveryRepaymentLoanForm.patchValue({ - transactionDate: this.dateUtils.formatDate(prevTransactionDate, dateFormat) - }); - const recoveryRepaymentLoanData = this.recoveryRepaymentLoanForm.value; - recoveryRepaymentLoanData.locale = this.settingsService.language.code; - recoveryRepaymentLoanData.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(this.loanId, recoveryRepaymentLoanData, 'recoverypayment') + const prevTransactionDate: Date = this.recoveryRepaymentLoanForm.value.transactionDate; + if (recoveryRepaymentLoanFormData.transactionDate instanceof Date) { + recoveryRepaymentLoanFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...recoveryRepaymentLoanFormData, + dateFormat, + locale + }; + this.loanService.submitLoanActionButton(this.loanId, data, 'recoverypayment') .subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts b/src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts index 18c96a442..fdcb1c8ea 100644 --- a/src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts @@ -61,15 +61,19 @@ export class RejectLoanComponent implements OnInit { * Submit Reject Loan form. */ submit() { - const rejectedOnDate = this.rejectLoanForm.value.rejectedOnDate; + const rejectLoanFormData = this.rejectLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.rejectLoanForm.patchValue({ - rejectedOnDate: this.dateUtils.formatDate(rejectedOnDate, dateFormat) - }); - const rejectForm = this.rejectLoanForm.value; - rejectForm.locale = this.settingsService.language.code; - rejectForm.dateFormat = dateFormat; - this.loanService.loanActionButtons(this.loanId, 'reject', rejectForm).subscribe((response: any) => { + const prevRejectedOnDate = this.rejectLoanForm.value.rejectedOnDate; + if (rejectLoanFormData.rejectedOnDate instanceof Date) { + rejectLoanFormData.rejectedOnDate = this.dateUtils.formatDate(prevRejectedOnDate, dateFormat); + } + const data = { + ...rejectLoanFormData, + dateFormat, + locale + }; + this.loanService.loanActionButtons(this.loanId, 'reject', data).subscribe((response: any) => { this.router.navigate(['../../general'], { relativeTo: this.route }); }); } diff --git a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts index 52fb09b2a..d92034c46 100644 --- a/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/waive-interest/waive-interest.component.ts @@ -6,6 +6,7 @@ import { Router, ActivatedRoute } from '@angular/router'; /** Custom Services. */ import { LoansService } from 'app/loans/loans.service'; import { Dates } from 'app/core/utils/dates'; +import { SettingsService } from 'app/settings/settings.service'; /** * Waive Interest component. @@ -35,6 +36,7 @@ export class WaiveInterestComponent implements OnInit { */ constructor(private formBuilder: FormBuilder, private router: Router, + private settingsService: SettingsService, private dateUtils: Dates, private loanService: LoansService, private route: ActivatedRoute) { } @@ -58,18 +60,20 @@ export class WaiveInterestComponent implements OnInit { * Submits loan interest form. */ submit() { - const transactionDate = this.loanInterestForm.value.transactionDate; - const transactionAmount = this.loanInterestForm.value.transactionAmount; - const dateFormat = 'dd MMMM yyyy'; - this.loanInterestForm.patchValue({ - transactionDate: this.dateUtils.formatDate(transactionDate, dateFormat), - transactionAmount: parseInt(transactionAmount, 10) - }); + const loanInterestFormData = this.loanInterestForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; + const prevTransactionDate = this.loanInterestForm.value.transactionDate; + if (loanInterestFormData.transactionDate instanceof Date) { + loanInterestFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...loanInterestFormData, + dateFormat, + locale + }; const loanId = this.route.parent.snapshot.params['loanId']; - const loanInterestForm = this.loanInterestForm.value; - loanInterestForm.locale = 'en'; - loanInterestForm.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(loanId, loanInterestForm, 'waiveinterest').subscribe((response: any) => { + this.loanService.submitLoanActionButton(loanId, data, 'waiveinterest').subscribe((response: any) => { this.router.navigate(['../../general'], {relativeTo: this.route}); }); } diff --git a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts index 81bd29f26..266cb6636 100644 --- a/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/withdrawn-by-client/withdrawn-by-client.component.ts @@ -64,16 +64,19 @@ export class WithdrawnByClientComponent implements OnInit { /** Submits the withdraw by appplicant form */ submit() { - const prevTransactionDate: Date = this.withdrawnByClientLoanForm.value.withdrawnOnDate; - // TODO: Update once language and date settings are setup + const withdrawnByClientLoanFormData = this.withdrawnByClientLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.withdrawnByClientLoanForm.patchValue({ - withdrawnOnDate: this.dateUtils.formatDate(prevTransactionDate, dateFormat) - }); - const WithdrawnByClientLoanData = this.withdrawnByClientLoanForm.value; - WithdrawnByClientLoanData.locale = this.settingsService.language.code; - WithdrawnByClientLoanData.dateFormat = dateFormat; - this.loanService.loanActionButtons(this.loanId, 'withdrawnByApplicant', WithdrawnByClientLoanData) + const prevTransactionDate: Date = this.withdrawnByClientLoanForm.value.withdrawnOnDate; + if (withdrawnByClientLoanFormData.withdrawnOnDate instanceof Date) { + withdrawnByClientLoanFormData.withdrawnOnDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...withdrawnByClientLoanFormData, + dateFormat, + locale + }; + this.loanService.loanActionButtons(this.loanId, 'withdrawnByApplicant', data) .subscribe((response: any) => { this.router.navigate(['../../../general'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/loan-account-actions/write-off-page/write-off-page.component.ts b/src/app/loans/loans-view/loan-account-actions/write-off-page/write-off-page.component.ts index 2817360f1..2b2d06c85 100644 --- a/src/app/loans/loans-view/loan-account-actions/write-off-page/write-off-page.component.ts +++ b/src/app/loans/loans-view/loan-account-actions/write-off-page/write-off-page.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { LoansService } from 'app/loans/loans.service'; @@ -33,14 +33,14 @@ export class WriteOffPageComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. * @param {LoansService} loanService Loan Service. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {Router} router Router. * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private loanService: LoansService, - private datePipe: DatePipe, + private dateUtils: Dates, private router: Router, private settingsService: SettingsService) { } @@ -63,17 +63,21 @@ export class WriteOffPageComponent implements OnInit { * Submits write off form. */ submit() { - const transactionDate = this.writeOffForm.value.transactionDate; + const writeOffFormData = this.writeOffForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.writeOffForm.patchValue({ - transactionDate: this.datePipe.transform(transactionDate, dateFormat) - }); + const prevTransactionDate = this.writeOffForm.value.transactionDate; + if (writeOffFormData.transactionDate instanceof Date) { + writeOffFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat); + } + const data = { + ...writeOffFormData, + dateFormat, + locale + }; const loanId = this.route.parent.snapshot.params['loanId']; - const writeOffForm = this.writeOffForm.value; - delete writeOffForm.amount; - writeOffForm.locale = this.settingsService.language.code; - writeOffForm.dateFormat = dateFormat; - this.loanService.submitLoanActionButton(loanId, writeOffForm, 'writeoff').subscribe((response: any) => { + delete data.amount; + this.loanService.submitLoanActionButton(loanId, data, 'writeoff').subscribe((response: any) => { this.router.navigate(['../../../general'], {relativeTo: this.route}); }); } diff --git a/src/app/loans/loans-view/transactions/edit-transaction/edit-transaction.component.ts b/src/app/loans/loans-view/transactions/edit-transaction/edit-transaction.component.ts index 90e9fa351..6ff89fa52 100644 --- a/src/app/loans/loans-view/transactions/edit-transaction/edit-transaction.component.ts +++ b/src/app/loans/loans-view/transactions/edit-transaction/edit-transaction.component.ts @@ -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 { LoansService } from 'app/loans/loans.service'; @@ -44,14 +44,14 @@ export class EditTransactionComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {LoansService} loansService Loans 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 loansService: LoansService, private settingsService: SettingsService) { this.route.data.subscribe((data: { loansAccountTransactionTemplate: 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.loansService.executeLoansAccountTransactionsCommand(this.loanAccountId, '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.loansService.executeLoansAccountTransactionsCommand(this.loanAccountId, 'modify', data, this.transactionTemplateData.id) .subscribe((res: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.html b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.html index 81124a89e..2995e69bf 100644 --- a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.html +++ b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.html @@ -32,4 +32,4 @@ - + diff --git a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts index c3959d739..7949e40aa 100644 --- a/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts +++ b/src/app/loans/loans-view/transactions/export-transactions/export-transactions.component.ts @@ -2,11 +2,11 @@ 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 { Dates } from 'app/core/utils/dates'; /** * Export Client Loans Transactions Component @@ -36,13 +36,13 @@ 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 */ constructor(private sanitizer: DomSanitizer, private reportsService: ReportsService, private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute) { this.route.parent.parent.data.subscribe((data: { loanDetailsData: any }) => { this.loansAccountId = data.loanDetailsData.accountNo; @@ -70,8 +70,8 @@ export class ExportTransactionsComponent implements OnInit { generate() { const data = { 'output-type': 'PDF', - R_startDate: this.datePipe.transform(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'), - R_endDate: this.datePipe.transform(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'), + R_startDate: this.dateUtils.formatDate(this.transactionsReportForm.value.fromDate, 'yyyy-MM-dd'), + R_endDate: this.dateUtils.formatDate(this.transactionsReportForm.value.toDate, 'yyyy-MM-dd'), R_selectLoan: this.loansAccountId }; this.reportsService.getPentahoRunReportData('Client Loan Account Schedule', data, 'default', 'en', 'dd MMMM yyyy') diff --git a/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts b/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts index ead6a51f3..c9cce482a 100644 --- a/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts +++ b/src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services. */ import { OrganizationService } from '../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Bulk Loan Reassignment component. @@ -49,7 +49,7 @@ export class BulkLoanReassignmnetComponent implements OnInit { private route: ActivatedRoute, private organizationSevice: OrganizationService, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private router: Router) { this.route.data.subscribe((data: { offices: any} ) => { this.offices = data.offices; @@ -113,16 +113,20 @@ export class BulkLoanReassignmnetComponent implements OnInit { * Submits bulk loan reassignment form. */ submit() { + const bulkLoanFormData = this.bulkLoanForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const assignmentDate = this.bulkLoanForm.value.assignmentDate; - this.bulkLoanForm.patchValue({ - assignmentDate: this.datePipe.transform(assignmentDate, dateFormat) - }); - const bulkForm = this.bulkLoanForm.value; - bulkForm.locale = this.settingsService.language.code; - bulkForm.dateFormat = dateFormat; - bulkForm.loans = this.loans; - this.organizationSevice.createLoanReassignment(bulkForm).subscribe((response: any) => { + const prevAssignmentDate = this.bulkLoanForm.value.assignmentDate; + if (bulkLoanFormData.assignmentDate instanceof Date) { + bulkLoanFormData.assignmentDate = this.dateUtils.formatDate(prevAssignmentDate, dateFormat); + } + const data = { + ...bulkLoanFormData, + dateFormat, + locale + }; + data.loans = this.loans; + this.organizationSevice.createLoanReassignment(data).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/organization/employees/create-employee/create-employee.component.ts b/src/app/organization/employees/create-employee/create-employee.component.ts index c1971ff76..46470f42e 100644 --- a/src/app/organization/employees/create-employee/create-employee.component.ts +++ b/src/app/organization/employees/create-employee/create-employee.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create employee component. @@ -34,14 +34,14 @@ export class CreateEmployeeComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { offices: any }) => { this.officeData = data.offices; }); @@ -73,16 +73,19 @@ export class CreateEmployeeComponent implements OnInit { * if successful redirects to employees. */ submit() { - const prevJoiningDate: Date = this.employeeForm.value.joiningDate; - // TODO: Update once language and date settings are setup + const employeeFormData = this.employeeForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.employeeForm.patchValue({ - joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) - }); - const employee = this.employeeForm.value; - employee.locale = this.settingsService.language.code; - employee.dateFormat = dateFormat; - this.organizationService.createEmployee(employee).subscribe((response: any) => { + const prevJoiningDate: Date = this.employeeForm.value.joiningDate; + if (employeeFormData.joiningDate instanceof Date) { + employeeFormData.joiningDate = this.dateUtils.formatDate(prevJoiningDate, dateFormat); + } + const data = { + ...employeeFormData, + dateFormat, + locale + }; + this.organizationService.createEmployee(data).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/organization/employees/edit-employee/edit-employee.component.ts b/src/app/organization/employees/edit-employee/edit-employee.component.ts index 5ffdde810..4a9a68235 100644 --- a/src/app/organization/employees/edit-employee/edit-employee.component.ts +++ b/src/app/organization/employees/edit-employee/edit-employee.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Employee Component. @@ -36,14 +36,14 @@ export class EditEmployeeComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { employee: any, offices: any }) => { this.employeeData = data.employee; this.officeData = data.employee.allowedOffices; @@ -77,16 +77,19 @@ export class EditEmployeeComponent implements OnInit { * if successful redirects to the employee edited. */ submit() { - const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate; - // TODO: Update once language and date settings are setup + const editEmployeeFormData = this.editEmployeeForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.editEmployeeForm.patchValue({ - joiningDate: this.datePipe.transform(prevJoiningDate, dateFormat) - }); - const employee = this.editEmployeeForm.value; - employee.locale = this.settingsService.language.code; - employee.dateFormat = dateFormat; - this.organizationService.updateEmployee(this.employeeData.id, employee).subscribe((response: any) => { + const prevJoiningDate: Date = this.editEmployeeForm.value.joiningDate; + if (editEmployeeFormData.joiningDate instanceof Date) { + editEmployeeFormData.joiningDate = this.dateUtils.formatDate(prevJoiningDate, dateFormat); + } + const data = { + ...editEmployeeFormData, + dateFormat, + locale + }; + this.organizationService.updateEmployee(this.employeeData.id, data).subscribe((response: any) => { this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/organization/fund-mapping/fund-mapping.component.ts b/src/app/organization/fund-mapping/fund-mapping.component.ts index 93ac46794..2b0b364c8 100644 --- a/src/app/organization/fund-mapping/fund-mapping.component.ts +++ b/src/app/organization/fund-mapping/fund-mapping.component.ts @@ -5,11 +5,11 @@ import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Fund Mapping Component. @@ -48,13 +48,13 @@ export class FundMappingComponent implements OnInit { * @param {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private route: ActivatedRoute, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { advanceSearchTemplate: any }) => { this.advanceSearchTemplate = data.advanceSearchTemplate; }); @@ -148,20 +148,24 @@ export class FundMappingComponent implements OnInit { */ submit() { this.isCollapsed = true; - // TODO: Update once language and date settings are setup + const fundMappingFormData = this.fundMappingForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.fundMappingForm.patchValue({ - 'loanFromDate': this.datePipe.transform(this.fundMappingForm.value.loanFromDate, dateFormat), - 'loanToDate': this.datePipe.transform(this.fundMappingForm.value.loanToDate, dateFormat) - }); - const fundMapping = { - ...this.fundMappingForm.value, + const prevLoanFromDate: Date = this.fundMappingForm.value.loanFromDate; + const prevLoanToDate: Date = this.fundMappingForm.value.loanToDate; + if (fundMappingFormData.loanFromDate instanceof Date) { + fundMappingFormData.loanFromDate = this.dateUtils.formatDate(prevLoanFromDate, dateFormat); + } + if (fundMappingFormData.loanToDate instanceof Date) { + fundMappingFormData.loanToDate = this.dateUtils.formatDate(prevLoanToDate, dateFormat); + } + const data = { + ...fundMappingFormData, entities: ['loans'], dateFormat, locale }; - this.organizationService.retrieveAdvanceSearchResults(fundMapping).subscribe((response: any) => { + this.organizationService.retrieveAdvanceSearchResults(data).subscribe((response: any) => { this.setLoans(response); }); } diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.ts b/src/app/organization/holidays/create-holiday/create-holiday.component.ts index 1a60eda8a..c72250f39 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.ts +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -34,13 +34,13 @@ export class CreateHolidayComponent implements OnInit { * Get offices and holiday template from `Resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {OrganizationService} organizationService Organization Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settings: SettingsService, private router: Router ) { @@ -86,23 +86,27 @@ export class CreateHolidayComponent implements OnInit { * Submits the create holiday Form. */ submit() { + const holidayFormData = this.holidayForm.value; const dateFormat = this.settings.dateFormat; const locale = this.settings.language.code; - this.holidayForm.patchValue({ - 'fromDate': this.datePipe.transform(this.holidayForm.value.fromDate, dateFormat), - 'toDate': this.datePipe.transform(this.holidayForm.value.toDate, dateFormat), - }); - if (this.holidayForm.contains('repaymentsRescheduledTo')) { - this.holidayForm.patchValue({ - 'repaymentsRescheduledTo': this.datePipe.transform(this.holidayForm.value.repaymentsRescheduledTo, dateFormat) - }); + const prevFromDate: Date = this.holidayForm.value.fromDate; + const prevToDate: Date = this.holidayForm.value.toDate; + if (holidayFormData.closureDate instanceof Date) { + holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); } - const holiday = { - ...this.holidayForm.value, + if (holidayFormData.closureDate instanceof Date) { + holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); + } + if (this.holidayForm.contains('repaymentsRescheduledTo')) { + const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; + holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat); + } + const data = { + ...holidayFormData, dateFormat, locale }; - this.organizationService.createHoliday(holiday).subscribe((response: any) => { + this.organizationService.createHoliday(data).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts index b64ffd962..3846bda48 100644 --- a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts +++ b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -35,15 +35,15 @@ export class EditHolidayComponent implements OnInit { * Get holiday and holiday template from `Resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {OrganizationService} organizatioService Organization Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, private organizatioService: OrganizationService, - private settings: SettingsService, + private settingsService: SettingsService, private router: Router ) { this.route.data.subscribe((data: { holiday: any, holidayTemplate: any }) => { this.holidayData = data.holiday; @@ -100,25 +100,29 @@ export class EditHolidayComponent implements OnInit { * Submits Edit Holiday Form. */ submit() { - const dateFormat = this.settings.dateFormat; + const holidayFormData = this.holidayForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; if (!this.isActiveHoliday) { - const fromDate: Date = this.holidayForm.value.fromDate; - const toDate: Date = this.holidayForm.value.toDate; if (this.reSchedulingType === 2 ) { const repaymentScheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; - this.holidayForm.patchValue({ - repaymentsRescheduledTo: this.datePipe.transform(repaymentScheduledTo, dateFormat) - }); + holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(repaymentScheduledTo, dateFormat); + } + const prevFromDate: Date = this.holidayForm.value.fromDate; + const prevToDate: Date = this.holidayForm.value.toDate; + if (holidayFormData.closureDate instanceof Date) { + holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); + } + if (holidayFormData.closureDate instanceof Date) { + holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); } - this.holidayForm.patchValue({ - fromDate: this.datePipe.transform(fromDate, dateFormat), - toDate: this.datePipe.transform(toDate, dateFormat) - }); } - const holidayForm = this.holidayForm.value; - holidayForm.locale = this.settings.language.code; - holidayForm.dateFormat = dateFormat; - this.organizatioService.updateHoliday(this.holidayData.id, holidayForm).subscribe(response => { + const data = { + ...holidayFormData, + dateFormat, + locale + }; + this.organizatioService.updateHoliday(this.holidayData.id, data).subscribe(response => { /** TODO Add Redirects to ViewMakerCheckerTask page. */ this.router.navigate(['../'], { relativeTo: this.route }); }); diff --git a/src/app/organization/offices/create-office/create-office.component.ts b/src/app/organization/offices/create-office/create-office.component.ts index dce7b6c75..a53061ba6 100644 --- a/src/app/organization/offices/create-office/create-office.component.ts +++ b/src/app/organization/offices/create-office/create-office.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create Office component. @@ -34,14 +34,14 @@ export class CreateOfficeComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private router: Router, private route: ActivatedRoute, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { offices: any }) => { this.officeData = data.offices; }); @@ -68,16 +68,19 @@ export class CreateOfficeComponent implements OnInit { * if successful redirects to offices */ submit() { - const prevOpeningDate: Date = this.officeForm.value.openingDate; - // TODO: Update once language and date settings are setup + const officeFormData = this.officeForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.officeForm.patchValue({ - openingDate: this.datePipe.transform(prevOpeningDate, dateFormat) - }); - const office = this.officeForm.value; - office.locale = this.settingsService.language.code; - office.dateFormat = dateFormat; - this.organizationService.createOffice(office).subscribe(response => { + const prevOpeningDate: Date = this.officeForm.value.openingDate; + if (officeFormData.openingDate instanceof Date) { + officeFormData.openingDate = this.dateUtils.formatDate(prevOpeningDate, dateFormat); + } + const data = { + ...officeFormData, + dateFormat, + locale + }; + this.organizationService.createOffice(data).subscribe(response => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/organization/offices/edit-office/edit-office.component.html b/src/app/organization/offices/edit-office/edit-office.component.html index 36bb6a2bf..5fd03e616 100644 --- a/src/app/organization/offices/edit-office/edit-office.component.html +++ b/src/app/organization/offices/edit-office/edit-office.component.html @@ -40,7 +40,7 @@ External ID - +
diff --git a/src/app/organization/offices/edit-office/edit-office.component.ts b/src/app/organization/offices/edit-office/edit-office.component.ts index 6075151c9..d3ebb3591 100644 --- a/src/app/organization/offices/edit-office/edit-office.component.ts +++ b/src/app/organization/offices/edit-office/edit-office.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services */ import { OrganizationService } from 'app/organization/organization.service'; @@ -35,14 +35,14 @@ export class EditOfficeComponent implements OnInit { * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. * @param {MatDialog} dialog Dialog reference. - * @param {DatePipe} datepipe Convert Date. + * @param {Dates} dateUtils Date Utils */ constructor(private organizationService: OrganizationService, private settingsService: SettingsService, private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datepipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { officeTemplate: any }) => { this.officeData = data.officeTemplate; }); @@ -70,15 +70,19 @@ export class EditOfficeComponent implements OnInit { * Submits the edit office form. */ submit() { - const openedOn: Date = this.officeForm.value.openingDate; + const officeFormData = this.officeForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.officeForm.patchValue({ - openingDate: this.datepipe.transform(openedOn, dateFormat) - }); - const office = this.officeForm.value; - office.locale = this.settingsService.language.code; - office.dateFormat = dateFormat; - this.organizationService.updateOffice(this.officeData.id, office).subscribe((response: any) => { + const prevOpenedOn: Date = this.officeForm.value.openingDate; + if (officeFormData.openingDate instanceof Date) { + officeFormData.openingDate = this.dateUtils.formatDate(prevOpenedOn, dateFormat); + } + const data = { + ...officeFormData, + dateFormat, + locale + }; + this.organizationService.updateOffice(this.officeData.id, data).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts b/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts index 83fa61561..ba140cdf1 100644 --- a/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/organization/offices/view-office/datatable-tabs/multi-row/multi-row.component.ts @@ -50,7 +50,7 @@ export class MultiRowComponent implements OnInit, OnChanges { /** * Fetches office Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. diff --git a/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts b/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts index fc293503c..aa1d024d2 100644 --- a/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/organization/offices/view-office/datatable-tabs/single-row/single-row.component.ts @@ -40,7 +40,7 @@ export class SingleRowComponent implements OnInit { /** * Fetches office Id from parent route params. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. * @param {MatDialog} dialog Mat Dialog. @@ -150,7 +150,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) { diff --git a/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts b/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts index 289d80438..9a620b6fa 100644 --- a/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts +++ b/src/app/organization/sms-campaigns/create-campaign/create-campaign.component.ts @@ -37,7 +37,7 @@ export class CreateCampaignComponent { * @param {Router} router Router * @param {OrganizationService} organizationService Organization Service * @param {SettingsService} settingsService Settings Service - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils */ constructor(private route: ActivatedRoute, private router: Router, diff --git a/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts b/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts index 51b19f4e8..3aeb6ef87 100644 --- a/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts +++ b/src/app/organization/sms-campaigns/edit-campaign/edit-campaign.component.ts @@ -34,7 +34,7 @@ export class EditCampaignComponent { * Fetches campaign template from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {OrganizationService} organizationService Organiztion Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts index 7ed65d817..18f792168 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/edit-sms-campaign-step/edit-business-rule-parameters/edit-business-rule-parameters.component.ts @@ -1,7 +1,6 @@ /** Angular Imports */ import { Component, OnChanges, Input, Output, EventEmitter } from '@angular/core'; import { Validators, FormGroup, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Rxjs Imports */ import { distinctUntilChanged } from 'rxjs/operators'; @@ -13,6 +12,7 @@ import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; import { SelectOption } from 'app/reports/common-models/select-option.model'; +import { Dates } from 'app/core/utils/dates'; /** * Edit Business Rule Parameters. @@ -47,7 +47,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges { */ constructor(private reportsService: ReportsService, private settingsService: SettingsService, - private datePipe: DatePipe) { } + private dateUtils: Dates) { } ngOnChanges() { if (this.paramData) { @@ -78,7 +78,7 @@ export class EditBusinessRuleParametersComponent implements OnChanges { break; case 'date': const dateFormat = this.settingsService.dateFormat; - const newControlValue = this.datePipe.transform(controlValue, dateFormat); + const newControlValue = this.dateUtils.formatDate(controlValue, dateFormat); this.ReportForm.get(param.name).patchValue(newControlValue); break; } diff --git a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts index 54934d2ff..000c0ebf7 100644 --- a/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts +++ b/src/app/organization/sms-campaigns/sms-campaign-stepper/sms-campaign-step/business-rule-parameters/business-rule-parameters.component.ts @@ -1,7 +1,6 @@ /** Angular Imports */ import { Component, OnChanges, Input, Output, EventEmitter } from '@angular/core'; import { Validators, FormGroup, FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ReportsService } from 'app/reports/reports.service'; @@ -10,6 +9,7 @@ import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from 'app/reports/common-models/report-parameter.model'; import { SelectOption } from 'app/reports/common-models/select-option.model'; +import { Dates } from 'app/core/utils/dates'; /** * Business Rule Parameters Component. @@ -41,11 +41,11 @@ export class BusinessRuleParametersComponent implements OnChanges { /** * @param {ReportsService} reportsService Reports Service. * @param {SettingsService} settingsService Settings Service. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. */ constructor(private reportsService: ReportsService, private settingsService: SettingsService, - private datePipe: DatePipe) { } + private dateUtils: Dates) { } ngOnChanges() { if (this.paramData) { @@ -156,7 +156,7 @@ export class BusinessRuleParametersComponent implements OnChanges { break; case 'date': const dateFormat = this.settingsService.dateFormat; - formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); + formattedResponse[newKey] = this.dateUtils.formatDate(value, dateFormat); break; case 'none': formattedResponse[newKey] = value; diff --git a/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts b/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts index f8bd7bdce..212b0f290 100644 --- a/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts +++ b/src/app/organization/sms-campaigns/view-campaign/view-campaign.component.ts @@ -4,7 +4,6 @@ import { FormGroup, FormBuilder } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatTableDataSource, MatTable } from '@angular/material/table'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Dialogs */ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; @@ -17,6 +16,7 @@ import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicke /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * View SMS Campaign Component @@ -76,7 +76,7 @@ export class ViewCampaignComponent implements OnInit { * @param {ActivatedRoute} route Activated Route * @param {MatDialog} dialog Mat Dialog * @param {FormBuilder} formBuilder Form Builder - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {OrganizationService} organizationService Organization Service * @param {SettingsService} settingsService Setting Service */ @@ -84,7 +84,7 @@ export class ViewCampaignComponent implements OnInit { private route: ActivatedRoute, public dialog: MatDialog, private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settingsService: SettingsService) { this.route.data.subscribe((data: { smsCampaign: any }) => { @@ -146,7 +146,7 @@ export class ViewCampaignComponent implements OnInit { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const dataObject = { - closureDate: this.datePipe.transform(response.data.value.closureDate, dateFormat), + closureDate: this.dateUtils.formatDate(response.data.value.closureDate, dateFormat), dateFormat, locale }; @@ -181,7 +181,7 @@ export class ViewCampaignComponent implements OnInit { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const dataObject = { - activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), + activationDate: this.dateUtils.formatDate(response.data.value.activationDate, dateFormat), dateFormat, locale }; @@ -216,7 +216,7 @@ export class ViewCampaignComponent implements OnInit { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const dataObject = { - activationDate: this.datePipe.transform(response.data.value.activationDate, dateFormat), + activationDate: this.dateUtils.formatDate(response.data.value.activationDate, dateFormat), dateFormat, locale }; @@ -257,20 +257,25 @@ export class ViewCampaignComponent implements OnInit { * Retrives messages by status. */ search() { + const smsFormData = this.smsForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevFromDate: Date = this.smsForm.value.fromDate; const prevToDate: Date = this.smsForm.value.toDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.smsForm.patchValue({ - fromDate: this.datePipe.transform(prevFromDate, dateFormat), - toDate: this.datePipe.transform(prevToDate, dateFormat) - }); - const SMS = this.smsForm.value; - SMS.id = this.smsCampaignData.id; - SMS.locale = this.settingsService.language.code; - SMS.dateFormat = dateFormat; - SMS.status = this.status; - this.organizationService.getMessagebyStatus(SMS).subscribe((response: any) => { + if (smsFormData.fromDate instanceof Date) { + smsFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); + } + if (smsFormData.toDate instanceof Date) { + smsFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); + } + const data = { + ...smsFormData, + id: this.smsCampaignData.id, + status: this.status, + dateFormat, + locale + }; + this.organizationService.getMessagebyStatus(data).subscribe((response: any) => { this.dataSource.data = response.pageItems; this.messageTableRef.renderRows(); }); diff --git a/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts b/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts index 79aa1acbc..86c859d39 100644 --- a/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts +++ b/src/app/organization/standing-instructions-history/standing-instructions-history.component.ts @@ -5,11 +5,11 @@ import { MatSort } from '@angular/material/sort'; import { MatTableDataSource, MatTable } from '@angular/material/table'; import { FormGroup, FormBuilder, FormControl } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * View Standing Instructions History Component. @@ -49,14 +49,14 @@ export class StandingInstructionsHistoryComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private router: Router, private route: ActivatedRoute, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { standingInstructionsTemplate: any }) => { this.standingInstructionsTemplate = data.standingInstructionsTemplate; }); @@ -105,14 +105,23 @@ export class StandingInstructionsHistoryComponent implements OnInit { */ search() { this.isCollapsed = true; - // TODO: Update once language and date settings are setup + const instructionFormData = this.instructionForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const instruction = this.instructionForm.value; - instruction.locale = this.settingsService.language.code; - instruction.dateFormat = dateFormat; - instruction.fromDate = this.datePipe.transform(instruction.fromDate, dateFormat); - instruction.toDate = this.datePipe.transform(instruction.toDate, dateFormat); - this.organizationService.getStandingInstructions(instruction).subscribe((response: any) => { + const prevFromDate: Date = this.instructionForm.value.fromDate; + const prevToDate: Date = this.instructionForm.value.toDate; + if (instructionFormData.fromDate instanceof Date) { + instructionFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); + } + if (instructionFormData.toDate instanceof Date) { + instructionFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); + } + const data = { + ...instructionFormData, + dateFormat, + locale + }; + this.organizationService.getStandingInstructions(data).subscribe((response: any) => { this.setInstructions(response.pageItems); }); } diff --git a/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts b/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts index 6a2a49a9e..88d96e379 100644 --- a/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts +++ b/src/app/organization/tellers/cashiers/allocate-cash/allocate-cash.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -31,14 +31,14 @@ export class AllocateCashComponent implements OnInit { * Get cashier data from `Resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route ActivateRoute. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settingsService: SettingsService, private router: Router) { @@ -59,7 +59,7 @@ export class AllocateCashComponent implements OnInit { 'office': [{value: this.cashierData.officeName, disabled: true}], 'tellerName': [{value: this.cashierData.tellerName, disabled: true}], 'cashier': [{value: this.cashierData.cashierName, disabled: true}], - 'assignmentPeriod': [{value: this.datePipe.transform(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.datePipe.transform(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}], + 'assignmentPeriod': [{value: this.dateUtils.formatDate(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.dateUtils.formatDate(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}], 'txnDate': [new Date(), Validators.required], 'currencyCode': ['', Validators.required], 'txnAmount': ['', Validators.required], @@ -71,15 +71,19 @@ export class AllocateCashComponent implements OnInit { * Submits Allocate Cash form. */ submit() { + const allocateCashFormData = this.allocateCashForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const txnDate = this.allocateCashForm.value.txnDate; - this.allocateCashForm.patchValue({ - txnDate: this.datePipe.transform(txnDate, dateFormat) - }); - const allocateCashForm = this.allocateCashForm.value; - allocateCashForm.dateFormat = dateFormat; - allocateCashForm.locale = this.settingsService.language.code; - this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, allocateCashForm).subscribe((response: any) => { + if (allocateCashFormData.closureDate instanceof Date) { + allocateCashFormData.txnDate = this.dateUtils.formatDate(txnDate, dateFormat); + } + const data = { + ...allocateCashFormData, + dateFormat, + locale + }; + this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, data).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); } diff --git a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.html b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.html index ed0c468dd..82d0f116e 100644 --- a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.html +++ b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.html @@ -55,7 +55,7 @@ -
+
Full Day? diff --git a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.scss b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.scss index e69de29bb..e8a59f38c 100644 --- a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.scss +++ b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.scss @@ -0,0 +1,3 @@ +.space { + padding-top: 10px; +} diff --git a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts index 910ab86d6..1d221dd8f 100644 --- a/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts +++ b/src/app/organization/tellers/cashiers/create-cashier/create-cashier.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -32,14 +32,14 @@ export class CreateCashierComponent 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 {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { cashierTemplate: any }) => { @@ -68,17 +68,23 @@ export class CreateCashierComponent implements OnInit { * Submits Create cashier form. */ submit() { + const createCashierFormData = this.createCashierForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const startDate = this.createCashierForm.value.startDate; - const endDate = this.createCashierForm.value.endDate; - this.createCashierForm.patchValue({ - 'startDate': this.datePipe.transform(startDate, dateFormat), - 'endDate': this.datePipe.transform(endDate, dateFormat) - }); - const createCashierForm = this.createCashierForm.value; - createCashierForm.locale = this.settingsService.language.code; - createCashierForm.dateFormat = dateFormat; - this.organizationService.createCashier(this.cashierTemplate.tellerId, createCashierForm).subscribe((response: any) => { + const prevStartDate: Date = this.createCashierForm.value.startDate; + const prevEndDate: Date = this.createCashierForm.value.endDate; + if (createCashierFormData.startDate instanceof Date) { + createCashierFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (createCashierFormData.endDate instanceof Date) { + createCashierFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + const data = { + ...createCashierFormData, + dateFormat, + locale + }; + this.organizationService.createCashier(this.cashierTemplate.tellerId, data).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); } diff --git a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.html b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.html index 92b7003a7..2737cf14e 100644 --- a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.html +++ b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.html @@ -61,7 +61,7 @@ -
+
Full Day? diff --git a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.scss b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.scss index e69de29bb..e8a59f38c 100644 --- a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.scss +++ b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.scss @@ -0,0 +1,3 @@ +.space { + padding-top: 10px; +} diff --git a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts index 3ad9041b8..08e78592c 100644 --- a/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts +++ b/src/app/organization/tellers/cashiers/edit-cashier/edit-cashier.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -34,14 +34,14 @@ export class EditCashierComponent 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 {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settingsService: SettingsService ) { this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => { @@ -72,18 +72,24 @@ export class EditCashierComponent implements OnInit { * Submits edit cashier form. */ submit() { + const editCashierFormData = this.editCashierForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const startDate = this.editCashierForm.value.startDate; - const endDate = this.editCashierForm.value.endDate; - this.editCashierForm.patchValue({ - 'startDate': this.datePipe.transform(startDate, dateFormat), - 'endDate': this.datePipe.transform(endDate, dateFormat) - }); - const editCashierForm = this.editCashierForm.value; - editCashierForm.locale = this.settingsService.language.code; - editCashierForm.dateFormat = dateFormat; - editCashierForm.staffId = this.cashierData.data.staffId; - this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, editCashierForm).subscribe((response: any) => { + const prevStartDate: Date = this.editCashierForm.value.startDate; + const prevEndDate: Date = this.editCashierForm.value.endDate; + if (editCashierFormData.startDate instanceof Date) { + editCashierFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (editCashierFormData.endDate instanceof Date) { + editCashierFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + const data = { + ...editCashierFormData, + staffId: this.cashierData.data.staffId, + dateFormat, + locale + }; + this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, data).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); } diff --git a/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts b/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts index a966fab45..25c4b91f4 100644 --- a/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts +++ b/src/app/organization/tellers/cashiers/settle-cash/settle-cash.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Customer Services. */ import { OrganizationService } from 'app/organization/organization.service'; @@ -28,14 +28,14 @@ export class SettleCashComponent implements OnInit { * Get cashier data from `Resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route ActivateRoute. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {OrganizationService} organizationService Organization Service. * @param {SettingsService} settingsService Settings Service. * @param {Router} router Router. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, private organizationService: OrganizationService, private settingsService: SettingsService, private router: Router) { @@ -56,7 +56,7 @@ export class SettleCashComponent implements OnInit { 'office': [{value: this.cashierData.officeName, disabled: true}], 'tellerName': [{value: this.cashierData.tellerName, disabled: true}], 'cashier': [{value: this.cashierData.cashierName, disabled: true}], - 'assignmentPeriod': [{value: this.datePipe.transform(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.datePipe.transform(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}], + 'assignmentPeriod': [{value: this.dateUtils.formatDate(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.dateUtils.formatDate(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}], 'txnDate': [new Date(), Validators.required], 'currencyCode': ['', Validators.required], 'txnAmount': ['', Validators.required], @@ -68,15 +68,19 @@ export class SettleCashComponent implements OnInit { * Submits Settle Cash form. */ submit() { + const settleCashFormData = this.settleCashForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const txnDate = this.settleCashForm.value.txnDate; - this.settleCashForm.patchValue({ - txnDate: this.datePipe.transform(txnDate, dateFormat) - }); - const settleCashForm = this.settleCashForm.value; - settleCashForm.dateFormat = dateFormat; - settleCashForm.locale = this.settingsService.language.code; - this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, settleCashForm).subscribe((response: any) => { + const prevTxnDate: Date = this.settleCashForm.value.txnDate; + if (settleCashFormData.txnDate instanceof Date) { + settleCashFormData.txnDate = this.dateUtils.formatDate(prevTxnDate, dateFormat); + } + const data = { + ...settleCashFormData, + dateFormat, + locale + }; + this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, data).subscribe((response: any) => { this.router.navigate(['../'], {relativeTo: this.route}); }); } diff --git a/src/app/organization/tellers/create-teller/create-teller.component.ts b/src/app/organization/tellers/create-teller/create-teller.component.ts index 216112e02..20aa067b2 100644 --- a/src/app/organization/tellers/create-teller/create-teller.component.ts +++ b/src/app/organization/tellers/create-teller/create-teller.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create teller component. @@ -36,14 +36,14 @@ export class CreateTellerComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { offices: any }) => { this.officeData = data.offices; }); @@ -77,18 +77,23 @@ export class CreateTellerComponent implements OnInit { * if successful redirects to tellers. */ submit() { + const tellerFormData = this.tellerForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevStartDate: Date = this.tellerForm.value.startDate; const prevEndDate: Date = this.tellerForm.value.endDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.tellerForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - endDate: this.datePipe.transform(prevEndDate, dateFormat) - }); - const teller = this.tellerForm.value; - teller.locale = this.settingsService.language.code; - teller.dateFormat = dateFormat; - this.organizationService.createTeller(teller).subscribe((response: any) => { + if (tellerFormData.startDate instanceof Date) { + tellerFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (tellerFormData.endDate instanceof Date) { + tellerFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + const data = { + ...tellerFormData, + dateFormat, + locale + }; + this.organizationService.createTeller(data).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/organization/tellers/edit-teller/edit-teller.component.ts b/src/app/organization/tellers/edit-teller/edit-teller.component.ts index a5638af64..8a6db7675 100644 --- a/src/app/organization/tellers/edit-teller/edit-teller.component.ts +++ b/src/app/organization/tellers/edit-teller/edit-teller.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { OrganizationService } from '../../organization.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create teller component. @@ -39,14 +39,14 @@ export class EditTellerComponent implements OnInit { * @param {SettingsService} settingsService Settings Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. */ constructor(private formBuilder: FormBuilder, private organizationService: OrganizationService, private settingsService: SettingsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.route.data.subscribe((data: { teller: any, offices: any }) => { this.tellerData = data.teller; this.officeData = data.offices; @@ -89,19 +89,24 @@ export class EditTellerComponent implements OnInit { * if successful redirects to tellers. */ submit() { + const tellerFormData = this.tellerForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevStartDate: Date = this.tellerForm.value.startDate; const prevEndDate: Date = this.tellerForm.value.endDate; - // TODO: Update once language and date settings are setup - const dateFormat = this.settingsService.dateFormat; - this.tellerForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat), - endDate: this.datePipe.transform(prevEndDate, dateFormat) - }); - const teller = this.tellerForm.value; - teller.locale = this.settingsService.language.code; - teller.officeId = this.tellerData.officeId; - teller.dateFormat = dateFormat; - this.organizationService.updateTeller(this.tellerData.id, teller).subscribe((response: any) => { + if (tellerFormData.startDate instanceof Date) { + tellerFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (tellerFormData.endDate instanceof Date) { + tellerFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + const data = { + ...tellerFormData, + officeId: this.tellerData.officeId, + dateFormat, + locale + }; + this.organizationService.updateTeller(this.tellerData.id, data).subscribe((response: any) => { this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/products/charges/create-charge/create-charge.component.ts b/src/app/products/charges/create-charge/create-charge.component.ts index 23d4381e4..9ce52a203 100644 --- a/src/app/products/charges/create-charge/create-charge.component.ts +++ b/src/app/products/charges/create-charge/create-charge.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ProductsService } from '../../products.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create charge component. @@ -43,14 +43,14 @@ export class CreateChargeComponent implements OnInit { * @param {ProductsService} productsService Products Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private productsService: ProductsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe((data: { chargesTemplate: any }) => { this.chargesTemplateData = data.chargesTemplate; @@ -214,26 +214,30 @@ export class CreateChargeComponent implements OnInit { * if successful redirects to charges. */ submit() { + const chargeFormData = this.chargeForm.value; + const locale = this.settingsService.language.code; + const dateFormat = this.settingsService.dateFormat; const prevFeeOnMonthDay: Date = this.chargeForm.value.feeOnMonthDay; const monthDayFormat = 'dd MMM'; - this.chargeForm.patchValue({ - feeOnMonthDay: this.datePipe.transform(prevFeeOnMonthDay, monthDayFormat) - }); - const charge = this.chargeForm.getRawValue(); - // TODO: Update once language and date settings are setup - charge.locale = this.settingsService.language.code; - charge.monthDayFormat = monthDayFormat; - delete charge.addFeeFrequency; - if (!charge.taxGroupId) { - delete charge.taxGroupId; + if (chargeFormData.feeOnMonthDay instanceof Date) { + chargeFormData.feeOnMonthDay = this.dateUtils.formatDate(prevFeeOnMonthDay, monthDayFormat); } - if (!charge.minCap) { - delete charge.minCap; + const data = { + ...chargeFormData, + monthDayFormat, + locale + }; + delete data.addFeeFrequency; + if (!data.taxGroupId) { + delete data.taxGroupId; } - if (!charge.maxCap) { - delete charge.maxCap; + if (!data.minCap) { + delete data.minCap; } - this.productsService.createCharge(charge).subscribe((response: any) => { + if (!data.maxCap) { + delete data.maxCap; + } + this.productsService.createCharge(data).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-interest-rate-chart-step/fixed-deposit-product-interest-rate-chart-step.component.ts b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-interest-rate-chart-step/fixed-deposit-product-interest-rate-chart-step.component.ts index 4c88d3ff3..d0189d692 100644 --- a/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-interest-rate-chart-step/fixed-deposit-product-interest-rate-chart-step.component.ts +++ b/src/app/products/fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-interest-rate-chart-step/fixed-deposit-product-interest-rate-chart-step.component.ts @@ -1,7 +1,6 @@ /** Angular Imports */ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormArray } from '@angular/forms'; -import { DatePipe } from '@angular/common'; import { MatDialog } from '@angular/material/dialog'; import { animate, state, style, transition, trigger } from '@angular/animations'; @@ -17,6 +16,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; @Component({ selector: 'mifosx-fixed-deposit-product-interest-rate-chart-step', @@ -59,13 +59,13 @@ export class FixedDepositProductInterestRateChartStepComponent implements OnInit /** * @param {FormBuilder} formBuilder Form Builder. * @param {MatDialog} dialog Dialog reference. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, public dialog: MatDialog, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.createFixedDepositProductInterestRateChartForm(); } @@ -375,8 +375,8 @@ export class FixedDepositProductInterestRateChartStepComponent implements OnInit for (const chart of fixedDepositProductInterestRateChart.charts) { chart.dateFormat = dateFormat; chart.locale = locale; - chart.fromDate = this.datePipe.transform(chart.fromDate, dateFormat) || ''; - chart.endDate = this.datePipe.transform(chart.endDate, dateFormat) || ''; + chart.fromDate = this.dateUtils.formatDate(chart.fromDate, dateFormat) || ''; + chart.endDate = this.dateUtils.formatDate(chart.endDate, dateFormat) || ''; if (chart.endDate === '') { delete chart.endDate; } diff --git a/src/app/products/floating-rates/create-floating-rate/create-floating-rate.component.ts b/src/app/products/floating-rates/create-floating-rate/create-floating-rate.component.ts index 506d44907..9df5b9672 100644 --- a/src/app/products/floating-rates/create-floating-rate/create-floating-rate.component.ts +++ b/src/app/products/floating-rates/create-floating-rate/create-floating-rate.component.ts @@ -49,7 +49,7 @@ export class CreateFloatingRateComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {ProductsService} productsService Product Service. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {MatDialog} dialog Dialog reference. * @param {SettingsService} settingsService Settings Service. */ diff --git a/src/app/products/floating-rates/edit-floating-rate/edit-floating-rate.component.ts b/src/app/products/floating-rates/edit-floating-rate/edit-floating-rate.component.ts index 0442ae321..707d5e865 100644 --- a/src/app/products/floating-rates/edit-floating-rate/edit-floating-rate.component.ts +++ b/src/app/products/floating-rates/edit-floating-rate/edit-floating-rate.component.ts @@ -54,7 +54,7 @@ export class EditFloatingRateComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {ProductsService} productsService Product Service. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {MatDialog} dialog Dialog reference. * @param {SettingsService} settingsService Settings Service. */ diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts index cb0d488fb..98879bae9 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-details-step/loan-product-details-step.component.ts @@ -1,7 +1,7 @@ /** Angular Imports */ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services */ import { SettingsService } from 'app/settings/settings.service'; @@ -24,12 +24,12 @@ export class LoanProductDetailsStepComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.createLoanProductDetailsForm(); } @@ -61,15 +61,17 @@ export class LoanProductDetailsStepComponent implements OnInit { } get loanProductDetails() { + const loanProductDetailsFormData = this.loanProductDetailsForm.value; const prevStartDate: Date = this.loanProductDetailsForm.value.startDate; const prevCloseDate: Date = this.loanProductDetailsForm.value.closeDate; - // TODO: Update once language and date settings are setup const dateFormat = this.settingsService.dateFormat; - this.loanProductDetailsForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat) || '', - closeDate: this.datePipe.transform(prevCloseDate, dateFormat) || '' - }); - return this.loanProductDetailsForm.value; + if (loanProductDetailsFormData.startDate instanceof Date) { + loanProductDetailsFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat) || ''; + } + if (loanProductDetailsFormData.closeDate instanceof Date) { + loanProductDetailsFormData.closeDate = this.dateUtils.formatDate(prevCloseDate, dateFormat) || ''; + } + return loanProductDetailsFormData; } } diff --git a/src/app/products/manage-tax-components/create-tax-component/create-tax-component.component.ts b/src/app/products/manage-tax-components/create-tax-component/create-tax-component.component.ts index 750eb62a5..90aff5c10 100644 --- a/src/app/products/manage-tax-components/create-tax-component/create-tax-component.component.ts +++ b/src/app/products/manage-tax-components/create-tax-component/create-tax-component.component.ts @@ -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 { ProductsService } from '../../products.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Create Tax Component component. @@ -41,14 +41,14 @@ export class CreateTaxComponentComponent implements OnInit { * @param {ProductsService} productsService Products Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private productsService: ProductsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe((data: { taxComponentTemplate: any }) => { this.taxComponentTemplateData = data.taxComponentTemplate; @@ -115,16 +115,19 @@ export class CreateTaxComponentComponent implements OnInit { * if successful redirects to Tax Components. */ submit() { - const prevStartDate: Date = this.taxComponentForm.value.startDate; - // TODO: Update once language and date settings are setup + const taxComponentFormData = this.taxComponentForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.taxComponentForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat) - }); - const taxComponent = this.taxComponentForm.value; - taxComponent.locale = this.settingsService.language.code; - taxComponent.dateFormat = dateFormat; - this.productsService.createTaxComponent(taxComponent).subscribe((response: any) => { + const prevStartDate: Date = this.taxComponentForm.value.startDate; + if (taxComponentFormData.startDate instanceof Date) { + taxComponentFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + const data = { + ...taxComponentFormData, + dateFormat, + locale + }; + this.productsService.createTaxComponent(data).subscribe((response: any) => { this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/products/manage-tax-components/edit-tax-component/edit-tax-component.component.ts b/src/app/products/manage-tax-components/edit-tax-component/edit-tax-component.component.ts index 9b7d2a186..6e945d22f 100644 --- a/src/app/products/manage-tax-components/edit-tax-component/edit-tax-component.component.ts +++ b/src/app/products/manage-tax-components/edit-tax-component/edit-tax-component.component.ts @@ -2,11 +2,11 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ProductsService } from '../../products.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Edit tax component. @@ -31,14 +31,14 @@ export class EditTaxComponentComponent implements OnInit { * @param {ProductsService} productsService Products Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private productsService: ProductsService, private route: ActivatedRoute, private router: Router, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe((data: { taxComponent: any }) => { this.taxComponentData = data.taxComponent; @@ -70,16 +70,19 @@ export class EditTaxComponentComponent implements OnInit { * if successfull redirects to tax component. */ submit() { - const prevStartDate: Date = this.taxComponentForm.value.startDate; - // TODO: Update once language and date settings are setup + const taxComponentFormData = this.taxComponentForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - this.taxComponentForm.patchValue({ - startDate: this.datePipe.transform(prevStartDate, dateFormat) - }); - const taxComponent = this.taxComponentForm.value; - taxComponent.locale = this.settingsService.language.code; - taxComponent.dateFormat = dateFormat; - this.productsService.updateTaxComponent(this.taxComponentData.id, taxComponent).subscribe((response: any) => { + const prevStartDate: Date = this.taxComponentForm.value.startDate; + if (taxComponentFormData.startDate instanceof Date) { + taxComponentFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + const data = { + ...taxComponentFormData, + dateFormat, + locale + }; + this.productsService.updateTaxComponent(this.taxComponentData.id, data).subscribe((response: any) => { this.router.navigate(['../../', response.resourceId], { relativeTo: this.route }); }); } diff --git a/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts b/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts index b32a17312..cbffbe922 100644 --- a/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts +++ b/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts @@ -48,7 +48,7 @@ export class CreateTaxGroupComponent implements OnInit { * @param {ProductsService} productsService Products Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {DatePipe} datePipe Date Utils to format date. * @param {MatDialog} dialog Dialog reference. * @param {SettingsService} settingsService Settings Service. */ diff --git a/src/app/products/manage-tax-groups/edit-tax-group/edit-tax-group.component.ts b/src/app/products/manage-tax-groups/edit-tax-group/edit-tax-group.component.ts index 4818dc679..55cf80c53 100644 --- a/src/app/products/manage-tax-groups/edit-tax-group/edit-tax-group.component.ts +++ b/src/app/products/manage-tax-groups/edit-tax-group/edit-tax-group.component.ts @@ -48,7 +48,7 @@ export class EditTaxGroupComponent implements OnInit { * @param {ProductsService} productsService Products Service. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {DatePipe} datePipe Date Utils to format date. * @param {MatDialog} dialog Dialog reference. * @param {SettingsService} settingsService Settings Service. */ diff --git a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-interest-rate-chart-step/recurring-deposit-product-interest-rate-chart-step.component.ts b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-interest-rate-chart-step/recurring-deposit-product-interest-rate-chart-step.component.ts index 6c5223158..8ecca62d3 100644 --- a/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-interest-rate-chart-step/recurring-deposit-product-interest-rate-chart-step.component.ts +++ b/src/app/products/recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-interest-rate-chart-step/recurring-deposit-product-interest-rate-chart-step.component.ts @@ -1,7 +1,6 @@ /** Angular Imports */ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormArray } from '@angular/forms'; -import { DatePipe } from '@angular/common'; import { MatDialog } from '@angular/material/dialog'; import { animate, state, style, transition, trigger } from '@angular/animations'; @@ -17,6 +16,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; @Component({ selector: 'mifosx-recurring-deposit-product-interest-rate-chart-step', @@ -59,13 +59,13 @@ export class RecurringDepositProductInterestRateChartStepComponent implements On /** * @param {FormBuilder} formBuilder Form Builder. * @param {MatDialog} dialog Dialog reference. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, public dialog: MatDialog, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.createrecurringDepositProductInterestRateChartForm(); } @@ -376,8 +376,8 @@ export class RecurringDepositProductInterestRateChartStepComponent implements On for (const chart of recurringDepositProductInterestRateChart.charts) { chart.dateFormat = dateFormat; chart.locale = locale; - chart.fromDate = this.datePipe.transform(chart.fromDate, dateFormat) || ''; - chart.endDate = this.datePipe.transform(chart.endDate, dateFormat) || ''; + chart.fromDate = this.dateUtils.formatDate(chart.fromDate, dateFormat) || ''; + chart.endDate = this.dateUtils.formatDate(chart.endDate, dateFormat) || ''; if (chart.endDate === '') { delete chart.endDate; } diff --git a/src/app/products/share-products/create-dividend/create-dividend.component.ts b/src/app/products/share-products/create-dividend/create-dividend.component.ts index 68b492fff..22e175e92 100644 --- a/src/app/products/share-products/create-dividend/create-dividend.component.ts +++ b/src/app/products/share-products/create-dividend/create-dividend.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DatePipe } from '@angular/common'; +import { Dates } from 'app/core/utils/dates'; /** Custom Services. */ import { ProductsService } from 'app/products/products.service'; @@ -32,14 +32,14 @@ export class CreateDividendComponent implements OnInit { * Get Share Product data from `Resolver`. * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {Dates} dateUtils Date Utils to format date. * @param {ProductsService} productsService Products Service. * @param {Router} router Router. * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private route: ActivatedRoute, - private datePipe: DatePipe, + private dateUtils: Dates, private productService: ProductsService, private router: Router, private settingsService: SettingsService) { @@ -67,17 +67,23 @@ export class CreateDividendComponent implements OnInit { * Submits Create Dividend form. */ submit() { + const createDividendFormData = this.createDividendForm.value; + const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; - const startDate = this.createDividendForm.value.dividendPeriodStartDate; - const endDate = this.createDividendForm.value.dividendPeriodEndDate; - this.createDividendForm.patchValue({ - 'dividendPeriodStartDate': this.datePipe.transform(startDate, dateFormat), - 'dividendPeriodEndDate': this.datePipe.transform(endDate, dateFormat) - }); - const dividendForm = this.createDividendForm.value; - dividendForm.locale = this.settingsService.language.code; - dividendForm.dateFormat = dateFormat; - this.productService.createDividend(this.shareProductData.id, dividendForm).subscribe((response: any) => { + const prevStartDate: Date = this.createDividendForm.value.dividendPeriodStartDate; + const prevEndDate: Date = this.createDividendForm.value.dividendPeriodEndDate; + if (createDividendFormData.dividendPeriodStartDate instanceof Date) { + createDividendFormData.dividendPeriodStartDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (createDividendFormData.dividendPeriodEndDate instanceof Date) { + createDividendFormData.dividendPeriodEndDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + const data = { + ...createDividendFormData, + dateFormat, + locale + }; + this.productService.createDividend(this.shareProductData.id, data).subscribe((response: any) => { this.router.navigate(['../'], { relativeTo: this.route }); }); } diff --git a/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts b/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts index dc6f41a92..cebf593af 100644 --- a/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts +++ b/src/app/products/share-products/share-product-stepper/share-product-market-price-step/share-product-market-price-step.component.ts @@ -30,8 +30,8 @@ export class ShareProductMarketPriceStepComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder. - * @param {DatePipe} datePipe Date Pipe to format date. - * @param {DatePipe} datePipe Date Pipe to format date. + * @param {DatePipe} datePipe Date Utils to format date. + * @param {DatePipe} datePipe Date Utils to format date. * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/reports/run-report/run-report.component.html b/src/app/reports/run-report/run-report.component.html index 63c46c5d8..26d3aa94e 100644 --- a/src/app/reports/run-report/run-report.component.html +++ b/src/app/reports/run-report/run-report.component.html @@ -3,13 +3,13 @@
- + - + - + {{param.label}} @@ -17,7 +17,7 @@ {{param.label}} is required - + {{param.label}} required - + {{param.label}} @@ -40,11 +40,11 @@ {{param.label}} is required - + - + - + Decimal Places @@ -55,7 +55,7 @@ 4 - + Output Type @@ -71,7 +71,7 @@ - @@ -80,7 +80,7 @@
- +
diff --git a/src/app/reports/run-report/run-report.component.ts b/src/app/reports/run-report/run-report.component.ts index 2dd079ec2..9fbe10d2c 100644 --- a/src/app/reports/run-report/run-report.component.ts +++ b/src/app/reports/run-report/run-report.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Services */ import { ReportsService } from '../reports.service'; @@ -11,6 +10,7 @@ import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from '../common-models/report-parameter.model'; import { SelectOption } from '../common-models/select-option.model'; +import { Dates } from 'app/core/utils/dates'; /** * Run report component. @@ -57,12 +57,12 @@ export class RunReportComponent implements OnInit { * @param {ActivatedRoute} route ActivatedRoute. * @param {ReportsService} reportsService ReportsService * @param {SettingsService} settingsService Settings Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils */ constructor(private route: ActivatedRoute, private reportsService: ReportsService, private settingsService: SettingsService, - private datePipe: DatePipe) { + private dateUtils: Dates) { this.report.name = this.route.snapshot.params['name']; this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => { this.report.type = queryParams.type; @@ -193,7 +193,7 @@ export class RunReportComponent implements OnInit { break; case 'date': const dateFormat = this.settingsService.dateFormat; - formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); + formattedResponse[newKey] = this.dateUtils.formatDate(value, dateFormat); break; case 'none': formattedResponse[newKey] = value; diff --git a/src/app/reports/xbrl-report/xbrl-report.component.html b/src/app/reports/xbrl-report/xbrl-report.component.html index e58b3a1e6..ac192ac6e 100644 --- a/src/app/reports/xbrl-report/xbrl-report.component.html +++ b/src/app/reports/xbrl-report/xbrl-report.component.html @@ -24,11 +24,11 @@ - + - +
diff --git a/src/app/reports/xbrl-report/xbrl-report.component.ts b/src/app/reports/xbrl-report/xbrl-report.component.ts index d862bcbe2..186c4382c 100644 --- a/src/app/reports/xbrl-report/xbrl-report.component.ts +++ b/src/app/reports/xbrl-report/xbrl-report.component.ts @@ -2,12 +2,12 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormControl} from '@angular/forms'; import { MatTableDataSource } from '@angular/material/table'; -import { DatePipe } from '@angular/common'; import { DomSanitizer } from '@angular/platform-browser'; /** Custom Services */ import { ReportsService } from '../reports.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * XBRL Report Component @@ -47,7 +47,7 @@ export class XBRLReportComponent implements OnInit { constructor(private reportService: ReportsService, private formBuilder: FormBuilder, private settingsService: SettingsService, - private datePipe: DatePipe, + private dateUtils: Dates, private sanitizer: DomSanitizer) {} /** @@ -88,16 +88,17 @@ export class XBRLReportComponent implements OnInit { * Fetches XML Response, parses it and initializes mat-table with parsed data. */ runreport() { - const startDate: Date = this.xbrlForm.value.startDate; - const endDate: Date = this.xbrlForm.value.endDate; - // TODO: Update once language and date settings are setup + const xbrlFormData = this.xbrlForm.value; + const prevStartDate: Date = this.xbrlForm.value.startDate; + const prevEndDate: Date = this.xbrlForm.value.endDate; const dateFormat = this.settingsService.dateFormat; - this.xbrlForm.patchValue({ - startDate: this.datePipe.transform(startDate, dateFormat), - endDate: this.datePipe.transform(endDate, dateFormat) - }); - const dates = this.xbrlForm.value; - this.reportService.getMixReport(dates).subscribe((response: any) => { + if (xbrlFormData.startDate instanceof Date) { + xbrlFormData.startDate = this.dateUtils.formatDate(prevStartDate, dateFormat); + } + if (xbrlFormData.endDate instanceof Date) { + xbrlFormData.endDate = this.dateUtils.formatDate(prevEndDate, dateFormat); + } + this.reportService.getMixReport(xbrlFormData).subscribe((response: any) => { this.rawXml = response; this.buildXMLTable(response); this.dataSource = new MatTableDataSource(this.xmlData); diff --git a/src/app/savings/create-savings-account/create-savings-account.component.ts b/src/app/savings/create-savings-account/create-savings-account.component.ts index 5986ae974..400fe80fc 100644 --- a/src/app/savings/create-savings-account/create-savings-account.component.ts +++ b/src/app/savings/create-savings-account/create-savings-account.component.ts @@ -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 */ diff --git a/src/app/savings/edit-savings-account/edit-savings-account.component.ts b/src/app/savings/edit-savings-account/edit-savings-account.component.ts index 4dd5dd815..a095984ed 100644 --- a/src/app/savings/edit-savings-account/edit-savings-account.component.ts +++ b/src/app/savings/edit-savings-account/edit-savings-account.component.ts @@ -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 */ diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts index 99149f189..dcdbfa4e8 100644 --- a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html index a9ba9e5a8..cc95bfbd9 100644 --- a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.html @@ -23,7 +23,7 @@ Amount - + Amount is required diff --git a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts index be0ed3d9e..7447c7eee 100644 --- a/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/add-charge-savings-account/add-charge-savings-account.component.ts @@ -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); } } } diff --git a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts index 7c0255a2b..70b19a23a 100644 --- a/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/apply-annual-fees-savings-account/apply-annual-fees-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts b/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts index d3cd17a18..cc45e60af 100644 --- a/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/approve-savings-account/approve-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.html b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.html index ff151496a..d01d42e6d 100644 --- a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.html +++ b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.html @@ -30,7 +30,7 @@ Transaction Amount - + @@ -49,27 +49,27 @@
- + Account Number - + Cheque - + Routing Code - + Receipt Number - + Bank diff --git a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts index 465e43cb8..743dd5aee 100644 --- a/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/close-savings-account/close-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts b/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts index 8db0691c9..c8e4431b0 100644 --- a/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component.ts @@ -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 diff --git a/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts b/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts index 6e11efb0a..f53bd5fcf 100644 --- a/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/reject-savings-account/reject-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts index cf7e7d058..471e1f891 100644 --- a/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component.ts @@ -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 diff --git a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts index 8567cd53f..775c99649 100644 --- a/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-transactions/savings-account-transactions.component.ts @@ -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 }); }); } diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts index 9ce7585d2..1b35f7070 100644 --- a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts @@ -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 }; diff --git a/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts index 3eb39b0e9..493e2f251 100644 --- a/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts +++ b/src/app/savings/saving-account-actions/withdraw-by-client-savings-account/withdraw-by-client-savings-account.component.ts @@ -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 }; diff --git a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts index a56df4c09..7e856e660 100644 --- a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts +++ b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts @@ -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 diff --git a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts index 6582eb0a8..af6fdb3a8 100644 --- a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts +++ b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts @@ -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) { diff --git a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.html b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.html index 81124a89e..2995e69bf 100644 --- a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.html +++ b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.html @@ -32,4 +32,4 @@ - + diff --git a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts index c18699f47..612770e8d 100644 --- a/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts +++ b/src/app/savings/savings-account-view/transactions-tab/export-transactions/export-transactions.component.ts @@ -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) diff --git a/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts b/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts index c52af5dc9..fde5146f1 100644 --- a/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts +++ b/src/app/savings/savings-account-view/transactions/edit-transaction/edit-transaction.component.ts @@ -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 }); }); diff --git a/src/app/shares/create-shares-account/create-shares-account.component.ts b/src/app/shares/create-shares-account/create-shares-account.component.ts index 89c84f178..0a4dba469 100644 --- a/src/app/shares/create-shares-account/create-shares-account.component.ts +++ b/src/app/shares/create-shares-account/create-shares-account.component.ts @@ -38,7 +38,7 @@ export class CreateSharesAccountComponent { * Fetches shares account template from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {SharesService} sharesService Shares Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/shares/edit-shares-account/edit-shares-account.component.ts b/src/app/shares/edit-shares-account/edit-shares-account.component.ts index 725293dc9..d4ddf8a16 100644 --- a/src/app/shares/edit-shares-account/edit-shares-account.component.ts +++ b/src/app/shares/edit-shares-account/edit-shares-account.component.ts @@ -38,7 +38,7 @@ export class EditSharesAccountComponent { * Fetches shares account template from `resolve` * @param {ActivatedRoute} route Activated Route * @param {Router} router Router - * @param {DatePipe} datePipe Date Pipe + * @param {DatePipe} datePipe Date Utils * @param {SharesService} sharesService Shares Service * @param {SettingsService} settingsService Settings Service */ diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts index 9aee7b9f5..2a181993f 100644 --- a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Activate Shares Account Component @@ -30,14 +30,14 @@ export class ActivateSharesAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -65,15 +65,15 @@ export class ActivateSharesAccountComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const activateSharesAccountFormData = this.activateSharesAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevActivatedDate: Date = this.activateSharesAccountForm.value.activatedDate; - this.activateSharesAccountForm.patchValue({ - activatedDate: this.datePipe.transform(prevActivatedDate, dateFormat), - }); + if (activateSharesAccountFormData.activatedDate instanceof Date) { + activateSharesAccountFormData.activatedDate = this.dateUtils.formatDate(prevActivatedDate, dateFormat); + } const data = { - ...this.activateSharesAccountForm.value, + ...activateSharesAccountFormData, dateFormat, locale }; diff --git a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts index 2c11486d2..38abba6f0 100644 --- a/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts +++ b/src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Apply Shares Component @@ -33,14 +33,14 @@ export class ApplySharesComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -76,15 +76,15 @@ export class ApplySharesComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const applySharesFormData = this.applySharesForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRequestedDate: Date = this.applySharesForm.value.requestedDate; - this.applySharesForm.patchValue({ - requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat), - }); + if (applySharesFormData.requestedDate instanceof Date) { + applySharesFormData.requestedDate = this.dateUtils.formatDate(prevRequestedDate, dateFormat); + } const data = { - ...this.applySharesForm.value, + ...applySharesFormData, unitPrice: this.applySharesForm.get('unitPrice').value, dateFormat, locale diff --git a/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts b/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts index ac90f6708..ffcbddd25 100644 --- a/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Approve Shares Account Component @@ -30,14 +30,14 @@ export class ApproveSharesAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,15 +66,15 @@ export class ApproveSharesAccountComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const approveSharesAccountFormData = this.approveSharesAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevApprovedDate: Date = this.approveSharesAccountForm.value.approvedDate; - this.approveSharesAccountForm.patchValue({ - approvedDate: this.datePipe.transform(prevApprovedDate, dateFormat), - }); + if (approveSharesAccountFormData.approvedDate instanceof Date) { + approveSharesAccountFormData.approvedDate = this.dateUtils.formatDate(prevApprovedDate, dateFormat); + } const data = { - ...this.approveSharesAccountForm.value, + ...approveSharesAccountFormData, dateFormat, locale }; diff --git a/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts b/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts index 95aad8f8f..4cc001afd 100644 --- a/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/close-shares-account/close-shares-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Close Shares Account Component @@ -30,14 +30,14 @@ export class CloseSharesAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,15 +66,15 @@ export class CloseSharesAccountComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const closeSharesAccountFormData = this.closeSharesAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevClosedDate: Date = this.closeSharesAccountForm.value.closedDate; - this.closeSharesAccountForm.patchValue({ - closedDate: this.datePipe.transform(prevClosedDate, dateFormat), - }); + if (closeSharesAccountFormData.closedDate instanceof Date) { + closeSharesAccountFormData.closedDate = this.dateUtils.formatDate(prevClosedDate, dateFormat); + } const data = { - ...this.closeSharesAccountForm.value, + ...closeSharesAccountFormData, dateFormat, locale }; diff --git a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts index c3dec741d..dbb4cde1b 100644 --- a/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts +++ b/src/app/shares/shares-account-actions/redeem-shares/redeem-shares.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Redeem Shares Component @@ -33,14 +33,14 @@ export class RedeemSharesComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service. */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -76,15 +76,15 @@ export class RedeemSharesComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const redeemSharesFormData = this.redeemSharesForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRequestedDate: Date = this.redeemSharesForm.value.requestedDate; - this.redeemSharesForm.patchValue({ - requestedDate: this.datePipe.transform(prevRequestedDate, dateFormat), - }); + if (redeemSharesFormData.requestedDate instanceof Date) { + redeemSharesFormData.requestedDate = this.dateUtils.formatDate(prevRequestedDate, dateFormat); + } const data = { - ...this.redeemSharesForm.value, + ...redeemSharesFormData, unitPrice: this.redeemSharesForm.get('unitPrice').value, dateFormat, locale diff --git a/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts b/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts index d1fbf50cc..2325698d1 100644 --- a/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts +++ b/src/app/shares/shares-account-actions/reject-shares-account/reject-shares-account.component.ts @@ -1,12 +1,12 @@ /** 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'; /** Custom Services */ import { SharesService } from 'app/shares/shares.service'; import { SettingsService } from 'app/settings/settings.service'; +import { Dates } from 'app/core/utils/dates'; /** * Reject Shares Account Component @@ -30,14 +30,14 @@ export class RejectSharesAccountComponent implements OnInit { /** * @param {FormBuilder} formBuilder Form Builder * @param {SharesService} sharesService Shares Service - * @param {DatePipe} datePipe Date Pipe + * @param {Dates} dateUtils Date Utils * @param {ActivatedRoute} route Activated Route * @param {Router} router Router * @param {SettingsService} settingsService Settings Service */ constructor(private formBuilder: FormBuilder, private sharesService: SharesService, - private datePipe: DatePipe, + private dateUtils: Dates, private route: ActivatedRoute, private router: Router, private settingsService: SettingsService) { @@ -66,15 +66,15 @@ export class RejectSharesAccountComponent implements OnInit { * if successful redirects to the share account. */ submit() { - // TODO: Update once language and date settings are setup + const rejectSharesAccountFormData = this.rejectSharesAccountForm.value; const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const prevRejectedDate: Date = this.rejectSharesAccountForm.value.rejectedDate; - this.rejectSharesAccountForm.patchValue({ - rejectedDate: this.datePipe.transform(prevRejectedDate, dateFormat), - }); + if (rejectSharesAccountFormData.rejectedDate instanceof Date) { + rejectSharesAccountFormData.rejectedDate = this.dateUtils.formatDate(prevRejectedDate, dateFormat); + } const data = { - ...this.rejectSharesAccountForm.value, + ...rejectSharesAccountFormData, dateFormat, locale }; diff --git a/src/app/system/audit-trails/audit-trails.component.ts b/src/app/system/audit-trails/audit-trails.component.ts index bdd6f1888..e0af8388f 100644 --- a/src/app/system/audit-trails/audit-trails.component.ts +++ b/src/app/system/audit-trails/audit-trails.component.ts @@ -4,7 +4,6 @@ import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { ActivatedRoute } from '@angular/router'; import { FormControl } from '@angular/forms'; -import { DatePipe } from '@angular/common'; /** Custom Data Source */ import { AuditTrailsDataSource } from './audit-trail.datasource'; @@ -16,6 +15,7 @@ import { SettingsService } from 'app/settings/settings.service'; /** rxjs Imports */ import { merge } from 'rxjs'; import { tap, debounceTime, distinctUntilChanged, startWith, map } from 'rxjs/operators'; +import { Dates } from 'app/core/utils/dates'; /** * Audit Trails Component. @@ -131,7 +131,7 @@ export class AuditTrailsComponent implements OnInit, AfterViewInit { */ constructor(private route: ActivatedRoute, private systemService: SystemService, - private datePipe: DatePipe, + private dateUtils: Dates, private settingsService: SettingsService) { this.route.data.subscribe((data: { auditTrailSearchTemplate: any }) => { this.auditTrailSearchTemplateData = data.auditTrailSearchTemplate; @@ -391,7 +391,7 @@ export class AuditTrailsComponent implements OnInit, AfterViewInit { this.systemService.getAuditTrails(this.filterAuditTrailsBy, this.sort.active ? this.sort.active : '', this.sort.direction, 0, -1).subscribe((response: any) => { if (response !== undefined) { let csv = response.pageItems.map((row: any) => headerCode.map(fieldName => (fieldName === 'madeOnDate' || fieldName === 'checkedOnDate') && (JSON.stringify(row[fieldName], replacer) !== '""') - ? this.datePipe.transform(JSON.stringify(row[fieldName], replacer), dateFormat) + ? this.dateUtils.formatDate(JSON.stringify(row[fieldName], replacer), dateFormat) : JSON.stringify(row[fieldName], replacer))); csv.unshift(`data:text/csv;charset=utf-8,${header.join()}`); csv = csv.join('\r\n'); @@ -414,7 +414,7 @@ export class AuditTrailsComponent implements OnInit, AfterViewInit { */ private getDate(timestamp: any) { const dateFormat = this.settingsService.dateFormat; - return this.datePipe.transform(timestamp, dateFormat); + return this.dateUtils.formatDate(timestamp, dateFormat); } } diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/checker-inbox/checker-inbox.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/checker-inbox/checker-inbox.component.ts index 7ce4817a2..a83815314 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/checker-inbox/checker-inbox.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/checker-inbox/checker-inbox.component.ts @@ -3,7 +3,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { SelectionModel } from '@angular/cdk/collections'; import { FormBuilder, FormGroup } from '@angular/forms'; -import { DatePipe } from '@angular/common'; import { MatTableDataSource } from '@angular/material/table'; import { MatDialog } from '@angular/material/dialog'; @@ -13,6 +12,7 @@ import { SettingsService } from 'app/settings/settings.service'; /** Dialog Components */ import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component'; +import { Dates } from 'app/core/utils/dates'; @Component({ selector: 'mifosx-checker-inbox', @@ -46,7 +46,7 @@ export class CheckerInboxComponent implements OnInit { * Retrieves the maker checker data from `resolve`. * @param {ActivatedRoute} route Activated Route. * @param {Dialog} dialog MatDialog. - * @param {DatePipe} datePipe Date Pipe. + * @param {Dates} dateUtils Date Utils. * @param {router} router Router. * @param {SettingsService} settingsService Settings Service. * @param {TasksService} tasksService Tasks Service. @@ -54,7 +54,7 @@ export class CheckerInboxComponent implements OnInit { */ constructor(private route: ActivatedRoute, private dialog: MatDialog, - private datePipe: DatePipe, + private dateUtils: Dates, private router: Router, private tasksService: TasksService, private settingsService: SettingsService, @@ -91,8 +91,8 @@ export class CheckerInboxComponent implements OnInit { const dateFormat = this.settingsService.dateFormat; const makerCheckerSearchParams = { ...this.makerCheckerSearchForm.value, - makerDateTimeFrom: this.datePipe.transform(this.makerCheckerSearchForm.value.makerDateTimeFrom, dateFormat), - makerDateTimeto: this.datePipe.transform(this.makerCheckerSearchForm.value.makerDateTimeto, dateFormat) + makerDateTimeFrom: this.dateUtils.formatDate(this.makerCheckerSearchForm.value.makerDateTimeFrom, dateFormat), + makerDateTimeto: this.dateUtils.formatDate(this.makerCheckerSearchForm.value.makerDateTimeto, dateFormat) }; this.tasksService.getMakerCheckerData(makerCheckerSearchParams).subscribe((response: any) => { this.searchData = response; diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/client-approval/client-approval.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/client-approval/client-approval.component.ts index 171c87cc1..95625965a 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/client-approval/client-approval.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/client-approval/client-approval.component.ts @@ -40,7 +40,7 @@ export class ClientApprovalComponent { * Retrieves the grouped client data from `resolve`. * @param {ActivatedRoute} route Activated Route. * @param {Dialog} dialog MatDialog. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {router} router Router. * @param {SettingsService} settingsService Settings Service. * @param {TasksService} tasksService Tasks Service. diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/loan-approval/loan-approval.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/loan-approval/loan-approval.component.ts index 6a5d91076..62b344638 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/loan-approval/loan-approval.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/loan-approval/loan-approval.component.ts @@ -44,7 +44,7 @@ export class LoanApprovalComponent { * Retrieves the offices and loans data from `resolve`. * @param {ActivatedRoute} route Activated Route. * @param {Dialog} dialog MatDialog. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {router} router Router. * @param {SettingsService} settingsService Settings Service. * @param {TasksService} tasksService Tasks Service. diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component.ts index 5fa5c5de9..e71f5fc15 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component.ts @@ -35,7 +35,7 @@ export class LoanDisbursalComponent { * Retrieves the loans data from `resolve`. * @param {ActivatedRoute} route Activated Route. * @param {Dialog} dialog MatDialog. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {router} router Router. * @param {SettingsService} settingsService Settings Service. * @param {TasksService} tasksService Tasks Service. diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/reschedule-loan/reschedule-loan.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/reschedule-loan/reschedule-loan.component.ts index 653fc9add..68b43c923 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/reschedule-loan/reschedule-loan.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/reschedule-loan/reschedule-loan.component.ts @@ -36,7 +36,7 @@ export class RescheduleLoanComponent implements OnInit { * Retrieves the reschedule loan data from `resolve`. * @param {ActivatedRoute} route Activated Route. * @param {Dialog} dialog MatDialog. - * @param {DatePipe} datePipe Date Pipe. + * @param {DatePipe} datePipe Date Utils. * @param {router} router Router. * @param {SettingsService} settingsService Settings Service. * @param {TasksService} tasksService Tasks Service.