import{a as h}from"./chunk-QIATDDKB.js";import{a as l}from"./chunk-HECH75A2.js";import{a as n}from"./chunk-JAY45DEO.js";import{z as m}from"./chunk-GQAU5ACB.js";import{Ea as u,S as s,la as p,pa as a,qa as d,x as o}from"./chunk-ISMRT7VU.js";var W=(()=>{class r{constructor(e,t){this._productionActServiceApi=e,this._remainsService=t,this.destroyRef=d(u)}create(e){let t=this._migrateFormToRequestModel(e);return this._productionActServiceApi.create(t).pipe(s(1))}edit(e,t){let i=this._migrateFormToRequestModel(t);return this._productionActServiceApi.edit(e,{date:i.date,copies:i.copies,comment:i.comment}).pipe(s(1))}getById(e){return this._productionActServiceApi.getById(e).pipe(o(t=>(t.date=new Date(t.date),t)))}getAll(e){return this._productionActServiceApi.getAll(e).pipe(s(1))}calculateTotalCost(e,t){let i={warehouseId:t,positions:e};return this._remainsService.getCalculatedProductsCost(i).pipe(m(this.destroyRef),o(c=>c.positions.reduce((A,y)=>A+=y.totalCost,0)))}getProductRemains(e,t){let i={criteria:{search:null,filter:{nomenclatureIds:t,viewWithZeroQuantity:!0}},skip:0,take:t.length,orderBy:"id",isAscending:!1};return this._remainsService.getProductRemains(e,i).pipe(o(c=>c.data))}_migrateFormToRequestModel(e){return{prescriptId:e.prescriptId,date:e.date?n(e.date):n(new Date),copies:e.copies,resultsWarehouseId:e.resultsWarehouseId,componentsWarehouseId:e.componentsWarehouseId,comment:e.comment}}static{this.\u0275fac=function(t){return new(t||r)(a(h),a(l))}}static{this.\u0275prov=p({token:r,factory:r.\u0275fac})}}return r})();export{W as a};
//# sourceMappingURL=chunk-6VXHKLMR.js.map
