From f22be41f87a02f028c2a5b1ebf574b50b4a57d70 Mon Sep 17 00:00:00 2001 From: Abhay Chawla Date: Sun, 28 Jul 2019 21:27:29 +0530 Subject: [PATCH] feat: view saving product component (#456) Fixes: #452 --- src/app/products/products-routing.module.ts | 16 + src/app/products/products.module.ts | 4 +- src/app/products/products.service.ts | 4 + .../saving-product.resolver.ts | 31 ++ .../saving-products.component.html | 2 +- .../saving-products.component.scss | 7 + .../view-saving-product.component.html | 353 ++++++++++++++++++ .../view-saving-product.component.scss | 24 ++ .../view-saving-product.component.spec.ts | 25 ++ .../view-saving-product.component.ts | 26 ++ 10 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 src/app/products/saving-products/saving-product.resolver.ts create mode 100644 src/app/products/saving-products/view-saving-product/view-saving-product.component.html create mode 100644 src/app/products/saving-products/view-saving-product/view-saving-product.component.scss create mode 100644 src/app/products/saving-products/view-saving-product/view-saving-product.component.spec.ts create mode 100644 src/app/products/saving-products/view-saving-product/view-saving-product.component.ts diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index c764456b0..7d39ea9db 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -16,6 +16,7 @@ import { ViewLoanProductComponent } from './loan-products/view-loan-product/view import { EditLoanProductComponent } from './loan-products/edit-loan-product/edit-loan-product.component'; import { SavingProductsComponent } from './saving-products/saving-products.component'; import { CreateSavingProductComponent } from './saving-products/create-saving-product/create-saving-product.component'; +import { ViewSavingProductComponent } from './saving-products/view-saving-product/view-saving-product.component'; import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component'; import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component'; import { ChargesComponent } from './charges/charges.component'; @@ -30,6 +31,7 @@ import { LoanProductResolver } from './loan-products/loan-product.resolver'; import { LoanProductAndTemplateResolver } from './loan-products/edit-loan-product/loan-product-and-template.resolver'; import { SavingProductsResolver } from './saving-products/saving-products.resolver'; import { SavingProductsTemplateResolver } from './saving-products/saving-products-template.resolver'; +import { SavingProductResolver } from './saving-products/saving-product.resolver'; import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver'; import { ChargesResolver } from './charges/charges.resolver'; import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver'; @@ -108,6 +110,19 @@ const routes: Routes = [ savingProductsTemplate: SavingProductsTemplateResolver } }, + { + path: ':id', + data: { title: extract('View Saving Product'), routeParamBreadcrumb: 'id' }, + children: [ + { + path: '', + component: ViewSavingProductComponent, + resolve: { + savingProduct: SavingProductResolver + } + } + ] + } ] }, { @@ -180,6 +195,7 @@ const routes: Routes = [ LoanProductAndTemplateResolver, SavingProductsResolver, SavingProductsTemplateResolver, + SavingProductResolver, RecurringDepositProductsResolver, ChargesResolver, FixedDepositProductsResolver, diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index 9970ac079..befa94d5a 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -35,6 +35,7 @@ import { SavingProductChargesStepComponent } from './saving-products/saving-prod import { SavingProductAccountingStepComponent } from './saving-products/saving-product-stepper/saving-product-accounting-step/saving-product-accounting-step.component'; import { SavingProductPreviewStepComponent } from './saving-products/saving-product-stepper/saving-product-preview-step/saving-product-preview-step.component'; import { CreateSavingProductComponent } from './saving-products/create-saving-product/create-saving-product.component'; +import { ViewSavingProductComponent } from './saving-products/view-saving-product/view-saving-product.component'; /** * Products Module @@ -74,7 +75,8 @@ import { CreateSavingProductComponent } from './saving-products/create-saving-pr SavingProductChargesStepComponent, SavingProductAccountingStepComponent, SavingProductPreviewStepComponent, - CreateSavingProductComponent + CreateSavingProductComponent, + ViewSavingProductComponent ], entryComponents: [ ], diff --git a/src/app/products/products.service.ts b/src/app/products/products.service.ts index 40263d40a..608d677cb 100644 --- a/src/app/products/products.service.ts +++ b/src/app/products/products.service.ts @@ -57,6 +57,10 @@ export class ProductsService { return this.http.get('/savingsproducts/template'); } + getSavingProduct(savingProductId: string): Observable { + return this.http.get(`/savingsproducts/${savingProductId}`); + } + /** * @returns {Observable} Recurring deposit products data */ diff --git a/src/app/products/saving-products/saving-product.resolver.ts b/src/app/products/saving-products/saving-product.resolver.ts new file mode 100644 index 000000000..6eba7bced --- /dev/null +++ b/src/app/products/saving-products/saving-product.resolver.ts @@ -0,0 +1,31 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { ProductsService } from '../products.service'; + +/** + * Saving Product data resolver. + */ +@Injectable() +export class SavingProductResolver implements Resolve { + + /** + * @param {ProductsService} productsService Products service. + */ + constructor(private productsService: ProductsService) {} + + /** + * Returns the saving product data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const id = route.paramMap.get('id'); + return this.productsService.getSavingProduct(id); + } + +} diff --git a/src/app/products/saving-products/saving-products.component.html b/src/app/products/saving-products/saving-products.component.html index 4d1256b92..b8ee761fa 100644 --- a/src/app/products/saving-products/saving-products.component.html +++ b/src/app/products/saving-products/saving-products.component.html @@ -29,7 +29,7 @@ - + diff --git a/src/app/products/saving-products/saving-products.component.scss b/src/app/products/saving-products/saving-products.component.scss index e69de29bb..24edb63bb 100644 --- a/src/app/products/saving-products/saving-products.component.scss +++ b/src/app/products/saving-products/saving-products.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} diff --git a/src/app/products/saving-products/view-saving-product/view-saving-product.component.html b/src/app/products/saving-products/view-saving-product/view-saving-product.component.html new file mode 100644 index 000000000..0581cf862 --- /dev/null +++ b/src/app/products/saving-products/view-saving-product/view-saving-product.component.html @@ -0,0 +1,353 @@ +
+ +
+ +
+ + + + + +
+ +

{{ savingProduct.name }}

+ + + +

Details

+ + + +
+ Short Name: + {{ savingProduct.shortName }} +
+ +
+ Description: + {{ savingProduct.description }} +
+ +

Currency

+ + + +
+ Currency: + {{ savingProduct.currency.name }} +
+ +
+ Decimal Places: + {{ savingProduct.currency.decimalPlaces }} +
+ +
+ Currency in multiples of: + {{ savingProduct.currency.inMultiplesOf }} +
+ +

Terms

+ + + +
+ Nominal Annual Interest Rate: + {{ savingProduct.nominalAnnualInterestRate }} +
+ +
+ Interest Compounding Period: + {{ savingProduct.interestCompoundingPeriodType.value }} +
+ +
+ Interest Posting Period: + {{ savingProduct.interestPostingPeriodType.value }} +
+ +
+ Interest Calculated using: + {{ savingProduct.interestCalculationType.value }} +
+ +
+ Days in Year: + {{ savingProduct.interestCalculationDaysInYearType.value }} +
+ +

Settings

+ + + +
+ Minimum Opening Balance: + {{ savingProduct.minRequiredOpeningBalance }} +
+ +
+ Lock-in Period: + {{ savingProduct.lockinPeriodFrequency + ' ' + savingProduct.lockinPeriodFrequencyType.value }} +
+ +
+ Apply Withdrawal Fee for Transfers: + {{ savingProduct.withdrawalFeeForTransfers ? 'Yes' : 'No' }} +
+ +
+ Balance Required for Interest Calculation: + {{ savingProduct.minBalanceForInterestCalculation }} +
+ +
+ Enforce Minimum Balance: + {{ savingProduct.enforceMinRequiredBalance ? 'Yes' : 'No' }} +
+ +
+ Minimum Balance: + {{ savingProduct.minRequiredBalance }} +
+ +
+ Withhold Tax is Applicable: + {{ savingProduct.withHoldTax ? 'Yes' : 'No' }} +
+ +
+ Tax Group: + {{ savingProduct.taxGroup.name }} +
+ +
+ Is Overdraft Allowed: + {{ savingProduct.allowOverdraft ? 'Yes' : 'No' }} +
+ +
+ Minimum Overdraft Required for Interest Calculation: + {{ savingProduct.minOverdraftForInterestCalculation }} +
+ +
+ Nominal Annual Interest for Overdraft: + {{ savingProduct.nominalAnnualInterestRateOverdraft }} +
+ +
+ Maximum Overdraft Amount Limit: + {{ savingProduct.overdraftLimit }} +
+ +
+ Enable Dormancy Tracking: + {{ savingProduct.isDormancyTrackingActive ? 'Yes' : 'No' }} +
+ +
+ Number of Days to Inactive sub-status: + {{ savingProduct.daysToInactive }} + Number of Days to Dormant sub-status: + {{ savingProduct.daysToDormancy }} + Number of Days to Escheat: + {{ savingProduct.daysToEscheat }} +
+ +
+ +

Charges

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name + {{ charge.name + ', ' + charge.currency.displaySymbol }} + Type + {{ charge.chargeCalculationType.value }} + Amount + {{ charge.amount }} + Collected On + {{ charge.chargeTimeType.value }} +
+ +
+ +

Accounting

+ + + +
+ Type: + {{ savingProduct.accountingRule.value }} +
+ +
+ +

Assets

+ +
+ Saving reference: + {{ savingProduct.accountingMappings.savingsReferenceAccount.name }} + Overdraft portfolio: + {{ savingProduct.accountingMappings.overdraftPortfolioControl.name }} +
+ +

Liabilities

+ +
+ Saving control: + {{ savingProduct.accountingMappings.savingsControlAccount.name }} + Savings transfers in suspense: + {{ savingProduct.accountingMappings.transfersInSuspenseAccount.name }} +
+ Escheat liability: + {{ savingProduct.accountingMappings.escheatLiabilityAccount.name }} +
+
+ +

Expenses

+ +
+ Interest on savings: + {{ savingProduct.accountingMappings.interestOnSavingsAccount.name }} + Write-off: + {{ savingProduct.accountingMappings.writeOffAccount.name }} +
+ +

Income

+ +
+ Income from fees: + {{ savingProduct.accountingMappings.incomeFromFeeAccount.name }} + Income from penalties: + {{ savingProduct.accountingMappings.incomeFromPenaltyAccount.name }} + Overdraft Interest Income: + {{ savingProduct.accountingMappings.incomeFromInterest.name }} +
+ +
+ +

Advanced Accounting Rules

+ + + +
+ +

Fund Sources for Payment Channels

+ + + + + + + + + + + + + + + + +
Payment Type + {{ paymentFundSource.paymentType.name }} + Fund Source + {{ paymentFundSource.fundSourceAccount.name }} +
+ +
+ +
+ +

Fees to Specific Income Accounts

+ + + + + + + + + + + + + + + + +
Fees + {{ feesIncome.charge.name }} + Income Account + {{ feesIncome.incomeAccount.name }} +
+ +
+ +
+ +

Penalties to Specific Income Accounts

+ + + + + + + + + + + + + + + + +
Penalty + {{ penaltyIncome.charge.name }} + Income Account + {{ penaltyIncome.incomeAccount.name }} +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/app/products/saving-products/view-saving-product/view-saving-product.component.scss b/src/app/products/saving-products/view-saving-product/view-saving-product.component.scss new file mode 100644 index 000000000..a9f4fce2a --- /dev/null +++ b/src/app/products/saving-products/view-saving-product/view-saving-product.component.scss @@ -0,0 +1,24 @@ +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-card .mat-divider-horizontal.mat-divider-inset { + margin: 0 0 0.5em 0; +} + +.margin-t { + margin-top: 1em; +} diff --git a/src/app/products/saving-products/view-saving-product/view-saving-product.component.spec.ts b/src/app/products/saving-products/view-saving-product/view-saving-product.component.spec.ts new file mode 100644 index 000000000..7dc3ec052 --- /dev/null +++ b/src/app/products/saving-products/view-saving-product/view-saving-product.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewSavingProductComponent } from './view-saving-product.component'; + +describe('ViewSavingProductComponent', () => { + let component: ViewSavingProductComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewSavingProductComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewSavingProductComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts b/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts new file mode 100644 index 000000000..0fe87a98b --- /dev/null +++ b/src/app/products/saving-products/view-saving-product/view-saving-product.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'mifosx-view-saving-product', + templateUrl: './view-saving-product.component.html', + styleUrls: ['./view-saving-product.component.scss'] +}) +export class ViewSavingProductComponent implements OnInit { + + savingProduct: any; + + chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType']; + paymentFundSourceDisplayedColumns: string[] = ['paymentTypeId', 'fundSourceAccountId']; + feesPenaltyIncomeDisplayedColumns: string[] = ['chargeId', 'incomeAccountId']; + + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { savingProduct: any }) => { + this.savingProduct = data.savingProduct; + }); + } + + ngOnInit() { + } + +}