diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index af816c268..324ed5473 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -43,6 +43,8 @@ import { ManageFundsComponent } from './manage-funds/manage-funds.component'; import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage-currencies.component'; import { CashiersComponent } from './tellers/cashiers/cashiers.component'; import { TransactionsComponent } from './tellers/transactions/transactions.component'; +import { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.component'; +import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component'; /** Custom Resolvers */ import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver'; @@ -74,7 +76,6 @@ import { OfficeDatatableResolver } from './offices/common-resolvers/office-datat import { OfficeDatatablesResolver } from './offices/common-resolvers/office-datatables.resolver'; import { SmsCampaignResolver } from './sms-campaigns/common-resolvers/sms-campaign.resolver'; import { ManageFundsResolver } from './manage-funds/manage-funds.resolver'; -import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component'; import { CashierTransactionTemplateResolver } from './tellers/teller-transaction-template.resolver'; /** Organization Routes */ @@ -363,6 +364,11 @@ const routes: Routes = [ path: 'settle', component: SettleCashComponent, data: { title: extract('Settle Cash'), breadcrumb: 'Settle Cash', routeParamBreadcrumb: false }, + }, + { + path: 'allocate', + component: AllocateCashComponent, + data: { title: extract('Allocate Cash'), breadcrumb: 'Allocate Cash', routeParamBreadcrumb: false }, resolve: { cashierTemplate: CashierTransactionTemplateResolver } diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index b44c6fc79..247bffa7f 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -47,6 +47,7 @@ import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage import { CashiersComponent } from './tellers/cashiers/cashiers.component'; import { TransactionsComponent } from './tellers/transactions/transactions.component'; import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component'; +import { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.component'; /** * Organization Module @@ -99,7 +100,8 @@ import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component ManageCurrenciesComponent, CashiersComponent, TransactionsComponent, - SettleCashComponent + SettleCashComponent, + AllocateCashComponent ] }) export class OrganizationModule { } diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index a5859be6d..629e10939 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -295,6 +295,7 @@ export class OrganizationService { /** * Settle Cash. + * Allocate Cash. * @param {string} tellerId Teller Id. * @param {string} cashierId Cashier Id. * @param {string} cashData Cash Data. @@ -305,6 +306,11 @@ export class OrganizationService { return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/settle`, cashData, {params: httpParams}); } + allocateCash(tellerId: string, cashierId: string, cashData: any): Observable { + const httpParams = new HttpParams().set('command', 'allocate'); + return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/allocate`, cashData, {params: httpParams}); + } + /** * @param {string} tellerId Teller ID of teller to be deleted. * @returns {Observable} diff --git a/src/app/organization/tellers/allocate-cash/allocate-cash.component.html b/src/app/organization/tellers/allocate-cash/allocate-cash.component.html new file mode 100644 index 000000000..a19db977e --- /dev/null +++ b/src/app/organization/tellers/allocate-cash/allocate-cash.component.html @@ -0,0 +1,82 @@ +
+ + + +
+ + + +
+ + + Office + + + + + Teller Name + + + + + Cashier + + + + + Assignment Period + + + + + Date + + + + + Date is required + + + + + Currency + + + {{ currency.name }} + + + + Currency is required + + + + + Amount + + + Amount is required + + + + + Notes/Comments + + + Notes/Comments is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/organization/tellers/allocate-cash/allocate-cash.component.scss b/src/app/organization/tellers/allocate-cash/allocate-cash.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/organization/tellers/allocate-cash/allocate-cash.component.spec.ts b/src/app/organization/tellers/allocate-cash/allocate-cash.component.spec.ts new file mode 100644 index 000000000..eb5a24dee --- /dev/null +++ b/src/app/organization/tellers/allocate-cash/allocate-cash.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AllocateCashComponent } from './allocate-cash.component'; + +describe('AllocateCashComponent', () => { + let component: AllocateCashComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AllocateCashComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AllocateCashComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/tellers/allocate-cash/allocate-cash.component.ts b/src/app/organization/tellers/allocate-cash/allocate-cash.component.ts new file mode 100644 index 000000000..d14fe4eaf --- /dev/null +++ b/src/app/organization/tellers/allocate-cash/allocate-cash.component.ts @@ -0,0 +1,84 @@ +/** Angular Imports. */ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DatePipe } from '@angular/common'; + +/** Custom Services. */ +import { OrganizationService } from 'app/organization/organization.service'; + +/** + * Allocate Cash component. + */ +@Component({ + selector: 'mifosx-allocate-cash', + templateUrl: './allocate-cash.component.html', + styleUrls: ['./allocate-cash.component.scss'] +}) +export class AllocateCashComponent implements OnInit { + + /** Minimum Date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum Date allowed. */ + maxDate = new Date(); + /** Cashier data. */ + cashierData: any; + /** Cashier Form. */ + allocateCashForm: FormGroup; + + /** + * Get cashier data from `Resolver`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {ActivatedRoute} route ActivateRoute. + * @param {DatePipe} datePipe Date Pipe. + * @param {OrganizationService} organizationService Organization Service. + * @param {Router} router Router. + */ + constructor(private formBuilder: FormBuilder, + private route: ActivatedRoute, + private datePipe: DatePipe, + private organizationService: OrganizationService, + private router: Router) { + this.route.data.subscribe((data: { cashierTemplate: any}) => { + this.cashierData = data.cashierTemplate; + }); + } + + ngOnInit() { + this.setCashierForm(); + } + + /** + * Set Cashier form. + */ + setCashierForm() { + this.allocateCashForm = this.formBuilder.group({ + 'office': [{value: this.cashierData.officeName, disabled: true}], + 'tellerName': [{value: this.cashierData.tellerName, disabled: true}], + 'cashier': [{value: this.cashierData.cashierName, disabled: true}], + 'assignmentPeriod': [{value: this.datePipe.transform(this.cashierData.startDate, 'dd MMMM yyyy') + ' - ' + this.datePipe.transform(this.cashierData.endDate, 'dd MMMM yyyy'), disabled: true}], + 'txnDate': [new Date(), Validators.required], + 'currencyCode': ['', Validators.required], + 'txnAmount': ['', Validators.required], + 'txnNote': ['', Validators.required] + }); + } + + /** + * Submits Allocate Cash form. + */ + submit() { + const dateFormat = 'dd MMMM yyyy'; + const txnDate = this.allocateCashForm.value.txnDate; + this.allocateCashForm.patchValue({ + txnDate: this.datePipe.transform(txnDate, dateFormat) + }); + const allocateCashForm = this.allocateCashForm.value; + allocateCashForm.dateFormat = dateFormat; + allocateCashForm.locale = 'en'; + this.organizationService.allocateCash(this.cashierData.tellerId, this.cashierData.cashierId, allocateCashForm).subscribe((response: any) => { + this.router.navigate(['../'], {relativeTo: this.route}); + }); + } + +}