Fix Split Bill
This commit is contained in:
+63
-57
@@ -8,33 +8,34 @@ import (
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
CustomerID *uuid.UUID
|
||||
OrderNumber string
|
||||
TableNumber *string
|
||||
OrderType constants.OrderType
|
||||
Status constants.OrderStatus
|
||||
Subtotal float64
|
||||
TaxAmount float64
|
||||
DiscountAmount float64
|
||||
TotalAmount float64
|
||||
TotalCost float64
|
||||
PaymentStatus constants.PaymentStatus
|
||||
RefundAmount float64
|
||||
IsVoid bool
|
||||
IsRefund bool
|
||||
VoidReason *string
|
||||
VoidedAt *time.Time
|
||||
VoidedBy *uuid.UUID
|
||||
RefundReason *string
|
||||
RefundedAt *time.Time
|
||||
RefundedBy *uuid.UUID
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
CustomerID *uuid.UUID
|
||||
OrderNumber string
|
||||
TableNumber *string
|
||||
OrderType constants.OrderType
|
||||
Status constants.OrderStatus
|
||||
Subtotal float64
|
||||
TaxAmount float64
|
||||
DiscountAmount float64
|
||||
TotalAmount float64
|
||||
TotalCost float64
|
||||
RemainingAmount float64
|
||||
PaymentStatus constants.PaymentStatus
|
||||
RefundAmount float64
|
||||
IsVoid bool
|
||||
IsRefund bool
|
||||
VoidReason *string
|
||||
VoidedAt *time.Time
|
||||
VoidedBy *uuid.UUID
|
||||
RefundReason *string
|
||||
RefundedAt *time.Time
|
||||
RefundedBy *uuid.UUID
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
@@ -142,36 +143,40 @@ type RefundOrderItemRequest struct {
|
||||
|
||||
// Response DTOs
|
||||
type OrderResponse struct {
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
CustomerID *uuid.UUID
|
||||
OrderNumber string
|
||||
TableNumber *string
|
||||
OrderType constants.OrderType
|
||||
Status constants.OrderStatus
|
||||
Subtotal float64
|
||||
TaxAmount float64
|
||||
DiscountAmount float64
|
||||
TotalAmount float64
|
||||
TotalCost float64
|
||||
PaymentStatus constants.PaymentStatus
|
||||
RefundAmount float64
|
||||
IsVoid bool
|
||||
IsRefund bool
|
||||
VoidReason *string
|
||||
VoidedAt *time.Time
|
||||
VoidedBy *uuid.UUID
|
||||
RefundReason *string
|
||||
RefundedAt *time.Time
|
||||
RefundedBy *uuid.UUID
|
||||
Notes *string
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
OrderItems []OrderItemResponse
|
||||
Payments []PaymentResponse
|
||||
ID uuid.UUID
|
||||
OrganizationID uuid.UUID
|
||||
OutletID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
CustomerID *uuid.UUID
|
||||
OrderNumber string
|
||||
TableNumber *string
|
||||
OrderType constants.OrderType
|
||||
Status constants.OrderStatus
|
||||
Subtotal float64
|
||||
TaxAmount float64
|
||||
DiscountAmount float64
|
||||
TotalAmount float64
|
||||
TotalCost float64
|
||||
RemainingAmount float64
|
||||
PaymentStatus constants.PaymentStatus
|
||||
RefundAmount float64
|
||||
IsVoid bool
|
||||
IsRefund bool
|
||||
VoidReason *string
|
||||
VoidedAt *time.Time
|
||||
VoidedBy *uuid.UUID
|
||||
RefundReason *string
|
||||
RefundedAt *time.Time
|
||||
RefundedBy *uuid.UUID
|
||||
Notes *string
|
||||
Metadata map[string]interface{}
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
OrderItems []OrderItemResponse
|
||||
Payments []PaymentResponse
|
||||
TotalPaid float64
|
||||
PaymentCount int
|
||||
SplitType *string
|
||||
}
|
||||
|
||||
type OrderItemResponse struct {
|
||||
@@ -230,6 +235,7 @@ type ListOrdersRequest struct {
|
||||
|
||||
type ListOrdersResponse struct {
|
||||
Orders []OrderResponse
|
||||
Payments []PaymentResponse
|
||||
TotalCount int
|
||||
Page int
|
||||
Limit int
|
||||
|
||||
@@ -16,6 +16,7 @@ type Payment struct {
|
||||
TransactionID *string
|
||||
SplitNumber int
|
||||
SplitTotal int
|
||||
SplitType *string
|
||||
SplitDescription *string
|
||||
RefundAmount float64
|
||||
RefundReason *string
|
||||
@@ -33,6 +34,7 @@ type CreatePaymentRequest struct {
|
||||
TransactionID *string `validate:"omitempty"`
|
||||
SplitNumber int `validate:"omitempty,min=1"`
|
||||
SplitTotal int `validate:"omitempty,min=1"`
|
||||
SplitType *string `validate:"omitempty,oneof=AMOUNT ITEM"`
|
||||
SplitDescription *string `validate:"omitempty,max=255"`
|
||||
PaymentOrderItems []CreatePaymentOrderItemRequest `validate:"omitempty,dive"`
|
||||
Metadata map[string]interface{}
|
||||
@@ -48,11 +50,14 @@ type PaymentResponse struct {
|
||||
ID uuid.UUID
|
||||
OrderID uuid.UUID
|
||||
PaymentMethodID uuid.UUID
|
||||
PaymentMethodName string
|
||||
PaymentMethodType constants.PaymentMethodType
|
||||
Amount float64
|
||||
Status constants.PaymentTransactionStatus
|
||||
TransactionID *string
|
||||
SplitNumber int
|
||||
SplitTotal int
|
||||
SplitType *string
|
||||
SplitDescription *string
|
||||
RefundAmount float64
|
||||
RefundReason *string
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package models
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
const (
|
||||
Amount = "AMOUNT"
|
||||
Item = "ITEM"
|
||||
)
|
||||
|
||||
type SplitBillRequest struct {
|
||||
OrderID uuid.UUID `validate:"required"`
|
||||
PaymentMethodID uuid.UUID `validate:"required"`
|
||||
CustomerID uuid.UUID `validate:"required"`
|
||||
Type string `validate:"required,oneof=ITEM AMOUNT"`
|
||||
Items []SplitBillItemRequest `validate:"required_if=Type ITEM,dive"`
|
||||
Amount float64 `validate:"required_if=Type AMOUNT,min=0"`
|
||||
OrganizationID uuid.UUID
|
||||
}
|
||||
|
||||
func (s *SplitBillRequest) IsItem() bool {
|
||||
return s.Type == Item
|
||||
}
|
||||
|
||||
func (s *SplitBillRequest) IsAmount() bool {
|
||||
return s.Type == Amount
|
||||
}
|
||||
|
||||
type SplitBillItemRequest struct {
|
||||
OrderItemID uuid.UUID `validate:"required"`
|
||||
Amount float64 `validate:"required,min=0"`
|
||||
}
|
||||
|
||||
type SplitBillResponse struct {
|
||||
PaymentID uuid.UUID `json:"payment_id"`
|
||||
OrderID uuid.UUID `json:"order_id"`
|
||||
CustomerID uuid.UUID `json:"customer_id"`
|
||||
Type string `json:"type"`
|
||||
Amount float64 `json:"amount"`
|
||||
Items []SplitBillItemResponse `json:"items,omitempty"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type SplitBillItemResponse struct {
|
||||
OrderItemID uuid.UUID `json:"order_item_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
Reference in New Issue
Block a user