qa: establish authorised synthetic baseline and expose exact balance inconsistency
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
checkDecisionBalance,
|
||||
calculateDecisionRatios,
|
||||
} from '../../resources/js/lib/business-plan-guidance.ts';
|
||||
|
||||
const supplied2025 = () => ({
|
||||
cash: '90756',
|
||||
receivables: '469',
|
||||
inventory: '0',
|
||||
otherCurrentAssets: '150000',
|
||||
longTermAssets: '260250',
|
||||
accumulatedDepreciation: '0',
|
||||
currentLiabilities: '1642',
|
||||
longTermLiabilities: '0',
|
||||
paidCapital: '1825250',
|
||||
retainedResults: '-1325000',
|
||||
periodResult: '-416',
|
||||
});
|
||||
|
||||
void test('the supplied 2025 balance is one currency unit out of balance and cannot produce decision ratios', () => {
|
||||
const source = supplied2025(),
|
||||
before = JSON.stringify(source);
|
||||
const balance = checkDecisionBalance(source);
|
||||
assert.equal(balance.assets, '501475.00');
|
||||
assert.equal(balance.liabilitiesAndCapital, '501476.00');
|
||||
assert.equal(balance.difference, '-1.00');
|
||||
assert.equal(balance.balanced, false);
|
||||
assert.match(balance.error, /não estão equilibrados/);
|
||||
assert.throws(
|
||||
() => calculateDecisionRatios(source, '14537'),
|
||||
/não estão equilibrados/,
|
||||
);
|
||||
assert.equal(JSON.stringify(source), before);
|
||||
});
|
||||
|
||||
void test('cent discrepancies are never hidden by a balancing entry or materiality tolerance', () => {
|
||||
const source = { ...supplied2025(), currentLiabilities: '1641.01' };
|
||||
assert.equal(checkDecisionBalance(source).difference, '-0.01');
|
||||
assert.equal(checkDecisionBalance(source).balanced, false);
|
||||
assert.equal(source.currentLiabilities, '1641.01');
|
||||
});
|
||||
|
||||
void test('a separately identified synthetic balanced scenario produces the approved ratios', () => {
|
||||
const synthetic = { ...supplied2025(), currentLiabilities: '1641' };
|
||||
const balance = checkDecisionBalance(synthetic);
|
||||
assert.equal(balance.balanced, true);
|
||||
const ratios = calculateDecisionRatios(synthetic, '14537', '10000');
|
||||
assert.equal(ratios.currentLiquidity, 241225 / 1641);
|
||||
assert.equal(ratios.debtAssets, 1641 / 501475);
|
||||
assert.equal(ratios.netMargin, -416 / 14537);
|
||||
assert.equal(ratios.returnOnEquity, -416 / 499834);
|
||||
assert.equal(ratios.salesGrowth, 14537 / 10000 - 1);
|
||||
});
|
||||
|
||||
void test('missing data remains missing and zero denominators do not become zero ratios', () => {
|
||||
assert.throws(
|
||||
() => checkDecisionBalance({ ...supplied2025(), receivables: '' }),
|
||||
/Preencha este campo/,
|
||||
);
|
||||
const zero = Object.fromEntries(
|
||||
Object.keys(supplied2025()).map((key) => [key, '0']),
|
||||
);
|
||||
assert.deepEqual(calculateDecisionRatios(zero, '0', '0'), {
|
||||
salesGrowth: null,
|
||||
currentLiquidity: null,
|
||||
debtAssets: null,
|
||||
netMargin: null,
|
||||
returnOnEquity: null,
|
||||
});
|
||||
assert.throws(
|
||||
() =>
|
||||
checkDecisionBalance({ ...zero, accumulatedDepreciation: '0.01' }),
|
||||
/depreciação acumulada/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user