2018-05-25 13:49:00 +00:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {catchError} from 'rxjs/operators';
|
|
|
|
import {Observable} from 'rxjs/internal/Observable';
|
|
|
|
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
|
|
|
import {PurchaseEntries} from './purchase-entries';
|
|
|
|
import {ErrorLoggerService} from '../core/error-logger.service';
|
|
|
|
|
|
|
|
const httpOptions = {
|
|
|
|
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
|
|
|
};
|
|
|
|
|
2019-06-12 14:04:50 +00:00
|
|
|
const url = '/api/purchase-entries';
|
2018-05-25 13:49:00 +00:00
|
|
|
const serviceName = 'PurchaseEntriesService';
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class PurchaseEntriesService {
|
|
|
|
|
|
|
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
|
|
|
}
|
|
|
|
|
|
|
|
list(startDate: string, finishDate): Observable<PurchaseEntries> {
|
2020-05-11 22:22:25 +00:00
|
|
|
startDate = startDate ? `/${startDate}` : '';
|
|
|
|
finishDate = finishDate ? `/${finishDate}` : '';
|
|
|
|
return <Observable<PurchaseEntries>>this.http.get<PurchaseEntries>(`${url}${startDate}${finishDate}`)
|
2018-05-25 13:49:00 +00:00
|
|
|
.pipe(
|
|
|
|
catchError(this.log.handleError(serviceName, 'list'))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|