feat(accounting): add periodic accruals component (#274)
Add periodic accruals component to execute periodic accrual accounting till a specified date.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="periodicAccrualsForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="row">
|
||||
|
||||
<mat-form-field fxFlex>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="tillDatePicker" placeholder="Accrue Till Date" required formControlName="tillDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="tillDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #tillDatePicker></mat-datepicker>
|
||||
</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]="['/accounting']">Cancel</button>
|
||||
<button mat-raised-button color="primary"><mat-icon>play_arrow</mat-icon> Run Periodic Accruals</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PeriodicAccrualsComponent } from './periodic-accruals.component';
|
||||
|
||||
describe('PeriodicAccrualsComponent', () => {
|
||||
let component: PeriodicAccrualsComponent;
|
||||
let fixture: ComponentFixture<PeriodicAccrualsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PeriodicAccrualsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PeriodicAccrualsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { AccountingService } from '../accounting.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-periodic-accruals',
|
||||
templateUrl: './periodic-accruals.component.html',
|
||||
styleUrls: ['./periodic-accruals.component.scss']
|
||||
})
|
||||
export class PeriodicAccrualsComponent implements OnInit {
|
||||
|
||||
minDate = new Date(2000, 0, 1);
|
||||
maxDate = new Date();
|
||||
periodicAccrualsForm: FormGroup;
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private accountingService: AccountingService,
|
||||
private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.createPeriodicAccrualsForm();
|
||||
}
|
||||
|
||||
createPeriodicAccrualsForm() {
|
||||
this.periodicAccrualsForm = this.formBuilder.group({
|
||||
'tillDate': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
submit() {
|
||||
const periodicAccruals = this.periodicAccrualsForm.value;
|
||||
// TODO: Update once language and date settings are setup
|
||||
periodicAccruals.locale = 'en';
|
||||
periodicAccruals.dateFormat = 'dd MMMM yyyy';
|
||||
periodicAccruals.tillDate = '06 August 2018';
|
||||
this.accountingService.executePeriodicAccruals(periodicAccruals).subscribe(response => {
|
||||
this.router.navigate(['/accounting']);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user