Consolidated commit message to v22 signals

This commit is contained in:
2026-08-25 14:45:09 +00:00
parent 6403d25d3e
commit df289b20b8
443 changed files with 16058 additions and 17332 deletions
@@ -1,5 +1,5 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { HttpClient, httpResource, HttpParams } from '@angular/common/http';
import { inject, Injectable, Signal } from '@angular/core';
import { Observable } from 'rxjs/internal/Observable';
import { catchError } from 'rxjs/operators';
@@ -7,8 +7,6 @@ import { ErrorLoggerService } from '../core/error-logger.service';
import { ClosingStock } from './closing-stock';
const url = '/api/closing-stock';
const serviceName = 'ClosingStockService';
@Injectable({
providedIn: 'root',
})
@@ -16,34 +14,33 @@ export class ClosingStockService {
private http = inject(HttpClient);
private log = inject(ErrorLoggerService);
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, options)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ClosingStock>;
list(date: Signal<string | null>, costCentre: Signal<string | null>) {
return httpResource<ClosingStock>(() => {
const listUrl = date() === null ? url : `${url}/${date()}`;
const params: Record<string, string> = {};
const costCentre_val = costCentre();
if (costCentre_val !== null) params['d'] = costCentre_val;
return { url: listUrl, params };
});
}
save(closingStock: ClosingStock): Observable<ClosingStock> {
return this.http
.post<ClosingStock>(url, closingStock)
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<ClosingStock>;
.pipe(catchError(this.log.handleError('ClosingStockService', '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>;
.pipe(catchError(this.log.handleError('ClosingStockService', '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>;
.pipe(catchError(this.log.handleError('ClosingStockService', 'Delete Voucher'))) as Observable<ClosingStock>;
}
}