@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / ff507fc
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 00:30 UTC

Harden professional invoice print lifecycle

davoodmehraban89 committed Sep 28, 2026 at 15:35 UTC ff507fc05fee3a31204f8e52767fb7b694dbf434
1 file changed +4 -1
js/print.js
+4 -1
@@ -202,8 +202,10 @@ function printElectronicDoc(invId){
202 const printContainer=document.getElementById('printable-invoice');
203 printContainer.innerHTML=html;
204 printContainer.style.display='block';
205 + const cleanup=()=>{printContainer.style.display='none';window.removeEventListener('afterprint',cleanup);};
206 + window.addEventListener('afterprint',cleanup,{once:true});
207 window.print();
206 - printContainer.style.display='none';
208 + setTimeout(cleanup,1500);
209 }
210
211 // ============ فاکتورهای معمول ============
@@ -477,6 +479,7 @@ function renderAndPrintDirect(invId){
479 const builder=isFormal?buildFormalPage:buildNonFormalPage;
480 const rowsPerPage=isFormal?FORMAL_ROWS_PER_PAGE:NONFORMAL_ROWS_PER_PAGE;
481 const allLines=computeInvoiceLines(inv);
482 + if(!allLines.length){alert('این سند ردیف قابل چاپ ندارد.');return;}
483 const pageGroups=[];
484 let cumulativeSub=0,cumulativeDisc=0,cumulativeVat=0;
485 for(let start=0;start<allLines.length;start+=rowsPerPage){