2020-10-10 03:15:05 +00:00
|
|
|
import { HttpClient } from '@angular/common/http';
|
2020-10-01 15:21:22 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs/internal/Observable';
|
2020-10-10 03:15:05 +00:00
|
|
|
import { catchError } from 'rxjs/operators';
|
|
|
|
|
2020-10-01 15:21:22 +00:00
|
|
|
import { ErrorLoggerService } from '../core/error-logger.service';
|
2018-05-25 13:49:00 +00:00
|
|
|
|
2020-10-10 03:15:05 +00:00
|
|
|
import { ProfitLoss } from './profit-loss';
|
2018-05-25 13:49:00 +00:00
|
|
|
|
2019-06-12 14:04:50 +00:00
|
|
|
const url = '/api/profit-loss';
|
2018-05-25 13:49:00 +00:00
|
|
|
const serviceName = 'ProfitLossService';
|
|
|
|
|
|
|
|
@Injectable({
|
2020-10-01 15:21:22 +00:00
|
|
|
providedIn: 'root',
|
2018-05-25 13:49:00 +00:00
|
|
|
})
|
|
|
|
export class ProfitLossService {
|
2020-10-01 15:21:22 +00:00
|
|
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
2018-05-25 13:49:00 +00:00
|
|
|
|
2020-11-23 11:12:54 +00:00
|
|
|
list(startDate: string | null, finishDate: string | null): Observable<ProfitLoss> {
|
2020-10-10 03:15:05 +00:00
|
|
|
const startDateWithSlash = startDate ? `/${startDate}` : '';
|
|
|
|
const finishDateWithSlash = finishDate ? `/${finishDate}` : '';
|
2020-12-08 06:39:19 +00:00
|
|
|
return this.http
|
|
|
|
.get<ProfitLoss>(`${url}${startDateWithSlash}${finishDateWithSlash}`)
|
|
|
|
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ProfitLoss>;
|
2018-05-25 13:49:00 +00:00
|
|
|
}
|
|
|
|
}
|