import{a as c}from"./chunk-FSINNWUG.js";import{a as d}from"./chunk-PLVHWZTL.js";import{e as m,i as u}from"./chunk-YMOV4UGM.js";import{K as g,Z as _,ga as s,k as f,la as n,q as l}from"./chunk-I3FGJX2C.js";import{a as h,b as y}from"./chunk-B7YGBANW.js";var T=(()=>{let r=class r{constructor(t,e){this._http=t,this._warehouseService=e}getAll(t){return this._http.post("/api/return-order-document/all",t,{headers:d})}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 o=new m;return o=o.append("format",e),this._http.get(`/api-reporting/return-order-document/${t}/invoice`,{params:o,responseType:"blob"})}forReturn(t){return this._http.get(`/api/order-document/${t}/return`)}};r.\u0275fac=function(e){return new(e||r)(n(u),n(c))},r.\u0275prov=s({token:r,factory:r.\u0275fac,providedIn:"root"});let i=r;return i})();var H=(()=>{let r=class r{constructor(t,e){this._http=t,this._warehouseService=e}getAll(t){return this._http.post("/api/order-document/all",t,{headers:d})}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 o=new m;return o=o.append("format",e),this._http.get(`/api-reporting/order-document/${t}/invoice`,{params:o,responseType:"blob"})}getOrderDocumentWithRemainsById(t){return this.getById(t).pipe(_(e=>this.mapRemainsAndMapToOrderDocument(e)),g(1))}mapRemainsAndMapToOrderDocument(t){let{warehouse:e,positions:o}=t,p=o.map(a=>a.nomenclature.id);return p.length?this._warehouseService.getWarehouseRemains(e.id,p).pipe(l(a=>this._addRemainsToPositions(a,t))):f(this._addRemainsToPositions([],t))}_addRemainsToPositions(t,e){return y(h({},e),{positions:e.positions.map(o=>{let p=t.find(a=>a.nomenclature.id===o.nomenclature.id);return y(h({},o),{remains:p?.quantity})})})}};r.\u0275fac=function(e){return new(e||r)(n(u),n(c))},r.\u0275prov=s({token:r,factory:r.\u0275fac,providedIn:"root"});let i=r;return i})();export{T as a,H as b};
//# sourceMappingURL=chunk-UZUUTY77.js.map
