Chore: Changed the account_type and voucher_type enum.

The account type enum is not stored in the database as an enum.
The voucher_type enum is now a table in the database.

Feature: Closing stock can now be saved and in each department.
This commit is contained in:
2021-10-31 18:41:06 +05:30
parent f8de1cd3cf
commit 0574f9df14
71 changed files with 1382 additions and 497 deletions

View File

@ -1,9 +1,10 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { Voucher } from '../core/voucher';
import { ClosingStock } from './closing-stock';
@ -16,10 +17,38 @@ const serviceName = 'ClosingStockService';
export class ClosingStockService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
list(date: string | null): Observable<ClosingStock> {
list(date: string | null, costCentre: string | null): Observable<ClosingStock> {
const listUrl = date === null ? url : `${url}/${date}`;
const options = { params: new HttpParams() };
if (costCentre !== null) {
options.params = options.params.set('d', costCentre);
}
return this.http
.get<ClosingStock>(listUrl)
.get<ClosingStock>(listUrl, options)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ClosingStock>;
}
save(closingStock: ClosingStock): Observable<ClosingStock> {
return this.http
.post<ClosingStock>(url, closingStock)
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<ClosingStock>;
}
post(date: string, costCentre: string): Observable<ClosingStock> {
const options = { params: new HttpParams().set('d', costCentre) };
return this.http
.post<ClosingStock>(`${url}/${date}`, {}, options)
.pipe(
catchError(this.log.handleError(serviceName, 'Post Voucher')),
) as Observable<ClosingStock>;
}
delete(date: string, costCentre: string): Observable<ClosingStock> {
const options = { params: new HttpParams().set('d', costCentre) };
return this.http
.delete<ClosingStock>(`${url}/${date}`, options)
.pipe(
catchError(this.log.handleError(serviceName, 'Delete Voucher')),
) as Observable<ClosingStock>;
}
}