feat: view share product component (#469)

Fixes: #463
This commit is contained in:
Abhay Chawla
2019-12-01 23:20:51 +03:00
parent c3dcd4852a
commit 409d0cfe30
11 changed files with 359 additions and 4 deletions
@@ -20,6 +20,7 @@ import { ViewSavingProductComponent } from './saving-products/view-saving-produc
import { EditSavingProductComponent } from './saving-products/edit-saving-product/edit-saving-product.component';
import { ShareProductsComponent } from './share-products/share-products.component';
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-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';
@@ -38,6 +39,7 @@ import { SavingProductResolver } from './saving-products/saving-product.resolver
import { SavingProductAndTemplateResolver } from './saving-products/edit-saving-product/saving-product-and-template.resolver';
import { ShareProductsResolver } from './share-products/share-products.resolver';
import { ShareProductsTemplateResolver } from './share-products/share-products-template.resolver';
import { ShareProductResolver } from './share-products/share-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';
@@ -157,6 +159,19 @@ const routes: Routes = [
resolve: {
shareProductsTemplate: ShareProductsTemplateResolver
}
},
{
path: ':id',
data: { title: extract('View Share Product'), routeParamBreadcrumb: 'id' },
children: [
{
path: '',
component: ViewShareProductComponent,
resolve: {
shareProduct: ShareProductResolver
},
},
]
}
]
},
@@ -234,6 +249,7 @@ const routes: Routes = [
SavingProductAndTemplateResolver,
ShareProductsResolver,
ShareProductsTemplateResolver,
ShareProductResolver,
RecurringDepositProductsResolver,
ChargesResolver,
FixedDepositProductsResolver,
+3 -1
View File
@@ -47,6 +47,7 @@ import { ShareProductChargesStepComponent } from './share-products/share-product
import { ShareProductAccountingStepComponent } from './share-products/share-product-stepper/share-product-accounting-step/share-product-accounting-step.component';
import { ShareProductPreviewStepComponent } from './share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component';
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component';
/**
* Products Module
@@ -98,7 +99,8 @@ import { CreateShareProductComponent } from './share-products/create-share-produ
ShareProductChargesStepComponent,
ShareProductAccountingStepComponent,
ShareProductPreviewStepComponent,
CreateShareProductComponent
CreateShareProductComponent,
ViewShareProductComponent
],
entryComponents: [
],
+4
View File
@@ -81,6 +81,10 @@ export class ProductsService {
return this.http.get('/products/share/template');
}
getShareProduct(shareProductId: string): Observable<any> {
return this.http.get(`/products/share/${shareProductId}`);
}
/**
* @returns {Observable<any>} Recurring deposit products data
*/
@@ -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';
/**
* Share Product data resolver.
*/
@Injectable()
export class ShareProductResolver implements Resolve<Object> {
/**
* @param {ProductsService} productsService Products service.
*/
constructor(private productsService: ProductsService) {}
/**
* Returns the share product data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const id = route.paramMap.get('id');
return this.productsService.getShareProduct(id);
}
}
@@ -182,10 +182,10 @@
<span fxFlex="60%">{{ shareProduct.shareSuspenseId | find:shareProductsTemplate.accountingMappingOptions.liabilityAccountOptions:'id':'name' }}</span>
</div>
<h4 fxFlexFill class="mat-h4">Expenses</h4>
<h4 fxFlexFill class="mat-h4">Share Equity</h4>
<div fxFlexFill>
<span fxFlex="40%">Share Equity:</span>
<span fxFlex="40%">Equity:</span>
<span fxFlex="60%">{{ shareProduct.shareEquityId | find:shareProductsTemplate.accountingMappingOptions.equityAccountOptions:'id':'name' }}</span>
</div>
@@ -34,7 +34,7 @@
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[row.id]" class="select-row"></tr>
</table>
@@ -1,3 +1,7 @@
table {
width: 100%;
.select-row:hover {
cursor: pointer;
}
}
@@ -0,0 +1,224 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<button mat-raised-button color="primary">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;
Edit
</button>
<button mat-raised-button color="primary">
<fa-icon icon="hand-holding-usd"></fa-icon>&nbsp;&nbsp;
Dividends
</button>
</div>
<div class="container">
<mat-card>
<mat-card-content>
<div fxLayout="row wrap" fxLayout.lt-md="column">
<h2 class="mat-h2" fxFlexFill>{{ shareProduct.name }}</h2>
<mat-divider [inset]="true"></mat-divider>
<h3 class="mat-h3" fxFlexFill>Details</h3>
<mat-divider [inset]="true"></mat-divider>
<div fxFlexFill>
<span fxFlex="40%">Short Name:</span>
<span fxFlex="60%">{{ shareProduct.shortName }}</span>
</div>
<div fxFlexFill *ngIf="shareProduct.description">
<span fxFlex="40%">Description:</span>
<span fxFlex="60%">{{ shareProduct.description }}</span>
</div>
<h3 class="mat-h3" fxFlexFill>Currency</h3>
<mat-divider [inset]="true"></mat-divider>
<div fxFlexFill>
<span fxFlex="40%">Currency:</span>
<span fxFlex="60%">{{ shareProduct.currency.name }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Decimal Places:</span>
<span fxFlex="60%">{{ shareProduct.currency.decimalPlaces }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Currency in multiples of:</span>
<span fxFlex="60%">{{ shareProduct.currency.inMultiplesOf }}</span>
</div>
<h3 class="mat-h3" fxFlexFill>Terms</h3>
<mat-divider [inset]="true"></mat-divider>
<div fxFlexFill>
<span fxFlex="40%">Total Number of Shares:</span>
<span fxFlex="60%">{{ shareProduct.totalShares }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Shares to be Issued:</span>
<span fxFlex="60%">{{ shareProduct.totalSharesIssued }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Nominal/Unit Price:</span>
<span fxFlex="60%">{{ shareProduct.unitPrice }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Capital Value:</span>
<span fxFlex="60%">{{ shareProduct.shareCapital }}</span>
</div>
<h3 class="mat-h3" fxFlexFill>Settings</h3>
<mat-divider [inset]="true"></mat-divider>
<div fxFlexFill>
<span fxFlex="40%">Shares per Client:</span>
<span fxFlex="60%">{{ shareProduct.nominalShares + ' (Min: ' + (shareProduct.minimumShares ? shareProduct.minimumShares : shareProduct.nominalShares) + ', Max: ' + (shareProduct.maximumShares ? shareProduct.maximumShares : shareProduct.nominalShares) + ')' }}</span>
</div>
<div fxFlexFill *ngIf="shareProduct.minimumActivePeriod">
<span fxFlex="40%">Minimum Active Period:</span>
<span fxFlex="60%">{{ shareProduct.minimumActivePeriod + ' ' + shareProduct.minimumActivePeriodForDividendsTypeEnum.value }}</span>
</div>
<div fxFlexFill *ngIf="shareProduct.lockinPeriod">
<span fxFlex="40%">Lock-in Period:</span>
<span fxFlex="60%">{{ shareProduct.lockinPeriod + ' ' + shareProduct.lockPeriodTypeEnum.value }}</span>
</div>
<div fxFlexFill>
<span fxFlex="40%">Allow dividends for inactive clients:</span>
<span fxFlex="60%">{{ shareProduct.allowDividendCalculationForInactiveClients ? 'Yes' : 'No' }}</span>
</div>
<div fxFlexFill *ngIf="shareProduct.marketPrice?.length" fxLayout="row wrap" fxLayout.lt-md="column">
<h3 class="mat-h3" fxFlexFill>Market Price Periods</h3>
<mat-divider [inset]="true"></mat-divider>
<table fxFlexFill class="mat-elevation-z1" mat-table [dataSource]="shareProduct.marketPrice">
<ng-container matColumnDef="fromDate">
<th mat-header-cell *matHeaderCellDef> From Date </th>
<td mat-cell *matCellDef="let marketPrice">
{{ marketPrice.fromDate | date }}
</td>
</ng-container>
<ng-container matColumnDef="shareValue">
<th mat-header-cell *matHeaderCellDef> Nominal/Unit Price </th>
<td mat-cell *matCellDef="let marketPrice">
{{ marketPrice.shareValue }}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="marketPriceDisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: marketPriceDisplayedColumns;"></tr>
</table>
</div>
<div fxFlexFill *ngIf="shareProduct.charges.length" fxLayout="row wrap" fxLayout.lt-md="column">
<h3 class="mat-h3" fxFlexFill>Charges</h3>
<mat-divider [inset]="true"></mat-divider>
<table fxFlexFill class="mat-elevation-z1" mat-table [dataSource]="shareProduct.charges">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let charge">
{{ charge.name + ', ' + charge.currency.displaySymbol }}
</td>
</ng-container>
<ng-container matColumnDef="chargeCalculationType">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let charge">
{{ charge.chargeCalculationType.value }}
</td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef> Amount </th>
<td mat-cell *matCellDef="let charge">
{{ charge.amount }}
</td>
</ng-container>
<ng-container matColumnDef="chargeTimeType">
<th mat-header-cell *matHeaderCellDef> Collected On </th>
<td mat-cell *matCellDef="let charge">
{{ charge.chargeTimeType.value }}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="chargesDisplayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: chargesDisplayedColumns;"></tr>
</table>
</div>
<h3 class="mat-h3" fxFlexFill>Accounting</h3>
<mat-divider [inset]="true"></mat-divider>
<div fxFlexFill>
<span fxFlex="40%">Type:</span>
<span fxFlex="60%">{{ shareProduct.accountingRule.value }}</span>
</div>
<div fxFlexFill *ngIf="shareProduct.accountingRule.id === 2" fxLayout="row wrap" fxLayout.lt-md="column">
<h4 fxFlexFill class="mat-h4">Assets</h4>
<div fxFlexFill>
<span fxFlex="40%">Share reference:</span>
<span fxFlex="60%">{{ shareProduct.accountingMappings.shareReferenceId.name }}</span>
</div>
<h4 fxFlexFill class="mat-h4">Liabilities</h4>
<div fxFlexFill>
<span fxFlex="40%">Share suspense control:</span>
<span fxFlex="60%">{{ shareProduct.accountingMappings.shareSuspenseId.name }}</span>
</div>
<h4 fxFlexFill class="mat-h4">Share Equity</h4>
<div fxFlexFill>
<span fxFlex="40%">Equity:</span>
<span fxFlex="60%">{{ shareProduct.accountingMappings.shareEquityId.name }}</span>
</div>
<h4 fxFlexFill class="mat-h4">Income</h4>
<div fxFlexFill>
<span fxFlex="40%">Income from fees:</span>
<span fxFlex="60%">{{ shareProduct.accountingMappings.incomeFromFeeAccountId.name }}</span>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -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;
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewShareProductComponent } from './view-share-product.component';
describe('ViewShareProductComponent', () => {
let component: ViewShareProductComponent;
let fixture: ComponentFixture<ViewShareProductComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewShareProductComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewShareProductComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'mifosx-view-share-product',
templateUrl: './view-share-product.component.html',
styleUrls: ['./view-share-product.component.scss']
})
export class ViewShareProductComponent implements OnInit {
shareProduct: any;
marketPriceDisplayedColumns: string[] = ['fromDate', 'shareValue'];
chargesDisplayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType'];
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { shareProduct: any }) => {
this.shareProduct = data.shareProduct;
});
}
ngOnInit() {
}
}