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:
Abhay Chawla
2018-08-06 01:45:16 +05:30
committed by GitHub
parent ca80e5eff4
commit 6cbc13abb1
8 changed files with 116 additions and 5 deletions
@@ -30,6 +30,7 @@ import { CreateRuleComponent } from './accounting-rules/create-rule/create-rule.
import { ViewRuleComponent } from './accounting-rules/view-rule/view-rule.component';
import { ViewAccountingRuleResolver } from './accounting-rules/view-rule/view-rule.resolver';
import { EditRuleComponent } from './accounting-rules/edit-rule/edit-rule.component';
import { PeriodicAccrualsComponent } from './periodic-accruals/periodic-accruals.component';
const routes: Routes = [
Route.withShell([
@@ -200,6 +201,11 @@ const routes: Routes = [
]
}
]
},
{
path: 'periodic-accruals',
component: PeriodicAccrualsComponent,
data: { title: extract('Periodic Accrual Accounting'), breadcrumb: 'Execute Periodic Accrual Accounting' }
}
]
}
+2 -4
View File
@@ -64,11 +64,9 @@
<p matLine>List of all accounting rules</p>
</mat-list-item>
<mat-list-item>
<mat-list-item [routerLink]="['/accounting/periodic-accruals']">
<mat-icon matListIcon>calendar_today</mat-icon>
<a matLine href="https://www.google.com">
Accruals
</a>
<h4 matLine>Accruals</h4>
<p matLine>Accrues income, expenses and liabilities as on the provided date</p>
</mat-list-item>
+3 -1
View File
@@ -28,6 +28,7 @@ import { AccountingRulesComponent } from './accounting-rules/accounting-rules.co
import { CreateRuleComponent } from './accounting-rules/create-rule/create-rule.component';
import { ViewRuleComponent } from './accounting-rules/view-rule/view-rule.component';
import { EditRuleComponent } from './accounting-rules/edit-rule/edit-rule.component';
import { PeriodicAccrualsComponent } from './periodic-accruals/periodic-accruals.component';
@NgModule({
imports: [
@@ -60,7 +61,8 @@ import { EditRuleComponent } from './accounting-rules/edit-rule/edit-rule.compon
AccountingRulesComponent,
CreateRuleComponent,
ViewRuleComponent,
EditRuleComponent
EditRuleComponent,
PeriodicAccrualsComponent
],
entryComponents: [
RevertTransactionComponent,
+4
View File
@@ -165,4 +165,8 @@ export class AccountingService {
return this.http.put(`/accountingrules/${accoutingRuleId}`, accountingRule);
}
executePeriodicAccruals(periodicAccruals: any) {
return this.http.post('/runaccruals', periodicAccruals);
}
}
@@ -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>&nbsp;&nbsp;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']);
});
}
}