feat(closing-entries): create closure component

Add create closure component to close accounting periodically.
This commit is contained in:
Abhay Chawla
2018-08-04 23:03:39 +05:30
parent 3a676429f9
commit df3f9c7b8a
8 changed files with 144 additions and 4 deletions
@@ -1,5 +1,5 @@
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
<button mat-raised-button color="primary">
<button mat-raised-button color="primary" [routerLink]="['/accounting/closing-entries/create']">
<mat-icon>add</mat-icon>&nbsp;&nbsp;Create Closure
</button>
</div>
@@ -0,0 +1,42 @@
<div class="container">
<mat-card>
<form [formGroup]="accountingClosureForm" (ngSubmit)="submit()">
<mat-card-content>
<div fxLayout="column">
<mat-form-field>
<mat-select placeholder="Office" required formControlName="officeId">
<mat-option *ngFor="let office of officeData" [value]="office.id">
{{ office.name }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="closingDatePicker" placeholder="Closing Date" required formControlName="closingDate">
<mat-datepicker-toggle matSuffix [for]="closingDatePicker"></mat-datepicker-toggle>
<mat-datepicker #closingDatePicker></mat-datepicker>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Comments" formControlName="comments"></textarea>
</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/closing-entries']">Cancel</button>
<button mat-raised-button color="primary">Submit</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 { CreateClosureComponent } from './create-closure.component';
describe('CreateClosureComponent', () => {
let component: CreateClosureComponent;
let fixture: ComponentFixture<CreateClosureComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateClosureComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CreateClosureComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,53 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AccountingService } from '../../accounting.service';
@Component({
selector: 'mifosx-create-closure',
templateUrl: './create-closure.component.html',
styleUrls: ['./create-closure.component.scss']
})
export class CreateClosureComponent implements OnInit {
// TODO: Validations, Hints
minDate = new Date(2000, 0, 1);
maxDate = new Date();
accountingClosureForm: FormGroup;
officeData: any;
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService) { }
ngOnInit() {
this.createAccountingClosureForm();
this.getOffices();
}
createAccountingClosureForm() {
this.accountingClosureForm = this.formBuilder.group({
'officeId': ['', Validators.required],
'closingDate': ['', Validators.required],
'comments': ['']
});
}
getOffices() {
this.accountingService.getOffices().subscribe(officeData => {
this.officeData = officeData;
});
}
submit() {
const accountingClosure = this.accountingClosureForm.value;
// TODO: Update once language and date settings are setup
accountingClosure.locale = 'en';
accountingClosure.dateFormat = 'dd MMMM yyyy';
accountingClosure.closingDate = '4 August 2018';
this.accountingService.createAccountingClosure(accountingClosure).subscribe(response => {
console.log(response);
});
}
}