{"version":3,"sources":["webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/api/FuelApi.ts"],"names":["FuelApi","http","rootPath","this","cancelTokenSource","pkCuaa","pagingParams","filter","filterArr","item_name","push","toUpperCase","item_code","get","params","offset","count","length","undefined","res","data","search","code","itemId","paging","fuelId","detailOut","put","post","delete"],"mappings":"uMASqBA,G,+BAMjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,EAChBC,KAAKC,kBAAoB,K,wGAItB,WAAeC,EAAgBC,EAA4BC,GAA3D,gGACGC,EAAY,GACdD,IACIA,EAAOE,WAAWD,EAAUE,KAAV,yBAAiCH,EAAOE,UAAUE,gBACpEJ,EAAOK,WAAWJ,EAAUE,KAAV,yBAAiCH,EAAOK,UAAUD,iBAJzE,SAQeR,KAAKF,KAAKY,IAAV,6DAAoER,EAApE,UAAoF,CAClGS,OAAQ,CACJC,OAAQT,EAAaS,OACrBC,MAAOV,EAAaU,MACpBT,OAAQC,EAAUS,OAAS,EAAIT,OAAYU,KAZhD,cAQGC,EARH,yBAeIA,EAAIC,MAfR,gD,mJAiBA,WAAqBf,EAAgBC,EAA4Be,GAAjE,gGACGd,EAAS,GACXc,GACAd,EAAOG,KAAP,yBAA8BW,IAH/B,SAKelB,KAAKF,KAAKY,IAAV,6DAAoER,EAApE,UAAoF,CAClGS,OAAQ,CACJP,OAAQA,EAAOU,OAASV,OAASW,EACjCH,OAAQT,EAAaS,OACrBC,MAAOV,EAAaU,SATzB,cAKGG,EALH,yBAYIA,EAAIC,MAZR,gD,sJAeA,WAAwBf,EAAgBiB,GAAxC,gGACGf,EAAS,GACXe,IACAA,EAAOA,EAAKX,cACZJ,EAAOG,KAAP,wBAA6BY,KAJ9B,SAMenB,KAAKF,KAAKY,IAAV,6DAAoER,EAApE,UAAoF,CAClGS,OAAQ,CACJP,OAAQA,EAAOU,OAASV,OAASW,EACjCH,OAAQ,EACRC,MAAO,KAVZ,cAMGG,EANH,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APR,gD","file":"js/chunk-2d21a431.7e517bcc.js","sourcesContent":["import { HTTPClient, propsToDate, propsToDatePaged } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { DateHelper } from '@abaco/web-components/src/components/DateUtils';\nimport axios, { CancelTokenSource } from \"axios\";\nimport { Fuel, FuelType, FuelOut, FuelFilter, FuelEditOut } from '../models/Fuel';\nimport { UnitOfMeasure } from '../models/UnitsOfMeasure';\nimport { parseDeclaredArea } from './utils';\nimport { PriceType } from '../models/Product';\n\nexport default class FuelApi {\n\n private http: HTTPClient;\n private rootPath: string;\n private cancelTokenSource: CancelTokenSource | null;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath;\n this.cancelTokenSource = null;\n }\n\n\n public async getFuels(pkCuaa: number, pagingParams: PagingParams, filter: FuelFilter | null): Promise> {\n const filterArr = [];\n if (filter) {\n if (filter.item_name) filterArr.push(`item_name like ${filter.item_name.toUpperCase()}`);\n if (filter.item_code) filterArr.push(`item_code like ${filter.item_code.toUpperCase()}`);\n }\n // filterArr.push(`is_shared eq 0`);\n // filterArr.push(`is_used eq 0`);\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels`, {\n params: {\n offset: pagingParams.offset,\n count: pagingParams.count,\n filter: filterArr.length > 0 ? filterArr : undefined,\n }\n });\n return res.data;\n }\n public async getFuelsSearch(pkCuaa: number, pagingParams: PagingParams, search: string): Promise> {\n const filter = [];\n if (search) {\n filter.push(`item_name like ${search}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: pagingParams.offset,\n count: pagingParams.count,\n }\n });\n return res.data;\n }\n\n public async getFuelsCodeCheck(pkCuaa: number, code: string | undefined): Promise> {\n const filter = [];\n if (code) {\n code = code.toUpperCase();\n filter.push(`^item_code eq ${code}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: 0,\n count: 0,\n }\n });\n return res.data;\n }\n public async getFuelsCodeCheckOnEdit(pkCuaa: number, itemId: number, code: string | undefined): Promise> {\n const filter = [];\n filter.push(`item_id ne ${itemId}`);\n if (code) {\n code = code.toUpperCase();\n filter.push(`^item_code eq ${code}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: 0,\n count: 0,\n }\n });\n return res.data;\n }\n\n public async getFuelTypes(paging: PagingParams): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/warehouse/fuel_types`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n }\n })\n\n return res.data;\n }\n\n public async getFuel(pkCuaa: number, fuelId: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels/${fuelId}`);\n return res.data;\n }\n public async editFuel(pkCuaa: number, fuelId: number, detailOut: FuelEditOut): Promise {\n const res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels/${fuelId}`, detailOut);\n return res.data;\n }\n public async insertFuel(pkCuaa: number, detailOut: FuelOut): Promise {\n const res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels`, detailOut);\n return res.data;\n }\n public async deleteFuel(pkCuaa: number, fuelId: number): Promise {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/fuels/${fuelId}`);\n return res.data;\n }\n\n public async getPriceType(paging: PagingParams): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/ref_prices/dictionary/price_type/FUEL`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n }\n })\n return res.data;\n }\n\n}\n"],"sourceRoot":""}