perbaikan cost management service

This commit is contained in:
2024-06-12 10:08:23 +07:00
parent 70d8993141
commit ef118ad33e
3 changed files with 66 additions and 53 deletions

View File

@@ -2,6 +2,8 @@ import { Injectable } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { Observable } from "rxjs";
const BASE_URL = 'https://kapi.absys.ninja/hemat';
@Injectable({
providedIn: "root",
})
@@ -9,7 +11,7 @@ export class CostManagementService {
constructor(private http: HttpClient) {}
getCostManagement(id, period, category): Observable<any> {
const baseUrl = `https://kapi.absys.ninja/hemat/cost_management`;
const endpoint = `/cost_management`;
const params = new URLSearchParams({
page: "1",
limit: "100",
@@ -19,31 +21,37 @@ export class CostManagementService {
if (category) {
params.append("category_id", category);
}
const url = `${baseUrl}?${params.toString()}`;
const url = `${BASE_URL}${endpoint}?${params.toString()}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
});
return this.http.get<any>(url, { headers });
}
getCompWaterElectCost(id): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/cost_management/card/comp-water-elect-cost?building_id=${id}`;
const endpoint = `/cost_management/card/comp-water-elect-cost`;
const url = `${BASE_URL}${endpoint}?building_id=${id}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
});
return this.http.get<any>(url, { headers });
}
getCompPrevMonthCost(id): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/cost_management/card/comp-prev-month-cost?building_id=${id}`;
const endpoint = `/cost_management/card/comp-prev-month-cost`;
const url = `${BASE_URL}${endpoint}?building_id=${id}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
});
return this.http.get<any>(url, { headers });
}
getCompActEstCost(id): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/cost_management/card/comp-act-est-cost?building_id=${id}`;
const endpoint = `/cost_management/card/comp-act-est-cost`;
const url = `${BASE_URL}${endpoint}?building_id=${id}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
@@ -52,7 +60,8 @@ export class CostManagementService {
}
getSyncCost(data: any): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/cost_management/cost/sync`;
const endpoint = `/cost_management/cost/sync`;
const url = `${BASE_URL}${endpoint}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",
@@ -61,7 +70,8 @@ export class CostManagementService {
}
getRealCostByBuildingId(id: any, period: any): Observable<any> {
const url = `https://kapi.absys.ninja/hemat/real-cost/get/byBuildingId?building_id=${id}&periode=${period}`;
const endpoint = `/real-cost/get/byBuildingId`;
const url = `${BASE_URL}${endpoint}?building_id=${id}&periode=${period}`;
const headers = new HttpHeaders({
"Content-Type": "application/json",
"x-api-key": "j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT",