@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 4a39127
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 22:00 UTC

feat: expose ATF and temporary journal number in UI

davoodmehraban89 committed Nov 18, 2026 at 09:00 UTC 4a39127344e9b687c3fd5bd700658260270f6dad
1 file changed +5 -5
js/journal-ui.js
+5 -5
@@ -5,7 +5,7 @@ function ensureJournalView(){
5 <div class="card" data-finora-task="new"><h3>ثبت سند حسابداری</h3><div class="form-row"><div class="form-group"><label>شماره سند</label><input id="je-number" class="form-control" value="پس از قطعی‌سازی توسط سرور تخصیص می‌یابد" readonly></div><div class="form-group"><label>تاریخ</label><input id="je-date" class="form-control"></div><div class="form-group"><label>نوع سند</label><select id="je-voucher-type" class="form-control"><option value="manual">عادی</option><option value="adjustment">اصلاحی</option><option value="opening">افتتاحیه</option><option value="closing">اختتامیه</option></select></div><div class="form-group"><label>مرجع</label><input id="je-reference" class="form-control" placeholder="شماره فاکتور/قرارداد/نامه"></div></div>
6 <div class="form-row"><div class="form-group" style="flex:1"><label>شرح سند</label><input id="je-desc" class="form-control"></div></div><div id="je-lines"></div>
7 <div id="je-totals" class="af-hint" style="margin:10px 0;font-weight:700"></div><input type="hidden" id="je-edit-voucher-id" value=""><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn btn-secondary" onclick="jeAddRow()">+ آرتیکل</button><button id="je-save-draft-button" class="btn btn-success" onclick="jeSaveManual()">ثبت پیش‌نویس</button><button id="je-cancel-edit-button" class="btn btn-secondary" onclick="jeClearManualForm()" style="display:none">انصراف از ویرایش</button></div></div>
8 - <div class="card" data-finora-task="register"><h3>فهرست اسناد حسابداری</h3><div class="table-responsive"><table><thead><tr><th>شماره</th><th>تاریخ</th><th>نوع</th><th>مرجع</th><th>شرح</th><th>وضعیت</th><th>بدهکار</th><th>بستانکار</th><th>منبع</th><th>عملیات</th></tr></thead><tbody id="je-vouchers"></tbody></table></div></div>
8 + <div class="card" data-finora-task="register"><h3>فهرست اسناد حسابداری</h3><div class="table-responsive"><table><thead><tr><th>شماره عطف</th><th>شماره سند</th><th>شماره موقت</th><th>تاریخ</th><th>نوع</th><th>مرجع</th><th>شرح</th><th>وضعیت</th><th>بدهکار</th><th>بستانکار</th><th>منبع</th><th>عملیات</th></tr></thead><tbody id="je-vouchers"></tbody></table></div></div>
9 <div class="card" data-finora-task="documents"><h3>مدیریت اسناد — فروش، خرید، دریافت و پرداخت</h3>
10 <p class="af-hint">«اصلاح» همان سند را در فرم اصلی باز می‌کند. هنگام ذخیره، سابقه حسابداری به‌صورت قابل‌ردیابی حفظ می‌شود؛ بازکردن یا انصراف هیچ ثبت جدیدی ایجاد نمی‌کند. دریافت/پرداختِ دارای تخصیص به فاکتور یا چک، ابتدا نیازمند تطبیق مستقل است. ابطال فقط ثبت نرم‌افزاری را خنثی می‌کند و تراکنش واقعی بانکی را برگشت نمی‌دهد.</p>
11 <label for="document-status-filter">نمایش وضعیت</label> <select id="document-status-filter" class="form-control" style="max-width:200px" onchange="renderDocumentManagement()"><option value="all">همه</option><option value="draft">پیش‌نویس</option><option value="posted">قطعی</option><option value="reversed">ابطال/برگشت‌شده</option><option value="legacy_review">قدیمی و نیازمند تطبیق</option></select>
@@ -49,7 +49,7 @@ async function jeCancelPostedUi(id){
49 if(!confirm('سند قطعی بدون حذف سابقه، با سند برگشتی خنثی شود؟'))return;
50 try{await jeRpcReverse(id,getJalaliNumeric(),'ابطال: '+why);renderJournal()}catch(e){alert(e.message)}
51 }
52 -async function jeSaveManual(){try{const input={date:document.getElementById('je-date').value||getJalaliNumeric(),voucherType:document.getElementById('je-voucher-type').value,reference:document.getElementById('je-reference').value,description:document.getElementById('je-desc').value,lines:jeCollectRows()};const editId=document.getElementById('je-edit-voucher-id')?.value;const v=editId?await jeRpcUpdateDraft(editId,input):await jeRpcCreateDraft(input);alert('پیش‌نویس سند در سرور ذخیره شد. شماره پس از قطعی‌سازی تخصیص می‌یابد.');jeClearManualForm();renderJournal()}catch(e){alert(e.message)}}
52 +async function jeSaveManual(){try{const input={date:document.getElementById('je-date').value||getJalaliNumeric(),voucherType:document.getElementById('je-voucher-type').value,reference:document.getElementById('je-reference').value,description:document.getElementById('je-desc').value,lines:jeCollectRows()};const editId=document.getElementById('je-edit-voucher-id')?.value;const v=editId?await jeRpcUpdateDraft(editId,input):await jeRpcCreateDraft(input);alert('پیش‌نویس سند در سرور ذخیره شد. شماره عطف از همین لحظه اختصاص یافته و هرگز تکرار نمی‌شود؛ شماره موقت نیز ثبت شد. شماره قطعی هنگام قطعی‌سازی اختصاص می‌یابد.');jeClearManualForm();renderJournal()}catch(e){alert(e.message)}}
53 async function jePostUi(id){try{await jeRpcPost(id);renderJournal()}catch(e){alert(e.message)}}
54 async function jeReverseUi(id){const why=prompt('علت برگشت سند:','اصلاح ثبت');if(why===null)return;try{await jeRpcReverse(id,getJalaliNumeric(),why);renderJournal()}catch(e){alert(e.message)}}
55 async function jeCopyVoucherUi(id){try{const v=await jeRpcCopyVoucher(id,getJalaliNumeric());alert('کپی سند در سرور به‌صورت پیش‌نویس ایجاد شد.');renderJournal()}catch(e){alert(e.message)}}
@@ -74,15 +74,15 @@ function renderJournal(options={}){
74 if(typeof afEnsureAccountingP0Compatibility==='function')afEnsureAccountingP0Compatibility();
75 jeEnsureDefaultProfiles();
76 const body=document.getElementById('je-vouchers'),vs=getMyJournalVouchers().slice().sort((a,b)=>String(b.createdAt).localeCompare(String(a.createdAt)));
77 - if(body)body.innerHTML=vs.length?vs.map(v=>{const status=typeof jeRpcEffectiveStatus==='function'?jeRpcEffectiveStatus(v):v.status;return '<tr data-voucher-id="'+esc(v.id)+'"><td>'+esc(v.number||'پس از قطعی‌سازی')+'</td><td>'+esc(v.date)+'</td><td>'+esc(jeTypeLabel(v.voucherType))+'</td><td>'+esc(v.reference||'—')+'</td><td>'+esc(v.description)+'</td><td data-status-cell>'+esc(jeStatusLabel(status))+'</td><td>'+Number(v.totalDebit||0).toLocaleString('fa-IR')+'</td><td>'+Number(v.totalCredit||0).toLocaleString('fa-IR')+'</td><td>'+esc(v.sourceType||'manual')+'</td><td data-actions-cell>'+jeJournalActions(v,status)+'</td></tr>'}).join(''):'<tr><td colspan="10" class="af-empty">سندی ثبت نشده است.</td></tr>';
77 + if(body)body.innerHTML=vs.length?vs.map(v=>{const status=typeof jeRpcEffectiveStatus==='function'?jeRpcEffectiveStatus(v):v.status;return '<tr data-voucher-id="'+esc(v.id)+'"><td>'+esc(v.atfNumber||'—')+'</td><td>'+esc(v.number||'—')+'</td><td>'+esc(v.temporaryNumber||'—')+'</td><td>'+esc(v.date)+'</td><td>'+esc(jeTypeLabel(v.voucherType))+'</td><td>'+esc(v.reference||'—')+'</td><td>'+esc(v.description)+'</td><td data-status-cell>'+esc(jeStatusLabel(status))+'</td><td>'+Number(v.totalDebit||0).toLocaleString('fa-IR')+'</td><td>'+Number(v.totalCredit||0).toLocaleString('fa-IR')+'</td><td>'+esc(v.sourceType||'manual')+'</td><td data-actions-cell>'+jeJournalActions(v,status)+'</td></tr>'}).join(''):'<tr><td colspan="12" class="af-empty">سندی ثبت نشده است.</td></tr>';
78 const tb=document.getElementById('je-trial'),rows=jeTrialBalance();
79 if(tb)tb.innerHTML=rows.length?rows.map(x=>'<tr><td>'+esc(x.code)+'</td><td>'+esc(x.title)+'</td><td>'+x.debit.toLocaleString('fa-IR')+'</td><td>'+x.credit.toLocaleString('fa-IR')+'</td><td>'+x.balance.toLocaleString('fa-IR')+'</td></tr>').join(''):'<tr><td colspan="5" class="af-empty">گردشی وجود ندارد.</td></tr>';
80 const d=document.getElementById('je-date');if(d&&!d.value)d.value=getJalaliNumeric();
81 - const n=document.getElementById('je-number');if(n)n.value='پس از قطعی‌سازی توسط سرور تخصیص می‌یابد';
81 + const n=document.getElementById('je-number');if(n)n.value='شماره قطعی پس از قطعی‌سازی توسط سرور تخصیص می‌یابد';
82 if(!document.querySelector('#je-lines .je-line')){jeAddRow();jeAddRow()}
83 jeUpdateTotals();if(typeof renderDocumentManagement==='function')renderDocumentManagement();
84 if(!options.skipStatusRefresh&&currentUser?.organizationId&&typeof jeRpcRefreshEffectiveStatuses==='function'){
85 jeRpcRefreshEffectiveStatuses().then(()=>renderJournal({skipStatusRefresh:true})).catch(e=>console.error('journal reversal status read failed',e));
86 }
87 }
88 -document.addEventListener('DOMContentLoaded',ensureJournalView);
88 +document.addEventListener('DOMContentLoaded',ensureJournalView);
\ No newline at end of file