feat: add team cash flow amount presentation

This commit is contained in:
Bastian Wagner
2026-08-01 20:16:09 +02:00
parent 4e6b945eec
commit 239b157015
6 changed files with 200 additions and 1 deletions

View File

@@ -1,4 +1,50 @@
import { signedTransactionAmount } from './transaction-amount';
import { presentCashFlow, signedTransactionAmount } from './transaction-amount';
describe('presentCashFlow', () => {
it.each([
{
amount: 12,
type: 0,
context: 'player' as const,
expected: { direction: 'inflow', amount: 12, sign: '+' },
},
{
amount: -12,
type: 'payment',
context: 'player' as const,
expected: { direction: 'outflow', amount: 12, sign: '' },
},
{
amount: 8.5,
type: { id: 1, name: 'credit' },
context: 'team' as const,
expected: { direction: 'inflow', amount: 8.5, sign: '+' },
},
{
amount: 8.5,
type: { id: 14, name: 'expense' },
context: 'team' as const,
expected: { direction: 'outflow', amount: 8.5, sign: '' },
},
{
amount: 7,
type: 'fine',
context: 'player' as const,
expected: { direction: 'neutral', amount: 7, sign: '' },
},
{
amount: -7,
type: 'unknown',
context: 'player' as const,
expected: { direction: 'neutral', amount: 7, sign: '' },
},
])(
'presents $context $type transactions with their cash-flow direction',
({ amount, type, context, expected }) => {
expect(presentCashFlow(amount, type, context)).toEqual(expected);
},
);
});
describe('signedTransactionAmount', () => {
it('shows debit transaction types as negative amounts', () => {