feat: edit, delete and enable/disable GL Account
Chart of Accounts: * Edit GL Account Component * Delete GL Account * Enable/Disable GL Account
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material';
|
||||
|
||||
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||
import { AccountingService } from '../../accounting.service';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-view-gl-account',
|
||||
@@ -10,7 +14,10 @@ export class ViewGlAccountComponent implements OnInit {
|
||||
|
||||
glAccount: any;
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private accountingService: AccountingService,
|
||||
private router: Router,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: { glAccount: any }) => {
|
||||
this.glAccount = data.glAccount;
|
||||
});
|
||||
@@ -19,4 +26,26 @@ export class ViewGlAccountComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
deleteGlAccount() {
|
||||
// TODO: (Validation) gl account cannot be deleted if it has transactions logged against it
|
||||
const deleteGlAccountDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `gl account ${this.glAccount.id}` }
|
||||
});
|
||||
deleteGlAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.accountingService.deleteGlAccount(this.glAccount.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/accounting/chart-of-accounts']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeGlAccountState() {
|
||||
this.accountingService.updateGlAccount(this.glAccount.id, { disabled: !this.glAccount.disabled })
|
||||
.subscribe((response: any) => {
|
||||
this.glAccount.disabled = response.changes.disabled;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user