add product ingredients
This commit is contained in:
@@ -166,3 +166,110 @@ func ModelToContractAccountResponse(resp *models.AccountResponse) *contract.Acco
|
||||
|
||||
return contractResp
|
||||
}
|
||||
|
||||
// Order Ingredient Transaction mappers
|
||||
func ContractToModelCreateOrderIngredientTransactionRequest(req *contract.CreateOrderIngredientTransactionRequest) *models.CreateOrderIngredientTransactionRequest {
|
||||
return &models.CreateOrderIngredientTransactionRequest{
|
||||
OrderID: req.OrderID,
|
||||
OrderItemID: req.OrderItemID,
|
||||
ProductID: req.ProductID,
|
||||
ProductVariantID: req.ProductVariantID,
|
||||
IngredientID: req.IngredientID,
|
||||
GrossQty: req.GrossQty,
|
||||
NetQty: req.NetQty,
|
||||
WasteQty: req.WasteQty,
|
||||
Unit: req.Unit,
|
||||
TransactionDate: req.TransactionDate,
|
||||
}
|
||||
}
|
||||
|
||||
func ContractToModelUpdateOrderIngredientTransactionRequest(req *contract.UpdateOrderIngredientTransactionRequest) *models.UpdateOrderIngredientTransactionRequest {
|
||||
return &models.UpdateOrderIngredientTransactionRequest{
|
||||
GrossQty: req.GrossQty,
|
||||
NetQty: req.NetQty,
|
||||
WasteQty: req.WasteQty,
|
||||
Unit: req.Unit,
|
||||
TransactionDate: req.TransactionDate,
|
||||
}
|
||||
}
|
||||
|
||||
func ModelToContractOrderIngredientTransactionResponse(resp *models.OrderIngredientTransactionResponse) *contract.OrderIngredientTransactionResponse {
|
||||
return &contract.OrderIngredientTransactionResponse{
|
||||
ID: resp.ID,
|
||||
OrganizationID: resp.OrganizationID,
|
||||
OutletID: resp.OutletID,
|
||||
OrderID: resp.OrderID,
|
||||
OrderItemID: resp.OrderItemID,
|
||||
ProductID: resp.ProductID,
|
||||
ProductVariantID: resp.ProductVariantID,
|
||||
IngredientID: resp.IngredientID,
|
||||
GrossQty: resp.GrossQty,
|
||||
NetQty: resp.NetQty,
|
||||
WasteQty: resp.WasteQty,
|
||||
Unit: resp.Unit,
|
||||
TransactionDate: resp.TransactionDate,
|
||||
CreatedBy: resp.CreatedBy,
|
||||
CreatedAt: resp.CreatedAt,
|
||||
UpdatedAt: resp.UpdatedAt,
|
||||
Organization: resp.Organization,
|
||||
Outlet: resp.Outlet,
|
||||
Order: resp.Order,
|
||||
OrderItem: resp.OrderItem,
|
||||
Product: resp.Product,
|
||||
ProductVariant: resp.ProductVariant,
|
||||
Ingredient: resp.Ingredient,
|
||||
CreatedByUser: resp.CreatedByUser,
|
||||
}
|
||||
}
|
||||
|
||||
func ModelToContractOrderIngredientTransactionResponses(responses []*models.OrderIngredientTransactionResponse) []*contract.OrderIngredientTransactionResponse {
|
||||
if responses == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
contractResponses := make([]*contract.OrderIngredientTransactionResponse, len(responses))
|
||||
for i, resp := range responses {
|
||||
contractResponses[i] = ModelToContractOrderIngredientTransactionResponse(resp)
|
||||
}
|
||||
|
||||
return contractResponses
|
||||
}
|
||||
|
||||
func ContractToModelListOrderIngredientTransactionsRequest(req *contract.ListOrderIngredientTransactionsRequest) *models.ListOrderIngredientTransactionsRequest {
|
||||
return &models.ListOrderIngredientTransactionsRequest{
|
||||
OrderID: req.OrderID,
|
||||
OrderItemID: req.OrderItemID,
|
||||
ProductID: req.ProductID,
|
||||
ProductVariantID: req.ProductVariantID,
|
||||
IngredientID: req.IngredientID,
|
||||
StartDate: req.StartDate,
|
||||
EndDate: req.EndDate,
|
||||
Page: req.Page,
|
||||
Limit: req.Limit,
|
||||
}
|
||||
}
|
||||
|
||||
func ModelToContractOrderIngredientTransactionSummary(resp *models.OrderIngredientTransactionSummary) *contract.OrderIngredientTransactionSummary {
|
||||
return &contract.OrderIngredientTransactionSummary{
|
||||
IngredientID: resp.IngredientID,
|
||||
IngredientName: resp.IngredientName,
|
||||
TotalGrossQty: resp.TotalGrossQty,
|
||||
TotalNetQty: resp.TotalNetQty,
|
||||
TotalWasteQty: resp.TotalWasteQty,
|
||||
WastePercentage: resp.WastePercentage,
|
||||
Unit: resp.Unit,
|
||||
}
|
||||
}
|
||||
|
||||
func ModelToContractOrderIngredientTransactionSummaries(responses []*models.OrderIngredientTransactionSummary) []*contract.OrderIngredientTransactionSummary {
|
||||
if responses == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
contractResponses := make([]*contract.OrderIngredientTransactionSummary, len(responses))
|
||||
for i, resp := range responses {
|
||||
contractResponses[i] = ModelToContractOrderIngredientTransactionSummary(resp)
|
||||
}
|
||||
|
||||
return contractResponses
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user