Files
template-vitrine/backend/internal/modules/pricing/model.go
T
2026-09-14 20:50:19 +02:00

27 lines
928 B
Go

// Package pricing implements quantity-based pricing for products (spec
// section 16): a product can have several price tiers, each pairing a
// quantity with a unit (from the units module) and a price. Pricing logic
// (computing an order line's total from a chosen tier) is centralized here
// in the backend -- the frontend only ever displays tiers and sends back a
// tier ID + multiplier; it never sends a price the backend has to trust.
package pricing
import (
"time"
"github.com/google/uuid"
)
type PriceTier struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey"`
ProductID uuid.UUID `gorm:"type:uuid;not null;index"`
UnitID uuid.UUID `gorm:"type:uuid;not null"`
Quantity float64 `gorm:"not null"`
PriceCents int64 `gorm:"not null"`
Position int `gorm:"not null;default:0"`
CreatedAt time.Time
UpdatedAt time.Time
}
func (PriceTier) TableName() string { return "price_tiers" }