{"version":3,"sources":["webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/models/UnitsOfMeasure.ts","webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/models/Product.ts","webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/api/SeedApi.ts","webpack:///./node_modules/@abaco/treatment-register-module/src/modules/treatment-register-module/models/Utils.ts"],"names":["HA_UNIT","copyUnitMeasure","list","from","to","forEach","r","SeedApi","http","rootPath","this","pk_cuaa","paging","filter","get","params","offset","count","toUpperCase","undefined","res","data","item_id","records","plot_id","action_id","action_resource_id","editedSeed","put","pkCuaa","protocol_id","newSeed","post","delete","campaign","execution_id","toHA","execution_resource_id","object","keys","key","path","split","lastKey","splice","length","join","ref","reduce","accum","k","console","warn","val","toPercentage","perc","Math","floor"],"mappings":"gHAAA,kCAAO,IAAMA,EAAU,U,kIC2OjB,SAAUC,EAAgBC,EAA8BC,EAAcC,GACpEF,GAGJA,EAAKG,SAAQ,SAAAC,GAAC,OAAIA,EAAEF,GAAME,EAAEH,Q,uKCxOXI,E,WAKjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,E,4GAGb,WAAmBE,EAAiBC,EAAsBC,GAA1D,uGACeH,KAAKF,KAAKM,IAAV,UAAiBJ,KAAKD,SAAtB,kCAAwDE,EAAxD,UAAyE,CACvFI,OAAQ,CACJC,OAAQJ,EAAOI,OACfC,MAAOL,EAAOK,MACdJ,OAAQA,EAAS,mBAAH,OAAsBA,EAAOK,oBAAkBC,KALlE,cACGC,EADH,yBASIA,EAAIC,MATR,gD,gJAYA,WAAkBV,EAAiBW,GAAnC,uGACeZ,KAAKF,KAAKM,IAAV,UAAiBJ,KAAKD,SAAtB,kCAAwDE,EAAxD,kBAAyEW,IADxF,cACGF,EADH,yBAGIA,EAAIC,MAHR,gD,iJAMA,oHACeX,KAAKF,KAAKM,IAAV,UAAiBJ,KAAKD,SAAtB,kCAAg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F,EAAKG,OAAOH,EAAKI,OAAS,EAAG,GAAGC,KAAK,IAC/CC,EAAMN,EAAKO,QAAO,SAACC,EAAOC,GAAR,OAAcD,EAAQA,EAAMC,GAAKD,IAAOX,GAChE,QAAYnB,IAAR4B,EACAI,QAAQC,KAAR,kCAAwCZ,EAAxC,+BACG,GAAY,OAARO,EAAc,CAErB,IAAMM,EAAMN,EAAIJ,GAChBI,EAAIJ,GAAWU,EAAM,QAa3B,SAAUC,EAAaC,GAEzB,OAAQC,KAAKC,MAAa,IAAPF,GAAgB,IAAO","file":"js/chunk-c2369856.ff73cf30.js","sourcesContent":["export const HA_UNIT = \"000001\";\n\nexport interface UnitOfMeaseureFamily {\n ext_code: string;\n cod_family: string;\n sco_family: string;\n ds_family: string;\n de_family: string;\n applicable_to_resource: number;\n}\n\nexport interface UnitOfMeasure {\n ext_code: string;\n sco_unit_of_measure: string;\n cod_unit_of_measure: string;\n ds_unit_of_measure: string;\n de_unit_of_measure: string;\n default_unimis: number;\n unit_of_measure_family_name: string;\n}\n\nexport interface UnitOfMeasureCollection {\n [family_name: string]: UnitOfMeasure[];\n}\n\nexport interface UnitConversion {\n conversion_sco: string;\n conversion_ext: string;\n factor: number;\n}\n\n","import { ActionItemIn } from './Action';\nimport { HA_UNIT } from './UnitsOfMeasure';\nimport { Stock, StockItemOut } from './Warehouse';\n\nexport interface ProductOut {\n description?: string;\n sco_unit_measure: string;\n sco_unit_measure_denominator?: string;\n quantity: number;\n area_covered?: number;\n item_id: number;\n}\n\nexport type GenOrUse = \"product_gen\" | \"product_use\" | \"harvest\" | \"delivery_in\" | \"delivery_out\";\n\nexport function toProductOut(p: Product): ProductOut {\n return {\n description: p.description || undefined,\n sco_unit_measure: p.unit_measure,\n sco_unit_measure_denominator: p.area_covered ? HA_UNIT : undefined,\n quantity: p.quantity,\n area_covered: p.area_covered || undefined,\n item_id: p.item_id,\n };\n}\n\nexport interface Product {\n description: string;\n quantity: number;\n item_id: number;\n action_id: number;\n area_covered: number;\n unit_measure: string;\n item_code: string;\n item_name: string;\n physical_quantity: string;\n ds_unit_measure: string;\n sco_unit_measure: string;\n action_resource_id: number;\n resource_type: string;\n unit_measure_denominator: string;\n stocked_lot_number?: string;\n stock?: Stock;\n}\n\nexport interface ProductAction extends ActionItemIn {\n itemId: number;\n stock: Stock;\n product: ProductType;\n}\n\nexport interface ProductActionOut {\n description?: string;\n sco_unit_measure: string;\n quantity: number;\n area_covered?: number;\n sco_uom_area?: string;\n item_id: number;\n warehouse_id: number | undefined;\n stocked_lot_id?: number;\n stocked_lot: StockItemOut;\n operation_type: string;\n}\n\nexport interface Harvest {\n sco_unit_measure: string;\n ds_unit_measure: string;\n quantity: number;\n area_covered: number;\n sco_uom_area: string;\n item_id?: number;\n product?: ProductType;\n warehouse_id?: number;\n physical_quantity?: string;\n}\nexport interface HarvestOut {\n sco_unit_measure: string;\n quantity: number;\n area_covered: number;\n sco_uom_area: string;\n item_id?: number;\n warehouse_id?: number;\n}\n\nexport interface HarvestIn {\n description: string;\n quantity: number;\n execution_id: number;\n execution_resource_id: number;\n fk_resource_id: number;\n physical_quantity: string;\n area_covered: number;\n unit_measure: string;\n ds_unit_measure: string;\n resource_type: string;\n resource_name: string;\n item_name: string;\n total_cost: number;\n dataset_type: string;\n}\n\nexport interface ProductType {\n item_id: number;\n item_code: string;\n physical_quantity: string;\n ds_unimis_family: string;\n manufacturer_id: number;\n manufacturer_code: string;\n item_name: string;\n unimis_family: string;\n is_used: number;\n is_shared: number;\n prices: Price[];\n last_update: Date;\n item_note: string;\n company_name: string;\n class_p_code: string;\n class_s_code: string;\n ds_class_code: string;\n}\n\nexport interface Price {\n currency: string;\n cod_price_type: string;\n pkid: number;\n unit_measure: string;\n ref_price: number;\n sco_currency: string;\n sco_unit_measure: string;\n price_type: string;\n is_cost: number;\n is_revenue: number;\n entity_type: string;\n entity_id: number;\n}\n\nexport function toProductAction(p: Product): ProductAction {\n return {\n area_covered: p.area_covered,\n description: p.description,\n ds_unit_measure: p.ds_unit_measure,\n quantity: p.quantity,\n unit_measure: p.sco_unit_measure,\n physical_quantity: p.physical_quantity,\n product: {\n item_id: p.item_id,\n item_name: p.item_name,\n item_code: p.item_code,\n } as ProductType,\n itemId: p.item_id\n } as ProductAction\n}\n\nexport function toProductActionOut(p: ProductAction, type: GenOrUse): ProductActionOut {\n return {\n description: p.description || undefined,\n sco_unit_measure: p.unit_measure,\n quantity: p.quantity,\n area_covered: p.area_covered || undefined,\n sco_uom_area: p.area_covered ? HA_UNIT : undefined,\n item_id: p.product?.item_id,\n warehouse_id: p.stock?.warehouse_id,\n stocked_lot_id: p.stock?.stocked_lot_id,\n stocked_lot: {\n lot_number: p.stock?.stocked_lot_number?p.stock?.stocked_lot_number:\"\"\n },\n operation_type: type === \"product_gen\" || type === \"delivery_in\" ? \"LOAD_ACTIVITY\" : \"UNLOAD_ACTIVITY\"\n }\n}\n\nexport function toHarvest(p: ProductAction): Harvest {\n return {\n area_covered: p.area_covered,\n item_id: p.product.item_id,\n product: p.product,\n quantity: p.quantity,\n sco_unit_measure: p.unit_measure,\n ds_unit_measure: p.ds_unit_measure,\n sco_uom_area: \"HA\",\n warehouse_id: p.stock?.warehouse_id,\n physical_quantity: p.physical_quantity\n }\n}\n\nexport function toHarvestOut(h: Harvest): HarvestOut{\n return {\n area_covered: h.area_covered,\n quantity: h.quantity,\n sco_unit_measure: h.sco_unit_measure,\n sco_uom_area: h.sco_uom_area,\n item_id: h.item_id,\n warehouse_id: h.warehouse_id\n }\n}\n\nexport function toDeliveryProductAction(p: ProductAction): ProductAction {\n return {\n product: p.product,\n description: p.description || undefined,\n sco_unit_measure: p.sco_unit_measure,\n ds_unit_measure: p.ds_unit_measure,\n unit_measure: p.sco_unit_measure,\n quantity: p.quantity,\n itemId: p.itemId,\n stock: {\n ...p.stock,\n warehouse_id: undefined,\n },\n area_covered: p.area_covered,\n execution_id: p.execution_id,\n dataset_type: p.dataset_type,\n execution_resource_id: p.execution_id,\n physical_quantity: p.physical_quantity,\n fk_resource_id: p.execution_id,\n resource_type: p.resource_type,\n resource_name: p.resource_name,\n total_cost: p.execution_id,\n }\n}\n// export function toDeliveryProductActionOut(p: ProductAction): any {\n// return {\n// description: p.description || undefined,\n// sco_unit_measure: p.sco_unit_measure,\n// quantity: p.quantity,\n// item_id: p.product?.item_id,\n// warehouse_id: undefined,\n// stocked_lot_id: p.stock?.stocked_lot_id,\n// stocked_lot: {\n// lot_number: p.stock?.stocked_lot_number\n// },\n// operation_type: \"LOAD_ACTIVITY\"\n// }\n// }\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function copyUnitMeasure(list: {[key: string]: any}[], from: string, to: string){\n if(!list){\n return;\n }\n list.forEach(r => r[to] = r[from]);\n}\n","import { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { ProtocolActivityResourceOut } from '../models/Activity';\nimport { Adveristy, SeedType, SeedOut, Seed, SeedActionOut, SeedAction } from '../models/Seed';\nimport { copyUnitMeasure } from '../models/Product';\nimport { toHA } from '../models/Utils';\n\nexport default class SeedApi {\n\n private http: HTTPClient;\n private rootPath: string;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath\n }\n\n public async getSeedTypes(pk_cuaa: number, paging: PagingParams, filter: string | null): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/warehouse/subjects/${pk_cuaa}/seeds`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n filter: filter ? `^item_name like ${filter.toUpperCase()}` : undefined\n }\n })\n\n return res.data;\n }\n\n public async getSeedType(pk_cuaa: number, item_id: number): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/warehouse/subjects/${pk_cuaa}/seeds/${item_id}`)\n\n return res.data;\n }\n\n public async getAdversities(): Promise {\n const res = await this.http.get(`${this.rootPath}/v1/plots/dictionary_adversity`, {\n params: {\n offset: 0,\n count: 300\n }\n })\n\n return res.data.records\n }\n\n public async editSeed(plot_id: number, action_id: number, action_resource_id: number, editedSeed: SeedOut): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/plots/plots/${plot_id}/activities/${action_id}/seed/${action_resource_id}`, editedSeed);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async editProtocolSeed(pkCuaa: number, protocol_id: number, action_id: number, action_resource_id: number, editedSeed: ProtocolActivityResourceOut): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/protocols/subjects/${pkCuaa}/dictionary_protocols/${protocol_id}/activities/${action_id}/seed/${action_resource_id}`, editedSeed);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async addSeed(plot_id: number, action_id: number, newSeed: SeedOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/plots/plots/${plot_id}/activities/${action_id}/seed`, newSeed);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async addProtocolSeed(pkCuaa: number, protocol_id: number, action_id: number, newSeed: SeedOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/protocols/subjects/${pkCuaa}/dictionary_protocols/${protocol_id}/activities/${action_id}/seed`, newSeed);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n\n public async deleteSeed(plot_id: number, action_id: number, action_resource_id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/plots/plots/${plot_id}/activities/${action_id}/seed/${action_resource_id}`);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async deleteProtocolSeed(pkCuaa: number, protocol_id: number, action_id: number, action_resource_id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/protocols/subjects/${pkCuaa}/dictionary_protocols/${protocol_id}/activities/${action_id}/seed/${action_resource_id}`);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async addActionSeed(pk_cuaa: number, campaign: number, execution_id: number, newSeed: SeedActionOut): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/plots/subjects/${pk_cuaa}/${campaign}/actions/${execution_id}/seed`, newSeed);\n toHA(res.data, ['area_covered']);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n public async editActionSeed(pk_cuaa: number, campaign: number, execution_id: number, execution_resource_id: number, editedSeed: SeedActionOut): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/plots/subjects/${pk_cuaa}/${campaign}/actions/${execution_id}/seed/${execution_resource_id}`, editedSeed);\n copyUnitMeasure([res.data], \"sco_unit_measure\", \"unit_measure\")\n return res.data;\n }\n\n public async deleteActionSeed(pk_cuaa: number, campaign: number, execution_id: number, execution_resource_id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/plots/subjects/${pk_cuaa}/${campaign}/actions/${execution_id}/seed/${execution_resource_id}`);\n return res.data;\n }\n}\n","import { TranslateResult } from \"vue-i18n\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function toHA(object: { [key: string]: any }, keys: string[]) {\n keys.forEach((key) => {\n const path = key.split(\".\");\n const lastKey = path.splice(path.length - 1, 1).join(\"\");\n const ref = path.reduce((accum, k) => accum ? accum[k] : accum, object);\n if (ref === undefined) {\n console.warn(`Invalid path to object, ${key} points to undefined `);\n } else if (ref !== null) {\n // Ignore null objects\n const val = ref[lastKey];\n ref[lastKey] = val / 10000;\n }\n });\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function toHAList(list: {[key: string]: any}[], keys: string[]): void {\n if(!list){\n return;\n }\n list.forEach(r => toHA(r, keys));\n}\n\nexport function toPercentage(perc: number): string{\n // due to 0.56 * 100 gives 0.5655000001, damn javascript!\n return (Math.floor(perc * 10000) / 100) + \" %\";\n}\n\n\n\nexport interface SelectionStep {\n component: string;\n isDisabled: boolean;\n title: string | TranslateResult;\n optional?: boolean;\n canNavigateToWarehouse?: boolean;\n}\n\n"],"sourceRoot":""}