Fix Split Bill
This commit is contained in:
@@ -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