feat(closing-entries): edit and delete closure
Add edit closure component and ability to delete an accounting closure to backdate a transaction.
This commit is contained in:
@@ -24,6 +24,7 @@ import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit
|
|||||||
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';
|
import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component';
|
||||||
import { ViewClosureComponent } from './closing-entries/view-closure/view-closure.component';
|
import { ViewClosureComponent } from './closing-entries/view-closure/view-closure.component';
|
||||||
|
import { EditClosureComponent } from './closing-entries/edit-closure/edit-closure.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
Route.withShell([
|
Route.withShell([
|
||||||
@@ -146,8 +147,18 @@ const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'view/:id',
|
path: 'view/:id',
|
||||||
component: ViewClosureComponent,
|
data: { title: extract('View Accounting Closure'), routeParamBreadcrumb: 'id' },
|
||||||
data: { title: extract('View Accounting Closure'), routeParamBreadcrumb: 'id' }
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: ViewClosureComponent
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: EditClosureComponent,
|
||||||
|
data: { title: extract('Edit Accounting Closure'), breadcrumb: 'Edit', routeParamBreadcrumb: false }
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { EditGlAccountComponent } from './chart-of-accounts/edit-gl-account/edit
|
|||||||
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';
|
import { CreateClosureComponent } from './closing-entries/create-closure/create-closure.component';
|
||||||
import { ViewClosureComponent } from './closing-entries/view-closure/view-closure.component';
|
import { ViewClosureComponent } from './closing-entries/view-closure/view-closure.component';
|
||||||
|
import { EditClosureComponent } from './closing-entries/edit-closure/edit-closure.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -50,7 +51,8 @@ import { ViewClosureComponent } from './closing-entries/view-closure/view-closur
|
|||||||
EditGlAccountComponent,
|
EditGlAccountComponent,
|
||||||
ClosingEntriesComponent,
|
ClosingEntriesComponent,
|
||||||
CreateClosureComponent,
|
CreateClosureComponent,
|
||||||
ViewClosureComponent
|
ViewClosureComponent,
|
||||||
|
EditClosureComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
RevertTransactionComponent,
|
RevertTransactionComponent,
|
||||||
|
|||||||
@@ -133,4 +133,12 @@ export class AccountingService {
|
|||||||
return this.http.get(`/glclosures/${accountingClosureId}`);
|
return this.http.get(`/glclosures/${accountingClosureId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteAccountingClosure(accountingClosureId: number) {
|
||||||
|
return this.http.delete(`/glclosures/${accountingClosureId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAccountingClosure(accountingClosureId: number, accountingClosure: any) {
|
||||||
|
return this.http.put(`/glclosures/${accountingClosureId}`, accountingClosure);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { AccountingService } from '../../accounting.service';
|
|||||||
})
|
})
|
||||||
export class CreateClosureComponent implements OnInit {
|
export class CreateClosureComponent implements OnInit {
|
||||||
|
|
||||||
// TODO: Validations, Hints
|
// TODO: Validations, Hints
|
||||||
|
|
||||||
minDate = new Date(2000, 0, 1);
|
minDate = new Date(2000, 0, 1);
|
||||||
maxDate = new Date();
|
maxDate = new Date();
|
||||||
|
|||||||
@@ -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 [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/view', accountingClosure?.id]">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 { EditClosureComponent } from './edit-closure.component';
|
||||||
|
|
||||||
|
describe('EditClosureComponent', () => {
|
||||||
|
let component: EditClosureComponent;
|
||||||
|
let fixture: ComponentFixture<EditClosureComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ EditClosureComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EditClosureComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
import { Router, ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
import { AccountingService } from '../../accounting.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-edit-closure',
|
||||||
|
templateUrl: './edit-closure.component.html',
|
||||||
|
styleUrls: ['./edit-closure.component.scss']
|
||||||
|
})
|
||||||
|
export class EditClosureComponent implements OnInit {
|
||||||
|
|
||||||
|
// TODO: Update once language and date settings are setup
|
||||||
|
|
||||||
|
accountingClosureForm: FormGroup;
|
||||||
|
accountingClosureId: number;
|
||||||
|
accountingClosure: any;
|
||||||
|
officeData: any;
|
||||||
|
|
||||||
|
constructor(private formBuilder: FormBuilder,
|
||||||
|
private accountingService: AccountingService,
|
||||||
|
private router: Router,
|
||||||
|
private route: ActivatedRoute) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.accountingClosureId = Number(this.route.snapshot.paramMap.get('id'));
|
||||||
|
this.createAccountingClosureForm();
|
||||||
|
this.getAccountingClosure();
|
||||||
|
this.getOffices();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAccountingClosure() {
|
||||||
|
this.accountingService.getAccountingClosure(this.accountingClosureId)
|
||||||
|
.subscribe((accountingClosure: any) => {
|
||||||
|
this.accountingClosure = accountingClosure;
|
||||||
|
this.accountingClosureForm.get('officeId').setValue(this.accountingClosure.officeId);
|
||||||
|
this.accountingClosureForm.get('closingDate').setValue(new Date());
|
||||||
|
this.accountingClosureForm.get('comments').setValue(this.accountingClosure.comments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createAccountingClosureForm() {
|
||||||
|
this.accountingClosureForm = this.formBuilder.group({
|
||||||
|
'officeId': [{ value: '', disabled: true }, Validators.required],
|
||||||
|
'closingDate': [{ value: '', disabled: true }, Validators.required],
|
||||||
|
'comments': ['']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getOffices() {
|
||||||
|
this.accountingService.getOffices().subscribe(officeData => {
|
||||||
|
this.officeData = officeData;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
this.accountingService.updateAccountingClosure(this.accountingClosureId, { comments: this.accountingClosureForm.value.comments })
|
||||||
|
.subscribe((response: any) => {
|
||||||
|
this.router.navigate(['/accounting/closing-entries/view', response.resourceId]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||||
|
<button mat-raised-button color="primary" [routerLink]="['/accounting/closing-entries/view', accountingClosure?.id, 'edit']">
|
||||||
|
<mat-icon>edit</mat-icon> Edit
|
||||||
|
</button>
|
||||||
<button mat-raised-button color="warn" (click)="deleteAccountingClosure()">
|
<button mat-raised-button color="warn" (click)="deleteAccountingClosure()">
|
||||||
<mat-icon>delete</mat-icon> Delete
|
<mat-icon>delete</mat-icon> Delete
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
|
||||||
import { AccountingService } from '../../accounting.service';
|
import { AccountingService } from '../../accounting.service';
|
||||||
|
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'mifosx-view-closure',
|
selector: 'mifosx-view-closure',
|
||||||
@@ -14,7 +16,9 @@ export class ViewClosureComponent implements OnInit {
|
|||||||
accountingClosure: any;
|
accountingClosure: any;
|
||||||
|
|
||||||
constructor(private accountingService: AccountingService,
|
constructor(private accountingService: AccountingService,
|
||||||
private route: ActivatedRoute) { }
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
public dialog: MatDialog) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.accountingClosureId = Number(this.route.snapshot.paramMap.get('id'));
|
this.accountingClosureId = Number(this.route.snapshot.paramMap.get('id'));
|
||||||
@@ -28,4 +32,18 @@ export class ViewClosureComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteAccountingClosure() {
|
||||||
|
const deleteAccountingClosureDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
|
data: { deleteContext: `accounting closure ${this.accountingClosureId}` }
|
||||||
|
});
|
||||||
|
deleteAccountingClosureDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.delete) {
|
||||||
|
this.accountingService.deleteAccountingClosure(this.accountingClosureId)
|
||||||
|
.subscribe(() => {
|
||||||
|
this.router.navigate(['/accounting/closing-entries']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user