سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 19:30 UTC
Integrate sales with Phase 3 automatic posting
davoodmehraban89 committed
Sep 28, 2026 at 18:33 UTC
64211cd7353813969e557af59f488a2a132e1131
1 file changed
+3
-1
js/invoices.js
+3
-1
@@ -381,6 +381,7 @@ function commitSaveInvoice(){
381
const kindLabels={formal:'رسمی',non_formal:'غیررسمی',pre_invoice:'پیشفاکتور',contract_statement:'صورت وضعیت پیمان'};
382
const cur=getCurrencyLabel();
383
if(editId){
384
+ const lockedExisting=getMyInvoices().find(i=>i.id===editId);if(typeof jeGuardSourceMutation==='function'){try{jeGuardSourceMutation(lockedExisting,'فاکتور فروش');}catch(e){alert(e.message);return;}}
385
const existingIndex=datastore.invoices.findIndex(i=>i.id===editId&&i.ownerUserId===currentUser.id);
386
if(existingIndex!==-1){
387
const prev=datastore.invoices[existingIndex];
@@ -392,7 +393,8 @@ function commitSaveInvoice(){
393
}else{
394
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};
395
datastore.invoices.push(record);
395
- alert('فاکتور با موفقیت ثبت شد.');
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('فاکتور و سند حسابداری با موفقیت ثبت شد.');
398
cancelInvoiceEdit();
399
renderAndPrintDirect(record.id);
400
}