package entities

import (
	"time"

	"gorm.io/gorm"
)

type Initial struct {
	Id                 uint           `gorm:"primaryKey;autoIncrement"`
	ReferenceNumber    string         `gorm:"type:varchar(100);not null"`
	TransactionType    string         `gorm:"type:varchar(50);not null"`
	InitialBalanceType string         `gorm:"type:varchar(20);not null"`
	PartyType          string         `gorm:"type:varchar(50);not null;index:initials_party_polymorphic,priority:1"`
	PartyId            uint           `gorm:"not null;index:initials_party_polymorphic,priority:2"`
	BankId             *uint          `gorm:"index"`
	Direction          string         `gorm:"type:varchar(5);not null"`
	Nominal            float64        `gorm:"type:numeric(15,3);not null"`
	Notes              string         `gorm:"type:text;not null"`
	CreatedBy          uint           `gorm:"index" json:"-"`
	CreatedAt          time.Time      `gorm:"autoCreateTime"`
	UpdatedAt          time.Time      `gorm:"autoUpdateTime"`
	DeletedAt          gorm.DeletedAt `gorm:"index" json:"-"`

	Bank           Bank      `gorm:"foreignKey:BankId;references:Id"`
	CreatedUser    User      `gorm:"foreignKey:CreatedBy;references:Id"`
	Customer       *Customer `gorm:"foreignKey:PartyId;references:Id"`
	Supplier       *Supplier `gorm:"foreignKey:PartyId;references:Id"`
	LatestApproval *Approval `gorm:"-" json:"-"`
}
