package com.example.demo.order.dto;

import java.math.BigDecimal;
import java.util.List;

public class OrderDtos {

    public static class CreateOrderRequest {
        public String type; // sale.out / sale.return / sale.collect / purchase.in / purchase.return / purchase.pay
        public String orderTime; // ISO8601 或 yyyy-MM-dd
        public Long customerId; // 可空
        public Long supplierId; // 可空
        public List<Item> items; // 出入库时必填
        public List<PaymentItem> payments; // 收款/付款时必填
        public BigDecimal amount; // 前端提供，后端将重算覆盖
        public String remark;
    }

    public static class Item {
        public Long productId;
        public BigDecimal quantity;
        public BigDecimal unitPrice;
        public BigDecimal discountRate; // 可空，缺省 0
    }

    public static class PaymentItem {
        public String method; // cash/bank/wechat
        public BigDecimal amount;
        public Long orderId; // 可选：若挂单则带上
    }

    public static class CreateOrderResponse {
        public Long id;
        public String orderNo;
        public CreateOrderResponse(Long id, String orderNo) { this.id = id; this.orderNo = orderNo; }
    }

    public static class CreatePaymentsResponse {
        public java.util.List<Long> paymentIds;
        public CreatePaymentsResponse(java.util.List<Long> ids) { this.paymentIds = ids; }
    }

    public static class CreateOtherTransactionRequest {
        public String type; // income | expense
        public String category; // 分类key
        public String counterpartyType; // customer | supplier | other
        public Long counterpartyId; // 可空
        public Long accountId; // 必填
        public java.math.BigDecimal amount; // 必填，>0
        public String txTime; // yyyy-MM-dd 或 ISO8601
        public String remark; // 可空
    }
}


