diff --git a/pkg/internal/services/programs.go b/pkg/internal/services/programs.go index 8c57584..bb5db65 100644 --- a/pkg/internal/services/programs.go +++ b/pkg/internal/services/programs.go @@ -84,12 +84,14 @@ func PeriodicChargeProgramFee() { var members []models.ProgramMember // Every month paid once if err := database.C.Where("last_paid IS NULL OR last_paid < ?", time.Now().AddDate(0, 0, -30)). - Preload("Program").Find(&members).Error; err != nil { + Preload("Program").Preload("Account").Find(&members).Error; err != nil { return } for _, member := range members { if err := ChargeForProgram(member); err == nil { database.C.Model(&member).Update("last_paid", time.Now()) + } else { + LeaveProgram(member.Account, member.Program) } } }