From b0b4a926ebb42a6514bc34b72a7a0d6f25b4f5f3 Mon Sep 17 00:00:00 2001 From: "Oussema.exe" Date: Sat, 11 Jan 2020 22:44:46 +0100 Subject: [PATCH] feat: add view tax component (#559) Fixes: #540 --- .../manage-tax-components.component.html | 2 +- .../tax-component.resolver.ts | 30 +++++++ .../view-tax-component.component.html | 78 +++++++++++++++++++ .../view-tax-component.component.scss | 10 +++ .../view-tax-component.component.spec.ts | 25 ++++++ .../view-tax-component.component.ts | 31 ++++++++ src/app/products/products-routing.module.ts | 31 ++++++-- src/app/products/products.module.ts | 4 +- src/app/products/products.service.ts | 8 ++ 9 files changed, 212 insertions(+), 7 deletions(-) create mode 100644 src/app/products/manage-tax-components/tax-component.resolver.ts create mode 100644 src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.html create mode 100644 src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.scss create mode 100644 src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.spec.ts create mode 100644 src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.ts diff --git a/src/app/products/manage-tax-components/manage-tax-components.component.html b/src/app/products/manage-tax-components/manage-tax-components.component.html index 79269e86c..6fba8ffe2 100644 --- a/src/app/products/manage-tax-components/manage-tax-components.component.html +++ b/src/app/products/manage-tax-components/manage-tax-components.component.html @@ -29,7 +29,7 @@ - + diff --git a/src/app/products/manage-tax-components/tax-component.resolver.ts b/src/app/products/manage-tax-components/tax-component.resolver.ts new file mode 100644 index 000000000..30a5d839b --- /dev/null +++ b/src/app/products/manage-tax-components/tax-component.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { ProductsService } from '../products.service'; + +/** + * tax Component data resolver. + */ +@Injectable() +export class TaxComponentResolver implements Resolve { + + /** + * @param {ProductsService} productsService Products service. + */ + constructor(private productsService: ProductsService) {} + + /** + * Returns the tax Component data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const taxComponentId = route.paramMap.get('id'); + return this.productsService.getTaxComponent(taxComponentId); + } +} diff --git a/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.html b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.html new file mode 100644 index 000000000..d02c8930b --- /dev/null +++ b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.html @@ -0,0 +1,78 @@ +
+ +
+ +
+ + + + + +
+ +
+ Name +
+ +
+ {{ taxComponentData.name }} +
+ +
+ Percentage +
+ +
+ {{ taxComponentData.percentage }} +
+ +
+ Debit Account Type +
+ +
+ {{ taxComponentData.debitAccountType.value }} +
+ +
+ Debit Account +
+ +
+ {{ taxComponentData.debitAccount.name}} +
+ +
+ Credit Account Type +
+ +
+ {{ taxComponentData.creditAccountType.value }} +
+ +
+ Credit Account +
+ +
+ {{ taxComponentData.creditAccount.name }} +
+ +
+ Start date +
+ +
+ {{ taxComponentData.startDate | date }} +
+ +
+ +
+ +
+ +
diff --git a/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.scss b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.scss new file mode 100644 index 000000000..46cf44760 --- /dev/null +++ b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.scss @@ -0,0 +1,10 @@ +.container { + max-width: 37rem; + + .content { + div { + margin: 1rem 0; + word-wrap: break-word; + } + } +} diff --git a/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.spec.ts b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.spec.ts new file mode 100644 index 000000000..25d5f9ef4 --- /dev/null +++ b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewTaxComponentComponent } from './view-tax-component.component'; + +describe('ViewTaxComponentComponent', () => { + let component: ViewTaxComponentComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewTaxComponentComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewTaxComponentComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.ts b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.ts new file mode 100644 index 000000000..283460363 --- /dev/null +++ b/src/app/products/manage-tax-components/view-tax-component/view-tax-component.component.ts @@ -0,0 +1,31 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +/** + * View tax Component component. + */ +@Component({ + selector: 'mifosx-view-tax-component', + templateUrl: './view-tax-component.component.html', + styleUrls: ['./view-tax-component.component.scss'] +}) +export class ViewTaxComponentComponent implements OnInit { + + /** tax Component Data. */ + taxComponentData: any; + + /** + * Retrieves the tax Component data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { taxComponent: any }) => { + this.taxComponentData = data.taxComponent; + }); + } + + ngOnInit() { + } + +} diff --git a/src/app/products/products-routing.module.ts b/src/app/products/products-routing.module.ts index 343493828..f51e4e73f 100644 --- a/src/app/products/products-routing.module.ts +++ b/src/app/products/products-routing.module.ts @@ -31,6 +31,7 @@ import { CreateFixedDepositProductComponent } from './fixed-deposit-products/cre import { ProductsMixComponent } from './products-mix/products-mix.component'; import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax-components.component'; import { ManageTaxGroupsComponent } from './manage-tax-groups/manage-tax-groups.component'; +import { ViewTaxComponentComponent } from './manage-tax-components/view-tax-component/view-tax-component.component'; /** Custom Resolvers */ import { LoanProductsResolver } from './loan-products/loan-products.resolver'; @@ -53,6 +54,7 @@ import { FixedDepositProductsTemplateResolver } from './fixed-deposit-products/f import { ProductsMixResolver } from './products-mix/products-mix.resolver'; import { ManageTaxComponentsResolver } from './manage-tax-components/manage-tax-components.resolver'; import { ManageTaxGroupsResolver } from './manage-tax-groups/manage-tax-groups.resolver'; +import { TaxComponentResolver } from './manage-tax-components/tax-component.resolver'; /** Products Routes */ const routes: Routes = [ @@ -201,11 +203,29 @@ const routes: Routes = [ }, { path: 'tax-components', - component: ManageTaxComponentsComponent, - resolve: { - taxComponents: ManageTaxComponentsResolver - }, data: { title: extract('Manage Tax Components'), breadcrumb: 'Tax Components'}, + children: [ + { + path: '', + component: ManageTaxComponentsComponent, + resolve: { + taxComponents: ManageTaxComponentsResolver + } + }, + { + path: ':id', + data: { title: extract('View Tax Component'), routeParamBreadcrumb: 'id' }, + children: [ + { + path: '', + component: ViewTaxComponentComponent, + resolve: { + taxComponent: TaxComponentResolver + } + } + ] + } + ] }, { path: 'tax-groups', @@ -308,7 +328,8 @@ const routes: Routes = [ FixedDepositProductsTemplateResolver, ProductsMixResolver, ManageTaxComponentsResolver, - ManageTaxGroupsResolver + ManageTaxGroupsResolver, + TaxComponentResolver ] }) export class ProductsRoutingModule { } diff --git a/src/app/products/products.module.ts b/src/app/products/products.module.ts index 84147ac20..92de19214 100644 --- a/src/app/products/products.module.ts +++ b/src/app/products/products.module.ts @@ -61,6 +61,7 @@ import { FixedDepositProductAccountingStepComponent } from './fixed-deposit-prod import { FixedDepositProductPreviewStepComponent } from './fixed-deposit-products/fixed-deposit-product-stepper/fixed-deposit-product-preview-step/fixed-deposit-product-preview-step.component'; import { DepositProductIncentiveFormDialogComponent } from './deposit-product-incentive-form-dialog/deposit-product-incentive-form-dialog.component'; import { ManageTaxGroupsComponent } from './manage-tax-groups/manage-tax-groups.component'; +import { ViewTaxComponentComponent } from './manage-tax-components/view-tax-component/view-tax-component.component'; /** * Products Module @@ -126,7 +127,8 @@ import { ManageTaxGroupsComponent } from './manage-tax-groups/manage-tax-groups. FixedDepositProductAccountingStepComponent, FixedDepositProductPreviewStepComponent, DepositProductIncentiveFormDialogComponent, - ManageTaxGroupsComponent + ManageTaxGroupsComponent, + ViewTaxComponentComponent ], entryComponents: [ DepositProductIncentiveFormDialogComponent diff --git a/src/app/products/products.service.ts b/src/app/products/products.service.ts index 1be63caad..df7aa1413 100644 --- a/src/app/products/products.service.ts +++ b/src/app/products/products.service.ts @@ -142,6 +142,14 @@ export class ProductsService { return this.http.get('/taxes/component'); } + /** + * @param {string} taxComponentId tax Component ID of tax Component. + * @returns {Observable} Tax Component. + */ + getTaxComponent(taxComponentId: string): Observable { + return this.http.get(`/taxes/component/${taxComponentId}`); + } + /** * @returns {Observable} Tax Groups data */