From 3b7406057a2b2c8a795d743e157a9487eb76e7bd Mon Sep 17 00:00:00 2001 From: Karan Takalkar Date: Tue, 7 Jul 2020 00:56:52 +0530 Subject: [PATCH] feat: create fixed deposit account page (#1001) Fixes: #226 --- .../clients-view/clients-view.component.html | 1 + ...fixed-deposit-account-template.resolver.ts | 32 ++ ...reate-fixed-deposit-account.component.html | 106 ++++++ ...reate-fixed-deposit-account.component.scss | 0 ...te-fixed-deposit-account.component.spec.ts | 25 ++ .../create-fixed-deposit-account.component.ts | 145 ++++++++ ...eposit-account-charges-step.component.html | 110 ++++++ ...eposit-account-charges-step.component.scss | 11 + ...sit-account-charges-step.component.spec.ts | 25 ++ ...-deposit-account-charges-step.component.ts | 181 +++++++++ ...posit-account-currency-step.component.html | 33 ++ ...posit-account-currency-step.component.scss | 0 ...it-account-currency-step.component.spec.ts | 25 ++ ...deposit-account-currency-step.component.ts | 47 +++ ...eposit-account-details-step.component.html | 50 +++ ...eposit-account-details-step.component.scss | 3 + ...sit-account-details-step.component.spec.ts | 25 ++ ...-deposit-account-details-step.component.ts | 90 +++++ ...nt-interest-rate-chart-step.component.html | 149 ++++++++ ...nt-interest-rate-chart-step.component.scss | 23 ++ ...interest-rate-chart-step.component.spec.ts | 25 ++ ...ount-interest-rate-chart-step.component.ts | 50 +++ ...eposit-account-preview-step.component.html | 344 ++++++++++++++++++ ...eposit-account-preview-step.component.scss | 48 +++ ...sit-account-preview-step.component.spec.ts | 25 ++ ...-deposit-account-preview-step.component.ts | 53 +++ ...posit-account-settings-step.component.html | 147 ++++++++ ...posit-account-settings-step.component.scss | 28 ++ ...it-account-settings-step.component.spec.ts | 25 ++ ...deposit-account-settings-step.component.ts | 131 +++++++ ...-deposit-account-terms-step.component.html | 102 ++++++ ...-deposit-account-terms-step.component.scss | 24 ++ ...posit-account-terms-step.component.spec.ts | 25 ++ ...ed-deposit-account-terms-step.component.ts | 91 +++++ .../fixed-deposits-routing.module.ts | 19 +- .../fixed-deposits/fixed-deposits.module.ts | 18 +- .../fixed-deposits/fixed-deposits.service.ts | 18 + 37 files changed, 2249 insertions(+), 5 deletions(-) create mode 100644 src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-template.resolver.ts create mode 100644 src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.html create mode 100644 src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.scss create mode 100644 src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.html create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.scss create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.spec.ts create mode 100644 src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.ts diff --git a/src/app/clients/clients-view/clients-view.component.html b/src/app/clients/clients-view/clients-view.component.html index 68344e54e..f7bf3582d 100644 --- a/src/app/clients/clients-view/clients-view.component.html +++ b/src/app/clients/clients-view/clients-view.component.html @@ -39,6 +39,7 @@ + diff --git a/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-template.resolver.ts b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-template.resolver.ts new file mode 100644 index 000000000..3bde4df0a --- /dev/null +++ b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-template.resolver.ts @@ -0,0 +1,32 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { FixedDepositsService } from '../fixed-deposits.service'; + +/** + * Fixed Deposits Account Template resolver. + */ +@Injectable() +export class FixedDepositsAccountTemplateResolver implements Resolve { + + /** + * @param {FixedDepositsService} fixedDepositsService Fixed Deposits service. + */ + constructor(private fixedDepositsService: FixedDepositsService) { } + + /** + * Returns the Fixed Deposits Account Template. + * @param {ActivatedRouteSnapshot} route Route Snapshot + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const clientId = route.parent.parent.paramMap.get('clientId'); + return this.fixedDepositsService.getFixedDepositsAccountTemplate(clientId); + } + +} diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.html b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.html new file mode 100644 index 000000000..d8373a31a --- /dev/null +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.html @@ -0,0 +1,106 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + DETAILS + + + + + + + + + CURRENCY + + + + + + + + + TERMS + + + + + + + + + SETTINGS + + + + + + + + + INTEREST RATE CHART + + > + + + + + + + CHARGES + + + + + + + + + PREVIEW + + + + + + + + +
diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.scss b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.spec.ts b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.spec.ts new file mode 100644 index 000000000..9be45a29e --- /dev/null +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateFixedDepositAccountComponent } from './create-fixed-deposit-account.component'; + +describe('CreateFixedDepositAccountComponent', () => { + let component: CreateFixedDepositAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CreateFixedDepositAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateFixedDepositAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 000000000..99613482d --- /dev/null +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts @@ -0,0 +1,145 @@ +/** Angular Imports */ +import { Component, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DatePipe } from '@angular/common'; + +/** Custom Services */ +import { FixedDepositsService } from '../fixed-deposits.service'; + +/** Custom Components */ +import { FixedDepositAccountDetailsStepComponent } from '../fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component'; +import { FixedDepositAccountCurrencyStepComponent } from '../fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component'; +import { FixedDepositAccountTermsStepComponent } from '../fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component'; +import { FixedDepositAccountSettingsStepComponent } from '../fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component'; +import { FixedDepositAccountChargesStepComponent } from '../fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component'; + +/** + * Create Fixed Deposit Account Component + */ +@Component({ + selector: 'mifosx-create-fixed-deposit-account', + templateUrl: './create-fixed-deposit-account.component.html', + styleUrls: ['./create-fixed-deposit-account.component.scss'] +}) +export class CreateFixedDepositAccountComponent { + + /** Fixed Deposits Account Details Step */ + @ViewChild(FixedDepositAccountDetailsStepComponent) fixedDepositsAccountDetailsStep: FixedDepositAccountDetailsStepComponent; + /** Fixed Deposits Account Currency Step */ + @ViewChild(FixedDepositAccountCurrencyStepComponent) fixedDepositAccountCurrencyStep: FixedDepositAccountCurrencyStepComponent; + /** Fixed Deposits Account Terms Step */ + @ViewChild(FixedDepositAccountTermsStepComponent) fixedDepositAccountTermsStep: FixedDepositAccountTermsStepComponent; + /** Fixed Deposits Account Settings Step */ + @ViewChild(FixedDepositAccountSettingsStepComponent) fixedDepositAccountSettingsStep: FixedDepositAccountSettingsStepComponent; + /** Fixed Deposits Account Charges Step */ + @ViewChild(FixedDepositAccountChargesStepComponent) fixedDepositAccountChargesStep: FixedDepositAccountChargesStepComponent; + + /** Fixed Deposits Account Template */ + fixedDepositsAccountTemplate: any; + /** Fixed Deposit Account Product Template */ + fixedDepositsAccountProductTemplate: any; + + /** + * Fetches FD account template from `resolve` + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + * @param {DatePipe} datePipe Date Pipe + * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service + */ + constructor(private route: ActivatedRoute, + private router: Router, + private datePipe: DatePipe, + private fixedDepositsService: FixedDepositsService) { + this.route.data.subscribe((data: { fixedDepositsAccountTemplate: any }) => { + this.fixedDepositsAccountTemplate = data.fixedDepositsAccountTemplate; + }); + } + + /** + * Sets fixed deposits account product template. + * @param {any} $event API response + */ + setTemplate($event: any) { + this.fixedDepositsAccountProductTemplate = $event; + } + + /** + * Retrieves Fixed Deposit Account Details Form Data + */ + get fixedDepositAccountDetailsForm() { + return this.fixedDepositsAccountDetailsStep.fixedDepositAccountDetailsForm; + } + + /** + * Retrieves Fixed Deposit Account Currency Form Data + */ + get fixedDepositAccountCurrencyForm() { + return this.fixedDepositAccountCurrencyStep.fixedDepositAccountCurrencyForm; + } + + /** + * Retrieves Fixed Deposit Account Terms Form Data + */ + get fixedDepositAccountTermsForm() { + return this.fixedDepositAccountTermsStep.fixedDepositAccountTermsForm; + } + + /** + * Retrieves Fixed Deposit Account Settings Form Data + */ + get fixedDepositAccountSettingsForm() { + return this.fixedDepositAccountSettingsStep.fixedDepositAccountSettingsForm; + } + + /** + * Checks stepper validity. + */ + get fixedDepositAccountFormValid() { + return ( + this.fixedDepositAccountDetailsForm.valid && + this.fixedDepositAccountTermsForm.valid && + this.fixedDepositAccountSettingsForm.valid + ); + } + + /** + * Creates the fixed deposit account object. + */ + get fixedDepositAccount() { + return { + ...this.fixedDepositsAccountDetailsStep.fixedDepositAccountDetails, + ...this.fixedDepositAccountTermsStep.fixedDepositAccountTerms, + ...this.fixedDepositAccountSettingsStep.fixedDepositAccountSettings, + ...this.fixedDepositAccountChargesStep.fixedDepositAccountCharges, + }; + } + + /** + * Submits the fixed deposit form and creates a new fixed deposit account + */ + submit() { + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const monthDayFormat = 'dd MMMM'; + const fixedDepositAccount = { + ...this.fixedDepositAccount, + clientId: this.fixedDepositsAccountTemplate.clientId, + charges: this.fixedDepositAccount.charges.map((charge: any) => ({ + chargeId: charge.id, + amount: charge.amount, + dueDate: charge.dueDate, + feeOnMonthDay: charge.feeOnMonthDay && this.datePipe.transform([2000].concat(charge.feeOnMonthDay), monthDayFormat), + feeInterval: charge.feeInterval + })), + submittedOnDate: this.datePipe.transform(this.fixedDepositAccount.submittedOnDate, dateFormat), + charts: [{chartSlabs: this.fixedDepositsAccountProductTemplate.accountChart.chartSlabs}], + dateFormat, + monthDayFormat, + locale + }; + this.fixedDepositsService.createFixedDepositAccount(fixedDepositAccount).subscribe((response: any) => { + this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.html new file mode 100644 index 000000000..13720890f --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.html @@ -0,0 +1,110 @@ +
+ + + Charge + + + {{ charge.name }} + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name + {{ charge.name + ', ' + charge.currency.displaySymbol }} + Type + {{ charge.chargeCalculationType.value }} + Amount + {{ charge.amount }} + + Collected On + {{ charge.chargeTimeType.value }} + Date + + {{(charge.dueDate | date) || 'Unassigned'}} + + + {{charge.feeOnMonthDay ? ([2000].concat(charge.feeOnMonthDay) | date: 'dd MMMM') : 'Unassigned'}} + + + N/A + + + Repayments Every + {{ charge.feeInterval || 'Not Provided' }} + + Actions + +
+ +
+ +
+ + +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.scss new file mode 100644 index 000000000..dd420676a --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.scss @@ -0,0 +1,11 @@ +table { + width: 100%; +} + +.mat-elevation-z1 { + margin: 1em 0 1.5em 0; +} + +.margin-t { + margin-top: 1em; +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.spec.ts new file mode 100644 index 000000000..c62e3f599 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountChargesStepComponent } from './fixed-deposit-account-charges-step.component'; + +describe('FixedDepositAccountChargesStepComponent', () => { + let component: FixedDepositAccountChargesStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountChargesStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountChargesStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 000000000..9ecd29e89 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts @@ -0,0 +1,181 @@ +/** Angular Imports */ +import { Component, OnInit, Input } from '@angular/core'; +import { FormControl } from '@angular/forms'; +import { MatDialog } from '@angular/material'; + +/** Dialog Components */ +import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; + +/** Custom Services */ +import { DatePipe } from '@angular/common'; +import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base'; +import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base'; +import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; + +/** + * Fixed Deposit Account Charges Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-charges-step', + templateUrl: './fixed-deposit-account-charges-step.component.html', + styleUrls: ['./fixed-deposit-account-charges-step.component.scss'] +}) +export class FixedDepositAccountChargesStepComponent implements OnInit { + + /** Fixed deposits account template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed deposits account and product template */ + @Input() fixedDepositsAccountProductTemplate: any; + /** Validity of fixed depsits account form */ + @Input() fixedDepositAccountFormValid: boolean; + /** Currency Code */ + @Input() currencyCode: FormControl; + + /** Charges Data */ + chargeData: any; + /** Charges Data Source */ + chargesDataSource: {}[]; + /** Charges table columns */ + displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery', 'action']; + /** Component is pristine if there has been no changes by user interaction */ + pristine = true; + + /** + * @param {MatDialog} dialog Mat Dialog + * @param {DatePipe} datePipe Date Pipe + */ + constructor(public dialog: MatDialog, + private datePipe: DatePipe) { } + + ngOnInit() { + this.chargeData = this.fixedDepositsAccountTemplate.chargeOptions; + this.chargesDataSource = []; + this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []); + } + + /** + * Add a charge + */ + addCharge(charge: any) { + this.chargesDataSource = this.chargesDataSource.concat([charge.value]); + charge.value = ''; + } + + /** + * Edits the Charge Amount + * @param {any} charge Charge + */ + editChargeAmount(charge: any) { + const formfields: FormfieldBase[] = [ + new InputBase({ + controlName: 'amount', + label: 'Amount', + value: charge.amount, + type: 'number', + required: false + }), + ]; + const data = { + title: 'Edit Charge Amount', + layout: { addButtonText: 'Confirm' }, + formfields: formfields + }; + const editChargeAmountDialogRef = this.dialog.open(FormDialogComponent, { data }); + editChargeAmountDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + const newCharge = { ...charge, amount: response.data.value.amount }; + this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1, newCharge); + this.chargesDataSource = this.chargesDataSource.concat([]); + } + }); + this.pristine = false; + } + + /** + * Edits the Charge Date + * @param {any} charge Charge + */ + editChargeDate(charge: any) { + const formfields: FormfieldBase[] = [ + new DatepickerBase({ + controlName: 'date', + label: 'Date', + value: charge.dueDate || charge.feeOnMonthDay || '', + type: 'datetime-local', + required: false + }), + ]; + const data = { + title: 'Edit Charge Date', + layout: { addButtonText: 'Confirm' }, + formfields: formfields + }; + const editChargeDateDialogRef = this.dialog.open(FormDialogComponent, { data }); + editChargeDateDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + let newCharge: any; + const dateFormat = 'dd MMMM yyyy'; + const date = this.datePipe.transform(response.data.value.date, dateFormat); + switch (charge.chargeTimeType.value) { + case 'Specified due date': + case 'Weekly Fee': + newCharge = { ...charge, dueDate: date }; + break; + case 'Annual Fee': + newCharge = { ...charge, feeOnMonthDay: date }; + break; + } + this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1, newCharge); + this.chargesDataSource = this.chargesDataSource.concat([]); + } + }); + this.pristine = false; + } + + /** + * Edits the Charge Fee Interval + * @param {any} charge Charge + */ + editChargeFeeInterval(charge: any) { + const formfields: FormfieldBase[] = [ + new InputBase({ + controlName: 'feeInterval', + label: 'Fee Interval', + value: charge.feeInterval, + type: 'text', + required: false + }), + ]; + const data = { + title: 'Edit Charge Fee Interval', + layout: { addButtonText: 'Confirm' }, + formfields: formfields + }; + const editChargeFeeIntervalDialogRef = this.dialog.open(FormDialogComponent, { data }); + editChargeFeeIntervalDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + const newCharge = { ...charge, feeInterval: response.data.value.feeInterval }; + this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1, newCharge); + this.chargesDataSource = this.chargesDataSource.concat([]); + } + }); + this.pristine = false; + } + + /** + * Delete a particular charge + * @param charge Charge + */ + deleteCharge(charge: any) { + this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1); + this.chargesDataSource = this.chargesDataSource.concat([]); + } + + /** + * Returns Fixed Deposits Account Charges Form + */ + get fixedDepositAccountCharges() { + return { charges: this.chargesDataSource }; + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html new file mode 100644 index 000000000..9a6cb041d --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html @@ -0,0 +1,33 @@ +
+ +
+ + + Currency + + + + + Decimal Places + + + + + Currency Multiple + + + +
+ +
+ + +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.spec.ts new file mode 100644 index 000000000..76f1990b5 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountCurrencyStepComponent } from './fixed-deposit-account-currency-step.component'; + +describe('FixedDepositAccountCurrencyStepComponent', () => { + let component: FixedDepositAccountCurrencyStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountCurrencyStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountCurrencyStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts new file mode 100644 index 000000000..b65df2439 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts @@ -0,0 +1,47 @@ +/** Angular Imports */ +import { Component, OnChanges, Input } from '@angular/core'; +import { FormGroup, FormBuilder } from '@angular/forms'; + +/** + * Fixed Deposit Account Currency Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-currency-step', + templateUrl: './fixed-deposit-account-currency-step.component.html', + styleUrls: ['./fixed-deposit-account-currency-step.component.scss'] +}) +export class FixedDepositAccountCurrencyStepComponent implements OnChanges { + + /** Fixed deposits account template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed deposits account and product template */ + @Input() fixedDepositsAccountProductTemplate: any; + + /** Fixed Deposit Account Currency Form */ + fixedDepositAccountCurrencyForm: FormGroup; + /** Currency Data */ + currencyData: any; + + constructor(private formBuilder: FormBuilder) { + this.createFixedDepositAccountCurrencyForm(); + } + + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.fixedDepositAccountCurrencyForm.patchValue({ + 'currencyCode': this.fixedDepositsAccountProductTemplate.currency.code, + 'decimalPlaces': this.fixedDepositsAccountProductTemplate.currency.decimalPlaces, + 'currencyMultiple': this.fixedDepositsAccountProductTemplate.currency.inMultiplesOf + }); + } + } + + createFixedDepositAccountCurrencyForm() { + this.fixedDepositAccountCurrencyForm = this.formBuilder.group({ + 'currencyCode': [{ value: '', disabled: true}], + 'decimalPlaces': [{ value: '', disabled: true }], + 'currencyMultiple': [{ value: '', disabled: true }] + }); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html new file mode 100644 index 000000000..4206c0283 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html @@ -0,0 +1,50 @@ +
+ +
+ + + Product Name + + + {{ product.name }} + + + + Product Name is required + + + + + Submitted On + + + + + Submission Date is required + + + + + Field Officer + + + {{ officer.displayName }} + + + + +
+ +
+ + +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss new file mode 100644 index 000000000..aa8d23226 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss @@ -0,0 +1,3 @@ +.margin-t { + margin-top: 1em; +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.spec.ts new file mode 100644 index 000000000..169dda7ba --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountDetailsStepComponent } from './fixed-deposit-account-details-step.component'; + +describe('FixedDepositAccountDetailsStepComponent', () => { + let component: FixedDepositAccountDetailsStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountDetailsStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountDetailsStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts new file mode 100644 index 000000000..0744e86eb --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts @@ -0,0 +1,90 @@ +/** Angular Imports */ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** Custom Services */ +import { FixedDepositsService } from '../../fixed-deposits.service'; + +/** + * Fixed Deposits Account Details Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-details-step', + templateUrl: './fixed-deposit-account-details-step.component.html', + styleUrls: ['./fixed-deposit-account-details-step.component.scss'] +}) +export class FixedDepositAccountDetailsStepComponent implements OnInit { + + /** Fixed Deposits Account Template */ + @Input() fixedDepositsAccountTemplate: any; + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Product Data */ + productData: any; + /** Field Officer Data */ + fieldOfficerData: any; + /** Fixed Deposits Account Details Form */ + fixedDepositAccountDetailsForm: FormGroup; + + /** Fixed Deposits Account Template with product data */ + @Output() fixedDepositsAccountProductTemplate = new EventEmitter(); + + /** + * Sets fixed deposits account details form. + * @param {FormBuilder} formBuilder Form Builder. + * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service. + */ + constructor(private formBuilder: FormBuilder, + private fixedDepositsService: FixedDepositsService) { + this.createFixedDepositsAccountDetailsForm(); + } + + ngOnInit() { + this.buildDependencies(); + if (this.fixedDepositsAccountTemplate) { + this.productData = this.fixedDepositsAccountTemplate.productOptions; + } + } + + /** + * Creates fixed deposits account details form. + */ + createFixedDepositsAccountDetailsForm() { + this.fixedDepositAccountDetailsForm = this.formBuilder.group({ + 'productId': ['', Validators.required], + 'submittedOnDate': ['', Validators.required], + 'fieldOfficerId': [''] + }); + } + + /** + * Fetches fixed deposits account product template on productId value changes + */ + buildDependencies() { + const clientId = this.fixedDepositsAccountTemplate.clientId; + this.fixedDepositAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => { + this.fixedDepositsService.getFixedDepositsAccountTemplate(clientId, productId).subscribe((response: any) => { + this.fixedDepositsAccountProductTemplate.emit(response); + this.fieldOfficerData = response.fieldOfficerOptions; + this.fixedDepositAccountDetailsForm.get('fieldOfficerId').patchValue(''); + }); + }); + } + + /** + * Returns fixed deposits account details form value. + */ + get fixedDepositAccountDetails() { + const fixedDepositAccountDetails = this.fixedDepositAccountDetailsForm.value; + for (const key in fixedDepositAccountDetails) { + if (fixedDepositAccountDetails[key] === '') { + delete fixedDepositAccountDetails[key]; + } + } + return fixedDepositAccountDetails; + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.html new file mode 100644 index 000000000..fdaae8db4 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.html @@ -0,0 +1,149 @@ +
+ +
+ Name: + {{ fixedDepositsAccountProductTemplate.accountChart.name }} +
+ +
+ Valid from Date: + {{ fixedDepositsAccountProductTemplate?.accountChart.fromDate | date }} +
+ +
+ End Date: + {{ fixedDepositsAccountProductTemplate?.accountChart.endDate | date }} +
+ +
+ Description: + {{ fixedDepositsAccountProductTemplate?.accountChart.description }} +
+ +
+ Primary Grouping by Amount: + {{ fixedDepositsAccountProductTemplate?.accountChart.isPrimaryGroupingByAmount ? 'Yes' : 'No' }} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Period + {{chartSlab.fromPeriod}}-{{chartSlab.toPeriod}} {{chartSlab.periodType.value}} Amount Range {{chartSlab.amountRangeFrom}}-{{chartSlab.amountRangeTo}} Interest {{ chartSlab.annualInterestRate }} Description {{ chartSlab.description }} Actions + + + +
+ + + +

+ Incentives +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Entity Type + {{ incentive.entityType.value }} + Attribute Name + {{ incentive.attributeName.value }} + Condition Type + {{ incentive.conditionType.value | titlecase }} + Attribute Value + {{ incentive.attributeValueDesc }} + Incentive Type + {{ incentive.incentiveType.value }} + Interest + {{ incentive.amount }} +
+ +
+
+
+ +
+ +
+ + +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.scss new file mode 100644 index 000000000..bc815c2d2 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.scss @@ -0,0 +1,23 @@ +.margin-t { + margin-top: 2em; +} + +table { + width: 100%; + + tr.incentives-row { + height: 0; + + > td { + padding: 0; + } + + .incentives { + overflow: hidden; + } + + .mat-card { + border-radius: 0; + } + } +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.spec.ts new file mode 100644 index 000000000..66e46ce3f --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountInterestRateChartStepComponent } from './fixed-deposit-account-interest-rate-chart-step.component'; + +describe('FixedDepositAccountInterestRateChartStepComponent', () => { + let component: FixedDepositAccountInterestRateChartStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountInterestRateChartStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountInterestRateChartStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts new file mode 100644 index 000000000..7b78dc899 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component.ts @@ -0,0 +1,50 @@ +/** Angular Imports */ +import { Component, Input, OnChanges, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatTable } from '@angular/material'; +import { animate, state, style, transition, trigger } from '@angular/animations'; + +/** + * Fixed Deposits Account Interest Rate Chart Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-interest-rate-chart-step', + templateUrl: './fixed-deposit-account-interest-rate-chart-step.component.html', + styleUrls: ['./fixed-deposit-account-interest-rate-chart-step.component.scss'], + animations: [ + trigger('expandChartSlab', [ + state('collapsed', style({ height: '0px', minHeight: '0' })), + state('expanded', style({ height: '*' })), + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) + ]) + ] +}) +export class FixedDepositAccountInterestRateChartStepComponent implements OnChanges { + + /** Fixed deposits account template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed deposits account and product template */ + @Input() fixedDepositsAccountProductTemplate: any; + + /** Interest Rate Chart Data */ + interestRateChartData: any = []; + /** Columns to be displayed in interest rate chart table. */ + chartSlabsDisplayedColumns: any[] = ['period', 'amountRange', 'interest', 'description', 'actions']; + /** Columns to be displayed in incentives sub-table. */ + incentivesDisplayedColumns: string[] = ['entityType', 'attributeName', 'conditionType', 'attributeValue', 'incentiveType', 'amount']; + /** Additional Column to disblac incentives table */ + chartSlabsIncentivesDisplayedColumns: string[] = ['incentives']; + /** Expand Chart Slab Index used in the view */ + expandChartSlabIndex: number; + + @ViewChild('chartsTable') chartsTableRef: MatTable; + + constructor() { } + + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.interestRateChartData = this.fixedDepositsAccountProductTemplate.accountChart.chartSlabs; + this.chartsTableRef.renderRows(); + } + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.html new file mode 100644 index 000000000..061e6b2e1 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.html @@ -0,0 +1,344 @@ +
+ +

Details

+ + + +
+ Product + {{ fixedDepositAccountData.productId | find:fixedDepositsAccountTemplate.productOptions:'id':'name' }} +
+ +
+ Submitted On + {{ fixedDepositAccountData.submittedOnDate | date }} +
+ +
+ Field Officer + {{ (fixedDepositAccountData.fieldOfficerId | find:fixedDepositsAccountProductTemplate.fieldOfficerOptions:'id':'displayName') || 'Unassigned' }} +
+ +

Terms

+ + + +
+ Fixed Deposit Amount: + {{ fixedDepositAccountData.depositAmount }} +
+ +
+ Deposit Period: + {{ fixedDepositAccountData.depositPeriod + ' ' + (fixedDepositAccountData.depositPeriodFrequencyId | find:fixedDepositsAccountProductTemplate.periodFrequencyTypeOptions:'id':'value') }} +
+ +
+ Currency + {{ fixedDepositsAccountProductTemplate.currency.code }} +
+ +
+ Currency Multiple + {{ fixedDepositsAccountProductTemplate.currency.inMultiplesOf }} +
+ +
+ Decimal Places + {{ fixedDepositsAccountProductTemplate.currency.decimalPlaces }} +
+ +
+ Interest Compounding Period: + {{ fixedDepositAccountData.interestCompoundingPeriodType | find:fixedDepositsAccountProductTemplate.interestCompoundingPeriodTypeOptions:'id':'value' }} +
+ +
+ Interest Posting Period: + {{ fixedDepositAccountData.interestPostingPeriodType | find:fixedDepositsAccountProductTemplate.interestPostingPeriodTypeOptions:'id':'value' }} +
+ +
+ Interest Calculated using: + {{ fixedDepositAccountData.interestCalculationType | find:fixedDepositsAccountProductTemplate.interestCalculationTypeOptions:'id':'value' }} +
+ +
+ Days in Year: + {{ fixedDepositAccountData.interestCalculationDaysInYearType | find:fixedDepositsAccountProductTemplate.interestCalculationDaysInYearTypeOptions:'id':'value' }} +
+ +

Settings

+ + + +
+ Lock-in Period: + {{ fixedDepositAccountData.lockinPeriodFrequency + ' ' + (fixedDepositAccountData.lockinPeriodFrequencyType | find:fixedDepositsAccountProductTemplate.lockinPeriodFrequencyTypeOptions:'id':'value') }} +
+ +
+ Minimum Deposit Term: + {{ fixedDepositsAccountProductTemplate.minDepositTerm + ' ' + (fixedDepositsAccountProductTemplate.minDepositTermType?.value || '') }} +
+ +
+ In Multiples Of: + {{ fixedDepositsAccountProductTemplate.inMultiplesOfDepositTerm + ' ' + (fixedDepositsAccountProductTemplate.inMultiplesOfDepositTermType?.value || '') }} +
+ +
+ Maximum Deposit Term + {{ fixedDepositsAccountProductTemplate.maxDepositTerm + ' ' + (fixedDepositsAccountProductTemplate.maxDepositTermType?.value || '') }} +
+ +
+ Transfer Interest to Savings Account? + {{ fixedDepositAccountData.transferInterestToSavings ? 'Yes' : 'No' }} +
+ +
+ Linked Savings Account + {{ fixedDepositAccountData.linkAccountId | find:fixedDepositsAccountProductTemplate.savingsAccounts:'id':'accountNo' }} +
+ +
+ Apply Penal Interest (less): + {{ fixedDepositsAccountProductTemplate.preClosurePenalApplicable ? 'Yes' : 'No' }} +
+ +
+ Penal Interest (%): + {{ fixedDepositsAccountProductTemplate.preClosurePenalInterest + '% (' + (fixedDepositsAccountProductTemplate.preClosurePenalInterestOnType?.id) + ')' }} +
+ +
+ Withhold Tax is Applicable: + {{ fixedDepositAccountData.withHoldTax ? 'Yes' : 'No' }} +
+ +

Interest Rate Chart

+ + + +
+ +
+ Name: + {{ fixedDepositsAccountProductTemplate?.accountChart.name }} +
+ +
+ Valid from Date: + {{ fixedDepositsAccountProductTemplate?.accountChart.fromDate | date }} +
+ +
+ End Date: + {{ fixedDepositsAccountProductTemplate?.accountChart.endDate | date }} +
+ +
+ Description: + {{ fixedDepositsAccountProductTemplate?.accountChart.description }} +
+ +
+ Primary Grouping by Amount: + {{ fixedDepositsAccountProductTemplate?.accountChart.isPrimaryGroupingByAmount ? 'Yes' : 'No' }} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Period + {{chartSlab.fromPeriod}}-{{chartSlab.toPeriod}} {{chartSlab.periodType.value}} Amount Range {{chartSlab.amountRangeFrom}}-{{chartSlab.amountRangeTo}} Interest {{ chartSlab.annualInterestRate }} Description {{ chartSlab.description }} Actions + + + +
+ + + +

+ Incentives +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Entity Type + {{ incentive.entityType.value }} + Attribute Name + {{ incentive.attributeName.value }} + Condition Type + {{ incentive.conditionType.value | titlecase }} + Attribute Value + {{ incentive.attributeValueDesc }} + Incentive Type + {{ incentive.incentiveType.value }} + Interest + {{ incentive.amount }} +
+ +
+
+
+ +
+ +
+ +

Charges

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name + {{ charge.name + ', ' + charge.currency.displaySymbol }} + Type + {{ charge.chargeCalculationType.value }} + Amount + {{ charge.amount }} + Date + + {{(charge.dueDate | date) || 'Unassigned'}} + + + {{charge.feeOnMonthDay ? ([2000].concat(charge.feeOnMonthDay) | date: 'dd MMMM') : 'Unassigned'}} + + + N/A + + Repayments Every + {{ charge.feeInterval || 'Not Provided' }} + Collected On + {{ charge.chargeTimeType.value }} +
+ +
+ +
+ +
+ + + +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.scss new file mode 100644 index 000000000..eabc0e02c --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.scss @@ -0,0 +1,48 @@ +table { + width: 100%; +} + +.mat-elevation-z1 { + margin: 1em 0 1.5em 0; +} + +h2, h3, h4 { + margin: 0; + font-weight: 500; +} + +span { + margin: 0.5em 0; +} + +mat-divider { + margin: 0 0 0.5em 0; +} + +.margin-t { + margin-top: 1em; +} + +.margin-b { + margin-bottom: 0.25em; +} + +.irc-table { + width: 100%; + + tr.incentives-row { + height: 0; + + > td { + padding: 0; + } + + .incentives { + overflow: hidden; + } + + .mat-card { + border-radius: 0; + } + } +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.spec.ts new file mode 100644 index 000000000..183debb51 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountPreviewStepComponent } from './fixed-deposit-account-preview-step.component'; + +describe('FixedDepositAccountPreviewStepComponent', () => { + let component: FixedDepositAccountPreviewStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountPreviewStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountPreviewStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.ts new file mode 100644 index 000000000..94c0a2cc1 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component.ts @@ -0,0 +1,53 @@ +/** Angular Imports */ +import { Component, OnInit, Input, Output, EventEmitter, OnChanges } from '@angular/core'; +import { animate, state, style, transition, trigger } from '@angular/animations'; + +/** + * Fixed Deposit Preview Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-preview-step', + templateUrl: './fixed-deposit-account-preview-step.component.html', + styleUrls: ['./fixed-deposit-account-preview-step.component.scss'], + animations: [ + trigger('expandChartSlab', [ + state('collapsed', style({ height: '0px', minHeight: '0' })), + state('expanded', style({ height: '*' })), + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) + ]) + ] +}) +export class FixedDepositAccountPreviewStepComponent implements OnChanges { + + /** Fixed Deposits Account Template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed Deposits Account Product Template */ + @Input() fixedDepositsAccountProductTemplate: any; + /** Fixed Deposits Account Data */ + @Input() fixedDepositAccountData: any; + + /** Charges Displayed Columns */ + chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery']; + /** Interest Rate Chart Data */ + interestRateChartData: any = []; + /** Columns to be displayed in interest rate chart table. */ + chartSlabsDisplayedColumns: any[] = ['period', 'amountRange', 'interest', 'description', 'actions']; + /** Columns to be displayed in incentives sub-table. */ + incentivesDisplayedColumns: string[] = ['entityType', 'attributeName', 'conditionType', 'attributeValue', 'incentiveType', 'amount']; + /** Additional Column to disblac incentives table */ + chartSlabsIncentivesDisplayedColumns: string[] = ['incentives']; + /** Expand Chart Slab Index used in the view */ + expandChartSlabIndex: number; + + /** Form submission event */ + @Output() submit = new EventEmitter(); + + constructor() { } + + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.interestRateChartData = this.fixedDepositsAccountProductTemplate.accountChart.chartSlabs; + } + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.html new file mode 100644 index 000000000..ae4ce675d --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.html @@ -0,0 +1,147 @@ +
+ +
+ +

Lock-in Period

+ + + Frequency + + + + + Type + + + {{ lockinPeriodFrequencyType.value }} + + + + +

Minimum Deposit Term

+ + + Frequency + + + Minimum Deposit Term Frequency is required + + + + + Frequency Type + + + {{ periodFrequencyType.value }} + + + + Minimum Deposit Term Frequency Type is required + + + +

And thereafter, in Multiples of

+ + + Frequency + + + + + Type + + + {{ periodFrequencyType.value }} + + + + +

Maximum Deposit Term

+ + + Frequency + + + + + Type + + + {{ periodFrequencyType.value }} + + + + + + +

Interest Transfer

+ + + Transfer Interest to Linked Savings Account? + + + + Link Savings Account + + + {{ account.accountNo }} + + + + Linked Savings Account is required + + + + + +

For Pre-mature closure

+ + + Apply Penal Interest (less) + + + + Penal Interest (%) + + + + + Period + + + {{ preClosurePenalInterestOnType.value }} + + + + + + + + + + Is Withhold Tax Applicable? + + + + Tax Group + + + + + +
+ +
+ + +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.scss new file mode 100644 index 000000000..3a19d4b57 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.scss @@ -0,0 +1,28 @@ +h4 { + font-weight: 500; + margin: 1em 0; +} + +h3 { + font-weight: 500; +} + +mat-divider { + margin: 1em 0 2em 0; +} + +.margin-v { + margin: 1em 0; +} + +.margin-b { + margin: 0 0 1em 0; +} + +.margin-t { + margin-top: 1em; +} + +.margin-p { + margin-top: 1.7em; +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.spec.ts new file mode 100644 index 000000000..2d928b0bf --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountSettingsStepComponent } from './fixed-deposit-account-settings-step.component'; + +describe('FixedDepositAccountSettingsStepComponent', () => { + let component: FixedDepositAccountSettingsStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountSettingsStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountSettingsStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.ts new file mode 100644 index 000000000..a373ea1e3 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.ts @@ -0,0 +1,131 @@ +/** Angular Imports */ +import { Component, OnInit, Input, OnChanges } from '@angular/core'; +import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; + +/** + * Fixed Deposits Account Settings Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-settings-step', + templateUrl: './fixed-deposit-account-settings-step.component.html', + styleUrls: ['./fixed-deposit-account-settings-step.component.scss'] +}) +export class FixedDepositAccountSettingsStepComponent implements OnInit, OnChanges { + + /** Fixed deposits account template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed deposits account and product template */ + @Input() fixedDepositsAccountProductTemplate: any; + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Fixed Deposits Account Settings Form */ + fixedDepositAccountSettingsForm: FormGroup; + /** Lockin Period Frequency Type Data */ + lockinPeriodFrequencyTypeData: any; + /** Period Frequency Type Data */ + periodFrequencyTypeData: any; + /** Pre Closure Penal Data */ + preClosurePenalInterestOnTypeData: any; + /** Savings Accounts Data */ + savingsAccountsData: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + */ + constructor(private formBuilder: FormBuilder) { + this.createFixedDepositAccountSettingsForm(); + this.buildDependencies(); + } + + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.fixedDepositAccountSettingsForm.patchValue({ + 'minDepositTerm': this.fixedDepositsAccountProductTemplate.minDepositTerm, + 'minDepositTermTypeId': this.fixedDepositsAccountProductTemplate.minDepositTermType ? this.fixedDepositsAccountProductTemplate.minDepositTermType.id : '', + 'inMultiplesOfDepositTerm': this.fixedDepositsAccountProductTemplate.inMultiplesOfDepositTerm, + 'inMultiplesOfDepositTermTypeId': this.fixedDepositsAccountProductTemplate.inMultiplesOfDepositTermType ? this.fixedDepositsAccountProductTemplate.inMultiplesOfDepositTermType.id : '', + 'maxDepositTerm': this.fixedDepositsAccountProductTemplate.maxDepositTerm, + 'maxDepositTermTypeId': this.fixedDepositsAccountProductTemplate.maxDepositTermType ? this.fixedDepositsAccountProductTemplate.maxDepositTermType.id : '', + 'preClosurePenalApplicable': this.fixedDepositsAccountProductTemplate.preClosurePenalApplicable, + 'preClosurePenalInterest': this.fixedDepositsAccountProductTemplate.preClosurePenalInterest, + 'preClosurePenalInterestOnTypeId': this.fixedDepositsAccountProductTemplate.preClosurePenalInterestOnType ? this.fixedDepositsAccountProductTemplate.preClosurePenalInterestOnType.id : '' + }); + if (this.fixedDepositsAccountProductTemplate.withHoldTax) { + this.fixedDepositAccountSettingsForm.addControl('withHoldTax', new FormControl(false)); + this.fixedDepositAccountSettingsForm.get('withHoldTax').valueChanges.subscribe((value: boolean) => { + if (value) { + this.fixedDepositAccountSettingsForm.addControl('taxGroupId', new FormControl({ value: '', disabled: true })); + this.fixedDepositAccountSettingsForm.get('taxGroupId').patchValue(this.fixedDepositsAccountProductTemplate.taxGroup && this.fixedDepositsAccountProductTemplate.taxGroup.name); + } else { + this.fixedDepositAccountSettingsForm.removeControl('taxGroupId'); + } + }); + } else { + this.fixedDepositAccountSettingsForm.removeControl('withHoldTax'); + } + this.setOptions(); + } + } + + ngOnInit() { } + + /** + * Creates fixed deposits account terms form. + */ + createFixedDepositAccountSettingsForm() { + this.fixedDepositAccountSettingsForm = this.formBuilder.group({ + 'lockinPeriodFrequency': [''], + 'lockinPeriodFrequencyType': [''], + 'minDepositTerm': [{value: '', disabled: true}], + 'minDepositTermTypeId': [{ value: '', disabled: true }], + 'inMultiplesOfDepositTerm': [{ value: '', disabled: true }], + 'inMultiplesOfDepositTermTypeId': [{ value: '', disabled: true }], + 'maxDepositTerm': [{ value: '', disabled: true }], + 'maxDepositTermTypeId': [{ value: '', disabled: true }], + 'transferInterestToSavings': [false], + 'preClosurePenalApplicable': [{ value: '', disabled: true }], + 'preClosurePenalInterest': [{ value: '', disabled: true }], + 'preClosurePenalInterestOnTypeId': [{ value: '', disabled: true }] + }); + } + + /** + * Subscribes to value changes and sets new form controls accordingly. + */ + buildDependencies() { + this.fixedDepositAccountSettingsForm.get('transferInterestToSavings').valueChanges.subscribe((value: boolean) => { + if (value) { + this.fixedDepositAccountSettingsForm.addControl('linkAccountId', new FormControl('', Validators.required)); + } else { + this.fixedDepositAccountSettingsForm.removeControl('linkAccountId'); + } + }); + } + + /** + * Sets all select dropdown options. + */ + setOptions() { + this.lockinPeriodFrequencyTypeData = this.fixedDepositsAccountProductTemplate.lockinPeriodFrequencyTypeOptions; + this.periodFrequencyTypeData = this.fixedDepositsAccountProductTemplate.periodFrequencyTypeOptions; + this.savingsAccountsData = this.fixedDepositsAccountProductTemplate.savingsAccounts; + this.preClosurePenalInterestOnTypeData = this.fixedDepositsAccountProductTemplate.preClosurePenalInterestOnTypeOptions; + } + + /** + * Returns fixed deposits account settings form value. + */ + get fixedDepositAccountSettings() { + const fixedDepositAccountSettings = this.fixedDepositAccountSettingsForm.getRawValue(); + for (const key in fixedDepositAccountSettings) { + if (fixedDepositAccountSettings[key] === '' || key === 'taxGroupId') { + delete fixedDepositAccountSettings[key]; + } + } + return fixedDepositAccountSettings; + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.html new file mode 100644 index 000000000..f3597645c --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.html @@ -0,0 +1,102 @@ +
+ +
+ + + Deposit Amount + + + Fixed Deposit Amount is required + + + + + + + Deposit Period Frequency + + + Deposit Period Frequency is required + + + + + Deposit Period Type + + + {{ periodFrequencyType.value }} + + + + Deposit Period Type is required + + + + + + + Interest Compounding Period + + + {{ interestCompoundingPeriodType.value }} + + + + Interest Compounding Period is required + + + + + Interest Posting Period + + + {{ interestPostingPeriodType.value }} + + + + Interest Posting Period is required + + + + + Interest Calculated using + + + {{ interestCalculationType.value }} + + + + Interest Calculated using is required + + + + + Days in Year + + + {{ interestCalculationDaysInYearType.value }} + + + + Days in Year is required + + + +
+ +
+ + +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.scss new file mode 100644 index 000000000..17e77f81d --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.scss @@ -0,0 +1,24 @@ +h4 { + font-weight: 500; + margin: 1em 0; +} + +h3 { + font-weight: 500; +} + +mat-divider { + margin: 1em 0 2em 0; +} + +.margin-v { + margin: 1em 0; +} + +.margin-b { + margin: 0 0 1em 0; +} + +.margin-t { + margin-top: 1em; +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.spec.ts new file mode 100644 index 000000000..6f795f584 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FixedDepositAccountTermsStepComponent } from './fixed-deposit-account-terms-step.component'; + +describe('FixedDepositAccountTermsStepComponent', () => { + let component: FixedDepositAccountTermsStepComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ FixedDepositAccountTermsStepComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(FixedDepositAccountTermsStepComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.ts new file mode 100644 index 000000000..4aecb6a22 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component.ts @@ -0,0 +1,91 @@ +/** Angular Imports */ +import { Component, OnInit, Input, OnChanges } from '@angular/core'; +import { FormGroup, FormBuilder, Validators} from '@angular/forms'; + +/** + * Fixed Deposits Terms Step + */ +@Component({ + selector: 'mifosx-fixed-deposit-account-terms-step', + templateUrl: './fixed-deposit-account-terms-step.component.html', + styleUrls: ['./fixed-deposit-account-terms-step.component.scss'] +}) +export class FixedDepositAccountTermsStepComponent implements OnInit, OnChanges { + + /** Fixed deposits account template */ + @Input() fixedDepositsAccountTemplate: any; + /** Fixed deposits account and product template */ + @Input() fixedDepositsAccountProductTemplate: any; + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Fixed Deposits Account Terms Form */ + fixedDepositAccountTermsForm: FormGroup; + /** Interest Compounding Period Type Data */ + interestCompoundingPeriodTypeData: any; + /** Interest Posting Period Type Data */ + interestPostingPeriodTypeData: any; + /** Interest Calculation Type Data */ + interestCalculationTypeData: any; + /** Interest Calculation Days in Year Data */ + interestCalculationDaysInYearTypeData: any; + /** Period Frequency Type Data */ + periodFrequencyTypeData: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + */ + constructor(private formBuilder: FormBuilder) { + this.createFixedDepositsAccountTermsForm(); + } + + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.setOptions(); + } + } + + ngOnInit() { } + + /** + * Creates fixed deposits account terms form. + */ + createFixedDepositsAccountTermsForm() { + this.fixedDepositAccountTermsForm = this.formBuilder.group({ + 'interestCompoundingPeriodType': ['', Validators.required], + 'interestPostingPeriodType': ['', Validators.required], + 'interestCalculationType': ['', Validators.required], + 'interestCalculationDaysInYearType': ['', Validators.required], + 'depositAmount': ['', Validators.required], + 'depositPeriod': ['', Validators.required], + 'depositPeriodFrequencyId': ['', Validators.required] + }); + } + + /** + * Sets all select dropdown options. + */ + setOptions() { + this.interestCompoundingPeriodTypeData = this.fixedDepositsAccountProductTemplate.interestCompoundingPeriodTypeOptions; + this.interestPostingPeriodTypeData = this.fixedDepositsAccountProductTemplate.interestPostingPeriodTypeOptions; + this.interestCalculationTypeData = this.fixedDepositsAccountProductTemplate.interestCalculationTypeOptions; + this.interestCalculationDaysInYearTypeData = this.fixedDepositsAccountProductTemplate.interestCalculationDaysInYearTypeOptions; + this.periodFrequencyTypeData = this.fixedDepositsAccountProductTemplate.periodFrequencyTypeOptions; + } + + /** + * Returns fixed deposits account terms form value. + */ + get fixedDepositAccountTerms() { + const fixedDepositAccountTerms = this.fixedDepositAccountTermsForm.value; + for (const key in fixedDepositAccountTerms) { + if (fixedDepositAccountTerms[key] === '') { + delete fixedDepositAccountTerms[key]; + } + } + return fixedDepositAccountTerms; + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts index 1ac6b4028..d1c5873fb 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts @@ -14,19 +14,29 @@ import { StandingInstructionsTabComponent } from './fixed-deposit-account-view/s import { DatatableTabsComponent } from './fixed-deposit-account-view/datatable-tabs/datatable-tabs.component'; import { FixedDepositsAccountActionsComponent } from './fixed-deposits-account-actions/fixed-deposits-account-actions.component'; import { ViewTransactionComponent } from './fixed-deposit-account-view/view-transaction/view-transaction.component'; +import { CreateFixedDepositAccountComponent } from './create-fixed-deposit-account/create-fixed-deposit-account.component'; /** Custom Resolvers */ -import { FixedDepositsAccountViewResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-view.resolver'; +import { FixedDepositsAccountViewResolver } from './common-resolvers/fixed-deposit-account-view.resolver'; import { SavingsDatatableResolver } from 'app/savings/common-resolvers/savings-datatable.resolver'; import { SavingsDatatablesResolver } from 'app/savings/common-resolvers/savings-datatables.resolver'; -import { FixedDepositsAccountTransactionResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver'; -import { FixedDepositsAccountActionsResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-actions.resolver'; +import { FixedDepositsAccountTransactionResolver } from './common-resolvers/fixed-deposit-account-transaction.resolver'; +import { FixedDepositsAccountActionsResolver } from './common-resolvers/fixed-deposit-account-actions.resolver'; +import { FixedDepositsAccountTemplateResolver } from './common-resolvers/fixed-deposit-account-template.resolver'; const routes: Routes = [ { path: '', data: { title: extract('All Fixed Deposits'), breadcrumb: 'Fixed Deposits', routeParamBreadcrumb: false }, children: [ + { + path: 'create-fixed-deposit-account', + data: { title: extract('Create Fixed Deposit Account'), breadcrumb: 'Create Fixed Deposit Account' }, + component: CreateFixedDepositAccountComponent, + resolve: { + fixedDepositsAccountTemplate: FixedDepositsAccountTemplateResolver + } + }, { path: ':fixedDepositAccountId', data: { title: extract('Fixed Deposit Account View'), routeParamBreadcrumb: 'fixedDepositAccountId' }, @@ -119,7 +129,8 @@ const routes: Routes = [ SavingsDatatableResolver, SavingsDatatablesResolver, FixedDepositsAccountTransactionResolver, - FixedDepositsAccountActionsResolver + FixedDepositsAccountActionsResolver, + FixedDepositsAccountTemplateResolver ] }) export class FixedDepositsRoutingModule { } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts index 96cd36dc2..b946263f6 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -32,6 +32,14 @@ import { InactivateChargeDialogComponent } from './fixed-deposit-account-view/cu import { AddChargeFixedDepositsAccountComponent } from './fixed-deposits-account-actions/add-charge-fixed-deposits-account/add-charge-fixed-deposits-account.component'; import { PrematureCloseFixedDepositsAccountComponent } from './fixed-deposits-account-actions/premature-close-fixed-deposits-account/premature-close-fixed-deposits-account.component'; import { CloseFixedDepositsAccountComponent } from './fixed-deposits-account-actions/close-fixed-deposits-account/close-fixed-deposits-account.component'; +import { CreateFixedDepositAccountComponent } from './create-fixed-deposit-account/create-fixed-deposit-account.component'; +import { FixedDepositAccountDetailsStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component'; +import { FixedDepositAccountTermsStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-terms-step/fixed-deposit-account-terms-step.component'; +import { FixedDepositAccountChargesStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component'; +import { FixedDepositAccountSettingsStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component'; +import { FixedDepositAccountInterestRateChartStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-interest-rate-chart-step/fixed-deposit-account-interest-rate-chart-step.component'; +import { FixedDepositAccountPreviewStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-preview-step/fixed-deposit-account-preview-step.component'; +import { FixedDepositAccountCurrencyStepComponent } from './fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component'; @NgModule({ declarations: [ @@ -57,7 +65,15 @@ import { CloseFixedDepositsAccountComponent } from './fixed-deposits-account-act InactivateChargeDialogComponent, AddChargeFixedDepositsAccountComponent, PrematureCloseFixedDepositsAccountComponent, - CloseFixedDepositsAccountComponent + CloseFixedDepositsAccountComponent, + CreateFixedDepositAccountComponent, + FixedDepositAccountDetailsStepComponent, + FixedDepositAccountTermsStepComponent, + FixedDepositAccountChargesStepComponent, + FixedDepositAccountSettingsStepComponent, + FixedDepositAccountInterestRateChartStepComponent, + FixedDepositAccountPreviewStepComponent, + FixedDepositAccountCurrencyStepComponent ], imports: [ SharedModule, diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts index 31a810e43..88a604c6c 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -73,6 +73,24 @@ export class FixedDepositsService { return this.http.get(`/fixeddepositaccounts/${accountId}/template`, { params: httpParams }); } + /** + * @param clientId Client Id assosciated with fixed deposits account. + * @returns {Observable} Fixed Deposits account template. + */ + getFixedDepositsAccountTemplate(clientId: string, productId?: string): Observable { + let httpParams = new HttpParams().set('clientId', clientId); + httpParams = productId ? httpParams.set('productId', productId) : httpParams; + return this.http.get('/fixeddepositaccounts/template', { params: httpParams }); + } + + /** + * @param fixedDepositAccount Fixed Deposit Account + * @returns {Observable} + */ + createFixedDepositAccount(fixedDepositAccount: any): Observable { + return this.http.post(`/fixeddepositaccounts`, fixedDepositAccount); + } + /** * @param clientId Client Id * @param clientName Client Name