import{a as d}from"./chunk-2JBQM4A4.js";import{a as u}from"./chunk-KXX3UDJ3.js";import{f as s,j as m}from"./chunk-GQAU5ACB.js";import{S as l,da as g,la as p,pa as i,r as y,x as f}from"./chunk-ISMRT7VU.js";import{a as c,b as h}from"./chunk-M5TX2NVG.js";var B=(()=>{class o{constructor(t,e){this._http=t,this._warehouseService=e}getAll(t){return this._http.post("/api/return-order-document/all",t,{headers:u})}create(t){return this._http.post("/api/return-order-document",t)}getById(t){return this._http.get(`/api/return-order-document/${t}`)}editById(t,e){return this._http.put(`/api/return-order-document/${t}`,e)}getPaymentsToBuyer(t){return this._http.get(`/api/return-order-document/${t}/payments-to-buyer`)}paymentToBuyer(t,e){return this._http.post(`/api/return-order-document/${t}/payment-to-buyer`,e)}deletePaymentToBuyer(t,e){return this._http.delete(`/api/return-order-document/${t}/payment-to-buyer/${e}`)}getInvoice(t,e){let r=new s;return r=r.append("format",e),this._http.get(`/api-reporting/return-order-document/${t}/invoice`,{params:r,responseType:"blob"})}forReturn(t){return this._http.get(`/api/order-document/${t}/return`)}static{this.\u0275fac=function(e){return new(e||o)(i(m),i(d))}}static{this.\u0275prov=p({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var R=(()=>{class o{constructor(t,e){this._http=t,this._warehouseService=e}getAll(t){return this._http.post("/api/order-document/all",t,{headers:u})}create(t){return this._http.post("/api/order-document",t)}getById(t){return this._http.get(`/api/order-document/${t}`)}editById(t,e){return this._http.put(`/api/order-document/${t}`,e)}getPaymentsFromBuyer(t){return this._http.get(`/api/order-document/${t}/payments-from-buyer`)}paymentFromBuyer(t,e){return this._http.post(`/api/order-document/${t}/payment-from-buyer`,e)}deletePaymentToSupplier(t,e){return this._http.delete(`/api/order-document/${t}/payment-from-buyer/${e}`)}getInvoice(t,e){let r=new s;return r=r.append("format",e),this._http.get(`/api-reporting/order-document/${t}/invoice`,{params:r,responseType:"blob"})}getOrderDocumentWithRemainsById(t){return this.getById(t).pipe(g(e=>this.mapRemainsAndMapToOrderDocument(e)),l(1))}mapRemainsAndMapToOrderDocument(t){let{warehouse:e,positions:r}=t,a=r.map(n=>n.nomenclature.id);return a.length?this._warehouseService.getWarehouseRemains(e.id,a).pipe(f(n=>this._addRemainsToPositions(n,t))):y(this._addRemainsToPositions([],t))}_addRemainsToPositions(t,e){return h(c({},e),{positions:e.positions.map(r=>{let a=t.find(n=>n.nomenclature.id===r.nomenclature.id);return h(c({},r),{remains:a?.quantity})})})}static{this.\u0275fac=function(e){return new(e||o)(i(m),i(d))}}static{this.\u0275prov=p({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();export{B as a,R as b};
//# sourceMappingURL=chunk-NF66BI4O.js.map
