performance - Optimize double entry balance calculations -
i'm implementing double entry bookkeeping system wallet service , have concern regarding fast , accurate balance calculation. thing double entry method transactions traceable i'm trying find out way avoid recalculations. suppose have following structure account (golang syntax):
type account struct { entries []accountentry details accountdetails // ... other relevant fields } type accountentry struct { amount int currency string direction direction //debit or credit accountnumber accountnumber // account number current entry belongs timestamp time uuid string }
so particular account balance calculation need iterate on entries , calculate debits , credits , deduction every time. there solution seems obvious me pre-calculate balance previous entries , keep somewhere , reuse future queries i'm wondering if it's right direction or there better way achieve that. advice designed such systems before appreciated.
please comment down if explanation of problem not clear enough. try add more details
thanks in advance.
Comments
Post a Comment