Add interest calculation tests from go-luca #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
As part of the go-luca decomposition, interest computation is moving from go-luca to gobank-products. go-luca will retain the schema (account interest fields, balances_live table) but all interest calculation logic and tests now belong here.
What was removed from go-luca
Code (
interest.go)defaultInterest— simple daily: balance * rate / 365InterestResulttypeEnsureInterestAccounts— create Expense:Interest / Income:Interest accountscomputeInterest— dispatch to InterestFunc or defaultCalculateDailyInterest— one day, one accountpostInterest— record interest as movementRunDailyInterest— all accounts for one dayRunInterestForPeriod— date rangeTests (
interest_test.go)TestDailyInterestCalculation— 3.65% on £1000 = 10p/dayTestInterestCompounding— 30 days at 10%, verify compound > simpleTestZeroRateNoInterest— zero rate returns nilTestRunDailyInterestMultipleAccounts— two accounts, different ratesTestSetInterestMethod— set/get method on accountTestMethodBackwardCompat— empty method falls back to defaultTestCustomInterestFunc— pluggable interest function (doubles default)TestInterestFuncWithAccumulator— discrete method with extended-precision accumulatorTestRunDailyInterestNoInterestBearingAccounts— no interest accounts = empty resultsTestIssue1_InterestCrossTimezone— cross-timezone interest regression (issue #1)Benchmarks
BenchmarkInterestNAccounts— N=10/100/1000/10000 accountsBenchmarkCompoundMovementWithProjections— movement + interest + live balanceWhat gobank-products already has
interest.gowithInterestAccrualevent handler andcomputeDailyInterestinterest_test.gowithTestInterestAccrual_SingleDayandTestInterestAccrual_TenDaysTODO
InterestAccrualcovers all go-luca scenariosMigrated from Codeberg: originally #2, opened 2026-03-27.