3 ms·
To build a chart of accounts, you can have a parent column in accounts table. Account balances is just: SELECT account.name, SUM(amount) balance FROM account
by meekaaku 4y ago
To build a chart of accounts, you can have a parent column in accounts table.
Account balances is just:
SELECT account.name, SUM(amount) balance
FROM account ac
INNER JOIN transaction_line tl ON tl.account_id = ac.id
GROUP BY account.name
You can cache this balance values with a current_balance column on accounts table
Once you have that, for any real world transaction, all you need to figure out is what are the accounts to debit/credit, ie classification. That is a higher level thing and is the business logic of an accounting application.