{"version":3,"sources":["webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/api/MovementApi.ts","webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/models/Movement.ts"],"names":["MovementApi","http","rootPath","this","pkCuaa","warehouseId","itemId","stockedLotNumber","paging","sortDesc","url","filterArr","push","params","filter","count","offset","sort","get","res","propsToDatePaged","data","records","forEach","mv","delivery_notes","dn","propsToDate","ACTIVITY_TYPES","delete","detailOut","put","toMovementOut","e","operation_date","quantity","undefined","sco_unit_measure","is_load","operation_desc_key","operation_type","operation_desc"],"mappings":"qRAIqBA,E,WAKjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,E,4GAGb,WAAmBE,EAAgBC,EAAqBC,EAAgBC,EAAiCC,EAAsBC,GAA/H,oGACGC,EADH,UACYP,KAAKD,SADjB,kCACmDE,EADnD,uBACwEC,EADxE,WAEGM,EAAY,GAClBA,EAAUC,KAAV,qBAA6BN,IACzBC,EACCI,EAAUC,KAAV,gCAAwCL,IAExCI,EAAUC,KAAV,0BAECC,EAAS,CACXC,OAAQH,EACRI,MAAOP,EAAOO,MACdC,OAAQR,EAAOQ,OACfC,KAAMR,EAAW,kBAAoB,mBAbtC,SAeeN,KAAKF,KAAKiB,IAAIR,EAAK,CAACG,WAfnC,cAeGM,EAfH,OAgBHC,eAAiBD,EAAIE,KAAM,CAAC,mBAC5BF,EAAIE,KAAKC,QAAQC,SAAQ,SAACC,GACtBA,EAAGC,eAAeF,SAAQ,SAAAG,GAAE,OAAIC,eAAYD,EAAI,CAAC,kBAlBlD,kBAoBIP,EAAIE,MApBR,iD,2JAuBA,+GACGX,EADH,UACYP,KAAKD,SADjB,4CAEGW,EAAS,CACXE,MAAO,IACPC,OAAQ,GAJT,SAMeb,KAAKF,KAAKiB,IAAIR,EAAK,CAACG,WANnC,cAMGM,EANH,OAOHA,EAAIE,KAAJ,yBAAgBF,EAAIE,MAApB,eAA6BO,SAP1B,kBAQIT,EAAIE,MARR,gD,8IAWA,WAAqBjB,EAAgBC,EAAqBC,GAA1D,uGACeH,KAAKF,KAAK4B,OAAV,UAAoB1B,KAAKD,SAAzB,kCAA2DE,EAA3D,uBAAgFC,EAAhF,2BAA8GC,IAD7H,cACGa,EADH,yBAEIA,EAAIE,MAFR,gD,iJAKA,WAAmBjB,EAAgBC,EAAqBC,EAAgBwB,GAAxE,uGACe3B,KAAKF,KAAK8B,IAAV,UAAiB5B,KAAKD,SAAtB,kCAAwDE,EAAxD,uBAA6EC,EAA7E,2BAA2GC,GAAUwB,GADpI,cACGX,EADH,yBAEIA,EAAIE,MAFR,gD,0GCyEL,SAAUW,EAAcC,GAC1B,MAAO,CACHC,eAAgBD,EAAEC,eAAiBD,EAAEC,eAAiB,KACtDC,SAAUF,EAAEE,SAAWF,EAAEE,cAAWC,EACpCC,iBAAkBJ,EAAEI,iBAAmBJ,EAAEI,sBAAmBD,GAJpE,oEAQO,IAAMR,EAAiB,CAC1B,CACIU,QAAS,EACTC,mBAAoB,yCACpBC,eAAgB,gBAChBC,eAAgB,IAEpB,CACIH,QAAS,EACTC,mBAAoB,2CACpBC,eAAgB,kBAChBC,eAAgB","file":"js/chunk-48b145d4.fa95e70f.js","sourcesContent":["import { HTTPClient, propsToDate, propsToDatePaged } from \"@abaco/web-common/src/HTTP\";\nimport { PagedResults, PagingParams } from \"@abaco/web-common/src/Paging\";\nimport { ACTIVITY_TYPES, Movement, MovementOut, MovementType } from \"../models/Movement\";\n\nexport default class MovementApi{\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 getMovements(pkCuaa: number, warehouseId: number, itemId: number, stockedLotNumber: string | null, paging: PagingParams, sortDesc: boolean): Promise>{\n const url = `${this.rootPath}/v1/warehouse/subjects/${pkCuaa}/warehouses/${warehouseId}/stocks`;\n const filterArr = [];\n filterArr.push(`item_id eq ${itemId}`);\n if (stockedLotNumber) {\n filterArr.push(`stocked_lot_number eq ${stockedLotNumber}`);\n } else {\n filterArr.push(`stocked_lot_number eq `);\n }\n const params = {\n filter: filterArr,\n count: paging.count,\n offset: paging.offset,\n sort: sortDesc ? '-operation_date' : '+operation_date',\n }\n const res = await this.http.get(url, {params});\n propsToDatePaged(res.data, [\"operation_date\"])\n res.data.records.forEach((mv: Movement) => {\n mv.delivery_notes.forEach(dn => propsToDate(dn, [\"dn_date\"]))\n });\n return res.data;\n }\n\n public async getMovementsType(): Promise{\n const url = `${this.rootPath}/v1/warehouse/dictionary/operation_types`;\n const params = {\n count: 300,\n offset: 0\n }\n const res = await this.http.get(url, {params});\n res.data = [... res.data, ...ACTIVITY_TYPES];\n return res.data;\n }\n\n public async deleteMovement(pkCuaa: number, warehouseId: number, itemId: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/warehouse/subjects/${pkCuaa}/warehouses/${warehouseId}/stock_movement/${itemId}`);\n return res.data;\n }\n\n public async editMovement(pkCuaa: number, warehouseId: number, itemId: number, detailOut: MovementOut): Promise {\n const res = await this.http.put(`${this.rootPath}/v1/warehouse/subjects/${pkCuaa}/warehouses/${warehouseId}/stock_movement/${itemId}`, detailOut);\n return res.data;\n }\n\n}\n","export interface Barcode {\n id_stampa_log: number;\n print_hash: string;\n fg_active: number;\n validity_date: Date;\n stock_document_id: number;\n}\n\nexport interface Person {\n address: string;\n name: string;\n last_update: Date;\n company_code: string;\n fiscal_code: string;\n vat_number: string;\n full_name: string;\n last_name: string;\n zip_code: string;\n flag_vat_number: string;\n council_id: string;\n subject_id: number;\n province_code: string;\n council_name: string;\n}\n\nexport interface DeliveryNote {\n fg_active: number;\n supplier_id: number | null;\n supplier: Person | null;\n dn_ref: string;\n dn_date: number;\n stock_item_document_id: number;\n dn_file_id: number | null;\n stock_document_id: number;\n id_stampa_log: number | null;\n print_hash: string | null;\n recipient: Person | null;\n recipient_id: number | null;\n item_attachment_id: number;\n}\n\nexport interface Attachment {\n attachment_description: string | null;\n attachment_type: string;\n custom_repository: number | null;\n expiry_date: number | null;\n fg_active: number | null;\n fg_expired: number | null;\n file_repository_id: number | null;\n issue_date: number | null;\n item_attachment_id: number | null;\n recipient: Person | null;\n recipient_id: number | null;\n stock_item_document_id: number | null;\n stock_item_id: number | null;\n supplier: Person | null;\n supplier_id: number | null;\n validity_date: number | null;\n stock_document_id: number;\n mime_type?: any;\n file_name?: any;\n}\n\nexport interface Movement {\n last_update: Date;\n item_name: string;\n sco_unit_measure: string;\n item_id: number;\n physical_quantity: string;\n quantity: number;\n unit_measure: string;\n ds_unit_measure: string;\n quantity_abs: number;\n warehouse_id: number;\n warehouse_description: string;\n operation_type: string;\n production_date: Date;\n stocked_lot_id: number;\n operation_date: Date;\n stock_item_id: number;\n unit_price: number;\n unimis_family: string;\n barcodes: Barcode[];\n delivery_notes: DeliveryNote[];\n attachments: MovementAttachment[];\n expire_date: Date;\n stocked_lot_number: string;\n ds_unimis_family: string;\n stock_full_text: string;\n}\n\nexport interface MovementAttachment {\n stock_document_id: number;\n file_repository_id: number;\n attachment_type: string;\n attachment_description?: string;\n issue_date?: number;\n validity_date?: number;\n expiry_date?: number;\n recipient_id?: number;\n supplier_id?: number;\n stock_item_id: number;\n item_attachment_id: number;\n fg_expired: number;\n stock_item_document_id: number;\n custom_repository: number;\n mime_type?: string;\n supplier?: string;\n recipient?: string;\n file_name?: string;\n fg_active: number;\n}\n\nexport interface MovementType {\n is_load: number;\n operation_desc_key: string;\n operation_type: string;\n operation_desc: string;\n}\n\nexport interface MovementOut {\n operation_date: Date | null;\n quantity: number | undefined;\n sco_unit_measure: string | undefined;\n}\n\nexport function toMovementOut(e: Movement): MovementOut {\n return {\n operation_date: e.operation_date ? e.operation_date : null,\n quantity: e.quantity ? e.quantity : undefined,\n sco_unit_measure: e.sco_unit_measure ? e.sco_unit_measure : undefined,\n }\n}\n\nexport const ACTIVITY_TYPES = [\n {\n is_load: 1,\n operation_desc_key: \"warehouse.operation_type.LOAD_ACTIVITY\",\n operation_type: \"LOAD_ACTIVITY\",\n operation_desc: \"\"\n },\n {\n is_load: 0,\n operation_desc_key: \"warehouse.operation_type.UNLOAD_ACTIVITY\",\n operation_type: \"UNLOAD_ACTIVITY\",\n operation_desc: \"\"\n }\n];\n"],"sourceRoot":""}