add partial share ownership support (float)... and penny rounding errors.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Steven Polley 2025-05-07 21:14:02 -06:00
parent 61074bfd80
commit 3c274c614b

View File

@ -10,7 +10,7 @@ import (
type security struct { type security struct {
Symbol string `json:"symbol"` Symbol string `json:"symbol"`
Quantity int `json:"quantity"` Quantity float64 `json:"quantity"`
} }
type account struct { type account struct {
@ -63,7 +63,7 @@ func (p *Provider) GetBalances() ([]int, []string, error) {
if err != nil { if err != nil {
return balances, ynabAccountIDs, fmt.Errorf("failed to get quote for security with symbol '%s': %v", p.data.Accounts[i].Securities[j].Symbol, err) return balances, ynabAccountIDs, fmt.Errorf("failed to get quote for security with symbol '%s': %v", p.data.Accounts[i].Securities[j].Symbol, err)
} }
balance += price * p.data.Accounts[i].Securities[j].Quantity balance += int(float64(price) * p.data.Accounts[i].Securities[j].Quantity)
} }
balances = append(balances, balance) balances = append(balances, balance)
ynabAccountIDs = append(ynabAccountIDs, p.data.Accounts[i].YnabAccountID) ynabAccountIDs = append(ynabAccountIDs, p.data.Accounts[i].YnabAccountID)