Files
roa2web-service-auto/deploy-package-20260223-151231/frontend/assets/exportUtils.BtGzMnqV.js
Claude Agent 8bc567a9c5 fix telegram
2026-02-23 15:12:33 +00:00

3 lines
8.2 KiB
JavaScript

import{u as A,w as Z,E as H,a as L}from"./vendor-export.BWjBvx7Z.js";const K=d=>d==null||d==="-"?"-":new Intl.NumberFormat("ro-RO",{style:"currency",currency:"RON",minimumFractionDigits:0,maximumFractionDigits:0}).format(d),nt=(d,g,k="Sheet1")=>{try{const e=A.json_to_sheet(d),n=A.book_new();return A.book_append_sheet(n,e,k),Z(n,`${g}_${new Date().toISOString().split("T")[0]}.xlsx`),{success:!0}}catch(e){return console.error("Excel export failed:",e),{success:!1,error:e}}},b=d=>{if(d==null||d===""||d==="-")return"-";const g=parseFloat(d);return isNaN(g)?"-":new Intl.NumberFormat("ro-RO",{minimumFractionDigits:2,maximumFractionDigits:2}).format(g)},ot=(d,g,k,e)=>{try{if(!d||d.length===0)return console.error("No data to export"),{success:!1,error:"No data available"};if(typeof H>"u")return console.error("jsPDF not properly imported"),{success:!1,error:"PDF library not available"};const n=new H("landscape","mm","a4"),T=n.internal.pageSize.getWidth(),m=n.internal.pageSize.getHeight(),f=8,i=8,z=T-f-i,B=e.initialBalances&&e.initialBalances.length>0,w=()=>{n.setFontSize(13),n.setFont(void 0,"bold");const a=e.companyName||"N/A";n.text(a,f,15),n.setFontSize(14),n.setFont(void 0,"bold");const s=n.getTextWidth(e.title||""),c=f+(z-s)/2;n.text(e.title||"",c,24),n.setFontSize(11),n.setFont(void 0,"normal");const u=e.period||"",S=n.getTextWidth(u),R=f+(z-S)/2;n.text(u,R,32);let o=32;e.subtitle2&&(o=39,n.setFontSize(10),n.setFont(void 0,"normal"),n.text(e.subtitle2,f,o))},N=g.map(a=>a.header),I=new Set,Y=new Set,W=d.map((a,s)=>(a._isTotal&&I.add(s),a._isGrandTotal&&Y.add(s),g.map(c=>{const u=a[c.field];return c.type==="currency"?K(u):c.type==="number"?b(u):u||"-"}))),r=(a,s)=>{const c=m-10;n.setFontSize(8),n.setFont(void 0,"normal"),n.text(`Generat: ${new Date().toLocaleString("ro-RO")}`,f,c);const u=`Pagina ${a} din ${s}`,S=n.getTextWidth(u);n.text(u,T-i-S,c)};if(typeof L=="function"){const a={},s=T-f-i,c={};g.forEach((t,l)=>{if(t.width&&typeof t.width=="number")c[l]=s*t.width;else if(t.width==="auto")c[l]="auto";else{const h={0:s*.07,1:s*.33,2:s*.1,3:s*.1,4:s*.1,5:s*.1,6:s*.1,7:s*.1};c[l]=h[l]||"auto"}}),g.forEach((t,l)=>{a[l]={cellWidth:c[l]},t.type==="number"||t.type==="currency"?a[l].halign="right":t.type==="text"&&(a[l].halign="left")});let u=36;if(e.subtitle2&&(u=43),B){const t=e.initialBalances.length,l=t>1,h=t*5+(l?7:0);u=(e.subtitle2?43:36)+h+5}const S=t=>{if(!B)return;const l=T-i,h=e.initialBalances.length,x=h>1,j=h*5+(x?7:0);let F=t-3-(x?7:0)-h*5;if(n.setFont(void 0,"normal"),n.setFontSize(9),e.initialBalances.forEach(P=>{const p=b(P.sold),y=n.getTextWidth(p),C=`${P.accountName} sold precedent:`;n.text(C,l-y-n.getTextWidth(" sold precedent:")-n.getTextWidth(P.accountName)-2,F),n.text(p,l-y,F),F+=5}),x){n.setDrawColor(150,150,150),n.line(l-40,F-2,l,F-2),n.setFont(void 0,"bold");const P=b(e.totalInitialBalance||0),p=n.getTextWidth(P),y="TOTAL sold precedent:",C=n.getTextWidth(y);n.text(y,l-p-3-C,F+2),n.text(P,l-p,F+2)}};let R=!0;L(n,{head:[N],body:W,startY:u,styles:{fontSize:9,cellPadding:2.5,valign:"middle",lineColor:[200,200,200],lineWidth:.1,overflow:"linebreak"},headStyles:{fillColor:[41,128,185],textColor:255,fontStyle:"bold",halign:"center",fontSize:9,cellPadding:2.5},alternateRowStyles:{fillColor:[248,248,248]},columnStyles:a,margin:{left:f,right:i,top:u,bottom:15},tableWidth:T-f-i,theme:"grid",didDrawPage:function(){w(),R&&B&&(S(u),R=!1)},didParseCell:function(t){if(t.section==="body"){const l=t.row.index,h=t.column.index,x=g[h];Y.has(l)?(t.cell.styles.fontStyle="bold",t.cell.styles.fillColor=[200,200,200],t.cell.styles.fontSize=10):I.has(l)&&(t.cell.styles.fontStyle="bold",t.cell.styles.fillColor=[235,235,235]),x&&(x.type==="number"||x.type==="currency"?t.cell.styles.halign="right":x.type==="text"&&(h===0?t.cell.styles.halign="center":t.cell.styles.halign="left"))}},willDrawCell:function(t){if(t.section==="body"&&Y.has(t.row.index)){const l=t.doc;l.setDrawColor(100,100,100),l.setLineWidth(.5),l.line(t.cell.x,t.cell.y,t.cell.x+t.cell.width,t.cell.y)}}});const o=n.internal.getNumberOfPages();for(let t=1;t<=o;t++)n.setPage(t),r(t,o)}else{w();let a=45;n.setFontSize(8),n.setFont(void 0,"bold"),N.forEach((s,c)=>{n.text(s,14+c*35,a)}),n.setFont(void 0,"normal"),n.setFontSize(7),W.forEach((s,c)=>{a+=7,s.forEach((u,S)=>{n.text(String(u),14+S*35,a)})}),r(1,1)}return n.save(`${k}_${new Date().toISOString().split("T")[0]}.pdf`),{success:!0}}catch(n){return console.error("PDF export error details:",n),{success:!1,error:n.message||"PDF generation failed"}}},lt=(d,g,k)=>{try{if(!d||d.length===0)return console.error("No data to export"),{success:!1,error:"No data available"};const e=new H("landscape","mm","a4"),n=e.internal.pageSize.getWidth(),T=e.internal.pageSize.getHeight(),m=8,f=8,i=n-m-f,z=o=>o?o.replace(/[ăâ]/gi,t=>t===t.toLowerCase()?"a":"A").replace(/[î]/gi,t=>t===t.toLowerCase()?"i":"I").replace(/[ș]/gi,t=>t===t.toLowerCase()?"s":"S").replace(/[ț]/gi,t=>t===t.toLowerCase()?"t":"T"):"",B=(o,t=100)=>o?o.length<=t?o:o.substring(0,t)+"...":"",w={},N={};d.forEach(o=>{const t=o.nume_cont_bancar||"Necunoscut";w[t]||(w[t]=[],N[t]=0),o.dataact?w[t].push(o):N[t]=parseFloat(o.sold)||0});const I=["Data act","Nr.act","Explicatia","Incasari","Plati","Sold"],Y={0:i*.1,1:i*.08,2:i*.42,3:i*.13,4:i*.13,5:i*.14},W={};Object.keys(Y).forEach(o=>{W[o]={cellWidth:Y[o]},o>=3&&(W[o].halign="right")});let r=15,a=1;const s=()=>{e.setFontSize(12),e.setFont(void 0,"bold"),e.text(z(g.companyName||""),m,12),e.setFontSize(10),e.setFont(void 0,"normal");const o=`Luna: ${g.luna||""} / ${g.an||""}`,t=e.getTextWidth(o);e.text(o,n-f-t,12),e.setFontSize(13),e.setFont(void 0,"bold");const l=e.getTextWidth(g.title||"");e.text(g.title||"",m+(i-l)/2,20)},c=(o=20)=>r+o>T-15?(e.addPage(),a++,s(),r=28,!0):!1;Object.keys(w).sort((o,t)=>o.localeCompare(t,"ro")).forEach((o,t)=>{const l=w[o],h=N[o]||0;t>0&&(e.addPage(),a++),s(),r=28,e.setFontSize(10),e.setFont(void 0,"bold");const j=`${g.isBanca?"Banca:":"Casa:"} ${z(o)}`;e.text(j,m,r);const F=`Sold precedent: ${b(h)}`,P=e.getTextWidth(F);if(e.text(F,n-f-P,r),r+=6,l.length===0){L(e,{head:[I],body:[],startY:r,styles:{fontSize:8,cellPadding:1.5,lineColor:[200,200,200],lineWidth:.1},headStyles:{fillColor:[41,128,185],textColor:255,fontStyle:"bold",halign:"center",fontSize:8},columnStyles:W,margin:{left:m,right:f},tableWidth:i,theme:"grid"}),r=e.lastAutoTable.finalY;const p=[["","","Total:",b(0),b(0),b(h)]],y=r;L(e,{body:p,startY:r,styles:{fontSize:8,cellPadding:1.5,fontStyle:"bold",lineWidth:0},columnStyles:W,margin:{left:m,right:f},tableWidth:i,theme:"plain"});const C=e.lastAutoTable.finalY;e.setDrawColor(200,200,200),e.setLineWidth(.1),e.rect(m,y,i,C-y),r=e.lastAutoTable.finalY+3}else{const p={};l.forEach(E=>{const $=E.dataact;p[$]||(p[$]=[]),p[$].push(E)});let y=0,C=0,O=h;Object.keys(p).sort().forEach((E,$)=>{const M=p[E],G=E?new Date(E).toLocaleDateString("ro-RO"):"";c(30);const V=[];let _=0,v=0;M.forEach(D=>{const q=parseFloat(D.incasari)||0,J=parseFloat(D.plati)||0;_+=q,v+=J,O=parseFloat(D.sold)||O,V.push([G,D.nract||"",B(z(D.explicatia||D.nume||""),100),b(q),b(J),b(D.sold)])}),y+=_,C+=v,L(e,{head:$===0?[I]:[],body:V,startY:r,styles:{fontSize:8,cellPadding:1.5,lineColor:[200,200,200],lineWidth:.1,overflow:"linebreak"},headStyles:{fillColor:[41,128,185],textColor:255,fontStyle:"bold",halign:"center",fontSize:8},columnStyles:W,margin:{left:m,right:f},tableWidth:i,theme:"grid",showHead:$===0?"firstPage":"never"}),r=e.lastAutoTable.finalY,c(16);const Q=[["","",`Total zi: ${G}`,b(_),b(v),"Sold"],["","","Total cumulat:",b(y),b(C),b(O)]],X=r;L(e,{body:Q,startY:r,styles:{fontSize:8,cellPadding:1.5,fontStyle:"bold",lineWidth:0},columnStyles:W,margin:{left:m,right:f},tableWidth:i,theme:"plain"});const U=e.lastAutoTable.finalY;e.setDrawColor(200,200,200),e.setLineWidth(.1),e.rect(m,X,i,U-X),r=e.lastAutoTable.finalY+3})}});const S=e.internal.getNumberOfPages(),R=`Generat: ${new Date().toLocaleString("ro-RO")}`;for(let o=1;o<=S;o++){e.setPage(o),e.setFontSize(8),e.setFont(void 0,"normal");const t=T-8;e.text(R,m,t);const l=`Pagina ${o} din ${S}`,h=e.getTextWidth(l);e.text(l,n-f-h,t)}return e.save(`${k}_${new Date().toISOString().split("T")[0]}.pdf`),{success:!0}}catch(e){return console.error("Bank Cash Register PDF export error:",e),{success:!1,error:e.message||"PDF generation failed"}}};export{ot as a,lt as b,nt as e};
//# sourceMappingURL=exportUtils.BtGzMnqV.js.map