Skip to content
Snippets Groups Projects
Commit aef01032 authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

Merge branch 'kasszasch' into 'master'

fix credits

See merge request !28
parents b080177d 38ab16d4
No related branches found
No related tags found
1 merge request!28fix credits
Pipeline #45076 passed
......@@ -331,8 +331,6 @@ func (u *User) Load() error {
return e
}
const credit = 5000
func SaveMultipleSpend(sp []*Spend) error {
e := db.RunInTransaction(context.Background(), func(tx *pg.Tx) error {
for _, s := range sp {
......@@ -349,6 +347,12 @@ func SaveMultipleSpend(sp []*Spend) error {
}
e = tx.Model(u).WherePK().First()
var credit int64
if u.Credits > 5000 {
credit = u.Credits
} else {
credit = 5000
}
price := p.Price * s.Amount
if price > u.Money+credit {
return fmt.Errorf("Not enough funds")
......
......@@ -95,7 +95,7 @@ func NewHandler(w http.ResponseWriter, r *http.Request) {
}
var credit int64
if session.User.Credits > 0 {
if session.User.Credits > 5000 {
credit = session.User.Credits
} else {
credit = 5000
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment