109 lines
4.2 KiB
Go
109 lines
4.2 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type OrderIngredientTransaction struct {
|
|
ID uuid.UUID
|
|
OrganizationID uuid.UUID
|
|
OutletID *uuid.UUID
|
|
OrderID uuid.UUID
|
|
OrderItemID *uuid.UUID
|
|
ProductID uuid.UUID
|
|
ProductVariantID *uuid.UUID
|
|
IngredientID uuid.UUID
|
|
GrossQty float64
|
|
NetQty float64
|
|
WasteQty float64
|
|
Unit string
|
|
TransactionDate time.Time
|
|
CreatedBy uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
|
|
// Relations
|
|
Organization *Organization `json:"organization,omitempty"`
|
|
Outlet *Outlet `json:"outlet,omitempty"`
|
|
Order *Order `json:"order,omitempty"`
|
|
OrderItem *OrderItem `json:"order_item,omitempty"`
|
|
Product *Product `json:"product,omitempty"`
|
|
ProductVariant *ProductVariant `json:"product_variant,omitempty"`
|
|
Ingredient *Ingredient `json:"ingredient,omitempty"`
|
|
CreatedByUser *User `json:"created_by_user,omitempty"`
|
|
}
|
|
|
|
type CreateOrderIngredientTransactionRequest struct {
|
|
OrderID uuid.UUID `json:"order_id" validate:"required"`
|
|
OrderItemID *uuid.UUID `json:"order_item_id,omitempty"`
|
|
ProductID uuid.UUID `json:"product_id" validate:"required"`
|
|
ProductVariantID *uuid.UUID `json:"product_variant_id,omitempty"`
|
|
IngredientID uuid.UUID `json:"ingredient_id" validate:"required"`
|
|
GrossQty float64 `json:"gross_qty" validate:"required,gt=0"`
|
|
NetQty float64 `json:"net_qty" validate:"required,gt=0"`
|
|
WasteQty float64 `json:"waste_qty" validate:"min=0"`
|
|
Unit string `json:"unit" validate:"required,max=50"`
|
|
TransactionDate *time.Time `json:"transaction_date,omitempty"`
|
|
}
|
|
|
|
type UpdateOrderIngredientTransactionRequest struct {
|
|
GrossQty *float64 `json:"gross_qty,omitempty" validate:"omitempty,gt=0"`
|
|
NetQty *float64 `json:"net_qty,omitempty" validate:"omitempty,gt=0"`
|
|
WasteQty *float64 `json:"waste_qty,omitempty" validate:"min=0"`
|
|
Unit *string `json:"unit,omitempty" validate:"omitempty,max=50"`
|
|
TransactionDate *time.Time `json:"transaction_date,omitempty"`
|
|
}
|
|
|
|
type OrderIngredientTransactionResponse struct {
|
|
ID uuid.UUID
|
|
OrganizationID uuid.UUID
|
|
OutletID *uuid.UUID
|
|
OrderID uuid.UUID
|
|
OrderItemID *uuid.UUID
|
|
ProductID uuid.UUID
|
|
ProductVariantID *uuid.UUID
|
|
IngredientID uuid.UUID
|
|
GrossQty float64
|
|
NetQty float64
|
|
WasteQty float64
|
|
Unit string
|
|
TransactionDate time.Time
|
|
CreatedBy uuid.UUID
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
|
|
// Relations
|
|
Organization *Organization `json:"organization,omitempty"`
|
|
Outlet *Outlet `json:"outlet,omitempty"`
|
|
Order *Order `json:"order,omitempty"`
|
|
OrderItem *OrderItem `json:"order_item,omitempty"`
|
|
Product *Product `json:"product,omitempty"`
|
|
ProductVariant *ProductVariant `json:"product_variant,omitempty"`
|
|
Ingredient *Ingredient `json:"ingredient,omitempty"`
|
|
CreatedByUser *User `json:"created_by_user,omitempty"`
|
|
}
|
|
|
|
type ListOrderIngredientTransactionsRequest struct {
|
|
OrderID *uuid.UUID `json:"order_id,omitempty"`
|
|
OrderItemID *uuid.UUID `json:"order_item_id,omitempty"`
|
|
ProductID *uuid.UUID `json:"product_id,omitempty"`
|
|
ProductVariantID *uuid.UUID `json:"product_variant_id,omitempty"`
|
|
IngredientID *uuid.UUID `json:"ingredient_id,omitempty"`
|
|
StartDate *time.Time `json:"start_date,omitempty"`
|
|
EndDate *time.Time `json:"end_date,omitempty"`
|
|
Page int `json:"page" validate:"min=1"`
|
|
Limit int `json:"limit" validate:"min=1,max=100"`
|
|
}
|
|
|
|
type OrderIngredientTransactionSummary struct {
|
|
IngredientID uuid.UUID `json:"ingredient_id"`
|
|
IngredientName string `json:"ingredient_name"`
|
|
TotalGrossQty float64 `json:"total_gross_qty"`
|
|
TotalNetQty float64 `json:"total_net_qty"`
|
|
TotalWasteQty float64 `json:"total_waste_qty"`
|
|
WastePercentage float64 `json:"waste_percentage"`
|
|
Unit string `json:"unit"`
|
|
}
|