فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(A02): ensure imbalanced inputs return actionable issues without posting

davoodmehraban89 committed Oct 16, 2026 at 16:58 UTC e7425b2514d76ff9f624594cf9fc574b18a8925c
1 file changed +14
tests/a02-opening-posting-integration.test.mjs
+14
@@ -167,3 +167,17 @@ test('A02: ordinary users cannot preview or post ledger opening', async () => {
167 confirmation: 'CONFIRM_OPENING_LEDGER'
168 }), /فقط برای مدیر/);
169 });
170 +
171 +test('A02: an unbalanced opening preview displays its discrepancy without ledger mutations', async () => {
172 + const { input } = await setup();
173 + input.lines[4].credit = 699;
174 + const report = await OpeningBalanceService.preview(input);
175 + assert.equal(report.readiness, 'blocked');
176 + assert.ok(report.issues.includes('UNBALANCED_OPENING_JOURNAL'));
177 + assert.deepEqual(report.journal, { debit: 900, credit: 899 });
178 + assert.equal((await StorageService.getAll('journal_entries')).length, 0);
179 + await assert.rejects(OpeningBalanceService.commit(input, {
180 + confirmation: 'CONFIRM_OPENING_LEDGER'
181 + }), /UNBALANCED_OPENING_JOURNAL/);
182 + assert.equal((await StorageService.getAll('journal_entries')).length, 0);
183 +});