@@ -45,6 +45,7 @@ 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 { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.component';
|
||||||
import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component';
|
import { SettleCashComponent } from './tellers/settle-cash/settle-cash.component';
|
||||||
|
import { EditCashierComponent } from './tellers/edit-cashier/edit-cashier.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';
|
||||||
@@ -77,6 +78,7 @@ import { OfficeDatatablesResolver } from './offices/common-resolvers/office-data
|
|||||||
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 { CashierTransactionTemplateResolver } from './tellers/teller-transaction-template.resolver';
|
import { CashierTransactionTemplateResolver } from './tellers/teller-transaction-template.resolver';
|
||||||
|
import { EditCashierResolver } from './tellers/edit-cashier/edit-cashier.resolver';
|
||||||
|
|
||||||
/** Organization Routes */
|
/** Organization Routes */
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
@@ -332,7 +334,7 @@ const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'cashiers',
|
path: 'cashiers',
|
||||||
data: { title: extract('View Cashiers'), breadcrumb: 'View Cashiers', routeParamBreadcrumb: false },
|
data: { title: extract('Cashiers'), breadcrumb: 'Cashiers', routeParamBreadcrumb: false },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@@ -348,6 +350,7 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ViewCashierComponent,
|
component: ViewCashierComponent,
|
||||||
|
data: { title: extract('View Cashier'), breadcrumb: 'View Cashier', routeParamBreadcrumb: false },
|
||||||
resolve: {
|
resolve: {
|
||||||
cashier: CashierResolver
|
cashier: CashierResolver
|
||||||
}
|
}
|
||||||
@@ -372,6 +375,15 @@ const routes: Routes = [
|
|||||||
resolve: {
|
resolve: {
|
||||||
cashierTemplate: CashierTransactionTemplateResolver
|
cashierTemplate: CashierTransactionTemplateResolver
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: EditCashierComponent,
|
||||||
|
data: { title: extract('Edit Cashier'), breadcrumb: 'Edit', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
cashier: CashierResolver,
|
||||||
|
cashierTemplate: EditCashierResolver
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -516,7 +528,8 @@ const routes: Routes = [
|
|||||||
OfficeDatatableResolver,
|
OfficeDatatableResolver,
|
||||||
OfficeDatatablesResolver,
|
OfficeDatatablesResolver,
|
||||||
ManageFundsResolver,
|
ManageFundsResolver,
|
||||||
CashierTransactionTemplateResolver
|
CashierTransactionTemplateResolver,
|
||||||
|
EditCashierResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationRoutingModule { }
|
export class OrganizationRoutingModule { }
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ 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';
|
import { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.component';
|
||||||
|
import { EditCashierComponent } from './tellers/edit-cashier/edit-cashier.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organization Module
|
* Organization Module
|
||||||
@@ -101,7 +102,8 @@ import { AllocateCashComponent } from './tellers/allocate-cash/allocate-cash.com
|
|||||||
CashiersComponent,
|
CashiersComponent,
|
||||||
TransactionsComponent,
|
TransactionsComponent,
|
||||||
SettleCashComponent,
|
SettleCashComponent,
|
||||||
AllocateCashComponent
|
AllocateCashComponent,
|
||||||
|
EditCashierComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationModule { }
|
export class OrganizationModule { }
|
||||||
|
|||||||
@@ -311,6 +311,25 @@ export class OrganizationService {
|
|||||||
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/allocate`, cashData, {params: httpParams});
|
return this.http.post(`/tellers/${tellerId}/cashiers/${cashierId}/allocate`, cashData, {params: httpParams});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get Cashier Template.
|
||||||
|
* @param tellerId Teller ID.
|
||||||
|
* @returns {Observable<any>} Cashier template.
|
||||||
|
*/
|
||||||
|
getCashierTemplate(tellerId: string): Observable<any> {
|
||||||
|
return this.http.get(`/tellers/${tellerId}/cashiers/template`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Cashier.
|
||||||
|
* @param tellerId Teller Id.
|
||||||
|
* @param cashierId Cashier Id.
|
||||||
|
* @param cashierData Cashier data to be updated.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
updateCashier(tellerId: string, cashierId: string, cashierData: any): Observable<any> {
|
||||||
|
return this.http.put(`/tellers/${tellerId}/cashiers/${cashierId}`, cashierData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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,83 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="editCashierForm" (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 autofocus [value]="cashierData.template.officeName" disabled>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Teller Name</mat-label>
|
||||||
|
<input matInput required autofocus [value]="cashierData.data.tellerName" disabled>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%" *ngIf="isStaffId">
|
||||||
|
<mat-label>Cashier</mat-label>
|
||||||
|
<mat-select formControlName="staffId">
|
||||||
|
<mat-option *ngFor="let staff of cashierData.template.staffOptions" [value]="staff.id">
|
||||||
|
{{ staff.displayName }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%" *ngIf="!isStaffId">
|
||||||
|
<mat-label>Cashier</mat-label>
|
||||||
|
<mat-select formControlName="staffId" *ngIf="!isStaffId">
|
||||||
|
<mat-option [value]="cashierData.data.staffId">
|
||||||
|
Select Option
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>Description/Notes</mat-label>
|
||||||
|
<input matInput autofocus formControlName="description">
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>From</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="fromDatePicker" required formControlName="startDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="fromDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #fromDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="editCashierForm.controls.startDate.hasError('required')">
|
||||||
|
From Date <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="48%">
|
||||||
|
<mat-label>To</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="toDatePicker" required formControlName="endDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="toDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #toDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="editCashierForm.controls.endDate.hasError('required')">
|
||||||
|
To Date <strong>is required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div fxFlex="48%" style="padding-top: 10px;">
|
||||||
|
<mat-checkbox labelPosition="before" formControlName="isFullDay">
|
||||||
|
Full Day?
|
||||||
|
</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</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]="!editCashierForm.valid">Submit</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EditCashierComponent } from './edit-cashier.component';
|
||||||
|
|
||||||
|
describe('EditCashierComponent', () => {
|
||||||
|
let component: EditCashierComponent;
|
||||||
|
let fixture: ComponentFixture<EditCashierComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ EditCashierComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EditCashierComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/** Angular Imports. */
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { DatePipe } from '@angular/common';
|
||||||
|
|
||||||
|
/** Custom Services. */
|
||||||
|
import { OrganizationService } from 'app/organization/organization.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit Cashier component.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-edit-cashier',
|
||||||
|
templateUrl: './edit-cashier.component.html',
|
||||||
|
styleUrls: ['./edit-cashier.component.scss']
|
||||||
|
})
|
||||||
|
export class EditCashierComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Cashier Data. */
|
||||||
|
cashierData: any = new Object();
|
||||||
|
/** Edit cashier form. */
|
||||||
|
editCashierForm: FormGroup;
|
||||||
|
/** Is Staff ID present. */
|
||||||
|
isStaffId = true;
|
||||||
|
/** Minimum Date allowed. */
|
||||||
|
minDate = new Date(2000, 0, 1);
|
||||||
|
/** Maximum Date allowed. */
|
||||||
|
maxDate = new Date();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {FormBuilder} formBuilder Form Builder.
|
||||||
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
* @param {Router} router Router.
|
||||||
|
* @param {DatePipe} datePipe Date Pipe.
|
||||||
|
* @param {OrganizationService} organizationService Organization Service.
|
||||||
|
*/
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private datePipe: DatePipe,
|
||||||
|
private organizationService: OrganizationService ) {
|
||||||
|
this.route.data.subscribe((data: { cashier: any, cashierTemplate: any }) => {
|
||||||
|
this.cashierData.data = data.cashier;
|
||||||
|
this.cashierData.template = data.cashierTemplate;
|
||||||
|
this.isStaffId = this.cashierData.template.staffOptions.some((element: any) => element.id === this.cashierData.data.staffId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.setEditChargeForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Edit Charge Form.
|
||||||
|
*/
|
||||||
|
setEditChargeForm() {
|
||||||
|
this.editCashierForm = this.formBuilder.group({
|
||||||
|
'staffId': [{value: this.cashierData.data.staffId, disabled: true}],
|
||||||
|
'description': [this.cashierData.data.description],
|
||||||
|
'startDate': [this.cashierData.data.startDate && new Date(this.cashierData.data.startDate), Validators.required],
|
||||||
|
'endDate': [this.cashierData.data.endDate && new Date(this.cashierData.data.endDate), Validators.required],
|
||||||
|
'isFullDay': [this.cashierData.data.isFullDay, Validators.required]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits edit cashier form.
|
||||||
|
*/
|
||||||
|
submit() {
|
||||||
|
const dateFormat = 'yyyy-MM-dd';
|
||||||
|
const startDate = this.editCashierForm.value.startDate;
|
||||||
|
const endDate = this.editCashierForm.value.endDate;
|
||||||
|
this.editCashierForm.patchValue({
|
||||||
|
'startDate': this.datePipe.transform(startDate, dateFormat),
|
||||||
|
'endDate': this.datePipe.transform(endDate, dateFormat)
|
||||||
|
});
|
||||||
|
const editCashierForm = this.editCashierForm.value;
|
||||||
|
editCashierForm.locale = 'en';
|
||||||
|
editCashierForm.dateFormat = dateFormat;
|
||||||
|
editCashierForm.staffId = this.cashierData.data.staffId;
|
||||||
|
this.organizationService.updateCashier(this.cashierData.data.tellerId, this.cashierData.data.id, editCashierForm).subscribe((response: any) => {
|
||||||
|
this.router.navigate(['../'], {relativeTo: this.route});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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 { OrganizationService } from 'app/organization/organization.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cashier Template resolver.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class EditCashierResolver implements Resolve<Object> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OrganizationService} organizationService Organization service.
|
||||||
|
*/
|
||||||
|
constructor(private organizationService: OrganizationService) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the cashier template.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
const tellerId = route.parent.paramMap.get('id');
|
||||||
|
return this.organizationService.getCashierTemplate(tellerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||||
<button mat-raised-button color="primary">
|
<button mat-raised-button color="primary" [routerLink]="['edit']">
|
||||||
<fa-icon icon="edit"></fa-icon>
|
<fa-icon icon="edit"></fa-icon>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user