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
28 lines
914 B
Go
28 lines
914 B
Go
package cart
|
|
|
|
import (
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/models/types/currency"
|
|
. "github.com/hanzoai/commerce/types"
|
|
"github.com/hanzoai/commerce/util/fake"
|
|
)
|
|
|
|
func Fake(db *datastore.Datastore, userId string) *Cart {
|
|
c := New(db)
|
|
c.UserId = userId
|
|
c.Email = fake.EmailAddress()
|
|
c.Status = Active
|
|
c.Currency = currency.USD
|
|
c.LineTotal = currency.Cents(0).Fake()
|
|
c.Discount = currency.Cents(0).FakeN(990)
|
|
c.Subtotal = c.LineTotal - c.Discount
|
|
c.Shipping = currency.Cents(0).FakeN(990)
|
|
c.Tax = currency.Cents(0).FakeN(990)
|
|
c.Total = c.Subtotal + c.Tax + c.Shipping
|
|
c.Company = fake.Company()
|
|
c.BillingAddress = Address{Line1: fake.Street(), City: fake.City(), State: fake.State(), PostalCode: fake.Zip(), Country: "US"}
|
|
c.ShippingAddress = Address{Line1: fake.Street(), City: fake.City(), State: fake.State(), PostalCode: fake.Zip(), Country: "US"}
|
|
|
|
return c
|
|
}
|