diff --git a/src/app/accounting/accounting-routing.module.ts b/src/app/accounting/accounting-routing.module.ts index 820dbaa18..aafc9642b 100644 --- a/src/app/accounting/accounting-routing.module.ts +++ b/src/app/accounting/accounting-routing.module.ts @@ -15,6 +15,7 @@ import { EditFinancialActivityMappingComponent } from './financial-activity-mapp import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts.component'; import { ChartOfAccountsResolver } from './chart-of-accounts/chart-of-accounts.resolver'; +import { CreateGlAccountComponent } from './chart-of-accounts/create-gl-account/create-gl-account.component'; const routes: Routes = [ Route.withShell([ @@ -84,11 +85,21 @@ const routes: Routes = [ }, { path: 'chart-of-accounts', - component: ChartOfAccountsComponent, data: { title: extract('Chart of Accounts'), breadcrumb: 'Chart of Accounts' }, - resolve: { - glAccountData: ChartOfAccountsResolver - } + children: [ + { + path: '', + component: ChartOfAccountsComponent, + resolve: { + glAccountData: ChartOfAccountsResolver + } + }, + { + path: 'gl-accounts/create', + component: CreateGlAccountComponent, + data: { title: extract('Create GL Account'), breadcrumb: 'Create GL Account' }, + } + ] } ] } diff --git a/src/app/accounting/accounting.module.ts b/src/app/accounting/accounting.module.ts index 5fb733c8c..384968cf2 100644 --- a/src/app/accounting/accounting.module.ts +++ b/src/app/accounting/accounting.module.ts @@ -16,6 +16,7 @@ import { CreateFinancialActivityMappingComponent } from './financial-activity-ma import { ViewFinancialActivityMappingComponent } from './financial-activity-mappings/view-financial-activity-mapping/view-financial-activity-mapping.component'; import { EditFinancialActivityMappingComponent } from './financial-activity-mappings/edit-financial-activity-mapping/edit-financial-activity-mapping.component'; import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts.component'; +import { CreateGlAccountComponent } from './chart-of-accounts/create-gl-account/create-gl-account.component'; @NgModule({ imports: [ @@ -37,7 +38,8 @@ import { ChartOfAccountsComponent } from './chart-of-accounts/chart-of-accounts. CreateFinancialActivityMappingComponent, ViewFinancialActivityMappingComponent, EditFinancialActivityMappingComponent, - ChartOfAccountsComponent + ChartOfAccountsComponent, + CreateGlAccountComponent ], entryComponents: [ RevertTransactionComponent, diff --git a/src/app/accounting/accounting.service.ts b/src/app/accounting/accounting.service.ts index a08e5bf18..d508b5811 100644 --- a/src/app/accounting/accounting.service.ts +++ b/src/app/accounting/accounting.service.ts @@ -100,4 +100,12 @@ export class AccountingService { return this.http.get('/glaccounts'); } + getChartOfAccountsTemplate() { + return this.http.get('/glaccounts/template'); + } + + createGlAccount(glAccount: any) { + return this.http.post('/glaccounts', glAccount); + } + } diff --git a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html index 8b7abb060..c0ae7a43a 100644 --- a/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html +++ b/src/app/accounting/chart-of-accounts/chart-of-accounts.component.html @@ -7,7 +7,7 @@ device_hub - diff --git a/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.html b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.html new file mode 100644 index 000000000..c7de4a3ef --- /dev/null +++ b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.html @@ -0,0 +1,74 @@ +
+ + + +
+ + + +
+ + + + + {{ accountType.value }} + + + + + + + + + + + + {{ accountUsage.value }} + + + + + + + + + + + + {{ parent.name }} + + + + + + + + {{ tag.name }} + + + + +
+ + Manual Entries Allowed + +
+ + + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.scss b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.scss new file mode 100644 index 000000000..f6d5d645e --- /dev/null +++ b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.scss @@ -0,0 +1,10 @@ +.manualEntriesAllowedWrapper { + position: relative; + + .manualEntriesAllowed { + padding: 0 0 17.5px 0; + position: absolute; + bottom: 0; + right: 0; + } +} diff --git a/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.spec.ts b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.spec.ts new file mode 100644 index 000000000..df3ddf366 --- /dev/null +++ b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateGlAccountComponent } from './create-gl-account.component'; + +describe('CreateGlAccountComponent', () => { + let component: CreateGlAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CreateGlAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateGlAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.ts b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.ts new file mode 100644 index 000000000..715f0db8f --- /dev/null +++ b/src/app/accounting/chart-of-accounts/create-gl-account/create-gl-account.component.ts @@ -0,0 +1,77 @@ +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { AccountingService } from '../../accounting.service'; + +@Component({ + selector: 'mifosx-create-gl-account', + templateUrl: './create-gl-account.component.html', + styleUrls: ['./create-gl-account.component.scss'] +}) +export class CreateGlAccountComponent implements OnInit { + + glAccountForm: FormGroup; + chartOfAccountsData: any; + accountTypeData: any; + parentData: any; + accountUsageData: any; + tagData: any; + + constructor(private formBuilder: FormBuilder, + private accountingService: AccountingService) { } + + ngOnInit() { + this.createGlAccountForm(); + this.getChartOfAccountsTemplate(); + this.setGLAccountForm(); + } + + createGlAccountForm() { + this.glAccountForm = this.formBuilder.group({ + 'type': ['', Validators.required], + 'name': ['', Validators.required], + 'usage': ['', Validators.required], + 'glCode': ['', Validators.required], + 'parentId': [''], + 'tagId': [''], + 'manualEntriesAllowed': [true, Validators.required], + 'description': [''] + }); + } + + getChartOfAccountsTemplate() { + this.accountingService.getChartOfAccountsTemplate().subscribe((chartOfAccountsData: any) => { + this.chartOfAccountsData = chartOfAccountsData; + this.accountTypeData = chartOfAccountsData.accountTypeOptions; + this.accountUsageData = chartOfAccountsData.usageOptions; + }); + } + + setGLAccountForm() { + this.glAccountForm.get('type').valueChanges.subscribe(accountTypeId => { + switch (accountTypeId) { + case 1: this.parentData = this.chartOfAccountsData.assetHeaderAccountOptions; + this.tagData = this.chartOfAccountsData.allowedAssetsTagOptions; + break; + case 2: this.parentData = this.chartOfAccountsData.liabilityHeaderAccountOptions; + this.tagData = this.chartOfAccountsData.allowedLiabilitiesTagOptions; + break; + case 3: this.parentData = this.chartOfAccountsData.equityHeaderAccountOptions; + this.tagData = this.chartOfAccountsData.allowedEquityTagOptions; + break; + case 4: this.parentData = this.chartOfAccountsData.incomeHeaderAccountOptions; + this.tagData = this.chartOfAccountsData.allowedIncomeTagOptions; + break; + case 5: this.parentData = this.chartOfAccountsData.expenseHeaderAccountOptions; + this.tagData = this.chartOfAccountsData.allowedExpensesTagOptions; + break; + } + }); + } + + submit() { + this.accountingService.createGlAccount(this.glAccountForm.value).subscribe(response => { + console.log(response); + }); + } + +}