From 9c2f0d42e946380b992f433516d77e257572894a Mon Sep 17 00:00:00 2001 From: Dennis Kleber Date: Fri, 17 Nov 2023 13:52:25 +0100 Subject: [PATCH 1/4] email bug --- dao/participation.go | 8 ++++++++ handlers/token/participation.go | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dao/participation.go b/dao/participation.go index 9fadf07..36042d8 100644 --- a/dao/participation.go +++ b/dao/participation.go @@ -117,6 +117,14 @@ func ParticipationUpdate(ctx context.Context, i *models.ParticipationUpdate, tok ); err != nil { return } + if event.Status != result.Status { + if result.Status == "confirmed" || result.Status == "rejected" { + ParticipationNotification(ctx, result) + } + if result.Status == "withdrawn" { + ParticipationWithdrawnNotification(ctx, result) + } + } return } diff --git a/handlers/token/participation.go b/handlers/token/participation.go index b672ed3..4a8b3f0 100644 --- a/handlers/token/participation.go +++ b/handlers/token/participation.go @@ -127,12 +127,6 @@ func (i *ParticipationHandler) Update(cc echo.Context) (err error) { if result, err = dao.ParticipationUpdate(c.Ctx(), body, token); err != nil { return } - if result.Status == "confirmed" || result.Status == "rejected" { - dao.ParticipationNotification(c.Ctx(), result) - } - if result.Status == "withdrawn" { - dao.ParticipationWithdrawnNotification(c.Ctx(), result) - } return c.Updated(result) } From e6b5f997947caabd4aa4e3c21940d49b7376ca69 Mon Sep 17 00:00:00 2001 From: Dennis Kleber Date: Fri, 17 Nov 2023 14:12:22 +0100 Subject: [PATCH 2/4] add currency to empty currencies --- dao/updates.go | 15 ++++++++++++--- models/deposit.go | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dao/updates.go b/dao/updates.go index 658361a..7d47f8a 100644 --- a/dao/updates.go +++ b/dao/updates.go @@ -68,6 +68,12 @@ func UpdateDatabase() { UpdateEventCanceledNoIncome(ctx) InsertUpdate(ctx, "taking_no_income_event_canceled") } + if !CheckUpdated(ctx, "currency_problem") { + UpdateDepositCurrency(ctx) + UpdateDepositUnitCurrency(ctx) + UpdateTakingCurrency(ctx) + InsertUpdate(ctx, "currency_problem") + } } func UpdateCrewMaibox(ctx context.Context) { @@ -125,21 +131,24 @@ func UpdateConfirmAdmin(ctx context.Context) { func UpdateTakingCurrency(ctx context.Context) { update := bson.D{{Key: "currency", Value: "EUR"}} - if _, err := TakingCollection.Collection.UpdateMany(ctx, bson.D{}, vmdb.UpdateSet(update)); err != nil { + filter := bson.D{{Key: "money.currency", Value: ""}} + if _, err := TakingCollection.Collection.UpdateMany(ctx, filter, vmdb.UpdateSet(update)); err != nil { return } } func UpdateDepositCurrency(ctx context.Context) { update := bson.D{{Key: "money.currency", Value: "EUR"}} - if _, err := DepositCollection.Collection.UpdateMany(ctx, bson.D{}, vmdb.UpdateSet(update)); err != nil { + filter := bson.D{{Key: "money.currency", Value: ""}} + if _, err := DepositCollection.Collection.UpdateMany(ctx, filter, vmdb.UpdateSet(update)); err != nil { return } } func UpdateDepositUnitCurrency(ctx context.Context) { update := bson.D{{Key: "money.currency", Value: "EUR"}} - if _, err := DepositUnitCollection.Collection.UpdateMany(ctx, bson.D{}, vmdb.UpdateSet(update)); err != nil { + filter := bson.D{{Key: "money.currency", Value: ""}} + if _, err := DepositUnitCollection.Collection.UpdateMany(ctx, filter, vmdb.UpdateSet(update)); err != nil { return } } diff --git a/models/deposit.go b/models/deposit.go index c95cabc..4383cc9 100644 --- a/models/deposit.go +++ b/models/deposit.go @@ -55,7 +55,7 @@ type ( HasExternal bool `json:"has_external" bson:"has_external"` External External `json:"external" bson:"external"` UpdateState string `json:"update_state" bson:"-"` - Money vmod.Money `json:"-" bson:"money"` + Money vmod.Money `json:"money" bson:"money"` } DepositDatabase struct { ID string `json:"id" bson:"_id"` From d54aeb8742feefb7779c04e167eab4c531236337 Mon Sep 17 00:00:00 2001 From: Dennis Kleber Date: Fri, 17 Nov 2023 14:50:23 +0100 Subject: [PATCH 3/4] add currency while update deposit --- models/deposit.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/deposit.go b/models/deposit.go index 4383cc9..36fc611 100644 --- a/models/deposit.go +++ b/models/deposit.go @@ -223,8 +223,13 @@ func (i *DepositUpdate) DepositDatabase(current *Deposit) (r *DepositUpdate, cre amount += value.Money.Amount } } + currency := "EUR" + if current != nil { + currency = i.DepositUnit[0].Money.Currency + } r = i r.Money.Amount = amount + r.Money.Currency = currency return } From ac239243331b452aa09ceda988d7b4aae3d1cb00 Mon Sep 17 00:00:00 2001 From: Dennis Kleber Date: Fri, 17 Nov 2023 14:56:53 +0100 Subject: [PATCH 4/4] add currency while update deposit --- models/deposit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/deposit.go b/models/deposit.go index 36fc611..076245c 100644 --- a/models/deposit.go +++ b/models/deposit.go @@ -224,7 +224,7 @@ func (i *DepositUpdate) DepositDatabase(current *Deposit) (r *DepositUpdate, cre } } currency := "EUR" - if current != nil { + if i.DepositUnit != nil { currency = i.DepositUnit[0].Money.Currency } r = i