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

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

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

Synced Dec 4, 01:45 UTC

Protect project cost centers referenced by expenses

davoodmehraban89 committed Sep 28, 2026 at 15:08 UTC eae08b74e776c25747834649aa1496f687ea53c3
1 file changed +4 -2
js/projects.js
+4 -2
@@ -10,7 +10,8 @@ function deleteContactProject(contactId,projectId){
10 const ids=[projectId,...(p.subprojects||[]).map(s=>s.id)];
11 const usedSale=getMyInvoices().some(i=>ids.includes(i.projectId));
12 const usedBuy=(datastore.purchases||[]).some(x=>x.ownerUserId===currentUser?.id&&ids.includes(x.costCenterId));
13 - if(usedSale||usedBuy){alert('این پروژه یا یکی از زیرپروژه‌های آن در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
13 + const usedExpense=getMyExpenses().some(x=>ids.includes(x.projectId));
14 + if(usedSale||usedBuy||usedExpense){alert('این پروژه یا یکی از زیرپروژه‌های آن در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
15 if(!confirm('پروژه و همه زیرپروژه‌های آن حذف شود؟'))return;
16 const c=getMyContacts().find(x=>x.id===contactId);if(!c)return;c.projects=getContactProjects(contactId).filter(x=>x.id!==projectId);saveDatastore();refreshAllSurfaces();manageContactProjects(contactId);
17 }
@@ -20,7 +21,8 @@ function deleteSubproject(contactId,projectId,subId){
21 if(!requireWrite())return;
22 const usedSale=getMyInvoices().some(i=>i.projectId===subId);
23 const usedBuy=(datastore.purchases||[]).some(x=>x.ownerUserId===currentUser?.id&&x.costCenterId===subId);
23 - if(usedSale||usedBuy){alert('این زیرپروژه در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
24 + const usedExpense=getMyExpenses().some(x=>x.projectId===subId);
25 + if(usedSale||usedBuy||usedExpense){alert('این زیرپروژه در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
26 if(!confirm('زیرپروژه حذف شود؟'))return;const p=getContactProjects(contactId).find(x=>x.id===projectId);if(!p)return;p.subprojects=p.subprojects.filter(x=>x.id!==subId);saveDatastore();refreshAllSurfaces();manageContactProjects(contactId);
27 }
28 function ensureProjectModal(){if(document.getElementById('project-manager-modal'))return;const d=document.createElement('div');d.id='project-manager-modal';d.className='modal-backdrop';d.innerHTML='<div class="modal-card" style="max-width:900px;max-height:85vh;overflow:auto"><div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px"><h3 id="project-manager-title"></h3><button class="btn btn-secondary btn-inline" onclick="document.getElementById(\'project-manager-modal\').classList.remove(\'active\')">✕ بستن</button></div><div id="project-manager-body"></div></div>';document.body.appendChild(d);}