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

fix(treasury): maintain valid guarded payment UI handlers

davoodmehraban89 committed Oct 14, 2026 at 10:52 UTC 2fb73bf0bc6d065c3912c3cea85d0ca27a90992d
1 file changed +2 -2
js/payments.js
+2 -2
@@ -216,7 +216,7 @@ function deletePayment(id){
216 if(typeof requireWrite==='function'&&!requireWrite())return;
217 const source=paymentCurrentVisible(id);if(source&&paymentPostingStatus(source)==='posted')
218 return cancelPostedPaymentUi(source.id);
219 - if(typeof jeGuardSourceMutation==='function'{try{jeGuardSourceMutation(source,'دریافت/پرداخت');}catch(e){alert(e.message);return;}}if(!confirm('این دریافت/پرداخت حذف شود؟ مانده فاکتور دوباره محاسبه می‌شود.'))return;
219 + if(typeof jeGuardSourceMutation==='function'){try{jeGuardSourceMutation(source,'دریافت/پرداخت');}catch(e){alert(e.message);return;}}if(!confirm('این دریافت/پرداخت حذف شود؟ مانده فاکتور دوباره محاسبه می‌شود.'))return;
220 datastore.payments=datastore.payments.filter(p=>!(p.id===id&&p.ownerUserId===currentUser.id));
221 if(editingPaymentId===id)resetPaymentForm();
222 saveDatastore();refreshAllSurfaces();renderPayments();
@@ -227,7 +227,7 @@ function renderPayments(){
227 const companies=getMyCompanies(),active=getMySettings().default_company_id||companies[0]?.id||'',legacyOk=companies.length===1;const rows=paymentVisibleRecords().filter(p=>!active||p.companyId===active||(!p.companyId&&legacyOk))
228 .slice().sort((a,b)=>String(b.date).localeCompare(String(a.date)));
229 body.innerHTML=rows.length?rows.map(p=>{const displayDate=/^\d{4}\/\d{2}\/\d{2}$/.test(String(p.date||''))?p.date:new Date(p.date).toLocaleDateString('fa-IR');return `<tr><td>${escP(displayDate)}</td><td>${escP(paymentDirectionLabel(p.direction))}</td><td>${escP(p.contactName)}</td><td>${escP(paymentMethodLabel(p.method))}</td><td>${num(p.amount).toLocaleString('fa-IR')}</td><td>${escP(p.reference||'-')}</td><td>${paymentPostingStatus(p)==='posted'&&paymentCanAmend(p)?
230 - '<button class="btn btn-secondary btn-inline" onclick="editPayment(\\''+escP(p.id)+'\\')">اصلاح</button> <button class="btn btn-danger btn-inline" onclick="deletePayment(\\''+escP(p.id)+'\\')">ابطال ثبت</button>':
230 + '<button class="btn btn-secondary btn-inline" onclick="editPayment(&#39;'+escP(p.id)+'&#39;)">اصلاح</button> <button class="btn btn-danger btn-inline" onclick="deletePayment(&#39;'+escP(p.id)+'&#39;)">ابطال ثبت</button>':
231 paymentPostingStatus(p)==='reversed'?'ابطال‌شده':
232 '<button class="btn btn-secondary btn-inline" disabled title="نیازمند تطبیق ثبت‌های مرتبط">نیازمند تطبیق</button>'}</td></tr>`}).join(''):'<tr><td colspan="7" style="text-align:center">هنوز دریافت یا پرداختی ثبت نشده است.</td></tr>';
233 }