mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
пересчет поправил редактирование с перепроведением галка автопроведения работает рекомендации починил
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
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;"`
|
|
RMSServerID uuid.UUID `gorm:"type:uuid;not null;index"`
|
|
DocumentNumber string `gorm:"type:varchar(100);index"`
|
|
IncomingDocumentNumber string `gorm:"type:varchar(100)"`
|
|
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)"`
|
|
Comment string `gorm:"type:text"`
|
|
|
|
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"`
|
|
ContainerID *uuid.UUID `gorm:"type:uuid"`
|
|
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 {
|
|
GetByID(id uuid.UUID) (*Invoice, error)
|
|
GetLastInvoiceDate(serverID uuid.UUID) (*time.Time, error)
|
|
GetByPeriod(serverID uuid.UUID, from, to time.Time) ([]Invoice, error)
|
|
SaveInvoices(invoices []Invoice) error
|
|
CountRecent(serverID uuid.UUID, days int) (int64, error)
|
|
GetStats(serverID uuid.UUID) (total int64, lastMonth int64, last24h int64, err error)
|
|
}
|