Add refund order
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
type CashierSession struct {
|
||||
ID int64
|
||||
CashierID int64
|
||||
OpenedAt time.Time
|
||||
ClosedAt *time.Time
|
||||
OpeningAmount float64
|
||||
ClosingAmount *float64
|
||||
ExpectedAmount *float64
|
||||
Status string
|
||||
}
|
||||
|
||||
type PaymentSummary struct {
|
||||
PaymentType string
|
||||
PaymentProvider string
|
||||
TotalAmount float64
|
||||
}
|
||||
|
||||
type CashierSessionReport struct {
|
||||
SessionID int64
|
||||
ExpectedAmount float64
|
||||
ClosingAmount float64
|
||||
Payments []PaymentSummary
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package entity
|
||||
|
||||
type Category struct {
|
||||
ID int64
|
||||
PartnerID int64
|
||||
Name string
|
||||
CreatedAt int64
|
||||
UpdatedAt int64
|
||||
}
|
||||
@@ -26,6 +26,7 @@ type Order struct {
|
||||
User User `gorm:"foreignKey:CreatedBy;constraint:OnDelete:CASCADE;"`
|
||||
Source string `gorm:"type:varchar;column:source"`
|
||||
OrderType string `gorm:"type:varchar;column:order_type"`
|
||||
CashierSessionID int64 `gorm:"type:varchar;column:cashier_session_id"`
|
||||
TableNumber string
|
||||
InProgressOrderID int64
|
||||
}
|
||||
@@ -113,6 +114,7 @@ type OrderRequest struct {
|
||||
PaymentProvider string
|
||||
OrderType string
|
||||
ID int64
|
||||
CashierSessionID int64
|
||||
}
|
||||
|
||||
type OrderItemRequest struct {
|
||||
|
||||
@@ -26,6 +26,7 @@ type OrderInquiry struct {
|
||||
PaymentProvider string `json:"payment_provider"`
|
||||
TableNumber string `json:"table_number"`
|
||||
OrderType string `json:"order_type"`
|
||||
CashierSessionID int64 `json:"cashier_session_id"`
|
||||
}
|
||||
|
||||
type OrderCalculation struct {
|
||||
@@ -54,6 +55,7 @@ func NewOrderInquiry(
|
||||
paymentProvider string,
|
||||
tableNumber string,
|
||||
orderType string,
|
||||
cashierSessionID int64,
|
||||
) *OrderInquiry {
|
||||
return &OrderInquiry{
|
||||
ID: constants.GenerateUUID(),
|
||||
@@ -75,6 +77,7 @@ func NewOrderInquiry(
|
||||
PaymentProvider: paymentProvider,
|
||||
TableNumber: tableNumber,
|
||||
OrderType: orderType,
|
||||
CashierSessionID: cashierSessionID,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,22 +98,23 @@ func (i *OrderInquiry) ToOrder(paymentMethod, paymentProvider string) *Order {
|
||||
now := time.Now()
|
||||
|
||||
order := &Order{
|
||||
PartnerID: i.PartnerID,
|
||||
CustomerID: &i.CustomerID,
|
||||
InquiryID: &i.ID,
|
||||
Status: constants.StatusPaid,
|
||||
Amount: i.Amount,
|
||||
Tax: i.Tax,
|
||||
Total: i.Total,
|
||||
PaymentType: paymentMethod,
|
||||
PaymentProvider: paymentProvider,
|
||||
Source: i.Source,
|
||||
CreatedBy: i.CreatedBy,
|
||||
CreatedAt: now,
|
||||
OrderItems: make([]OrderItem, len(i.OrderItems)),
|
||||
OrderType: i.OrderType,
|
||||
CustomerName: i.CustomerName,
|
||||
TableNumber: i.TableNumber,
|
||||
PartnerID: i.PartnerID,
|
||||
CustomerID: &i.CustomerID,
|
||||
InquiryID: &i.ID,
|
||||
Status: constants.StatusPaid,
|
||||
Amount: i.Amount,
|
||||
Tax: i.Tax,
|
||||
Total: i.Total,
|
||||
PaymentType: paymentMethod,
|
||||
PaymentProvider: paymentProvider,
|
||||
Source: i.Source,
|
||||
CreatedBy: i.CreatedBy,
|
||||
CreatedAt: now,
|
||||
OrderItems: make([]OrderItem, len(i.OrderItems)),
|
||||
OrderType: i.OrderType,
|
||||
CustomerName: i.CustomerName,
|
||||
TableNumber: i.TableNumber,
|
||||
CashierSessionID: i.CashierSessionID,
|
||||
}
|
||||
|
||||
for idx, item := range i.OrderItems {
|
||||
|
||||
+27
-21
@@ -2,23 +2,26 @@ package entity
|
||||
|
||||
import (
|
||||
"enaklo-pos-be/internal/constants/product"
|
||||
"enaklo-pos-be/internal/repository/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
PartnerID int64 `gorm:"type:int;column:partner_id"`
|
||||
Name string `gorm:"type:varchar(255);not null;column:name"`
|
||||
Type string `gorm:"type:varchar;column:type"`
|
||||
Price float64 `gorm:"type:decimal;column:price"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Description string `gorm:"type:varchar(255);not null;column:description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
Image string `gorm:"type:varchar;column:image"`
|
||||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||||
PartnerID int64 `gorm:"type:int;column:partner_id"`
|
||||
Name string `gorm:"type:varchar(255);not null;column:name"`
|
||||
Type string `gorm:"type:varchar;column:type"`
|
||||
Price float64 `gorm:"type:decimal;column:price"`
|
||||
Status string `gorm:"type:varchar;column:status"`
|
||||
Description string `gorm:"type:varchar(255);not null;column:description"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;column:created_at"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;column:updated_at"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_at"`
|
||||
CreatedBy int64 `gorm:"type:int;column:created_by"`
|
||||
UpdatedBy int64 `gorm:"type:int;column:updated_by"`
|
||||
Image string `gorm:"type:varchar;column:image"`
|
||||
CategoryID *int64 `gorm:"column:category_id"`
|
||||
Category *models.CategoryDB `gorm:"foreignKey:CategoryID;references:ID"`
|
||||
}
|
||||
|
||||
func (Product) TableName() string {
|
||||
@@ -26,14 +29,15 @@ func (Product) TableName() string {
|
||||
}
|
||||
|
||||
type ProductSearch struct {
|
||||
Search string
|
||||
Name string
|
||||
Type product.ProductType
|
||||
BranchID int64
|
||||
PartnerID int64
|
||||
Available product.ProductStock
|
||||
Limit int
|
||||
Offset int
|
||||
Search string
|
||||
Name string
|
||||
Type product.ProductType
|
||||
BranchID int64
|
||||
PartnerID int64
|
||||
Available product.ProductStock
|
||||
Limit int
|
||||
Offset int
|
||||
CategoryID int64
|
||||
}
|
||||
|
||||
type ProductPOS struct {
|
||||
@@ -72,6 +76,8 @@ func (e *ProductDB) ToProduct() *Product {
|
||||
CreatedBy: e.CreatedBy,
|
||||
UpdatedBy: e.UpdatedBy,
|
||||
Image: e.Image,
|
||||
Category: e.Category,
|
||||
CategoryID: e.CategoryID,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user