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
@@ -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);
});
}
}