From df3f9c7b8a0fb9b42a28032cb77d80892b63c4f7 Mon Sep 17 00:00:00 2001 From: Abhay Chawla Date: Sat, 4 Aug 2018 20:34:08 +0530 Subject: [PATCH] feat(closing-entries): create closure component Add create closure component to close accounting periodically. --- .../accounting/accounting-routing.module.ts | 15 +++++- src/app/accounting/accounting.module.ts | 4 +- src/app/accounting/accounting.service.ts | 4 ++ .../closing-entries.component.html | 2 +- .../create-closure.component.html | 42 +++++++++++++++ .../create-closure.component.scss | 3 ++ .../create-closure.component.spec.ts | 25 +++++++++ .../create-closure.component.ts | 53 +++++++++++++++++++ 8 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 src/app/accounting/closing-entries/create-closure/create-closure.component.html create mode 100644 src/app/accounting/closing-entries/create-closure/create-closure.component.scss create mode 100644 src/app/accounting/closing-entries/create-closure/create-closure.component.spec.ts create mode 100644 src/app/accounting/closing-entries/create-closure/create-closure.component.ts diff --git a/src/app/accounting/accounting-routing.module.ts b/src/app/accounting/accounting-routing.module.ts index c1d377c51..980396ba5 100644 --- a/src/app/accounting/accounting-routing.module.ts +++ b/src/app/accounting/accounting-routing.module.ts @@ -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 { ClosingEntriesComponent } from './closing-entries/closing-entries.component'; +import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component'; const routes: Routes = [ Route.withShell([ @@ -131,8 +132,18 @@ const routes: Routes = [ }, { 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' } + } + ] } ] } diff --git a/src/app/accounting/accounting.module.ts b/src/app/accounting/accounting.module.ts index 0d73f1ed0..5a812e1ba 100644 --- a/src/app/accounting/accounting.module.ts +++ b/src/app/accounting/accounting.module.ts @@ -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 { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit-gl-account.component'; import { ClosingEntriesComponent } from './closing-entries/closing-entries.component'; +import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component'; @NgModule({ imports: [ @@ -46,7 +47,8 @@ import { ClosingEntriesComponent } from './closing-entries/closing-entries.compo CreateGlAccountComponent, ViewGlAccountComponent, EditGlAccountComponent, - ClosingEntriesComponent + ClosingEntriesComponent, + CreateClosureComponent ], entryComponents: [ RevertTransactionComponent, diff --git a/src/app/accounting/accounting.service.ts b/src/app/accounting/accounting.service.ts index 760986b12..0c9eff787 100644 --- a/src/app/accounting/accounting.service.ts +++ b/src/app/accounting/accounting.service.ts @@ -125,4 +125,8 @@ export class AccountingService { return this.http.get('/glclosures'); } + createAccountingClosure(accountingClosure: any) { + return this.http.post('/glclosures', accountingClosure); + } + } diff --git a/src/app/accounting/closing-entries/closing-entries.component.html b/src/app/accounting/closing-entries/closing-entries.component.html index 6e9ac6c51..7d887986e 100644 --- a/src/app/accounting/closing-entries/closing-entries.component.html +++ b/src/app/accounting/closing-entries/closing-entries.component.html @@ -1,5 +1,5 @@
-
diff --git a/src/app/accounting/closing-entries/create-closure/create-closure.component.html b/src/app/accounting/closing-entries/create-closure/create-closure.component.html new file mode 100644 index 000000000..2b5d45afb --- /dev/null +++ b/src/app/accounting/closing-entries/create-closure/create-closure.component.html @@ -0,0 +1,42 @@ +
+ + + +
+ + + +
+ + + + + {{ office.name }} + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/accounting/closing-entries/create-closure/create-closure.component.scss b/src/app/accounting/closing-entries/create-closure/create-closure.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/accounting/closing-entries/create-closure/create-closure.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/accounting/closing-entries/create-closure/create-closure.component.spec.ts b/src/app/accounting/closing-entries/create-closure/create-closure.component.spec.ts new file mode 100644 index 000000000..5057e46b7 --- /dev/null +++ b/src/app/accounting/closing-entries/create-closure/create-closure.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CreateClosureComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateClosureComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/accounting/closing-entries/create-closure/create-closure.component.ts b/src/app/accounting/closing-entries/create-closure/create-closure.component.ts new file mode 100644 index 000000000..3eb78e59a --- /dev/null +++ b/src/app/accounting/closing-entries/create-closure/create-closure.component.ts @@ -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); + }); + } + +}