{"version":3,"sources":["webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/api/WaterApi.ts"],"names":["WaterApi","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","waterId","detailOut","put","post","delete"],"mappings":"yMASqBA,G,+BAMjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,EAChBC,KAAKC,kBAAoB,K,yGAItB,WAAgBC,EAAgBC,EAA4BC,GAA5D,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,WAAqF,CACnGS,OAAQ,CACJC,OAAQT,EAAaS,OACrBC,MAAOV,EAAaU,MACpBT,OAAQC,EAAUS,OAAS,EAAIT,OAAYU,KAZhD,cAQGC,EARH,yBAeIA,EAAIC,MAfR,gD,oJAiBA,WAAsBf,EAAgBC,EAA4Be,GAAlE,gGACGd,EAAS,GACXc,GACAd,EAAOG,KAAP,yBAA8BW,IAH/B,SAKelB,KAAKF,KAAKY,IAAV,6DAAoER,EAApE,WAAqF,CACnGS,OAAQ,CACJP,OAAQA,EAAOU,OAASV,OAASW,EACjCH,OAAQT,EAAaS,OACrBC,MAAOV,EAAaU,SATzB,cAKGG,EALH,yBAYIA,EAAIC,MAZR,gD,uJAeA,WAAyBf,EAAgBiB,GAAzC,gGACGf,EAAS,GACXe,IACAA,EAAOA,EAAKX,cACZJ,EAAOG,KAAP,wBAA6BY,KAJ9B,SAMenB,KAAKF,KAAKY,IAAV,6DAAoER,EAApE,WAAqF,CACnGS,OAAQ,CACJP,OAAQA,EAAOU,OAASV,OAASW,EACjCH,OAAQ,EACRC,MAAO,KAVZ,cAMGG,EANH,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MAPR,gD","file":"js/chunk-2d0aecfa.e22be483.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 { Water, WaterType, WaterOut, WaterFilter, WaterEditOut } from '../models/Water';\nimport { UnitOfMeasure } from '../models/UnitsOfMeasure';\nimport { parseDeclaredArea } from './utils';\nimport { PriceType } from '../models/Product';\n\nexport default class WaterApi {\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 getWaters(pkCuaa: number, pagingParams: PagingParams, filter: WaterFilter | 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}/waters`, {\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 getWatersSearch(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}/waters`, {\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 getWatersCodeCheck(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}/waters`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: 0,\n count: 0,\n }\n });\n return res.data;\n }\n public async getWatersCodeCheckOnEdit(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}/waters`, {\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 getWaterTypes(paging: PagingParams): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/warehouse/water_types`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n }\n })\n\n return res.data;\n }\n\n public async getWater(pkCuaa: number, waterId: number): Promise {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/waters/${waterId}`);\n return res.data;\n }\n public async editWater(pkCuaa: number, waterId: number, detailOut: WaterEditOut): Promise {\n const res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/waters/${waterId}`, detailOut);\n return res.data;\n }\n public async insertWater(pkCuaa: number, detailOut: WaterOut): Promise {\n const res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/waters`, detailOut);\n return res.data;\n }\n public async deleteWater(pkCuaa: number, waterId: number): Promise {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/warehouse/subjects/${pkCuaa}/waters/${waterId}`);\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/WATER`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n }\n })\n return res.data;\n }\n\n}\n"],"sourceRoot":""}