Files
zeekay 1943f1c093 Hanzo Commerce
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
2026-09-23 21:52:16 -07:00

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
}