package models

import (
	"time"

	"gorm.io/gorm"
)

type PurchaseGroup struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	Name        string         `gorm:"size:100;not null;uniqueIndex" json:"name"`
	Description string         `json:"description"`
	SortOrder   int            `gorm:"default:0" json:"sort_order"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
	Categories  []Category     `gorm:"foreignKey:PurchaseGroupID" json:"categories,omitempty"`
}

func (PurchaseGroup) TableName() string {
	return "purchase_groups"
}