feat(closing-entries): create closure component
Add create closure component to close accounting periodically.
This commit is contained in:
@@ -22,6 +22,7 @@ import { ViewGlAccountResolver } from './chart-of-accounts/view-gl-account/view-
|
|||||||
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
||||||
|
|
||||||
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
||||||
|
import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
Route.withShell([
|
Route.withShell([
|
||||||
@@ -131,8 +132,18 @@ const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'closing-entries',
|
path: 'closing-entries',
|
||||||
component: ClosingEntriesComponent,
|
data: { title: extract('Accounting Closures'), breadcrumb: 'Closing Entries' },
|
||||||
data: { title: extract('Accounting Closures'), breadcrumb: 'Closing Entries' }
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: ClosingEntriesComponent
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'create',
|
||||||
|
component: CreateClosureComponent,
|
||||||
|
data: { title: extract('Create Accounting Closure'), breadcrumb: 'Create' }
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { CreateGlAccountComponent } from './chart-of-accounts/create-gl-account/
|
|||||||
import { ViewGlAccountComponent } from './chart-of-accounts/view-gl-account/view-gl-account.component';
|
import { ViewGlAccountComponent } from './chart-of-accounts/view-gl-account/view-gl-account.component';
|
||||||
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component';
|
||||||
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
import { ClosingEntriesComponent } from './closing-entries/closing-entries.component';
|
||||||
|
import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -46,7 +47,8 @@ import { ClosingEntriesComponent } from './closing-entries/closing-entries.compo
|
|||||||
CreateGlAccountComponent,
|
CreateGlAccountComponent,
|
||||||
ViewGlAccountComponent,
|
ViewGlAccountComponent,
|
||||||
EditGlAccountComponent,
|
EditGlAccountComponent,
|
||||||
ClosingEntriesComponent
|
ClosingEntriesComponent,
|
||||||
|
CreateClosureComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
RevertTransactionComponent,
|
RevertTransactionComponent,
|
||||||
|
|||||||
@@ -125,4 +125,8 @@ export class AccountingService {
|
|||||||
return this.http.get('/glclosures');
|
return this.http.get('/glclosures');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createAccountingClosure(accountingClosure: any) {
|
||||||
|
return this.http.post('/glclosures', accountingClosure);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
<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> Create Closure
|
<mat-icon>add</mat-icon> Create Closure
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user