update order response

This commit is contained in:
Efril
2026-05-25 20:28:24 +07:00
parent d0378b5ac4
commit 957c1ae53d
6 changed files with 22 additions and 25 deletions
+3 -25
View File
@@ -1,7 +1,6 @@
package processor
import (
"apskel-pos-be/internal/constants"
"context"
"errors"
"fmt"
@@ -388,31 +387,10 @@ func (p *OrderProcessorImpl) AddToOrder(ctx context.Context, orderID uuid.UUID,
return nil, fmt.Errorf("failed to create order item: %w", err)
}
itemResponse := models.OrderItemResponse{
ID: orderItem.ID,
OrderID: orderItem.OrderID,
ProductID: orderItem.ProductID,
ProductVariantID: orderItem.ProductVariantID,
Quantity: orderItem.Quantity,
UnitPrice: orderItem.UnitPrice,
TotalPrice: orderItem.TotalPrice,
UnitCost: orderItem.UnitCost,
TotalCost: orderItem.TotalCost,
RefundAmount: orderItem.RefundAmount,
RefundQuantity: orderItem.RefundQuantity,
IsPartiallyRefunded: orderItem.IsPartiallyRefunded,
IsFullyRefunded: orderItem.IsFullyRefunded,
RefundReason: orderItem.RefundReason,
RefundedAt: orderItem.RefundedAt,
RefundedBy: orderItem.RefundedBy,
Modifiers: []map[string]interface{}(orderItem.Modifiers),
Notes: orderItem.Notes,
Metadata: map[string]interface{}(orderItem.Metadata),
Status: constants.OrderItemStatus(orderItem.Status),
CreatedAt: orderItem.CreatedAt,
UpdatedAt: orderItem.UpdatedAt,
itemResponse := mappers.OrderItemEntityToResponse(orderItem)
if itemResponse != nil {
addedItemResponses = append(addedItemResponses, *itemResponse)
}
addedItemResponses = append(addedItemResponses, itemResponse)
}
orderWithRelations, err := p.orderRepo.GetWithRelations(ctx, orderID)