diff --git a/engine/account.go b/engine/account.go index 2b52cfead..fcb2a70c0 100644 --- a/engine/account.go +++ b/engine/account.go @@ -129,13 +129,15 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error { a.Balance.Value = -a.Balance.Value a.Balance.dirty = true // Mark the balance as dirty since we have modified and it should be checked by action triggers ub.BalanceMap[id] = append(ub.BalanceMap[id], a.Balance) - if a.Balance.SharedGroup != "" { - // add shared group member - sg, err := accountingStorage.GetSharedGroup(a.Balance.SharedGroup, false) - if err != nil || sg == nil { - //than problem - Logger.Warning(fmt.Sprintf("Could not get shared group: %v", a.Balance.SharedGroup)) - } else { + } + if a.Balance.SharedGroup != "" { + // add shared group member + sg, err := accountingStorage.GetSharedGroup(a.Balance.SharedGroup, false) + if err != nil || sg == nil { + //than problem + Logger.Warning(fmt.Sprintf("Could not get shared group: %v", a.Balance.SharedGroup)) + } else { + if !utils.IsSliceMember(sg.MemberIds, ub.Id) { // add member and save sg.MemberIds = append(sg.MemberIds, ub.Id) accountingStorage.SetSharedGroup(sg)