سامانه صدور فاکتور و حسابداری
feat(lifecycle): wire journal draft-post-delete lifecycle
davoodmehraban89 committed
Nov 18, 2026 at 09:07 UTC
135979937231b82e4c33c64eac10558f71a4d156
1 file changed
+7
-4
js/journal-rpc.js
+7
-4
@@ -112,17 +112,20 @@ async function jeRpcPost(voucherId){
112
const data=await jeRpcCall('finora_journal_post',{
113
p_organization_id:org,p_voucher_id:voucherId,p_expected_version:Number(v._serverVersion)
114
});
115
+ const postedLocal=data?.voucher||getMyJournalVouchers().find(x=>x.id===voucherId);
116
+ if(!postedLocal?.companyId||!postedLocal?.fiscalYearId)throw new Error('اطلاعات شرکت/سال مالی سند برای شماره قطعی کامل نیست.');
117
+ const {data:identified,error:identifyError}=await sb.rpc('finora_assign_permanent_document_number',{p_organization_id:org,p_collection:'journalVouchers',p_id:voucherId,p_company_id:String(postedLocal.companyId),p_fiscal_year_id:String(postedLocal.fiscalYearId),p_document_type:'journal'});
118
+ if(identifyError)throw identifyError;
119
await jeRpcRefresh(org);
116
- return data?.voucher||getMyJournalVouchers().find(x=>x.id===voucherId)||data;
120
+ return identified||getMyJournalVouchers().find(x=>x.id===voucherId)||data;
121
}
122
async function jeRpcDeleteDraft(voucherId){
123
if(!requireWrite())throw new Error('مجوز حذف پیشنویس ندارید.');
124
const org=await jeRpcAssertContext(),v=getMyJournalVouchers().find(x=>x.id===voucherId);
125
if(!v||v.status!=='draft'||(v.sourceType||'manual')!=='manual')throw new Error('فقط پیشنویس دستی قابل حذف است.');
126
if(!Number.isInteger(Number(v._serverVersion)))throw new Error('نسخه معتبر سند در سرور پیدا نشد.');
123
- const data=await jeRpcCall('finora_journal_delete_draft',{
124
- p_organization_id:org,p_voucher_id:voucherId,p_expected_version:Number(v._serverVersion)
125
- });
127
+ const {data,error}=await sb.rpc('finora_delete_draft_voucher',{p_organization_id:org,p_voucher_id:voucherId});
128
+ if(error)throw error;
129
await jeRpcRefresh(org);
130
return data;
131
}