سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 01:45 UTC
Protect projects referenced by financial settlements
davoodmehraban89 committed
Sep 28, 2026 at 15:23 UTC
4821aa5bd16449630705993a0f7153840c9d1669
1 file changed
+4
-2
js/projects.js
+4
-2
@@ -11,7 +11,8 @@ function deleteContactProject(contactId,projectId){
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
const usedExpense=getMyExpenses().some(x=>ids.includes(x.projectId));
14
- if(usedSale||usedBuy||usedExpense){alert('این پروژه یا یکی از زیرپروژههای آن در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
14
+ const usedPayment=typeof getMyPayments==='function'&&getMyPayments().some(x=>ids.includes(x.projectId));
15
+ if(usedSale||usedBuy||usedExpense||usedPayment){alert('این پروژه یا یکی از زیرپروژههای آن در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
16
if(!confirm('پروژه و همه زیرپروژههای آن حذف شود؟'))return;
17
const c=getMyContacts().find(x=>x.id===contactId);if(!c)return;c.projects=getContactProjects(contactId).filter(x=>x.id!==projectId);saveDatastore();refreshAllSurfaces();manageContactProjects(contactId);
18
}
@@ -22,7 +23,8 @@ function deleteSubproject(contactId,projectId,subId){
23
const usedSale=getMyInvoices().some(i=>i.projectId===subId);
24
const usedBuy=(datastore.purchases||[]).some(x=>x.ownerUserId===currentUser?.id&&x.costCenterId===subId);
25
const usedExpense=getMyExpenses().some(x=>x.projectId===subId);
25
- if(usedSale||usedBuy||usedExpense){alert('این زیرپروژه در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
26
+ const usedPayment=typeof getMyPayments==='function'&&getMyPayments().some(x=>x.projectId===subId);
27
+ if(usedSale||usedBuy||usedExpense||usedPayment){alert('این زیرپروژه در سند مالی استفاده شده و برای حفظ سابقه قابل حذف نیست.');return;}
28
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);
29
}
30
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);}