diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.ts b/src/app/clients/clients-view/general-tab/general-tab.component.ts index 6d6fecc1b..49fec3c01 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.ts +++ b/src/app/clients/clients-view/general-tab/general-tab.component.ts @@ -103,8 +103,6 @@ export class GeneralTabComponent { } routeTransferFund(loanId: any) { - console.log('loanId: ', loanId); - const queryParams: any = { loanId: loanId, accountType: 'fromloans' }; this.router.navigate(['../', 'loans', loanId, 'transfer-funds', 'make-account-transfer'], { relativeTo: this.route, queryParams: queryParams }); } diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index 870f85c35..ccb0e21e8 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -79,6 +79,8 @@ import { DividendsResolver } from './share-products/dividends-share-product/divi import { RecurringDepositProductsTemplateResolver } from './recurring-deposit-products/recurring-deposit-products-template.resolver'; import { EditRecurringDepositProductComponent } from './recurring-deposit-products/edit-recurring-deposit-product/edit-recurring-deposit-product.component'; import { RecurringDepositProductAndTemplateResolver } from './recurring-deposit-products/edit-recurring-deposit-product/recurring-deposit-product-and-template.resolver'; +import { ViewDividendComponent } from './share-products/view-dividend/view-dividend.component'; +import { ViewDividendDataResolver } from './share-products/view-dividend/view-dividend-data.resolver'; /** Products Routes */ const routes: Routes = [ @@ -231,6 +233,14 @@ const routes: Routes = [ resolve: { shareProduct: ShareProductResolver } + }, + { + path: ':dividendId', + component: ViewDividendComponent, + data: { title: extract('View Dividend'), routeParamBreadcrumb: 'dividendId' }, + resolve: { + dividendData: ViewDividendDataResolver + } } ] } @@ -440,7 +450,6 @@ const routes: Routes = [ } ] }, - { path: 'charges', data: { title: extract('Charges'), breadcrumb: 'Charges' }, @@ -521,7 +530,8 @@ const routes: Routes = [ TaxGroupResolver, DividendsResolver, RecurringDepositProductsTemplateResolver, - RecurringDepositProductAndTemplateResolver + RecurringDepositProductAndTemplateResolver, + ViewDividendDataResolver ] }) export class ProductsRoutingModule { } diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index 78298652a..a0626fcae 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -88,6 +88,7 @@ import { RecurringDepositProductSettingsStepComponent } from './recurring-deposi import { RecurringDepositProductTermsStepComponent } from './recurring-deposit-products/recurring-deposit-product-stepper/recurring-deposit-product-terms-step/recurring-deposit-product-terms-step.component'; import { EditRecurringDepositProductComponent } from './recurring-deposit-products/edit-recurring-deposit-product/edit-recurring-deposit-product.component'; import { CreateDividendComponent } from './share-products/create-dividend/create-dividend.component'; +import { ViewDividendComponent } from './share-products/view-dividend/view-dividend.component'; /** * Products Module @@ -179,7 +180,8 @@ import { CreateDividendComponent } from './share-products/create-dividend/create RecurringDepositProductSettingsStepComponent, RecurringDepositProductTermsStepComponent, EditRecurringDepositProductComponent, - CreateDividendComponent + CreateDividendComponent, + ViewDividendComponent ], entryComponents: [ DepositProductIncentiveFormDialogComponent, diff --git a/src/app/products/products.service.ts b/src/app/products/products.service.ts index 3aa9dd4ab..545d5e015 100644 --- a/src/app/products/products.service.ts +++ b/src/app/products/products.service.ts @@ -104,6 +104,20 @@ export class ProductsService { return this.http.post(`/shareproduct/${shareProductId}/dividend`, dividendData); } + getDividendData(shareProductId: any, dividendId: any): Observable { + const httpParams = new HttpParams().set('dateFormat', 'dd MMMM yyyy') + .set('limit', '10') + .set('locale', 'en') + .set('offset', '0'); + return this.http.get(`/shareproduct/${shareProductId}/dividend/${dividendId}`, { params: httpParams }); + } + + approveDividend(shareProductId: any, dividendId: any, data: any): Observable { + const httpParams = new HttpParams().set('command', 'approve'); + return this.http.put(`/shareproduct/${shareProductId}/dividend/${dividendId}`, data, { params: httpParams }); + + } + /** * @returns {Observable} Recurring deposit products data */ diff --git a/src/app/products/share-products/dividends-share-product/dividends.component.html b/src/app/products/share-products/dividends-share-product/dividends.component.html index 0187eb83e..1ea7f0899 100644 --- a/src/app/products/share-products/dividends-share-product/dividends.component.html +++ b/src/app/products/share-products/dividends-share-product/dividends.component.html @@ -44,7 +44,7 @@ - + diff --git a/src/app/products/share-products/dividends-share-product/dividends.components.ts b/src/app/products/share-products/dividends-share-product/dividends.components.ts index d419f0154..5823c965c 100644 --- a/src/app/products/share-products/dividends-share-product/dividends.components.ts +++ b/src/app/products/share-products/dividends-share-product/dividends.components.ts @@ -1,7 +1,7 @@ /** Angular Imports */ import { Component, OnInit, ViewChild } from '@angular/core'; import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; /** * Dividends component. @@ -29,7 +29,8 @@ export class ShareProductsDividendsComponent implements OnInit { * Retrieves the dividends data from `resolve`. * @param {ActivatedRoute} route Activated Route. */ - constructor(private route: ActivatedRoute) { + constructor(private route: ActivatedRoute, + private router: Router) { this.route.data.subscribe((data: {dividends: any}) => { this.dividendData = data.dividends.pageItems; }); @@ -51,6 +52,11 @@ export class ShareProductsDividendsComponent implements OnInit { this.dataSource.sort = this.sort; } + showDividend(dividendId: any, status: string) { + const queryParams: any = { status: status }; + this.router.navigate([dividendId], { relativeTo: this.route, queryParams: queryParams }); + } + /** * Filters data in dividends table based on passed value. * @param {string} filterValue Value to filter data. diff --git a/src/app/products/share-products/view-dividend/view-dividend-data.resolver.ts b/src/app/products/share-products/view-dividend/view-dividend-data.resolver.ts new file mode 100644 index 000000000..2722d2e46 --- /dev/null +++ b/src/app/products/share-products/view-dividend/view-dividend-data.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 { ProductsService } from '../../products.service'; + +/** + * Share products data resolver. + */ +@Injectable() +export class ViewDividendDataResolver implements Resolve { + + /** + * @param {ProductsService} productsService Products service. + */ + constructor(private productsService: ProductsService) {} + + /** + * Returns the share products data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const dividendId = route.paramMap.get('dividendId'); + const shareProductId = route.parent.parent.paramMap.get('id'); + return this.productsService.getDividendData(shareProductId, dividendId); + } + +} diff --git a/src/app/products/share-products/view-dividend/view-dividend.component.html b/src/app/products/share-products/view-dividend/view-dividend.component.html new file mode 100644 index 000000000..ac13dc703 --- /dev/null +++ b/src/app/products/share-products/view-dividend/view-dividend.component.html @@ -0,0 +1,50 @@ +
+ +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Client Name {{ dividend.accountData.clientName }} Share Account {{ dividend.accountData.accountNo }} Dividend Amount {{ dividend.amount }} Status {{ dividend.status.value }}
+ + + +
+ +
diff --git a/src/app/products/share-products/view-dividend/view-dividend.component.scss b/src/app/products/share-products/view-dividend/view-dividend.component.scss new file mode 100644 index 000000000..1922e7ffa --- /dev/null +++ b/src/app/products/share-products/view-dividend/view-dividend.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/products/share-products/view-dividend/view-dividend.component.spec.ts b/src/app/products/share-products/view-dividend/view-dividend.component.spec.ts new file mode 100644 index 000000000..776ea2b72 --- /dev/null +++ b/src/app/products/share-products/view-dividend/view-dividend.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewDividendComponent } from './view-dividend.component'; + +describe('ViewDividendComponent', () => { + let component: ViewDividendComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewDividendComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewDividendComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/products/share-products/view-dividend/view-dividend.component.ts b/src/app/products/share-products/view-dividend/view-dividend.component.ts new file mode 100644 index 000000000..66714a21f --- /dev/null +++ b/src/app/products/share-products/view-dividend/view-dividend.component.ts @@ -0,0 +1,52 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; +import { ProductsService } from 'app/products/products.service'; + +@Component({ + selector: 'mifosx-view-dividend', + templateUrl: './view-dividend.component.html', + styleUrls: ['./view-dividend.component.scss'] +}) +export class ViewDividendComponent implements OnInit { + + dividendData: any; + status: any; + isdividendPosted = false; + + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + displayedColumns: string[] = ['clientName', 'shareAccount', 'dividendAmount', 'status']; + dataSource: MatTableDataSource; + + constructor(private route: ActivatedRoute, + private productsService: ProductsService, + private router: Router) { + this.route.data.subscribe((data: { dividendData: any }) => { + this.dividendData = data.dividendData; + }); + this.status = this.route.snapshot.queryParams['status']; + if (this.status && (this.status === 'Dividend Approved' || this.status === 'Dividend Posted')) { + this.isdividendPosted = true; + } + } + + ngOnInit() { + this.dataSource = new MatTableDataSource(this.dividendData.pageItems); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + + postDividends() { + const shareProductId = this.route.parent.parent.snapshot.paramMap.get('id'); + const dividendId = this.route.snapshot.paramMap.get('dividendId'); + this.productsService.approveDividend(shareProductId, dividendId, { productId: shareProductId, dividendId: dividendId}).subscribe(() => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + +}