Moving in another direction regarding debts

This commit is contained in:
2025-08-25 22:04:35 +01:00
parent 49a1978736
commit b5d918a873
13 changed files with 177 additions and 16 deletions
+13 -1
View File
@@ -172,6 +172,8 @@ func ExpenseTotalPayed(exp *mod.Expense) decimal.Decimal {
}
func ExpenseIsEvenlyShared(exp *mod.Expense) bool {
log.Printf("is exp %d even?", exp.ExpID)
shares := mapShares(exp)
payments := mapPayments(exp)
@@ -184,11 +186,14 @@ func ExpenseIsEvenlyShared(exp *mod.Expense) bool {
return false
}
if !val.Equal(userShare) {
if !val.Truncate(2).Equal(userShare.Truncate(2)) {
log.Printf("No: %s != %s", val.Truncate(2), userShare.Truncate(2))
return false
}
}
log.Printf("Yes")
return true
}
@@ -198,6 +203,13 @@ func analyzeExpense(e *mod.Expense) {
// Figure out if its evenly shared by the people associated to it
e.SharesEven = ExpenseIsEvenlyShared(e)
// Create the debts
debts, err := CalculateDebts(e)
if err != nil {
// do nothing apparently
}
e.Debts = debts
}
func (s *Service) NewExpense(exp mod.Expense) error {