diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts
index 403643318..c8d82ffc9 100644
--- a/src/app/organization/organization-routing.module.ts
+++ b/src/app/organization/organization-routing.module.ts
@@ -17,6 +17,7 @@ import { CurrenciesComponent } from './currencies/currencies.component';
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
import { TellersComponent } from './tellers/tellers.component';
+import { PaymentTypesComponent } from './payment-types/payment-types.component';
/** Custom Resolvers */
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
@@ -26,6 +27,7 @@ import { CurrenciesResolver } from './currencies/currencies.resolver';
import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver';
import { AdhocQueriesResolver } from './adhoc-query/adhoc-queries.resolver';
import { TellersResolver } from './tellers/tellers.resolver';
+import { PaymentTypesResolver } from './payment-types/payment-types.resolver';
/** Organization Routes */
const routes: Routes = [
@@ -98,6 +100,14 @@ const routes: Routes = [
resolve: {
tellers: TellersResolver
}
+ },
+ {
+ path: 'payment-types',
+ component: PaymentTypesComponent,
+ data: { title: extract('Payment Types'), breadcrumb: 'Payment Types' },
+ resolve: {
+ paymentTypes: PaymentTypesResolver
+ }
}
]
}
@@ -119,7 +129,8 @@ const routes: Routes = [
CurrenciesResolver,
SmsCampaignsResolver,
AdhocQueriesResolver,
- TellersResolver
+ TellersResolver,
+ PaymentTypesResolver
]
})
export class OrganizationRoutingModule { }
diff --git a/src/app/organization/organization.component.html b/src/app/organization/organization.component.html
index 971841cc0..40555bcaf 100644
--- a/src/app/organization/organization.component.html
+++ b/src/app/organization/organization.component.html
@@ -121,7 +121,7 @@
Define working days and configure behaviour of payments due on holidays
-
+
diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts
index 3c4554dbd..fcfc458e8 100644
--- a/src/app/organization/organization.module.ts
+++ b/src/app/organization/organization.module.ts
@@ -15,6 +15,7 @@ import { CurrenciesComponent } from './currencies/currencies.component';
import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component';
import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component';
import { TellersComponent } from './tellers/tellers.component';
+import { PaymentTypesComponent } from './payment-types/payment-types.component';
/**
* Organization Module
@@ -35,7 +36,8 @@ import { TellersComponent } from './tellers/tellers.component';
CurrenciesComponent,
SmsCampaignsComponent,
AdhocQueryComponent,
- TellersComponent
+ TellersComponent,
+ PaymentTypesComponent
]
})
export class OrganizationModule { }
diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts
index a1770eee7..a648feb61 100644
--- a/src/app/organization/organization.service.ts
+++ b/src/app/organization/organization.service.ts
@@ -67,4 +67,19 @@ export class OrganizationService {
return this.http.get('/tellers');
}
+ /**
+ * @returns {Observable} Payment Types data
+ */
+ getPaymentTypes(): Observable {
+ return this.http.get('/paymenttypes');
+ }
+
+ /**
+ * @param {string} paymentTypeId Payment type ID of payment type to be deleted.
+ * @returns {Observable}
+ */
+ deletePaymentType(paymentTypeId: string): Observable {
+ return this.http.delete(`/paymenttypes/${paymentTypeId}`);
+ }
+
}
diff --git a/src/app/organization/payment-types/payment-types.component.html b/src/app/organization/payment-types/payment-types.component.html
new file mode 100644
index 000000000..055f9a0c7
--- /dev/null
+++ b/src/app/organization/payment-types/payment-types.component.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+ Filter
+
+
+
+
+
+
+
+
+
+ | Name |
+ {{ paymentType.name }} |
+
+
+
+ Description |
+ {{ paymentType.description }} |
+
+
+
+ Cash Payment |
+
+
+
+
+
+ |
+
+
+
+ Position |
+ {{ paymentType.position }} |
+
+
+
+ Actions |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/organization/payment-types/payment-types.component.scss b/src/app/organization/payment-types/payment-types.component.scss
new file mode 100644
index 000000000..bf52d42c8
--- /dev/null
+++ b/src/app/organization/payment-types/payment-types.component.scss
@@ -0,0 +1,11 @@
+table {
+ width: 100%;
+}
+
+.true {
+ color: #32cd32;
+}
+
+.false {
+ color: #f44366;
+}
diff --git a/src/app/organization/payment-types/payment-types.component.spec.ts b/src/app/organization/payment-types/payment-types.component.spec.ts
new file mode 100644
index 000000000..5d6809516
--- /dev/null
+++ b/src/app/organization/payment-types/payment-types.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { PaymentTypesComponent } from './payment-types.component';
+
+describe('PaymentTypesComponent', () => {
+ let component: PaymentTypesComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ PaymentTypesComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(PaymentTypesComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/organization/payment-types/payment-types.component.ts b/src/app/organization/payment-types/payment-types.component.ts
new file mode 100644
index 000000000..84c8f331c
--- /dev/null
+++ b/src/app/organization/payment-types/payment-types.component.ts
@@ -0,0 +1,94 @@
+/** Angular Imports */
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { MatTableDataSource, MatPaginator, MatSort, MatDialog } from '@angular/material';
+import { ActivatedRoute } from '@angular/router';
+
+/** rxjs Imports */
+import { of } from 'rxjs';
+
+/** Custom Services */
+import { OrganizationService } from '../organization.service';
+
+/** Custom Components */
+import { DeleteDialogComponent } from '../../shared/delete-dialog/delete-dialog.component';
+
+/**
+ * Payment Types component.
+ */
+@Component({
+ selector: 'mifosx-payment-types',
+ templateUrl: './payment-types.component.html',
+ styleUrls: ['./payment-types.component.scss']
+})
+export class PaymentTypesComponent implements OnInit {
+
+ /** Payment Types data. */
+ paymentTypesData: any;
+ /** Columns to be displayed in payment types table. */
+ displayedColumns: string[] = ['name', 'description', 'isCashPayment', 'position', 'actions'];
+ /** Data source for payment types table. */
+ dataSource: MatTableDataSource;
+
+ /** Paginator for payment types table. */
+ @ViewChild(MatPaginator) paginator: MatPaginator;
+ /** Sorter for payment types table. */
+ @ViewChild(MatSort) sort: MatSort;
+
+ /**
+ * Retrieves the payment types data from `resolve`.
+ * @param {OrganizationService} organizationService Organization Service.
+ * @param {ActivatedRoute} route Activated Route.
+ * @param {MatDialog} dialog Dialog reference.
+ */
+ constructor(private organizationService: OrganizationService,
+ private route: ActivatedRoute,
+ private dialog: MatDialog) {
+ this.route.data.subscribe(( data: { paymentTypes: any }) => {
+ this.paymentTypesData = data.paymentTypes;
+ });
+ }
+
+ /**
+ * Filters data in payment types table based on passed value.
+ * @param {string} filterValue Value to filter data.
+ */
+ applyFilter(filterValue: string) {
+ this.dataSource.filter = filterValue.trim().toLowerCase();
+ }
+
+ /**
+ * Sets the payment types table.
+ */
+ ngOnInit() {
+ this.setPaymentTypes();
+ }
+
+ /**
+ * Initializes the data source, paginator and sorter for payment types table.
+ */
+ setPaymentTypes() {
+ this.dataSource = new MatTableDataSource(this.paymentTypesData);
+ this.dataSource.paginator = this.paginator;
+ this.dataSource.sort = this.sort;
+ }
+
+ /**
+ * Deletes the payment type
+ * @param {string} paymentTypeId Payment Type ID of payment type to be deleted.
+ */
+ deletePaymentType(paymentTypeId: string) {
+ const deletePaymentTypeDialogRef = this.dialog.open(DeleteDialogComponent, {
+ data: { deleteContext: `payment type ${paymentTypeId}` }
+ });
+ deletePaymentTypeDialogRef.afterClosed().subscribe((response: any) => {
+ if (response.delete) {
+ this.organizationService.deletePaymentType(paymentTypeId)
+ .subscribe(() => {
+ this.paymentTypesData = this.paymentTypesData.filter((paymentType: any) => paymentType.id !== paymentTypeId);
+ this.setPaymentTypes();
+ });
+ }
+ });
+ }
+
+}
diff --git a/src/app/organization/payment-types/payment-types.resolver.ts b/src/app/organization/payment-types/payment-types.resolver.ts
new file mode 100644
index 000000000..05dff3235
--- /dev/null
+++ b/src/app/organization/payment-types/payment-types.resolver.ts
@@ -0,0 +1,30 @@
+/** Angular Imports */
+import { Injectable } from '@angular/core';
+import { Resolve } from '@angular/router';
+
+/** rxjs Imports */
+import { Observable } from 'rxjs';
+
+/** Custom Services */
+import { OrganizationService } from '../organization.service';
+
+/**
+ * Payment Types data resolver.
+ */
+@Injectable()
+export class PaymentTypesResolver implements Resolve