import{a as b}from"./chunk-RRSYYPWA.js";import{a as S}from"./chunk-WAMXHNDN.js";import{b as E}from"./chunk-HFDX2HBX.js";import{a as h}from"./chunk-AFI6Z2RM.js";import{a as f}from"./chunk-E3CNFAVP.js";import{a as x}from"./chunk-3E2O24RU.js";import{C as $}from"./chunk-E5WZX35Y.js";import{f as D,t as y}from"./chunk-W3BEWLBM.js";import{g as A}from"./chunk-LINAD4CC.js";import{c as I,d as M}from"./chunk-2MNVXWEX.js";import{a as j}from"./chunk-JUPKAJPM.js";import{e as _,i as w}from"./chunk-Z2AWIQRI.js";import{ia as v,na as u}from"./chunk-C2QKZJOP.js";import{a as P,b as g}from"./chunk-B7YGBANW.js";var k=(()=>{let n=class n{constructor(e){this._http=e}offer(){return this._http.get("/api-reporting/live/offer")}accept(){return this._http.post("/api-reporting/live/offer/accept",{})}getIncreasePriceAdvice(e){return this._http.get(`/api-reporting/live/store/${e}/advice/price-potential`)}getAdviceExclusion(e,t){let c=new _;return c=c.append("code",t),this._http.get(`/api-reporting/live/store/${e}/advice-exclusion`,{params:c})}createAdviceExclusion(e,t){return this._http.post(`/api-reporting/live/store/${e}/advice-exclusion`,t)}deleteAdviceExclusion(e,t){return this._http.delete(`/api-reporting/live/store/${e}/advice-exclusion`,{body:t})}getMetrics(e,t){return this._http.post(`/api-reporting/live/store/${e}/advice/price-potential/metrics`,t,{headers:j})}};n.\u0275fac=function(t){return new(t||n)(u(w))},n.\u0275prov=v({token:n,factory:n.\u0275fac});let l=n;return l})();function m(l,n){return+A(l)>+A(n)}var N=(()=>{let n=class n{constructor(e,t,c){this._pricePotentialServiceApi=e,this._priceActsService=t,this._localizationService=c,this.translateBind=this._localizationService.getSync.bind(this._localizationService)}offer(){return this._pricePotentialServiceApi.offer()}accept(){return this._pricePotentialServiceApi.accept()}getIncreasePriceAdvice(e){return this._pricePotentialServiceApi.getIncreasePriceAdvice(e)}getAdviceExclusion(e,t){return this._pricePotentialServiceApi.getAdviceExclusion(e,t)}createAdviceExclusion(e,t){return this._pricePotentialServiceApi.createAdviceExclusion(e,t)}deleteAdviceExclusion(e,t){return this._pricePotentialServiceApi.deleteAdviceExclusion(e,t)}getMetrics(e,t){return this._pricePotentialServiceApi.getMetrics(e,t)}getPriceList(){let e={criteria:{filter:{sources:[x.PricePotentialAdvice]}},take:100,skip:0,orderBy:"date"};return this._priceActsService.getAll(e)}createAdjustmentPriceAct(e,t){let c=e.map(i=>({nomenclatureId:i.id,purchasePrice:i.purchasePrice,markup:this._priceActsService.calculatePercentageChange(i.recommendedPrice,i.purchasePrice),oldPrice:i.sellPrice,newPrice:i.recommendedPrice})),o={storeId:t,positions:c,comment:null,source:x.PricePotentialAdvice};return this._priceActsService.create(o)}mergePriceHistoryByDay(e){let t=[...e].sort((o,i)=>new Date(o.operationDate).getTime()-new Date(i.operationDate).getTime()),c=new Map;for(let o of t){let i=o.operationDate.slice(0,10),d=c.get(i);d?d.last=o:c.set(i,{first:o,last:o})}return Array.from(c.values()).map(({first:o,last:i})=>({operationDate:i.operationDate,oldPrice:o.oldPrice,newPrice:i.newPrice,source:i.source,adjustmentPriceActId:i.adjustmentPriceActId}))}build30dPeriodLabels(e,t=6){let c=[],o=D(new Date(e)),i=new Date;for(let d=0;d<t;d++){let s=h(f(o,29)),p=y(o,"dd.MM.yyyy"),r=y(s,"dd.MM.yyyy");if(c.push(`${p} - ${r}`),m(i,s))o=D(f(s,1));else break}return c}convertDateFormat(e){let[t,c]=e.split("-").map(r=>r.trim()),o="dd:MM:yyyy",i=this._localizationService.currentLocale===I.KK?b:E,d=S(t,o,new Date),s=S(c,o,new Date),p=r=>y(r,"dd LLL",{locale:i});return`${p(d)} - ${p(s)}`}filterMetricsToYesterday(e,t){let c=h(f(new Date,-1)),o=h(f(c,-30));if(e.dailyData.length>0){let r=new Date(e.dailyData[0].date);if(m(r,c))return[e,t]}let i=e.dailyData.filter(r=>{let a=new Date(r.date);return!m(a,c)}),d=g(P({},e),{dailyData:i,total:{turnover:i.reduce((r,a)=>r+a.turnover,0),quantity:i.reduce((r,a)=>r+a.quantity,0),grossProfit:i.reduce((r,a)=>r+a.grossProfit,0),marginPercent:i.reduce((r,a)=>r+a.marginPercent,0)}}),s=t.dailyData.filter(r=>{let a=new Date(r.date);return!m(a,o)}),p=g(P({},t),{dailyData:s,total:{turnover:s.reduce((r,a)=>r+a.turnover,0),quantity:s.reduce((r,a)=>r+a.quantity,0),grossProfit:s.reduce((r,a)=>r+a.grossProfit,0),marginPercent:s.reduce((r,a)=>r+a.marginPercent,0)}});return[d,p]}};n.\u0275fac=function(t){return new(t||n)(u(k),u($),u(M))},n.\u0275prov=v({token:n,factory:n.\u0275fac});let l=n;return l})();export{k as a,N as b};
//# sourceMappingURL=chunk-BZIAK2NI.js.map
