Lazy loaded everything TODO: The cash flow module when clicking on sub-links, it reloads the whole page, it needs to be diagnosed and fixed, this problem also exists in the other modules TODO: Rename folders and modules such as account to accounts to match the url
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
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 {NetTransactions} from './net-transactions';
|
|
import {ErrorLoggerService} from '../core/error-logger.service';
|
|
|
|
const httpOptions = {
|
|
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
|
};
|
|
|
|
const url = '/api/net-transactions';
|
|
const serviceName = 'NetTransactionsService';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class NetTransactionsService {
|
|
|
|
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
|
}
|
|
|
|
list(startDate: string, finishDate): Observable<NetTransactions> {
|
|
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 <Observable<NetTransactions>>this.http.get<NetTransactions>(url, options)
|
|
.pipe(
|
|
catchError(this.log.handleError(serviceName, 'list'))
|
|
);
|
|
}
|
|
|
|
}
|