Documentation ¶
Index ¶
- Constants
- Variables
- type CreateTransactionRequestPayload
- type Product
- type ProductRepository
- type Repository
- type Transaction
- func (t *Transaction) FromProduct(product Product) *Transaction
- func (t Transaction) GetProduct() (product Product, err error)
- func (t Transaction) GetStatus() string
- func (t *Transaction) SetGrandTotal() *Transaction
- func (t *Transaction) SetPlatformFee(platformFee uint) *Transaction
- func (t *Transaction) SetProductJSON(product Product) (err error)
- func (t *Transaction) SetSubTotal()
- func (t Transaction) Validate() (err error)
- func (t Transaction) ValidateStock(productStock uint8) (err error)
- type TransactionDBRepository
- type TransactionRepository
- type TransactionStatus
Constants ¶
View Source
const ( TransactionStatus_Created = 1 TransactionStatus_Progress = 10 TransactionStatus_InDelivery = 15 TransactionStatus_Completed = 20 TRX_CREATED = "CREATED" TRX_PROGRESS = "PROGRESS" TRX_IN_DELIVERY = "IN DELIVERY" TRX_COMPLETED = "COMPLETED" TRX_UNKNOWN = "UNKNOWN STATUS" )
Variables ¶
View Source
var ( MappingTransactionStatus = map[TransactionStatus]string{ TransactionStatus_Created: TRX_CREATED, TransactionStatus_Progress: TRX_PROGRESS, TransactionStatus_InDelivery: TRX_IN_DELIVERY, TransactionStatus_Completed: TRX_COMPLETED, } )
Functions ¶
This section is empty.
Types ¶
type Product ¶
type Product struct { Id int `db:"id" json:"id"` SKU string `db:"sku" json:"sku"` Name string `db:"name" json:"name"` Stock int `db:"stock" json:"stock"` Price int `db:"price" json:"price"` }
func (*Product) UpdateStockProduct ¶
type ProductRepository ¶
type Repository ¶
type Repository interface { TransactionRepository ProductRepository TransactionDBRepository }
type Transaction ¶
type Transaction struct { Id int `db:"id"` UserPublicId string `db:"user_public_id"` ProductId uint `db:"product_id"` ProductPrice uint `db:"product_price"` Amount uint8 `db:"amount"` SubTotal uint `db:"sub_total"` PlatformFee uint `db:"platform_fee"` GrandTotal uint `db:"grand_total"` Status TransactionStatus `db:"status"` ProductJSON json.RawMessage `db:"product_snapshot"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
func NewTransaction ¶
func NewTransaction(userPublicId string) Transaction
func NewTransactionFromCreateRequest ¶
func NewTransactionFromCreateRequest(req CreateTransactionRequestPayload) Transaction
func (*Transaction) FromProduct ¶
func (t *Transaction) FromProduct(product Product) *Transaction
set productId, price, and json
func (Transaction) GetProduct ¶
func (t Transaction) GetProduct() (product Product, err error)
func (Transaction) GetStatus ¶
func (t Transaction) GetStatus() string
func (*Transaction) SetGrandTotal ¶
func (t *Transaction) SetGrandTotal() *Transaction
set subtotal and grandtotal
func (*Transaction) SetPlatformFee ¶
func (t *Transaction) SetPlatformFee(platformFee uint) *Transaction
func (*Transaction) SetProductJSON ¶
func (t *Transaction) SetProductJSON(product Product) (err error)
func (*Transaction) SetSubTotal ¶
func (t *Transaction) SetSubTotal()
func (Transaction) Validate ¶
func (t Transaction) Validate() (err error)
func (Transaction) ValidateStock ¶
func (t Transaction) ValidateStock(productStock uint8) (err error)
type TransactionDBRepository ¶
type TransactionRepository ¶
type TransactionStatus ¶
type TransactionStatus uint8
Click to show internal directories.
Click to hide internal directories.