سامانه صدور فاکتور و حسابداری
fix: reject autopost replay for effectively reversed source vouchers
davoodmehraban89 committed
Nov 17, 2026 at 14:21 UTC
3a9dbd6aa60e742f252b80778be9cec488421992
1 file changed
+3
-1
js/journal-rpc.js
+3
-1
@@ -209,7 +209,8 @@ async function jeRpcAutoPost(kind,sourceId){
209
if(source.journalVoucherId){
210
let existing=getMyJournalVouchers().find(v=>v.id===source.journalVoucherId);
211
if(!existing){await jeRpcRefresh(org);source=jeRpcSourceRecord(collection,sourceId);existing=getMyJournalVouchers().find(v=>v.id===source?.journalVoucherId);}
212
- if(existing?.status==='posted'){delete source.accountingPostingPending;delete source.accountingPostingPendingAt;return existing;}
212
+ if(existing?.status==='posted'&&jeRpcEffectiveStatus(existing)!=='reversed'){delete source.accountingPostingPending;delete source.accountingPostingPendingAt;return existing;}
213
+ if(existing&&jeRpcEffectiveStatus(existing)==='reversed')throw new Error('سند منبع قبلاً برگشت حسابداری شده است؛ ثبت مجدد مجاز نیست.');
214
throw new Error('رکورد منبع از قبل به سندی متصل است؛ وضعیت اتصال باید بررسی شود.');
215
}
216
if(!Number.isSafeInteger(Number(source.grandTotal))||Number(source.grandTotal)<=0)
@@ -249,6 +250,7 @@ async function jeRpcAutoPost(kind,sourceId){
250
throw new Error('این منبع قبلاً برگشت حسابداری شده است؛ ثبت مجدد آن مجاز نیست.');
251
}
252
await jeRpcRefresh(org);
253
+ if(jeRpcEffectiveStatus(voucher)==='reversed')throw new Error('این منبع قبلاً برگشت حسابداری شده است؛ ثبت مجدد آن مجاز نیست.');
254
const reconciledSource=jeRpcSourceRecord(collection,sourceId);
255
if(!reconciledSource||reconciledSource.journalVoucherId!==voucher.id||
256
reconciledSource.accountingStatus!=='posted'||reconciledSource.documentStatus!=='posted')