package com.erp.finance.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.erp.finance.dto.*;

import java.math.BigDecimal;

/**
 * 应付账款服务接口
 */
public interface AccountsPayableService {

    /**
     * 创建应付账款（采购订单审核通过后调用）
     */
    com.erp.finance.entity.AccountsPayable create(AccountsPayableCreateRequest request);

    /**
     * 取消应付账款（采购订单取消后调用）
     */
    void cancel(String purchaseOrderNo);

    /**
     * 更新入库状态（采购入库完成后调用）
     */
    void updateInboundStatus(String purchaseOrderNo, String inboundNo, BigDecimal inboundAmount, String action);

    /**
     * 确认付款
     */
    com.erp.finance.entity.PaymentRecord confirmPayment(PaymentConfirmRequest request);

    /**
     * 查询应付账款列表
     */
    IPage<com.erp.finance.entity.AccountsPayable> query(AccountsPayableQueryRequest request);

    /**
     * 根据应付单号查询
     */
    com.erp.finance.entity.AccountsPayable getByApNo(String apNo);

    /**
     * 根据采购单号查询
     */
    com.erp.finance.entity.AccountsPayable getByPurchaseOrderNo(String purchaseOrderNo);

    /**
     * 获取未付款总额
     */
    BigDecimal getTotalUnpaid();

    /**
     * 获取逾期总额
     */
    BigDecimal getOverdueAmount(java.time.LocalDate date);

    // ========== 请求体 ==========
    @lombok.Data
    @lombok.NoArgsConstructor
    @lombok.AllArgsConstructor
    class AccountsPayableCreateRequest {
        private Long purchaseOrderId;
        private String purchaseOrderNo;
        private Long supplierId;
        private String supplierName;
        private BigDecimal amount;
        private String paymentMethod;
        private java.time.LocalDate dueDate;
    }

    @lombok.Data
    @lombok.NoArgsConstructor
    @lombok.AllArgsConstructor
    class PaymentConfirmRequest {
        private String apNo;
        private BigDecimal amount;
        private String paymentMethod;
        private String fromAccount;
        private String toAccount;
        private String bankFlowNo;
        private String operator;
        private String remark;
    }
}
