@@ -166,6 +166,41 @@ func ComputeTotals(transactions []*TransactionOverview, formatBase func(int64) s
166166 }
167167}
168168
169+ // TotalsMicros holds the raw micros totals for the transaction list, suitable for
170+ // further computation (e.g., applying tax rates).
171+ type TotalsMicros struct {
172+ // DividendBaseMicros is the total dividends (including WHT) in base currency micros.
173+ DividendBaseMicros int64
174+ // InterestBaseMicros is the total interest income in base currency micros.
175+ InterestBaseMicros int64
176+ // PnLBaseMicros is the total realized P&L in base currency micros.
177+ PnLBaseMicros int64
178+ // STCGBaseMicros is the total short-term capital gain in base currency micros.
179+ STCGBaseMicros int64
180+ // LTCGBaseMicros is the total long-term capital gain in base currency micros.
181+ LTCGBaseMicros int64
182+ }
183+
184+ // ComputeTotalsMicros sums the dividend, interest, P&L, STCG, and LTCG columns
185+ // across all transactions, returning raw micros values for further computation.
186+ func ComputeTotalsMicros (transactions []* TransactionOverview ) * TotalsMicros {
187+ var dividend , interest , pnl , stcg , ltcg int64
188+ for _ , t := range transactions {
189+ dividend += mathpb .ParseMicros (t .DividendBase )
190+ interest += mathpb .ParseMicros (t .InterestBase )
191+ pnl += mathpb .ParseMicros (t .PnLBase )
192+ stcg += mathpb .ParseMicros (t .STCGBase )
193+ ltcg += mathpb .ParseMicros (t .LTCGBase )
194+ }
195+ return & TotalsMicros {
196+ DividendBaseMicros : dividend ,
197+ InterestBaseMicros : interest ,
198+ PnLBaseMicros : pnl ,
199+ STCGBaseMicros : stcg ,
200+ LTCGBaseMicros : ltcg ,
201+ }
202+ }
203+
169204// GetTransactionList computes the unified transaction list from all data sources.
170205// baseCurrency is the target currency for conversion (e.g., "USD", "CAD").
171206// fromDate and toDate filter on the transaction date (inclusive). Zero dates mean no filter.
0 commit comments