@davoodmehraban89 / Factor-easy / commits / 0ca72b1
Fork 0

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

Prevent non-accounting sales documents from posting

davoodmehraban89 committed Sep 29, 2026 at 12:02 UTC 0ca72b10025809ac88569ac3ddc50162b874954a
1 file changed +3 -2
js/invoices.js
+3 -2
@@ -314,6 +314,7 @@ function saveElectronicDocToPending(){
314 closeElectronicDocModal();
315 }
316
317 +function invoiceCreatesAccountingEntry(kind){return kind==='formal'||kind==='non_formal';}
318 function commitSaveInvoice(){
319 if(!requireWrite())return;
320 if(!currentUser)return;
@@ -393,8 +394,8 @@ function commitSaveInvoice(){
394 }else{
395 const record={id:'INV_'+Date.now(),ownerUserId:currentUser.id,number,date,companyId,companyName,kind,kindLabel:kindLabels[kind],contactId,contactName,projectId,projectName,contractNumber,paymentMethod,paymentMethodLabel,subtotal:totals.subtotal,discount:totals.fixedDiscount,discountType:totals.discountType,discountInput:totals.discountInput,vat:totals.vatAmount,vatType:totals.vatType,vatRate:totals.vatRate,grandTotal:totals.grandTotal,description,items,currencyLabel:cur,electronicDoc:edoc};
396 datastore.invoices.push(record);
396 - if(typeof jePostSourceRecord==='function'){try{jePostSourceRecord('sale',record);}catch(e){datastore.invoices=datastore.invoices.filter(x=>x.id!==record.id);alert('فاکتور ثبت نشد: '+e.message);return;}}
397 - alert('فاکتور و سند حسابداری با موفقیت ثبت شد.');
397 + if(invoiceCreatesAccountingEntry(kind)&&typeof jePostSourceRecord==='function'){try{jePostSourceRecord('sale',record);}catch(e){datastore.invoices=datastore.invoices.filter(x=>x.id!==record.id);alert('فاکتور ثبت نشد: '+e.message);return;}}
398 + alert(invoiceCreatesAccountingEntry(kind)?'فاکتور و سند حسابداری با موفقیت ثبت شد.':'سند عملیاتی ثبت شد؛ تا تبدیل به فاکتور فروش قطعی، ثبت حسابداری ایجاد نمی‌شود.');
399 cancelInvoiceEdit();
400 renderAndPrintDirect(record.id);
401 }