import{a as h}from"./chunk-PPYID2NY.js";import{a as m}from"./chunk-SAISWRBR.js";import{a}from"./chunk-34XLL2ET.js";import{a as u,b as l}from"./chunk-RBR4ZJRC.js";import{K as o,da as d,ja as n,r}from"./chunk-ZGECHOBP.js";import{b as p,i as g}from"./chunk-QOJKCMZT.js";g();var A=class c{constructor(e,t){this._productionActServiceApi=e,this._remainsService=t}create(e){let t=this._migrateFormToRequestModel(e);return this._productionActServiceApi.create(t).pipe(o(1))}edit(e,t){let i=this._migrateFormToRequestModel(t);return this._productionActServiceApi.edit(e,{date:i.date,copies:i.copies,comment:i.comment}).pipe(o(1))}getById(e){return this._productionActServiceApi.getById(e).pipe(r(t=>(t.date=new Date(t.date),t)))}getAll(e){return this._productionActServiceApi.getAll(e).pipe(o(1))}calculateTotalCost(e,t){let i={warehouseId:t,positions:e};return this._remainsService.getCalculatedProductsCost(i).pipe(l(this),r(s=>s.positions.reduce((S,v)=>S+=v.totalCost,0)))}getProductRemains(e,t){let i={criteria:{search:null,filter:{nomenclatureIds:t,name:null,barcode:null,article:null,unitId:[],viewArchived:null,categoryId:[]}},skip:0,take:t.length,orderBy:"id",isAscending:!1};return this._remainsService.getProductRemains(e,i).pipe(r(s=>s.data))}_migrateFormToRequestModel(e){return{prescriptId:e.prescriptId,date:e.date?a(e.date):a(new Date),copies:e.copies,resultsWarehouseId:e.resultsWarehouseId,componentsWarehouseId:e.componentsWarehouseId,comment:e.comment}}static{this.\u0275fac=function(t){return new(t||c)(n(h),n(m))}}static{this.\u0275prov=d({token:c,factory:c.\u0275fac})}};A=p([u()],A);export{A as a};
