using Meezi.Core.Enums;

namespace Meezi.API.Models.Orders;

public record OrderItemDto(
    string Id,
    string MenuItemId,
    string MenuItemName,
    int Quantity,
    decimal UnitPrice,
    string? Notes,
    bool IsVoided = false,
    DateTime? VoidedAt = null);

public record TransferTableRequest(string TargetTableId);

public record OrderDto(
    string Id,
    string CafeId,
    string? BranchId,
    string? TableId,
    string? TableNumber,
    string? GuestName,
    string? GuestPhone,
    string? CustomerName,
    string? CustomerPhone,
    string? CustomerId,
    string? EmployeeId,
    OrderType OrderType,
    OrderSource Source,
    OrderStatus Status,
    decimal Subtotal,
    decimal TaxTotal,
    decimal DiscountAmount,
    decimal Total,
    decimal PaidAmount,
    DateTime CreatedAt,
    int DisplayNumber,
    IReadOnlyList<OrderItemDto> Items,
    IReadOnlyList<PaymentDto> Payments);

public record AppendOrderItemsRequest(IReadOnlyList<CreateOrderItemRequest> Items);

public record UpdateOrderSessionRequest(
    string? GuestName,
    string? GuestPhone,
    string? CustomerId);


public record CreateOrderItemRequest(string MenuItemId, int Quantity, string? Notes);

public record CreateOrderRequest(
    OrderType OrderType,
    string? BranchId,
    string? TableId,
    string? ReservationId,
    string? GuestName,
    string? GuestPhone,
    string? CustomerId,
    string? CouponId,
    IReadOnlyList<CreateOrderItemRequest> Items);

public record UpdateOrderStatusRequest(OrderStatus Status);

public record CancelOrderRequest(string? Reason);

public record CreatePaymentRequest(PaymentMethod Method, decimal Amount, string? Reference);

public record RecordPaymentsRequest(
    IReadOnlyList<CreatePaymentRequest> Payments,
    int? LoyaltyPointsToRedeem = null);

public record PaymentDto(string Id, PaymentMethod Method, decimal Amount, PaymentStatus Status, string? Reference);

public record LiveOrderDto(
    string Id,
    int DisplayNumber,
    OrderStatus Status,
    string? TableNumber,
    OrderType OrderType,
    decimal Total,
    DateTime CreatedAt,
    IReadOnlyList<OrderItemDto> Items);
