package com.petshop.backend.dto.sale;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;

public class SaleRequest {
    @NotNull(message = "Store ID is required")
    private Long storeId;

    private String paymentMethod;

    @NotEmpty(message = "At least one item is required")
    @Valid
    private List<SaleItemRequest> items;

    private Boolean isRefund = false;

    private Long originalSaleId;

    private Long customerId;

    private String channel;

    private Long couponId;

    private Long cartId;

    private Integer pointsUsed;


    public Long getStoreId() {
        return storeId;
    }

    public void setStoreId(Long storeId) {
        this.storeId = storeId;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public List<SaleItemRequest> getItems() {
        return items;
    }

    public void setItems(List<SaleItemRequest> items) {
        this.items = items;
    }

    public Boolean getIsRefund() {
        return isRefund;
    }

    public void setIsRefund(Boolean isRefund) {
        this.isRefund = isRefund;
    }

    public Long getOriginalSaleId() {
        return originalSaleId;
    }

    public void setOriginalSaleId(Long originalSaleId) {
        this.originalSaleId = originalSaleId;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public Long getCouponId() {
        return couponId;
    }

    public void setCouponId(Long couponId) {
        this.couponId = couponId;
    }

    public Long getCartId() {
        return cartId;
    }

    public void setCartId(Long cartId) {
        this.cartId = cartId;
    }

    public Integer getPointsUsed() {
        return pointsUsed;
    }

    public void setPointsUsed(Integer pointsUsed) {
        this.pointsUsed = pointsUsed;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SaleRequest that = (SaleRequest) o;
        return Objects.equals(storeId, that.storeId) &&
                Objects.equals(paymentMethod, that.paymentMethod) &&
                Objects.equals(items, that.items) &&
                Objects.equals(isRefund, that.isRefund) &&
                Objects.equals(originalSaleId, that.originalSaleId) &&
                Objects.equals(customerId, that.customerId) &&
                Objects.equals(channel, that.channel) &&
                Objects.equals(couponId, that.couponId) &&
                Objects.equals(cartId, that.cartId) &&
                Objects.equals(pointsUsed, that.pointsUsed);
    }

    @Override
    public int hashCode() {
        return Objects.hash(storeId, paymentMethod, items, isRefund, originalSaleId, customerId, channel, couponId, cartId, pointsUsed);
    }

    @Override
    public String toString() {
        return "SaleRequest{" +
                "storeId=" + storeId +
                ", paymentMethod='" + paymentMethod + '\'' +
                ", items=" + items +
                ", isRefund=" + isRefund +
                ", originalSaleId=" + originalSaleId +
                ", customerId=" + customerId +
                ", channel='" + channel + '\'' +
                ", couponId=" + couponId +
                ", cartId=" + cartId +
                ", pointsUsed=" + pointsUsed +
                '}';
    }
}
