Format date fields without patch form

This commit is contained in:
Jose Alberto Hernandez
2022-06-10 10:34:19 +02:00
committed by Arnold Gálovics
parent 9d43181cea
commit 6ea3d97538
191 changed files with 1408 additions and 1173 deletions
@@ -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
*/
@@ -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
*/
@@ -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();
}
@@ -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
@@ -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) {
@@ -21,7 +21,7 @@
<mat-form-field>
<mat-label>Amount</mat-label>
<input type=number required matInput formControlName="amount" />
<input type="number" required matInput formControlName="amount" />
<mat-error *ngIf="loanChargeForm.controls.amount.hasError('required')">
Amount is <strong>required</strong>
</mat-error>
@@ -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 });
});
}
@@ -34,7 +34,7 @@
<mat-form-field>
<mat-label>Transaction Amount</mat-label>
<input matInput type="number" required formControlName="approvedLoanAmount" required>
<input matInput type="number" required formControlName="approvedLoanAmount">
<mat-error *ngIf="approveLoanForm.controls.approvedLoanAmount.hasError('required')">
Transaction Amount is <strong>required</strong>
</mat-error>
@@ -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 });
});
}
@@ -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 });
});
@@ -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 });
});
@@ -23,7 +23,7 @@
</mat-form-field>
<mat-autocomplete autoActiveFirstOption #clientsAutocomplete="matAutocomplete" [displayWith]="displayClient"
(optionSelected)='clientSelected($event.option.value)'>
(optionSelected)="clientSelected($event.option.value)">
<mat-option *ngFor="let client of clientsData" [value]="client">
{{ client.displayName }}
</mat-option>
@@ -51,7 +51,7 @@
<mat-form-field>
<mat-label>Amount</mat-label>
<input type="number" matInput required formControlName="amount" required>
<input type="number" matInput required formControlName="amount">
</mat-form-field>
</ng-container>
@@ -71,7 +71,7 @@
<mat-form-field>
<mat-label>First Name</mat-label>
<input matInput required formControlName="firstname" required>
<input matInput required formControlName="firstname">
<mat-error *ngIf="newGuarantorForm.controls.firstname.hasError('required')">
First Name <strong>is required</strong>
</mat-error>
@@ -79,7 +79,7 @@
<mat-form-field>
<mat-label>Last Name</mat-label>
<input matInput required formControlName="lastname" required>
<input matInput required formControlName="lastname">
<mat-error *ngIf="newGuarantorForm.controls.lastname.hasError('required')">
Last Name <strong>is required</strong>
</mat-error>
@@ -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 });
});
@@ -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});
});
}
@@ -38,7 +38,7 @@
<div fxFlexFill>
<span fxFlex="25%">Show Payment Details</span>
<span fxFlex="75%" class="expandCollapsebutton" (click)="addPaymentDetails()">
<span fxFlex="75%" class="expandcollapsebutton" (click)="addPaymentDetails()">
<button mat-raised-button color="primary" *ngIf="showPaymentDetails">
<i class="fa fa-minus"></i>
</button>
@@ -1,4 +1,4 @@
.expandCollapsebutton {
.expandcollapsebutton {
margin-top: -7px;
}
@@ -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 });
});
@@ -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 });
});
@@ -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:
@@ -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 });
});
@@ -38,7 +38,7 @@
<div fxFlexFill>
<span fxFlex="25%">Show Payment Details</span>
<span fxFlex="75%" class="expandCollapsebutton" (click)="addPaymentDetails()">
<span fxFlex="75%" class="expandcollapsebutton" (click)="addPaymentDetails()">
<button mat-raised-button color="primary" *ngIf="showPaymentDetails">
<i class="fa fa-minus"></i>
</button>
@@ -1,4 +1,4 @@
.expandCollapsebutton {
.expandcollapsebutton {
margin-top: -7px;
}
@@ -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 });
});
@@ -51,7 +51,7 @@
<div fxFlexFill>
<span fxFlex="25%">Show Payment Details</span>
<span fxFlex="75%" class="expandCollapsebutton" (click)="addPaymentDetails()">
<span fxFlex="75%" class="expandcollapsebutton" (click)="addPaymentDetails()">
<button mat-raised-button color="primary" *ngIf="showPaymentDetails">
<i class="fa fa-minus"></i>
</button>
@@ -1,4 +1,4 @@
.expandCollapsebutton {
.expandcollapsebutton {
margin-top: -7px;
}
@@ -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 });
});
@@ -38,7 +38,7 @@
<div fxFlexFill>
<span fxFlex="25%">Show Payment Details</span>
<span fxFlex="75%" class="expandCollapsebutton" (click)="addPaymentDetails()">
<span fxFlex="75%" class="expandcollapsebutton" (click)="addPaymentDetails()">
<button mat-raised-button color="primary" *ngIf="showPaymentDetails">
<i class="fa fa-minus"></i>
</button>
@@ -1,4 +1,4 @@
.expandCollapsebutton {
.expandcollapsebutton {
margin-top: -7px;
}
@@ -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 });
});
@@ -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 });
});
}
@@ -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});
});
}
@@ -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 });
});
@@ -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});
});
}
@@ -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 });
});
@@ -32,4 +32,4 @@
</form>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width=100% height="750px;"></iframe>
<iframe *ngIf="!hideOutput" [src]="pentahoUrl" frameborder="0" width="100%" height="750px;"></iframe>
@@ -2,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')