feat: add dividends list page (#804)

Fixes: #769
This commit is contained in:
stableapple
2020-05-31 18:07:30 +05:30
committed by GitHub
parent 28b3f730f0
commit 224ff151da
9 changed files with 255 additions and 58 deletions
+12 -1
View File
@@ -40,6 +40,7 @@ import { ViewTaxComponentComponent } from './manage-tax-components/view-tax-comp
import { CreateTaxComponentComponent } from './manage-tax-components/create-tax-component/create-tax-component.component';
import { EditTaxComponentComponent } from './manage-tax-components/edit-tax-component/edit-tax-component.component';
import { ViewTaxGroupComponent } from './manage-tax-groups/view-tax-group/view-tax-group.component';
import { ShareProductsDividendsComponent } from './share-products/dividends-share-product/dividends.components';
/** Custom Resolvers */
import { LoanProductsResolver } from './loan-products/loan-products.resolver';
@@ -70,6 +71,7 @@ import { TaxComponentTemplateResolver } from './manage-tax-components/tax-compon
import { EditChargeComponent } from './charges/edit-charge/edit-charge.component';
import { ChargesTemplateResolver } from './charges/charges-template.resolver';
import { TaxGroupResolver } from './manage-tax-groups/tax-group.resolver';
import { DividendsResolver } from './share-products/dividends-share-product/dividends.resolver';
/** Products Routes */
const routes: Routes = [
@@ -203,6 +205,14 @@ const routes: Routes = [
resolve: {
shareProductAndTemplate: ShareProductAndTemplateResolver
}
},
{
path: 'dividends',
data: { title: extract('Share Products Dividends'), breadcrumb: 'Dividends', routeParamBreadcrumb: false},
component: ShareProductsDividendsComponent,
resolve: {
dividends: DividendsResolver
}
}
]
}
@@ -452,7 +462,8 @@ const routes: Routes = [
FloatingRatesResolver,
TaxComponentTemplateResolver,
EditTaxComponentComponent,
TaxGroupResolver
TaxGroupResolver,
DividendsResolver
]
})
export class ProductsRoutingModule { }
+3 -1
View File
@@ -74,6 +74,7 @@ import { EditChargeComponent } from './charges/edit-charge/edit-charge.component
import { MatFormFieldModule, MatSelectModule, MatOptionModule } from '@angular/material';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ViewTaxGroupComponent } from './manage-tax-groups/view-tax-group/view-tax-group.component';
import { ShareProductsDividendsComponent } from './share-products/dividends-share-product/dividends.components';
/**
* Products Module
@@ -151,7 +152,8 @@ import { ViewTaxGroupComponent } from './manage-tax-groups/view-tax-group/view-t
CreateTaxComponentComponent,
EditTaxComponentComponent,
EditChargeComponent,
ViewTaxGroupComponent
ViewTaxGroupComponent,
ShareProductsDividendsComponent
],
entryComponents: [
FloatingRatePeriodDialogComponent
+4
View File
@@ -90,6 +90,10 @@ export class ProductsService {
return this.http.put(`/products/share/${shareProductId}`, shareProduct);
}
getDividends(shareProductId: string): Observable<any> {
return this.http.get(`/shareproduct/${shareProductId}/dividend`);
}
/**
* @returns {Observable<any>} Recurring deposit products data
*/
@@ -0,0 +1,55 @@
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
<button mat-raised-button color="primary">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;
Initiate Dividend
</button>
</div>
<div class="container">
<div fxLayout="row">
<mat-form-field fxFlex>
<mat-label>Filter</mat-label>
<input matInput (keyup)="applyFilter($event.target.value)">
</mat-form-field>
</div>
<div class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
<td mat-cell *matCellDef="let dividend">{{ dividend.productData.name }}</td>
</ng-container>
<ng-container matColumnDef="dividendPeriodStartDate">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Dividend Period Start Date </th>
<td mat-cell *matCellDef="let dividend">{{ dividend.dividendPeriodStartDate | date }}</td>
</ng-container>
<ng-container matColumnDef="dividendPeriodEndDate">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Dividend Period End Date </th>
<td mat-cell *matCellDef="let dividend">{{ dividend.dividendPeriodEndDate | date }}</td>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Amount </th>
<td mat-cell *matCellDef="let dividend"> {{ dividend.amount }}</td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
<td mat-cell *matCellDef="let dividend">{{ dividend.status.value }}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[row.id]" class="select-row"></tr>
</table>
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
</div>
</div>
@@ -0,0 +1,7 @@
table {
width: 100%;
.select-row:hover {
cursor: pointer;
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ShareProductsDividendsComponent } from './dividends.components';
describe('ShareProductsComponent', () => {
let component: ShareProductsDividendsComponent;
let fixture: ComponentFixture<ShareProductsDividendsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ShareProductsDividendsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ShareProductsDividendsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,62 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
import { ActivatedRoute } from '@angular/router';
/**
* Dividends component.
*/
@Component({
selector: 'mifosx-dividends-share-product',
templateUrl: './dividends.component.html',
styleUrls: ['./dividends.component.scss']
})
export class ShareProductsDividendsComponent implements OnInit {
/** Dividends data. */
dividendData: any;
/** Columns to be displayed in dividends table. */
displayedColumns: string[] = ['name', 'dividendPeriodStartDate', 'dividendPeriodEndDate', 'amount', 'status'];
/** Data source for accounting rules table. */
dataSource: MatTableDataSource<any>;
/** Paginator for dividends table. */
@ViewChild(MatPaginator) paginator: MatPaginator;
/** Sorter for dividends table. */
@ViewChild(MatSort) sort: MatSort;
/**
* Retrieves the dividends data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: {dividends: any}) => {
this.dividendData = data.dividends.pageItems;
});
}
/**
* Sets the dividends table.
*/
ngOnInit() {
this.setDividends();
}
/**
* Initializes the data source, paginator and sorter for dividends table.
*/
setDividends() {
this.dataSource = new MatTableDataSource(this.dividendData);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
/**
* Filters data in dividends table based on passed value.
* @param {string} filterValue Value to filter data.
*/
applyFilter(filterValue: string) {
this.dataSource.filter = filterValue.trim().toLowerCase();
}
}
@@ -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 products data resolver.
*/
@Injectable()
export class DividendsResolver implements Resolve<Object> {
/**
* @param {ProductsService} productsService Products service.
*/
constructor(private productsService: ProductsService) {}
/**
* Returns the share products data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const id = route.paramMap.get('id');
return this.productsService.getDividends(id);
}
}
@@ -3,7 +3,7 @@
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;
Edit
</button>
<button mat-raised-button color="primary">
<button mat-raised-button color="primary" [routerLink]="['dividends']">
<fa-icon icon="hand-holding-usd"></fa-icon>&nbsp;&nbsp;
Dividends
</button>
@@ -18,85 +18,85 @@
<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>
@@ -105,117 +105,117 @@
<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>
<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>
</div>
</mat-card-content>