start rmser

This commit is contained in:
2025-11-29 08:40:24 +03:00
commit 5aa2238eea
2117 changed files with 375169 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
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
}