mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
start rmser
This commit is contained in:
43
internal/domain/invoices/entity.go
Normal file
43
internal/domain/invoices/entity.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package invoices
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"rmser/internal/domain/catalog"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
// Invoice - Приходная накладная
|
||||
type Invoice struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;"`
|
||||
DocumentNumber string `gorm:"type:varchar(100);index"`
|
||||
DateIncoming time.Time `gorm:"index"`
|
||||
SupplierID uuid.UUID `gorm:"type:uuid;index"`
|
||||
DefaultStoreID uuid.UUID `gorm:"type:uuid;index"`
|
||||
Status string `gorm:"type:varchar(50)"`
|
||||
|
||||
Items []InvoiceItem `gorm:"foreignKey:InvoiceID;constraint:OnDelete:CASCADE"`
|
||||
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// InvoiceItem - Позиция накладной
|
||||
type InvoiceItem struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
|
||||
InvoiceID uuid.UUID `gorm:"type:uuid;not null;index"`
|
||||
ProductID uuid.UUID `gorm:"type:uuid;not null"`
|
||||
Amount decimal.Decimal `gorm:"type:numeric(19,4);not null"`
|
||||
Price decimal.Decimal `gorm:"type:numeric(19,4);not null"`
|
||||
Sum decimal.Decimal `gorm:"type:numeric(19,4);not null"`
|
||||
VatSum decimal.Decimal `gorm:"type:numeric(19,4)"`
|
||||
|
||||
Product catalog.Product `gorm:"foreignKey:ProductID"`
|
||||
}
|
||||
|
||||
type Repository interface {
|
||||
GetLastInvoiceDate() (*time.Time, error)
|
||||
SaveInvoices(invoices []Invoice) error
|
||||
}
|
||||
Reference in New Issue
Block a user