// Package warehouses implements warehouse master data (GDG-<3> codes, soft delete).
package warehouses

import (
	"context"

	"github.com/TaruLab/keluargamart-backend/internal/db"
	"github.com/shopspring/decimal"
)

// Input mirrors openapi request bodies.
type Input struct {
	Name      string           `json:"name"`
	Address   string           `json:"address"`
	IsActive  bool             `json:"is_active"`
	Latitude  *decimal.Decimal `json:"latitude,omitempty"`
	Longitude *decimal.Decimal `json:"longitude,omitempty"`
}

// Option is a slim warehouse entry for checkout pickers (any authenticated
// user; no inventory.warehouses.view permission required).
type Option struct {
	ID        int64            `json:"id"`
	Code      string           `json:"code"`
	Name      string           `json:"name"`
	Latitude  *decimal.Decimal `json:"latitude,omitempty"`
	Longitude *decimal.Decimal `json:"longitude,omitempty"`
}

// Store is the warehouses persistence seam.
type Store interface {
	List(ctx context.Context, page, perPage int, search string) ([]db.Warehouse, int, error)
	Options(ctx context.Context) ([]Option, error)
	ByID(ctx context.Context, id int64) (*db.Warehouse, error)
	Create(ctx context.Context, w *db.Warehouse) error
	Update(ctx context.Context, w *db.Warehouse) error
	Delete(ctx context.Context, id int64) error
}
