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

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

fix(company): stamp company on expenses.js records and guard company writes

davoodmehraban89 committed Oct 14, 2026 at 11:35 UTC a8b024a3da9dbd05e20f761223017453b385b39e
1 file changed +2 -1
js/expenses.js
+2 -1
@@ -3,7 +3,8 @@ function commitSaveExpense(){
3 if(!currentUser)return;
4 const amount=parseFormattedNumber(document.getElementById('trx-amount-input').value);
5 if(amount<=0){alert('مبلغ معتبر نیست.');return;}
6 - const kind=document.getElementById('trx-kind-input').value,contactId=document.getElementById('trx-contact-select')?.value||'',projectId=document.getElementById('trx-project-select')?.value||'',record={id:'TRX_'+Date.now(),ownerUserId:currentUser.id,companyId:typeof afCompanyId==='function'?afCompanyId():'',kind,category:document.getElementById('trx-category-input').value,amount,desc:document.getElementById('trx-desc-input').value,contactId,projectId,date:getJalaliNumeric(),accountingVersion:1};
6 + if(!finoraActiveCompanyId())return alert('ابتدا شرکت فعال را انتخاب کنید.');
7 + const kind=document.getElementById('trx-kind-input').value,contactId=document.getElementById('trx-contact-select')?.value||'',projectId=document.getElementById('trx-project-select')?.value||'',record={id:'TRX_'+Date.now(),ownerUserId:currentUser.id,companyId:finoraActiveCompanyId(),kind,category:document.getElementById('trx-category-input').value,amount,desc:document.getElementById('trx-desc-input').value,contactId,projectId,date:getJalaliNumeric(),accountingVersion:1};
8 datastore.expenses.push(record);
9 if(typeof jePostSourceRecord==='function'){try{jePostSourceRecord(kind,record);}catch(e){datastore.expenses=datastore.expenses.filter(x=>x.id!==record.id);alert('هزینه/درآمد ثبت نشد: '+e.message);return;}}
10 saveDatastore();