mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
25 lines
566 B
Go
25 lines
566 B
Go
package coupon
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/util/fake"
|
|
)
|
|
|
|
func Fake(db *datastore.Datastore) *Coupon {
|
|
c := New(db)
|
|
c.Name = fake.Word()
|
|
c.Type = Flat
|
|
c.Code_ = fake.Word() + fake.Word()
|
|
c.StartDate = time.Date(rand.Intn(25)+2000, time.Month(rand.Intn(12)+1), rand.Intn(25)+1, 0, 0, 0, 0, time.UTC).UTC()
|
|
c.EndDate = c.StartDate.AddDate(0, 0, rand.Intn(30))
|
|
c.Limit = rand.Intn(500) + 1
|
|
c.Enabled = true
|
|
c.Amount = rand.Intn(5000)
|
|
c.Used = c.Limit - rand.Intn(c.Limit)
|
|
|
|
return c
|
|
}
|