add product ingredients
This commit is contained in:
@@ -74,3 +74,11 @@ type ListIngredientUnitConvertersResponse struct {
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
type IngredientUnitsResponse struct {
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
IngredientName string `json:"ingredient_name"`
|
||||
BaseUnitID uuid.UUID `json:"base_unit_id"`
|
||||
BaseUnitName string `json:"base_unit_name"`
|
||||
Units []*UnitResponse `json:"units"`
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package contract
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type OrderIngredientTransactionContract interface {
|
||||
CreateOrderIngredientTransaction(ctx context.Context, req *CreateOrderIngredientTransactionRequest) (*OrderIngredientTransactionResponse, error)
|
||||
GetOrderIngredientTransactionByID(ctx context.Context, id uuid.UUID) (*OrderIngredientTransactionResponse, error)
|
||||
UpdateOrderIngredientTransaction(ctx context.Context, id uuid.UUID, req *UpdateOrderIngredientTransactionRequest) (*OrderIngredientTransactionResponse, error)
|
||||
DeleteOrderIngredientTransaction(ctx context.Context, id uuid.UUID) error
|
||||
ListOrderIngredientTransactions(ctx context.Context, req *ListOrderIngredientTransactionsRequest) ([]*OrderIngredientTransactionResponse, int64, error)
|
||||
GetOrderIngredientTransactionsByOrder(ctx context.Context, orderID uuid.UUID) ([]*OrderIngredientTransactionResponse, error)
|
||||
GetOrderIngredientTransactionsByOrderItem(ctx context.Context, orderItemID uuid.UUID) ([]*OrderIngredientTransactionResponse, error)
|
||||
GetOrderIngredientTransactionsByIngredient(ctx context.Context, ingredientID uuid.UUID) ([]*OrderIngredientTransactionResponse, error)
|
||||
GetOrderIngredientTransactionSummary(ctx context.Context, req *ListOrderIngredientTransactionsRequest) ([]*OrderIngredientTransactionSummary, error)
|
||||
BulkCreateOrderIngredientTransactions(ctx context.Context, transactions []*CreateOrderIngredientTransactionRequest) ([]*OrderIngredientTransactionResponse, error)
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package contract
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
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 `json:"id"`
|
||||
OrganizationID uuid.UUID `json:"organization_id"`
|
||||
OutletID *uuid.UUID `json:"outlet_id"`
|
||||
OrderID uuid.UUID `json:"order_id"`
|
||||
OrderItemID *uuid.UUID `json:"order_item_id"`
|
||||
ProductID uuid.UUID `json:"product_id"`
|
||||
ProductVariantID *uuid.UUID `json:"product_variant_id"`
|
||||
IngredientID uuid.UUID `json:"ingredient_id"`
|
||||
GrossQty float64 `json:"gross_qty"`
|
||||
NetQty float64 `json:"net_qty"`
|
||||
WasteQty float64 `json:"waste_qty"`
|
||||
Unit string `json:"unit"`
|
||||
TransactionDate time.Time `json:"transaction_date"`
|
||||
CreatedBy uuid.UUID `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// Relations - these would be populated by the service layer
|
||||
Organization interface{} `json:"organization,omitempty"`
|
||||
Outlet interface{} `json:"outlet,omitempty"`
|
||||
Order interface{} `json:"order,omitempty"`
|
||||
OrderItem interface{} `json:"order_item,omitempty"`
|
||||
Product interface{} `json:"product,omitempty"`
|
||||
ProductVariant interface{} `json:"product_variant,omitempty"`
|
||||
Ingredient interface{} `json:"ingredient,omitempty"`
|
||||
CreatedByUser interface{} `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"`
|
||||
}
|
||||
Reference in New Issue
Block a user