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

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

fix(stage2.2): stop blind retry after uncertain treasury correction sync, preserve strict Quality assertion

davoodmehraban89 committed Oct 20, 2026 at 08:37 UTC aab397e27587bcd79b50cc5672eda6257ba811ca
3 files changed +20
PROJECT_STATE.md
+6
@@ -193,3 +193,9 @@
193 - Quality Run 39279806527 Job 118153313734 Step 54 FAIL, 122/123: remaining treasury-payment correction alert test is outside Stage 2.2. Assertion and treasury behavior unchanged.
194 - Parity Run 39279797472 Job 118151737095 Step 7 FAIL: 1069 baseline objects each side, no missing/extra, 30 raw function-definition hash differences. QA-only repair must still require identical non-function definitions and tokenwise equivalence of all 154 functions plus function metadata; NEW RUN REQUIRED before a parity PASS claim. Baseline is 2026-10-16 read-only snapshot, not live Production.
195 - Stage 2.2 NOT accepted, PR #162 remains Draft [DO NOT MERGE]. No Stage 2.3, Production DDL/DML or enforce, main merge, Phase 1B, deployment, login-resilience or treasury code changes authorized.
196 +
197 +
198 +### 2026-10-20 — Stage2.2 QA: treasury uncertainty fail-closed correction on feature only
199 +- Quality Run 39321288312 static-quality Job 118295699805 Step 54: 122/123 PASS; sole failing browser assertion `scripts/accounting-document-workflow.spec.js:624–643` on treasury correction lost-RPC acknowledgement; `server.failCount=1` but automatic sync retry could erase the intended failure before the UI informed user.
200 +- Corrective Stage2.2-only behavior: mark an uncertain payment correction batch inside `js/organization-rbac.js` and stop automatic retries in `js/sync.js`, preserving unsaved records; test retains original strict expectations (one failure, no partial server correction, user notified). No new reversal, payment posting contract or Stage2.3 RPC.
201 +- Run 39321281224 real-stack PASS, 39321281261 harness PASS, 39321281478 exact-head snapshot parity PASS, 39321288324 Security PASS. No Production SQL, main merge, login branch changes or enforce Production.
js/organization-rbac.js
+5
@@ -137,6 +137,11 @@ runSync=async function(){
137 p_deletes:deletes,p_organization_id:currentUser.organizationId
138 });
139 if(error){
140 + // Protect legacy treasury correction batches from blind retry on a lost
141 + // acknowledgement: a timeout cannot distinguish committed vs uncommitted.
142 + // Keep all staged local records intact, do not run tenant-wide reload.
143 + if(up.some(r=>r.coll==='payments'&&typeof r.payload?.correctsPaymentId==='string'&&r.payload.correctsPaymentId))
144 + error.finoraFinancialAmendUncertain=true;
145 const changed=[...up,...del.map(key=>({coll:key.split('|')[0],id:key.split('|').slice(1).join('|')}))]
146 .find(x=>['journalVouchers','journalLines','journalLineDimensions'].includes(x.coll));
147 if(changed)error.finoraJournalVoucherId=changed.coll==='journalVouchers'?changed.id:
js/sync.js
+9
@@ -119,6 +119,15 @@ async function runSync(){
119 }
120 async function handleSyncError(err){
121 const msg=String((err&&err.message)||''),code=String((err&&err.code)||'');
122 + if(err?.finoraFinancialAmendUncertain){
123 + // Financial compensator + replacement is a single logical batch.
124 + // A network error means outcome uncertain. Do not blind-retry, do not
125 + // full-pull and never silently discard unrelated unsaved edits.
126 + syncFailCount++;
127 + syncPending=false;
128 + setSyncBadge('error');
129 + return;
130 + }
131 // Classify journal failures BEFORE generic RLS/CAS reconciliation.
132 // Never replace unrelated unsaved collections with a tenant-wide pullAll.
133 const journalError=!!err?.finoraJournalVoucherId ||