diff --git a/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-and-template.resolver.ts b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-and-template.resolver.ts new file mode 100644 index 000000000..c39803d4d --- /dev/null +++ b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-and-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 FixedDepositsAccountAndTemplateResolver 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 fixedDepositAccountId = route.paramMap.get('fixedDepositAccountId'); + return this.fixedDepositsService.getFixedDepositsAccountAndTemplate(fixedDepositAccountId); + } + +} 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 index d8373a31a..67a19cdb2 100644 --- 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 @@ -1,6 +1,7 @@
+ @@ -71,7 +72,7 @@ > + [fixedDepositsAccountProductTemplate]="fixedDepositsAccountProductTemplate"> diff --git a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts index 99613482d..d4a9b381e 100644 --- a/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts +++ b/src/app/deposits/fixed-deposits/create-fixed-deposit-account/create-fixed-deposit-account.component.ts @@ -127,7 +127,7 @@ export class CreateFixedDepositAccountComponent { charges: this.fixedDepositAccount.charges.map((charge: any) => ({ chargeId: charge.id, amount: charge.amount, - dueDate: charge.dueDate, + dueDate: charge.dueDate && this.datePipe.transform(charge.dueDate, dateFormat), feeOnMonthDay: charge.feeOnMonthDay && this.datePipe.transform([2000].concat(charge.feeOnMonthDay), monthDayFormat), feeInterval: charge.feeInterval })), diff --git a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.html b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.html new file mode 100644 index 000000000..ec5a90cde --- /dev/null +++ b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.html @@ -0,0 +1,107 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + DETAILS + + + + + + + + + CURRENCY + + + + + + + + + TERMS + + + + + + + + + SETTINGS + + + + + + + + + INTEREST RATE CHART + + + + + + + + + CHARGES + + + + + + + + + PREVIEW + + + + + + + + +
diff --git a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.scss b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.spec.ts b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.spec.ts new file mode 100644 index 000000000..187d9f19a --- /dev/null +++ b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditFixedDepositAccountComponent } from './edit-fixed-deposit-account.component'; + +describe('EditFixedDepositAccountComponent', () => { + let component: EditFixedDepositAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditFixedDepositAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditFixedDepositAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts new file mode 100644 index 000000000..69b78d6fc --- /dev/null +++ b/src/app/deposits/fixed-deposits/edit-fixed-deposit-account/edit-fixed-deposit-account.component.ts @@ -0,0 +1,151 @@ +/** 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'; + +/** + * Edit Fixed Deposit Account Component + */ +@Component({ + selector: 'mifosx-edit-fixed-deposit-account', + templateUrl: './edit-fixed-deposit-account.component.html', + styleUrls: ['./edit-fixed-deposit-account.component.scss'] +}) +export class EditFixedDepositAccountComponent { + + /** 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 */ + fixedDepositsAccountAndTemplate: 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: { fixedDepositsAccountAndTemplate: any }) => { + this.fixedDepositsAccountAndTemplate = data.fixedDepositsAccountAndTemplate; + }); + } + + /** + * 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 if stepper is valid and not pristine. + */ + get fixedDepositAccountFormValidAndNotPristine() { + return ( + this.fixedDepositAccountDetailsForm.valid && + this.fixedDepositAccountTermsForm.valid && + this.fixedDepositAccountSettingsForm.valid && + ( + !this.fixedDepositAccountDetailsForm.pristine || + !this.fixedDepositAccountTermsForm.pristine || + !this.fixedDepositAccountSettingsForm.pristine || + !this.fixedDepositAccountChargesStep.pristine + ) + ); + } + + /** + * 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.fixedDepositsAccountAndTemplate.clientId, + charges: this.fixedDepositAccount.charges.map((charge: any) => ({ + chargeId: charge.id, + amount: charge.amount, + dueDate: charge.dueDate && this.datePipe.transform(charge.dueDate, dateFormat), + 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.updateFixedDepositAccount(this.fixedDepositsAccountAndTemplate.id, fixedDepositAccount).subscribe((response: any) => { + this.router.navigate(['../'], { 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 index 13720890f..21eb416ae 100644 --- 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 @@ -54,7 +54,7 @@ Date - {{(charge.dueDate | date) || 'Unassigned'}} + {{(charge.dueDate | date) || 'Unassigned*'}} {{charge.feeOnMonthDay ? ([2000].concat(charge.feeOnMonthDay) | date: 'dd MMMM') : 'Unassigned'}} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts index 9ecd29e89..3ebd4bf9b 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-charges-step/fixed-deposit-account-charges-step.component.ts @@ -1,5 +1,5 @@ /** Angular Imports */ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, OnChanges } from '@angular/core'; import { FormControl } from '@angular/forms'; import { MatDialog } from '@angular/material'; @@ -20,7 +20,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; templateUrl: './fixed-deposit-account-charges-step.component.html', styleUrls: ['./fixed-deposit-account-charges-step.component.scss'] }) -export class FixedDepositAccountChargesStepComponent implements OnInit { +export class FixedDepositAccountChargesStepComponent implements OnInit, OnChanges { /** Fixed deposits account template */ @Input() fixedDepositsAccountTemplate: any; @@ -34,9 +34,11 @@ export class FixedDepositAccountChargesStepComponent implements OnInit { /** Charges Data */ chargeData: any; /** Charges Data Source */ - chargesDataSource: {}[]; + chargesDataSource: {}[] = []; /** Charges table columns */ displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery', 'action']; + /** For Edit Fixed Deposits Account Form */ + isChargesPatched = false; /** Component is pristine if there has been no changes by user interaction */ pristine = true; @@ -48,17 +50,29 @@ export class FixedDepositAccountChargesStepComponent implements OnInit { private datePipe: DatePipe) { } ngOnInit() { - this.chargeData = this.fixedDepositsAccountTemplate.chargeOptions; - this.chargesDataSource = []; - this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []); + this.currencyCode.valueChanges.subscribe(() => { + if (!this.isChargesPatched && this.fixedDepositsAccountTemplate.charges) { + this.chargesDataSource = this.fixedDepositsAccountTemplate.charges.map((charge: any) => ({...charge, id: charge.chargeId})) || []; + this.isChargesPatched = true; + } else { + this.chargesDataSource = []; + } + }); } + ngOnChanges() { + if (this.fixedDepositsAccountProductTemplate) { + this.chargeData = this.fixedDepositsAccountProductTemplate.chargeOptions; + } + } + /** * Add a charge */ addCharge(charge: any) { this.chargesDataSource = this.chargesDataSource.concat([charge.value]); charge.value = ''; + this.pristine = false; } /** @@ -169,6 +183,7 @@ export class FixedDepositAccountChargesStepComponent implements OnInit { deleteCharge(charge: any) { this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1); this.chargesDataSource = this.chargesDataSource.concat([]); + this.pristine = false; } /** 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 index 0744e86eb..48368d236 100644 --- 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 @@ -26,6 +26,8 @@ export class FixedDepositAccountDetailsStepComponent implements OnInit { productData: any; /** Field Officer Data */ fieldOfficerData: any; + /** For edit savings form */ + isFieldOfficerPatched = false; /** Fixed Deposits Account Details Form */ fixedDepositAccountDetailsForm: FormGroup; @@ -46,6 +48,12 @@ export class FixedDepositAccountDetailsStepComponent implements OnInit { this.buildDependencies(); if (this.fixedDepositsAccountTemplate) { this.productData = this.fixedDepositsAccountTemplate.productOptions; + if (this.fixedDepositsAccountTemplate.depositProductId) { + this.fixedDepositAccountDetailsForm.patchValue({ + 'productId': this.fixedDepositsAccountTemplate.depositProductId, + 'submittedOnDate': this.fixedDepositsAccountTemplate.timeline.submittedOnDate && new Date(this.fixedDepositsAccountTemplate.timeline.submittedOnDate) + }); + } } } @@ -69,7 +77,12 @@ export class FixedDepositAccountDetailsStepComponent implements OnInit { this.fixedDepositsService.getFixedDepositsAccountTemplate(clientId, productId).subscribe((response: any) => { this.fixedDepositsAccountProductTemplate.emit(response); this.fieldOfficerData = response.fieldOfficerOptions; - this.fixedDepositAccountDetailsForm.get('fieldOfficerId').patchValue(''); + if (!this.isFieldOfficerPatched && this.fixedDepositsAccountTemplate.fieldOfficerId) { + this.fixedDepositAccountDetailsForm.get('fieldOfficerId').patchValue(this.fixedDepositsAccountTemplate.fieldOfficerId); + this.isFieldOfficerPatched = true; + } else { + this.fixedDepositAccountDetailsForm.get('fieldOfficerId').patchValue(''); + } }); }); } 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 index 061e6b2e1..55131a9f6 100644 --- 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 @@ -19,20 +19,10 @@ {{ (fixedDepositAccountData.fieldOfficerId | find:fixedDepositsAccountProductTemplate.fieldOfficerOptions:'id':'displayName') || 'Unassigned' }}
-

Terms

+

Currency

-
- Fixed Deposit Amount: - {{ fixedDepositAccountData.depositAmount }} -
- -
- Deposit Period: - {{ fixedDepositAccountData.depositPeriod + ' ' + (fixedDepositAccountData.depositPeriodFrequencyId | find:fixedDepositsAccountProductTemplate.periodFrequencyTypeOptions:'id':'value') }} -
-
Currency {{ fixedDepositsAccountProductTemplate.currency.code }} @@ -48,6 +38,20 @@ {{ fixedDepositsAccountProductTemplate.currency.decimalPlaces }}
+

Terms

+ + + +
+ Fixed Deposit Amount: + {{ fixedDepositAccountData.depositAmount }} +
+ +
+ Deposit Period: + {{ fixedDepositAccountData.depositPeriod + ' ' + (fixedDepositAccountData.depositPeriodFrequencyId | find:fixedDepositsAccountProductTemplate.periodFrequencyTypeOptions:'id':'value') }} +
+
Interest Compounding Period: {{ fixedDepositAccountData.interestCompoundingPeriodType | find:fixedDepositsAccountProductTemplate.interestCompoundingPeriodTypeOptions:'id':'value' }} 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 index ae4ce675d..b07b1287c 100644 --- 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 @@ -124,7 +124,7 @@ 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.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-settings-step/fixed-deposit-account-settings-step.component.ts index a373ea1e3..d6dc49bbd 100644 --- 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 @@ -63,6 +63,7 @@ export class FixedDepositAccountSettingsStepComponent implements OnInit, OnChang this.fixedDepositAccountSettingsForm.removeControl('taxGroupId'); } }); + this.fixedDepositAccountSettingsForm.get('withHoldTax').patchValue(this.fixedDepositsAccountTemplate.withHoldTax); } else { this.fixedDepositAccountSettingsForm.removeControl('withHoldTax'); } @@ -70,7 +71,15 @@ export class FixedDepositAccountSettingsStepComponent implements OnInit, OnChang } } - ngOnInit() { } + ngOnInit() { + if (this.fixedDepositsAccountTemplate) { + this.fixedDepositAccountSettingsForm.patchValue({ + 'lockinPeriodFrequency': this.fixedDepositsAccountTemplate.lockinPeriodFrequency, + 'lockinPeriodFrequencyType': this.fixedDepositsAccountTemplate.lockinPeriodFrequencyType && this.fixedDepositsAccountTemplate.lockinPeriodFrequencyType.id, + 'transferInterestToSavings': this.fixedDepositsAccountTemplate.transferInterestToSavings + }); + } + } /** * Creates fixed deposits account terms form. @@ -99,6 +108,7 @@ export class FixedDepositAccountSettingsStepComponent implements OnInit, OnChang this.fixedDepositAccountSettingsForm.get('transferInterestToSavings').valueChanges.subscribe((value: boolean) => { if (value) { this.fixedDepositAccountSettingsForm.addControl('linkAccountId', new FormControl('', Validators.required)); + this.fixedDepositAccountSettingsForm.get('linkAccountId').patchValue(this.fixedDepositsAccountTemplate.linkedAccount && this.fixedDepositsAccountTemplate.linkedAccount.id); } else { this.fixedDepositAccountSettingsForm.removeControl('linkAccountId'); } 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 index 4aecb6a22..1d8ec3e6e 100644 --- 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 @@ -47,7 +47,19 @@ export class FixedDepositAccountTermsStepComponent implements OnInit, OnChanges } } - ngOnInit() { } + ngOnInit() { + if (this.fixedDepositsAccountTemplate) { + this.fixedDepositAccountTermsForm.patchValue({ + 'interestCompoundingPeriodType': this.fixedDepositsAccountTemplate.interestCompoundingPeriodType.id, + 'interestPostingPeriodType': this.fixedDepositsAccountTemplate.interestPostingPeriodType.id, + 'interestCalculationType': this.fixedDepositsAccountTemplate.interestCalculationType.id, + 'interestCalculationDaysInYearType': this.fixedDepositsAccountTemplate.interestCalculationDaysInYearType.id, + 'depositAmount': this.fixedDepositsAccountTemplate.depositAmount, + 'depositPeriod': this.fixedDepositsAccountTemplate.depositPeriod, + 'depositPeriodFrequencyId': this.fixedDepositsAccountTemplate.depositPeriodFrequency.id, + }); + } + } /** * Creates fixed deposits account terms form. diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.html index 8c72618fc..51f32a7a4 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/charges-tab/charges-tab.component.html @@ -35,8 +35,8 @@ - Repeats On (M/d) - {{ charge.feeOnMonthDay ? charge.feeOnMonthDay.join('/') : '' }} + Repeats On + {{charge.feeOnMonthDay ? ([2000].concat(charge.feeOnMonthDay) | date: 'dd MMMM') : 'Unassigned'}} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts index aa496b26f..c364efde7 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/fixed-deposit-account-view.component.ts @@ -36,6 +36,10 @@ export class FixedDepositAccountViewComponent implements OnInit { /** * Fetches fixed deposits account data from `resolve` * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + * @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service + * @param {SavingsService} savingsService Savings Service + * @param {MatDialog} dialog Mat Dialog */ constructor(private route: ActivatedRoute, private router: Router, @@ -99,7 +103,7 @@ export class FixedDepositAccountViewComponent implements OnInit { this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Modify Application': - this.router.navigate(['edit-savings-account'], { relativeTo: this.route }); + this.router.navigate(['edit-fixed-deposit-account'], { relativeTo: this.route }); break; case 'Delete': this.deleteFixedDepositsAccount(); 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 d1c5873fb..21be82559 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts @@ -15,6 +15,7 @@ import { DatatableTabsComponent } from './fixed-deposit-account-view/datatable-t 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'; +import { EditFixedDepositAccountComponent } from './edit-fixed-deposit-account/edit-fixed-deposit-account.component'; /** Custom Resolvers */ import { FixedDepositsAccountViewResolver } from './common-resolvers/fixed-deposit-account-view.resolver'; @@ -23,6 +24,7 @@ import { SavingsDatatablesResolver } from 'app/savings/common-resolvers/savings- 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'; +import { FixedDepositsAccountAndTemplateResolver } from './common-resolvers/fixed-deposit-account-and-template.resolver'; const routes: Routes = [ { @@ -84,6 +86,14 @@ const routes: Routes = [ } ] }, + { + path: 'edit-fixed-deposit-account', + data: { title: extract('Edit Fixed Deposit Account'), breadcrumb: 'Edit', routeParamBreadcrumb: false }, + component: EditFixedDepositAccountComponent, + resolve: { + fixedDepositsAccountAndTemplate: FixedDepositsAccountAndTemplateResolver + } + }, { path: 'transactions', data: { title: extract('Fixed Deposits Account Transactions'), breadcrumb: 'Transactions', routeParamBreadcrumb: false }, @@ -130,7 +140,8 @@ const routes: Routes = [ SavingsDatatablesResolver, FixedDepositsAccountTransactionResolver, FixedDepositsAccountActionsResolver, - FixedDepositsAccountTemplateResolver + FixedDepositsAccountTemplateResolver, + FixedDepositsAccountAndTemplateResolver ] }) 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 b946263f6..adb78698f 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -40,6 +40,7 @@ import { FixedDepositAccountSettingsStepComponent } from './fixed-deposit-accoun 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'; +import { EditFixedDepositAccountComponent } from './edit-fixed-deposit-account/edit-fixed-deposit-account.component'; @NgModule({ declarations: [ @@ -73,7 +74,8 @@ import { FixedDepositAccountCurrencyStepComponent } from './fixed-deposit-accoun FixedDepositAccountSettingsStepComponent, FixedDepositAccountInterestRateChartStepComponent, FixedDepositAccountPreviewStepComponent, - FixedDepositAccountCurrencyStepComponent + FixedDepositAccountCurrencyStepComponent, + EditFixedDepositAccountComponent ], 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 88a604c6c..545b9694c 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -83,6 +83,13 @@ export class FixedDepositsService { return this.http.get('/fixeddepositaccounts/template', { params: httpParams }); } + + getFixedDepositsAccountAndTemplate(accountId: any) { + const httpParams = new HttpParams().set('associations', 'charges,+linkedAccount') + .set('template', 'true'); + return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams }); + } + /** * @param fixedDepositAccount Fixed Deposit Account * @returns {Observable} @@ -91,6 +98,15 @@ export class FixedDepositsService { return this.http.post(`/fixeddepositaccounts`, fixedDepositAccount); } + /** + * @param {any} accountId Account Id + * @param {any} fixedDepositAccount Fixed Deposit Account + * @returns {Observable} + */ + updateFixedDepositAccount(accountId: any, fixedDepositAccount: any): Observable { + return this.http.put(`/fixeddepositaccounts/${accountId}`, fixedDepositAccount); + } + /** * @param clientId Client Id * @param clientName Client Name