سامانه صدور فاکتور و حسابداری
feat(sales): create linked accounting draft before final posting
davoodmehraban89 committed
Nov 18, 2026 at 09:06 UTC
ec62d0f7515b21cc8a0b4ca84319eb7e1d54f625
1 file changed
+4
-1
js/invoices.js
+4
-1
@@ -619,7 +619,10 @@ function commitSaveInvoice(){
619
}else{
620
const record={id:'INV_'+Date.now(),ownerUserId:currentUser.id,documentStatus:'draft',accountingStatus:'draft',documentVersion:1,createdAt:new Date().toISOString(),number,date,companyId,companyName,kind,kindLabel:kindLabels[kind],contactId,contactName,projectId,projectName,contractNumber,paymentMethod,paymentMethodLabel,warehouseId,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};
621
datastore.invoices.push(record);
622
- alert(invoiceCreatesAccountingEntry(kind)?'فاکتور بهصورت پیشنویس ذخیره شد. از حسابداری ← مدیریت اسناد میتوانید آن را بازبینی و قطعی کنید.':'سند عملیاتی ذخیره شد؛ ثبت حسابداری قطعی ایجاد نمیشود.');
622
+ if(invoiceCreatesAccountingEntry(kind)&&typeof jeRpcCreateSourceDraft==='function'){
623
+ void jeRpcCreateSourceDraft('sale',record.id).then(()=>refreshAllSurfaces()).catch(e=>alert('فاکتور ذخیره شد اما پیشنویس سند حسابداری روی سرور ایجاد نشد؛ پیش از قطعیسازی وضعیت را بررسی کنید: '+e.message));
624
+ }
625
+ alert(invoiceCreatesAccountingEntry(kind)?'فاکتور و سند حسابداری بهصورت موقت ذخیره شدند؛ قطعیسازی فقط از مسیر مجاز حسابداری انجام میشود.':'سند عملیاتی ذخیره شد؛ ثبت حسابداری قطعی ایجاد نمیشود.');
626
cancelInvoiceEdit();
627
renderAndPrintDirect(record.id);
628
}