committed by
Abhay Chawla
parent
98b01e0376
commit
d4281628ea
@@ -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 'app/products/products.service';
|
||||
|
||||
/**
|
||||
* Charge data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ChargeResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {productsService} productsService Products service.
|
||||
*/
|
||||
constructor(private productsService: ProductsService) {}
|
||||
|
||||
/**
|
||||
* Returns the charge data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const chargeId = route.paramMap.get('id');
|
||||
return this.productsService.getCharge(chargeId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[row.id]" class="select-row"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
<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>
|
||||
Edit
|
||||
</button>
|
||||
<button mat-raised-button color="warn" (click)="deleteCharge()">
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="row wrap" class="content">
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Type
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.penalty === true ? 'Penalty' : 'Charge' }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Currency
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.currency.name }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Amount
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.amount }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Time Type
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargeTimeType.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Applies to
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargeAppliesTo.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Calculation Type
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargeCalculationType.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Charge Payment Mode
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.chargePaymentMode.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong">
|
||||
Active
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ chargeData.active === true ? 'Yes' : 'No' }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong" *ngIf="chargeData.chargeTimeType.id == 9">
|
||||
Fee Frequency
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="chargeData.chargeTimeType.id == 9">
|
||||
{{ chargeData.feeFrequency.value }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong" *ngIf="chargeData.chargeTimeType.id == 9">
|
||||
Frequency Interval
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="chargeData.chargeTimeType.id == 9">
|
||||
{{ chargeData.feeInterval }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong" *ngIf="chargeData.incomeOrLiabilityAccount">
|
||||
Income from Charges
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="chargeData.incomeOrLiabilityAccount">
|
||||
{{ chargeData.incomeOrLiabilityAccount.name + ' (' + chargeData.incomeOrLiabilityAccount.glCode + ')' }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="mat-body-strong" *ngIf="chargeData.taxGroup">
|
||||
Tax Group
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" *ngIf="chargeData.taxGroup">
|
||||
{{ chargeData.taxGroup.name }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
|
||||
.content {
|
||||
div {
|
||||
margin: 1rem 0;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ViewChargeComponent } from './view-charge.component';
|
||||
|
||||
describe('ViewChargeComponent', () => {
|
||||
let component: ViewChargeComponent;
|
||||
let fixture: ComponentFixture<ViewChargeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewChargeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ViewChargeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
/** Custom Services */
|
||||
import { ProductsService } from 'app/products/products.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||
|
||||
/**
|
||||
* View Charge Component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-view-charge',
|
||||
templateUrl: './view-charge.component.html',
|
||||
styleUrls: ['./view-charge.component.scss']
|
||||
})
|
||||
export class ViewChargeComponent implements OnInit {
|
||||
|
||||
/** Charge data. */
|
||||
chargeData: any;
|
||||
|
||||
/**
|
||||
* Retrieves the charge data from `resolve`.
|
||||
* @param {ProductsService} productsService Products Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
*/
|
||||
constructor(private productsService: ProductsService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: { charge: any }) => {
|
||||
this.chargeData = data.charge;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the charge and redirects to charges.
|
||||
*/
|
||||
deleteCharge() {
|
||||
const deleteChargeDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `charge ${this.chargeData.id}` }
|
||||
});
|
||||
deleteChargeDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.productsService.deleteCharge(this.chargeData.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/products/charges']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import { EditShareProductComponent } from './share-products/edit-share-product/e
|
||||
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';
|
||||
import { ViewChargeComponent } from './charges/view-charge/view-charge.component';
|
||||
import { FixedDepositProductsComponent } from './fixed-deposit-products/fixed-deposit-products.component';
|
||||
import { CreateFixedDepositProductComponent } from './fixed-deposit-products/create-fixed-deposit-product/create-fixed-deposit-product.component';
|
||||
import { ProductsMixComponent } from './products-mix/products-mix.component';
|
||||
@@ -46,6 +47,7 @@ import { ShareProductResolver } from './share-products/share-product-resolver';
|
||||
import { ShareProductAndTemplateResolver } from './share-products/edit-share-product/share-product-and-template.resolver';
|
||||
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
||||
import { ChargesResolver } from './charges/charges.resolver';
|
||||
import { ChargeResolver } from './charges/charge.resolver';
|
||||
import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver';
|
||||
import { FixedDepositProductsTemplateResolver } from './fixed-deposit-products/fixed-deposit-products-template.resolver';
|
||||
import { ProductsMixResolver } from './products-mix/products-mix.resolver';
|
||||
@@ -225,11 +227,24 @@ const routes: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'charges',
|
||||
component: ChargesComponent,
|
||||
resolve: {
|
||||
charges: ChargesResolver
|
||||
},
|
||||
data: { title: extract('Charges'), breadcrumb: 'Charges' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: ChargesComponent,
|
||||
resolve: {
|
||||
charges: ChargesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
data: { title: extract('View Charge'), routeResolveBreadcrumb: ['charge', 'name'] },
|
||||
component: ViewChargeComponent,
|
||||
resolve: {
|
||||
charge: ChargeResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'fixed-deposit-products',
|
||||
@@ -288,6 +303,7 @@ const routes: Routes = [
|
||||
ShareProductAndTemplateResolver,
|
||||
RecurringDepositProductsResolver,
|
||||
ChargesResolver,
|
||||
ChargeResolver,
|
||||
FixedDepositProductsResolver,
|
||||
FixedDepositProductsTemplateResolver,
|
||||
ProductsMixResolver,
|
||||
|
||||
@@ -21,6 +21,7 @@ import { CreateLoanProductComponent } from './loan-products/create-loan-product/
|
||||
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';
|
||||
import { ViewChargeComponent } from './charges/view-charge/view-charge.component';
|
||||
import { FixedDepositProductsComponent } from './fixed-deposit-products/fixed-deposit-products.component';
|
||||
import { ProductsMixComponent } from './products-mix/products-mix.component';
|
||||
import { ManageTaxComponentsComponent } from './manage-tax-components/manage-tax-components.component';
|
||||
@@ -86,6 +87,7 @@ import { ManageTaxGroupsComponent } from './manage-tax-groups/manage-tax-groups.
|
||||
ManageTaxConfigurationsComponent,
|
||||
RecurringDepositProductsComponent,
|
||||
ChargesComponent,
|
||||
ViewChargeComponent,
|
||||
FixedDepositProductsComponent,
|
||||
ProductsMixComponent,
|
||||
ManageTaxComponentsComponent,
|
||||
|
||||
@@ -104,6 +104,22 @@ export class ProductsService {
|
||||
return this.http.get('/charges');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} chargeId Charge ID of charge.
|
||||
* @returns {Observable<any>} Charge.
|
||||
*/
|
||||
getCharge(chargeId: string): Observable<any> {
|
||||
return this.http.get(`/charges/${chargeId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} chargeId Charge ID of Charge to be deleted.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
deleteCharge(chargeId: string): Observable<any> {
|
||||
return this.http.delete(`/charges/${chargeId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Fixed deposit products data
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user