feat: create financial activity mapping component
Add create financial activity mapping component to define mapping between financial activity and account.
This commit is contained in:
@@ -8,6 +8,7 @@ import { ViewTransactionComponent } from './view-transaction/view-transaction.co
|
||||
import { CreateJournalEntryComponent } from './create-journal-entry/create-journal-entry.component';
|
||||
import { SearchJournalEntryComponent } from './search-journal-entry/search-journal-entry.component';
|
||||
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
|
||||
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
|
||||
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
@@ -47,8 +48,18 @@ const routes: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'financial-activity-mappings',
|
||||
component: FinancialActivityMappingsComponent,
|
||||
data: { title: extract('Financial Activity Mappings'), breadcrumb: 'Financial Activity Mappings' }
|
||||
data: { title: extract('Financial Activity Mappings'), breadcrumb: 'Financial Activity Mappings' },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: FinancialActivityMappingsComponent
|
||||
},
|
||||
{
|
||||
path: 'create',
|
||||
component: CreateFinancialActivityMappingComponent,
|
||||
data: { title: extract('Create Financial Activity Mapping'), breadcrumb: 'Create' },
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { CoreModule } from '../core/core.module';
|
||||
import { AccountingComponent } from './accounting.component';
|
||||
@@ -12,11 +12,13 @@ import { ViewJournalEntryComponent } from './view-journal-entry/view-journal-ent
|
||||
import { CreateJournalEntryComponent } from './create-journal-entry/create-journal-entry.component';
|
||||
import { SearchJournalEntryComponent } from './search-journal-entry/search-journal-entry.component';
|
||||
import { FinancialActivityMappingsComponent } from './financial-activity-mappings/financial-activity-mappings.component';
|
||||
import { CreateFinancialActivityMappingComponent } from './financial-activity-mappings/create-financial-activity-mapping/create-financial-activity-mapping.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
AccountingRoutingModule
|
||||
],
|
||||
@@ -28,7 +30,8 @@ import { FinancialActivityMappingsComponent } from './financial-activity-mapping
|
||||
ViewJournalEntryComponent,
|
||||
CreateJournalEntryComponent,
|
||||
SearchJournalEntryComponent,
|
||||
FinancialActivityMappingsComponent
|
||||
FinancialActivityMappingsComponent,
|
||||
CreateFinancialActivityMappingComponent
|
||||
],
|
||||
entryComponents: [
|
||||
RevertTransactionComponent,
|
||||
|
||||
@@ -75,4 +75,12 @@ export class AccountingService {
|
||||
return this.http.get('/financialactivityaccounts');
|
||||
}
|
||||
|
||||
getFinancialActivityAccountsTemplate() {
|
||||
return this.http.get('/financialactivityaccounts/template');
|
||||
}
|
||||
|
||||
createFinancialActivityAccount(financialActivityAccount: any) {
|
||||
return this.http.post('/financialactivityaccounts', financialActivityAccount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<mat-card class="container">
|
||||
<form [formGroup]="financialActivityMappingForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Financial Activity" required formControlName="financialActivityId">
|
||||
<mat-option *ngFor="let financialActivity of financialActivityData" [value]="financialActivity.id">
|
||||
{{ financialActivity.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Account" required formControlName="glAccountId">
|
||||
<mat-option *ngFor="let glAccount of glAccountData" [value]="glAccount.id">
|
||||
{{ glAccount.name + ' (' + glAccount.glCode + ')' }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</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/financial-activity-mappings']">Cancel</button>
|
||||
<button mat-raised-button color="primary">Submit</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CreateFinancialActivityMappingComponent } from './create-financial-activity-mapping.component';
|
||||
|
||||
describe('CreateFinancialActivityMappingComponent', () => {
|
||||
let component: CreateFinancialActivityMappingComponent;
|
||||
let fixture: ComponentFixture<CreateFinancialActivityMappingComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CreateFinancialActivityMappingComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CreateFinancialActivityMappingComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-create-financial-activity-mapping',
|
||||
templateUrl: './create-financial-activity-mapping.component.html',
|
||||
styleUrls: ['./create-financial-activity-mapping.component.scss']
|
||||
})
|
||||
export class CreateFinancialActivityMappingComponent implements OnInit {
|
||||
|
||||
financialActivityMappingForm: FormGroup;
|
||||
glAccountOptions: any;
|
||||
glAccountData: any;
|
||||
financialActivityData: any;
|
||||
|
||||
constructor(private formBuider: FormBuilder,
|
||||
private accountingService: AccountingService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.createFinancialActivityMappingForm();
|
||||
this.getFinancialActivityAccountsTemplate();
|
||||
this.setGLAccountData();
|
||||
}
|
||||
|
||||
createFinancialActivityMappingForm() {
|
||||
this.financialActivityMappingForm = this.formBuider.group({
|
||||
'financialActivityId': ['', Validators.required],
|
||||
'glAccountId': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
getFinancialActivityAccountsTemplate() {
|
||||
this.accountingService.getFinancialActivityAccountsTemplate().subscribe((financialActivityAccountData: any) => {
|
||||
this.glAccountOptions = financialActivityAccountData.glAccountOptions;
|
||||
this.financialActivityData = financialActivityAccountData.financialActivityOptions;
|
||||
});
|
||||
}
|
||||
|
||||
setGLAccountData() {
|
||||
this.financialActivityMappingForm.get('financialActivityId').valueChanges.subscribe(financialActivityId => {
|
||||
switch (financialActivityId) {
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103: this.glAccountData = this.glAccountOptions.assetAccountOptions;
|
||||
break;
|
||||
case 200:
|
||||
case 201: this.glAccountData = this.glAccountOptions.liabilityAccountOptions;
|
||||
break;
|
||||
case 300: this.glAccountData = this.glAccountOptions.equityAccountOptions;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.accountingService.createFinancialActivityAccount(this.financialActivityMappingForm.value)
|
||||
.subscribe(response => {
|
||||
console.log(response);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<div fxLayout="row" fxLayoutAlign="end" class="container m-b-20">
|
||||
<button mat-raised-button color="primary">
|
||||
<button mat-raised-button color="primary" [routerLink]="['/accounting/financial-activity-mappings/create']">
|
||||
<mat-icon>add</mat-icon> Define New Mapping
|
||||
</button>
|
||||
</div>
|
||||
|
||||
-1
@@ -35,7 +35,6 @@ export class FinancialActivityMappingsComponent implements OnInit {
|
||||
}
|
||||
};
|
||||
this.dataSource.sort = this.sort;
|
||||
console.log(financialActivityAccounts);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user