mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package operations
|
|
|
|
import (
|
|
"time"
|
|
|
|
"rmser/internal/domain/catalog"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type OperationType string
|
|
|
|
const (
|
|
OpTypePurchase OperationType = "PURCHASE" // Закупка (Приход)
|
|
OpTypeUsage OperationType = "USAGE" // Расход (Реализация + Списание)
|
|
OpTypeUnknown OperationType = "UNKNOWN" // Прочее (Инвентаризация, Перемещения - игнорируем пока)
|
|
)
|
|
|
|
// StoreOperation - запись из складского отчета
|
|
type StoreOperation struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
|
|
ProductID uuid.UUID `gorm:"type:uuid;not null;index"`
|
|
|
|
// Наш внутренний, "очищенный" тип операции
|
|
OpType OperationType `gorm:"type:varchar(50);index"`
|
|
|
|
// Raw данные из iiko для отладки и детализации
|
|
DocumentType string `gorm:"type:varchar(100);index"` // INCOMING_INVOICE, etc.
|
|
TransactionType string `gorm:"type:varchar(100)"` // INVOICE, WRITEOFF, etc.
|
|
DocumentNumber string `gorm:"type:varchar(100)"`
|
|
|
|
Amount decimal.Decimal `gorm:"type:numeric(19,4)"`
|
|
Sum decimal.Decimal `gorm:"type:numeric(19,4)"`
|
|
Cost decimal.Decimal `gorm:"type:numeric(19,4)"`
|
|
|
|
// Период синхронизации (для перезаписи данных)
|
|
PeriodFrom time.Time `gorm:"index"`
|
|
PeriodTo time.Time `gorm:"index"`
|
|
|
|
Product catalog.Product `gorm:"foreignKey:ProductID"`
|
|
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type Repository interface {
|
|
SaveOperations(ops []StoreOperation, opType OperationType, dateFrom, dateTo time.Time) error
|
|
}
|