@@ -0,0 +1,82 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="settleCashForm" (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="settleCashForm.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="settleCashForm.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="settleCashForm.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="settleCashForm.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]="!settleCashForm.valid">Settle Cash</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SettleCashComponent } from './settle-cash.component';
|
||||
|
||||
describe('SettleCashComponent', () => {
|
||||
let component: SettleCashComponent;
|
||||
let fixture: ComponentFixture<SettleCashComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SettleCashComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SettleCashComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { OrganizationService } from 'app/organization/organization.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-settle-cash',
|
||||
templateUrl: './settle-cash.component.html',
|
||||
styleUrls: ['./settle-cash.component.scss']
|
||||
})
|
||||
export class SettleCashComponent implements OnInit {
|
||||
|
||||
/** Minimum Date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum Date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Cashier data. */
|
||||
cashierData: any;
|
||||
/** Cashier Form. */
|
||||
settleCashForm: 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.settleCashForm = 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 Settle Cash form.
|
||||
*/
|
||||
submit() {
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const txnDate = this.settleCashForm.value.txnDate;
|
||||
this.settleCashForm.patchValue({
|
||||
txnDate: this.datePipe.transform(txnDate, dateFormat)
|
||||
});
|
||||
const settleCashForm = this.settleCashForm.value;
|
||||
settleCashForm.dateFormat = dateFormat;
|
||||
settleCashForm.locale = 'en';
|
||||
this.organizationService.settleCash(this.cashierData.tellerId, this.cashierData.cashierId, settleCashForm).subscribe((response: any) => {
|
||||
this.router.navigate(['../'], {relativeTo: this.route});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/** 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 transaction data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class CashierTransactionTemplateResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
constructor(private organizationService: OrganizationService) {}
|
||||
|
||||
/**
|
||||
* Returns the cashier transaction data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const cashierId = route.parent.paramMap.get('id');
|
||||
const tellerId = route.parent.parent.paramMap.get('id');
|
||||
return this.organizationService.getCashierTransactionTemplate(tellerId, cashierId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user