Fix mirror master persistence and add group diagnostics

This commit is contained in:
A R R R Associates
2026-09-09 11:59:54 +05:30
parent 8bbdd3be30
commit 88bcd4d0a4
6 changed files with 139 additions and 12 deletions
@@ -339,7 +339,8 @@
<div id="fullExportProgress" class="mt-5 hidden rounded-xl border border-slate-200 bg-slate-50 p-4">
<div class="flex items-center justify-between gap-3"><div><div id="fullExportStage" class="font-semibold text-slate-900">Waiting…</div><div id="fullExportMessage" class="mt-1 text-xs text-slate-500"></div></div><div id="fullExportPct" class="text-lg font-bold text-slate-900">0%</div></div>
<div class="mt-3 h-3 overflow-hidden rounded-full bg-slate-200"><div id="fullExportBar" class="h-full bg-emerald-600 transition-all duration-300" style="width:0%"></div></div>
<div class="mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4"><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Ledgers</div><div id="fullExportLedgers" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Vouchers</div><div id="fullExportVouchers" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Voucher Lines</div><div id="fullExportLines" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Stock Movements</div><div id="fullExportInventory" class="mt-1 text-lg font-semibold">0</div></div></div>
<div class="mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-5"><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Ledgers</div><div id="fullExportLedgers" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Groups</div><div id="fullExportGroups" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Vouchers</div><div id="fullExportVouchers" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Voucher Lines</div><div id="fullExportLines" class="mt-1 text-lg font-semibold">0</div></div><div class="rounded-lg bg-white p-3"><div class="text-xs uppercase text-slate-500">Stock Movements</div><div id="fullExportInventory" class="mt-1 text-lg font-semibold">0</div></div></div>
<div id="fullExportMasterDiagnostics" class="mt-3 hidden rounded-lg border border-slate-200 bg-white px-3 py-2 text-xs text-slate-600"></div>
<div id="fullExportPaths" class="mt-3 break-all text-xs text-slate-500"></div><div id="fullExportError" class="mt-3 hidden rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700"></div>
</div>
</section>
@@ -574,7 +575,23 @@
const j=d.job||{}, p=Math.max(0,Math.min(100,Number(j.percent)||0)); box.classList.remove('hidden');
setText('fullExportStage',j.stage||j.status||'Working…'); setText('fullExportMessage',j.message||''); setText('fullExportPct',Math.round(p)+'%');
document.getElementById('fullExportBar').style.width=p+'%';
const rows=j.rows||((j.mirror||{}).counts)||{}; setText('fullExportLedgers',rows.ledger_master||0); setText('fullExportVouchers',rows.voucher||rows.voucher_header||0); setText('fullExportLines',rows.voucher_ledger_entry||rows.voucher_ledger||0); setText('fullExportInventory',rows.inventory_movement||rows.inventory||0);
const rows=j.rows||((j.mirror||{}).counts)||{};
setText('fullExportLedgers',rows.ledger_master||0);
setText('fullExportGroups',rows.group_master||0);
setText('fullExportVouchers',rows.voucher||rows.voucher_header||0);
setText('fullExportLines',rows.voucher_ledger_entry||rows.voucher_ledger||0);
setText('fullExportInventory',rows.inventory_movement||rows.inventory||0);
const diag=j.import_diagnostics||{};
const ledgerDiag=diag.ledgers||{}, groupDiag=diag.groups||{};
const diagEl=document.getElementById('fullExportMasterDiagnostics');
if(diagEl && (ledgerDiag.extracted_rows!=null || groupDiag.extracted_rows!=null)){
const parts=[];
if(ledgerDiag.extracted_rows!=null) parts.push('Ledgers: '+Number(ledgerDiag.extracted_rows||0)+' extracted → '+Number(ledgerDiag.stored_rows||0)+' stored');
if(groupDiag.extracted_rows!=null) parts.push('Groups: '+Number(groupDiag.extracted_rows||0)+' extracted → '+Number(groupDiag.stored_rows||0)+' stored');
if(diag.flat_master_rows!=null) parts.push('Flat master rows: '+Number(diag.flat_master_rows||0));
diagEl.textContent=parts.join(' • ');
diagEl.classList.remove('hidden');
}
const paths=[]; if(j.mirror_db_path)paths.push('Mirror: '+j.mirror_db_path); if(j.accounting_db_path)paths.push('Client DB: '+j.accounting_db_path); setText('fullExportPaths',paths.join(' • '));
const er=document.getElementById('fullExportError'); if(j.error){er.textContent=j.error;er.classList.remove('hidden')}else{er.classList.add('hidden')}
const status=String(j.status||'').toLowerCase();