feat(BE): finance (payment, initial_balance, injection). fix(BE): kandang capacity

This commit is contained in:
Hafizh A. Y
2025-12-27 14:30:03 +07:00
parent e33b23a2aa
commit 1c875a916b
46 changed files with 3068 additions and 23 deletions
+30
View File
@@ -0,0 +1,30 @@
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:"-"`
}
+32
View File
@@ -0,0 +1,32 @@
package entities
import (
"time"
"gorm.io/gorm"
)
type Payment struct {
Id uint `gorm:"primaryKey;autoIncrement"`
PaymentCode string `gorm:"type:varchar(50);not null"`
ReferenceNumber *string `gorm:"type:varchar(100)"`
TransactionType string `gorm:"type:varchar(50)"`
PartyType string `gorm:"type:varchar(50);not null;index:payments_party_polymorphic,priority:1"`
PartyId uint `gorm:"not null;index:payments_party_polymorphic,priority:2"`
PaymentDate time.Time `gorm:"not null"`
PaymentMethod string `gorm:"type:varchar(20);not null"`
BankId *uint `gorm:"not null;index:idx_payments_bank_id"`
Direction string `gorm:"type:varchar(5);not null"`
Nominal float64 `gorm:"type:numeric(15,3);not null"`
Notes string `gorm:"type:text;not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CreatedBy uint `gorm:"index" json:"-"`
BankWarehouse 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:"-"`
}
+18
View File
@@ -0,0 +1,18 @@
package entities
import (
"time"
"gorm.io/gorm"
)
type Transaction struct {
Id uint `gorm:"primaryKey"`
Name string `gorm:"not null;uniqueIndex:idx_name,where:deleted_at IS NULL"`
CreatedBy uint `gorm:"not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CreatedUser User `gorm:"foreignKey:CreatedBy;references:Id"`
}