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

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

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

Synced Dec 4, 00:30 UTC

Connect global projects to financial documents

davoodmehraban89 committed Sep 28, 2026 at 17:52 UTC 177452810440190caf36fa8e22840ebe6f3a8850
1 file changed +16
js/accounting-foundation-render.js
+16
@@ -18,3 +18,19 @@ function renderAccountingFoundation(){
18 const pc=document.getElementById('af-project-contacts');if(pc)pc.innerHTML=C.map(x=>'<option value="'+x.id+'">'+esc(x.name)+'</option>').join('');
19 const pl=document.getElementById('af-projects-list');if(pl)pl.innerHTML=P.map(x=>{const pa=P.find(z=>z.id===x.parentId),br=B.find(z=>z.id===x.branchId),cn=(x.linkedContactIds||[]).map(id=>C.find(z=>z.id===id)?.name).filter(Boolean).join('، ');return '<div class="af-master-row"><div><b>'+esc(x.code||x.id)+' — '+esc(x.name)+'</b><small>'+(pa?'زیرپروژه '+esc(pa.name)+' · ':'')+(br?'شعبه '+esc(br.name)+' · ':'')+esc(cn||'بدون طرف‌حساب')+'</small></div><button class="btn btn-danger btn-inline" onclick="afDeleteProject(\''+x.id+'\')">حذف</button></div>'}).join('')||'<span class="af-hint">پروژه‌ای ثبت نشده است.</span>';
20 }
21 +
22 +function afProjectsForContact(contactId,direction){
23 + return getMyGlobalProjects().filter(p=>p.active!==false&&(!(p.linkedContactIds||[]).length||(p.linkedContactIds||[]).includes(contactId))&&(p.direction||'both')!==(direction==='sale'?'purchase':'sale'));
24 +}
25 +window.handleInvoiceContactChange=function(){
26 + const cid=document.getElementById('invoice-contact-id')?.value,row=document.getElementById('box-invoice-project-row'),sel=document.getElementById('invoice-project-id');if(!row||!sel)return;
27 + const ps=afProjectsForContact(cid,'sale');sel.innerHTML=ps.map(p=>'<option value="'+esc(p.id)+'">'+esc(p.name)+'</option>').join('');row.style.display=ps.length?'flex':'none';
28 +};
29 +window.purRefreshProjects=function(){
30 + const sup=document.getElementById('pur-supplier'),sel=document.getElementById('pur-costcenter');if(!sup||!sel)return;const old=sel.value,ps=afProjectsForContact(sup.value,'purchase');
31 + sel.innerHTML='<option value="">بدون پروژه (هزینه عمومی)</option>'+ps.map(p=>'<option value="'+esc(p.id)+'">'+esc(p.name)+'</option>').join('');if([...sel.options].some(o=>o.value===old))sel.value=old;
32 +};
33 +window.refreshExpenseProjects=function(){
34 + const c=document.getElementById('trx-contact-select'),sel=document.getElementById('trx-project-select');if(!c||!sel)return;const old=sel.value,ps=afProjectsForContact(c.value,'both');
35 + sel.innerHTML='<option value="">بدون پروژه</option>'+ps.map(p=>'<option value="'+esc(p.id)+'">'+esc(p.name)+'</option>').join('');if([...sel.options].some(o=>o.value===old))sel.value=old;
36 +};