@@ -43,6 +43,8 @@ import { ManageFundsComponent } from './manage-funds/manage-funds.component';
|
|||||||
import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage-currencies.component';
|
import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage-currencies.component';
|
||||||
import { CashiersComponent } from './tellers/cashiers/cashiers.component';
|
import { CashiersComponent } from './tellers/cashiers/cashiers.component';
|
||||||
import { TransactionsComponent } from './tellers/transactions/transactions.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 */
|
/** Custom Resolvers */
|
||||||
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
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 { OfficeDatatablesResolver } from './offices/common-resolvers/office-datatables.resolver';
|
||||||
import { SmsCampaignResolver } from './sms-campaigns/common-resolvers/sms-campaign.resolver';
|
import { SmsCampaignResolver } from './sms-campaigns/common-resolvers/sms-campaign.resolver';
|
||||||
import { ManageFundsResolver } from './manage-funds/manage-funds.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';
|
import { CashierTransactionTemplateResolver } from './tellers/teller-transaction-template.resolver';
|
||||||
|
|
||||||
/** Organization Routes */
|
/** Organization Routes */
|
||||||
@@ -363,6 +364,11 @@ const routes: Routes = [
|
|||||||
path: 'settle',
|
path: 'settle',
|
||||||
component: SettleCashComponent,
|
component: SettleCashComponent,
|
||||||
data: { title: extract('Settle Cash'), breadcrumb: 'Settle Cash', routeParamBreadcrumb: false },
|
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: {
|
resolve: {
|
||||||
cashierTemplate: CashierTransactionTemplateResolver
|
cashierTemplate: CashierTransactionTemplateResolver
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import { ManageCurrenciesComponent } from './currencies/manage-currencies/manage
|
|||||||
import { CashiersComponent } from './tellers/cashiers/cashiers.component';
|
import { CashiersComponent } from './tellers/cashiers/cashiers.component';
|
||||||
import { TransactionsComponent } from './tellers/transactions/transactions.component';
|
import { TransactionsComponent } from './tellers/transactions/transactions.component';
|
||||||
import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component';
|
import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component';
|
||||||
|
import { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organization Module
|
* Organization Module
|
||||||
@@ -99,7 +100,8 @@ import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component
|
|||||||
ManageCurrenciesComponent,
|
ManageCurrenciesComponent,
|
||||||
CashiersComponent,
|
CashiersComponent,
|
||||||
TransactionsComponent,
|
TransactionsComponent,
|
||||||
SettleCashComponent
|
SettleCashComponent,
|
||||||
|
AllocateCashComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationModule { }
|
export class OrganizationModule { }
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ export class OrganizationService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Settle Cash.
|
* Settle Cash.
|
||||||
|
* Allocate Cash.
|
||||||
* @param {string} tellerId Teller Id.
|
* @param {string} tellerId Teller Id.
|
||||||
* @param {string} cashierId Cashier Id.
|
* @param {string} cashierId Cashier Id.
|
||||||
* @param {string} cashData Cash Data.
|
* @param {string} cashData Cash Data.
|
||||||
@@ -305,6 +306,11 @@ export class OrganizationService {
|
|||||||
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/settle`, cashData, {params: httpParams});
|
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/settle`, cashData, {params: httpParams});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allocateCash(tellerId: string, cashierId: string, cashData: any): Observable<any> {
|
||||||
|
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.
|
* @param {string} tellerId Teller ID of teller to be deleted.
|
||||||
* @returns {Observable<any>}
|
* @returns {Observable<any>}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="allocateCashForm" (ngSubmit)="submit()">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="2%" fxLayout.lt-md="column">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Office</mat-label>
|
||||||
|
<input matInput required formControlName="office">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Teller Name</mat-label>
|
||||||
|
<input matInput required formControlName="tellerName">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Cashier</mat-label>
|
||||||
|
<input matInput required formControlName="cashier">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Assignment Period</mat-label>
|
||||||
|
<input matInput formControlName="assignmentPeriod">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Date</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="cashDatePicker" required formControlName="txnDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="cashDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #cashDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="allocateCashForm.controls.txnDate.hasError('required')">
|
||||||
|
Date <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Currency</mat-label>
|
||||||
|
<mat-select required formControlName="currencyCode">
|
||||||
|
<mat-option *ngFor="let currency of cashierData.currencyOptions" [value]="currency.code">
|
||||||
|
{{ currency.name }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="allocateCashForm.controls.currencyCode.hasError('required')">
|
||||||
|
Currency <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Amount</mat-label>
|
||||||
|
<input matInput required formControlName="txnAmount">
|
||||||
|
<mat-error *ngIf="allocateCashForm.controls.txnAmount.hasError('required')">
|
||||||
|
Amount <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Notes/Comments</mat-label>
|
||||||
|
<input matInput required formControlName="txnNote">
|
||||||
|
<mat-error *ngIf="allocateCashForm.controls.txnNote.hasError('required')">
|
||||||
|
Notes/Comments <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
|
||||||
|
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||||
|
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
|
||||||
|
<button mat-raised-button color="primary" [disabled]="!allocateCashForm.valid">Submit</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -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<AllocateCashComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ AllocateCashComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(AllocateCashComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user