32 lines
1000 B
TypeScript
32 lines
1000 B
TypeScript
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { Observable } from 'rxjs';
|
|
import { catchError } from 'rxjs/operators';
|
|
|
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
|
|
|
import { TaxReport } from './tax-report';
|
|
|
|
const url = '/api/tax-report';
|
|
const serviceName = 'TaxReportService';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class TaxReportService {
|
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
|
|
|
get(startDate: string | null, finishDate: string | null): Observable<TaxReport> {
|
|
const options = { params: new HttpParams() };
|
|
if (startDate !== null) {
|
|
options.params = options.params.set('s', startDate);
|
|
}
|
|
if (finishDate !== null) {
|
|
options.params = options.params.set('f', finishDate);
|
|
}
|
|
return this.http
|
|
.get<TaxReport>(url, options)
|
|
.pipe(catchError(this.log.handleError(serviceName, 'get'))) as Observable<TaxReport>;
|
|
}
|
|
}
|