Revert "change order response at self order"
This reverts commit 7ba776555e.
This commit is contained in:
@@ -3,7 +3,6 @@ package transformer
|
||||
import (
|
||||
"apskel-pos-be/internal/constants"
|
||||
"apskel-pos-be/internal/contract"
|
||||
"apskel-pos-be/internal/entities"
|
||||
"apskel-pos-be/internal/models"
|
||||
"apskel-pos-be/internal/util"
|
||||
"strconv"
|
||||
@@ -417,122 +416,3 @@ func SplitBillModelToContract(resp *models.SplitBillResponse) *contract.SplitBil
|
||||
Message: resp.Message,
|
||||
}
|
||||
}
|
||||
|
||||
func OrderEntityToContract(o *entities.Order) *contract.OrderResponse {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
orderItems := make([]contract.OrderItemResponse, 0, len(o.OrderItems))
|
||||
for _, oi := range o.OrderItems {
|
||||
lineItem := contract.OrderItemResponse{
|
||||
ID: oi.ID,
|
||||
OrderID: oi.OrderID,
|
||||
ProductID: oi.ProductID,
|
||||
ProductVariantID: oi.ProductVariantID,
|
||||
Quantity: oi.Quantity,
|
||||
UnitPrice: oi.UnitPrice,
|
||||
TotalPrice: oi.TotalPrice,
|
||||
Modifiers: oi.Modifiers,
|
||||
Notes: oi.Notes,
|
||||
Metadata: oi.Metadata,
|
||||
Status: string(oi.Status),
|
||||
CreatedAt: oi.CreatedAt,
|
||||
UpdatedAt: oi.UpdatedAt,
|
||||
}
|
||||
if oi.Product.ID != uuid.Nil {
|
||||
lineItem.ProductName = oi.Product.Name
|
||||
}
|
||||
if oi.ProductVariant != nil {
|
||||
lineItem.ProductVariantName = &oi.ProductVariant.Name
|
||||
}
|
||||
orderItems = append(orderItems, lineItem)
|
||||
}
|
||||
|
||||
payments := make([]contract.PaymentResponse, 0, len(o.Payments))
|
||||
for i := range o.Payments {
|
||||
if p := PaymentEntityToContract(&o.Payments[i]); p != nil {
|
||||
payments = append(payments, *p)
|
||||
}
|
||||
}
|
||||
|
||||
return &contract.OrderResponse{
|
||||
ID: o.ID,
|
||||
OrderNumber: o.OrderNumber,
|
||||
OutletID: o.OutletID,
|
||||
UserID: o.UserID,
|
||||
TableNumber: o.TableNumber,
|
||||
OrderType: string(o.OrderType),
|
||||
Status: string(o.Status),
|
||||
Subtotal: o.Subtotal,
|
||||
TaxAmount: o.TaxAmount,
|
||||
DiscountAmount: o.DiscountAmount,
|
||||
TotalAmount: o.TotalAmount,
|
||||
TotalCost: o.TotalCost,
|
||||
RemainingAmount: o.RemainingAmount,
|
||||
PaymentStatus: string(o.PaymentStatus),
|
||||
RefundAmount: o.RefundAmount,
|
||||
IsVoid: o.IsVoid,
|
||||
IsRefund: o.IsRefund,
|
||||
VoidReason: o.VoidReason,
|
||||
VoidedAt: o.VoidedAt,
|
||||
VoidedBy: o.VoidedBy,
|
||||
RefundReason: o.RefundReason,
|
||||
RefundedAt: o.RefundedAt,
|
||||
RefundedBy: o.RefundedBy,
|
||||
Metadata: o.Metadata,
|
||||
CreatedAt: o.CreatedAt,
|
||||
UpdatedAt: o.UpdatedAt,
|
||||
OrderItems: orderItems,
|
||||
Payments: payments,
|
||||
TotalPaid: o.GetTotalPaid(),
|
||||
PaymentCount: len(o.Payments),
|
||||
}
|
||||
}
|
||||
|
||||
func PaymentEntityToContract(p *entities.Payment) *contract.PaymentResponse {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var splitType *string
|
||||
if p.SplitType != nil {
|
||||
s := string(*p.SplitType)
|
||||
splitType = &s
|
||||
}
|
||||
|
||||
paymentOrderItems := make([]contract.PaymentOrderItemResponse, 0, len(p.PaymentOrderItems))
|
||||
for _, poi := range p.PaymentOrderItems {
|
||||
paymentOrderItems = append(paymentOrderItems, contract.PaymentOrderItemResponse{
|
||||
ID: poi.ID,
|
||||
PaymentID: poi.PaymentID,
|
||||
OrderItemID: poi.OrderItemID,
|
||||
Amount: poi.Amount,
|
||||
CreatedAt: poi.CreatedAt,
|
||||
UpdatedAt: poi.UpdatedAt,
|
||||
})
|
||||
}
|
||||
|
||||
return &contract.PaymentResponse{
|
||||
ID: p.ID,
|
||||
OrderID: p.OrderID,
|
||||
PaymentMethodID: p.PaymentMethodID,
|
||||
PaymentMethodName: p.PaymentMethod.Name,
|
||||
PaymentMethodType: string(p.PaymentMethod.Type),
|
||||
Amount: p.Amount,
|
||||
Status: string(p.Status),
|
||||
TransactionID: p.TransactionID,
|
||||
SplitNumber: p.SplitNumber,
|
||||
SplitTotal: p.SplitTotal,
|
||||
SplitType: splitType,
|
||||
SplitDescription: p.SplitDescription,
|
||||
RefundAmount: p.RefundAmount,
|
||||
RefundReason: p.RefundReason,
|
||||
RefundedAt: p.RefundedAt,
|
||||
RefundedBy: p.RefundedBy,
|
||||
Metadata: p.Metadata,
|
||||
CreatedAt: p.CreatedAt,
|
||||
UpdatedAt: p.UpdatedAt,
|
||||
PaymentOrderItems: paymentOrderItems,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user