Revert "Changed the code to use the currency_affinity value"

This reverts commit a67c103ccd.
This commit is contained in:
2025-08-31 19:35:30 +01:00
parent a67c103ccd
commit 05047af0c3
4 changed files with 4 additions and 21 deletions
+2 -7
View File
@@ -1,9 +1,7 @@
package expenses
import (
"expenses/config"
mod "expenses/expenses/models"
dec "github.com/shopspring/decimal"
)
@@ -50,9 +48,6 @@ func ParseFormShares(userIDs []string, shares []string, sharesIDs []string,
// NormalizeShares will take the total of an expense and the proposed shares
// and calculate how much each user actually has to pay - avoids fracd cents
func (a *ExpensesApp) NormalizeShares(e *mod.Expense) error {
cfg := config.GetInstance()
affi := cfg.CurrencyAffinity
excess := dec.NewFromFloat(0.0)
ownerShIdx := -1
for k := range e.Shares {
@@ -60,9 +55,9 @@ func (a *ExpensesApp) NormalizeShares(e *mod.Expense) error {
ownerShIdx = k
}
owed := e.Value.Mul(e.Shares[k].Share)
excess = excess.Add(owed.Sub(owed.Truncate(affi)))
excess = excess.Add(owed.Sub(owed.Truncate(2)))
e.Shares[k].Calculated = owed.Truncate(affi)
e.Shares[k].Calculated = owed.Truncate(2)
}
// It fails here for some reason