package com.jwipc.finance.logic;

import com.jwipc.finance.dto.ReceiveVoucherDTO;
import com.jwipc.finance.dto.StatementItemDTO;
import com.jwipc.finance.model.query.ReceiveVoucherQuery;
import com.jwipc.page.PageView;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * @author shenyang.ou
 * @date 2024/3/4 10:32
 * @desc
 */
public interface ReceiptVoucherLogic {
    PageView findByPage(ReceiveVoucherQuery query);

    List<ReceiveVoucherDTO> listAll(ReceiveVoucherQuery query);

    void updateRatio(List<String> idList, BigDecimal deductionRatio);

    void updatePayment(List<String> idList, String paymentTermCode);

    /**
     * 统计凭证在SRM中的使用情况
     *
     * @param asId 对账单ID
     * @param list 对账单明细数据
     * @param optType 操作类型 0:对账单查看/编辑 1:新增/添加新行
     */
    void statisticVoucherData(Long asId, List<StatementItemDTO> list, Integer optType);

    /**
     * 提供创建对账单时获取入库凭证数据
     *
     * @param query 查询条件
     * @return 结果
     */
    PageView provideCreateStatement(ReceiveVoucherQuery query);
    List<StatementItemDTO> provideCreateStatementList(ReceiveVoucherQuery query);
    PageView provideCreatePaymentMatching(ReceiveVoucherQuery query);
    PageView provideCreateCostMatching(ReceiveVoucherQuery query);
    PageView provideDetailByPaymentMatchingId(Long paymentMatchingId);
    PageView provideDetailByCostMatchingId(Long costMatchingId);

    /**
     * 根据物料凭证号检验凭证的参考凭证是否在内
     *
     * @param rvIdList 待检查的物料凭证ID
     * @param supplierCode 供应商编码
     * @param voucherType 凭证类型 1:材料类 2:运费类
     * @return 结果
     */
    String checkConsultVoucher(List<Long> rvIdList, String supplierCode, Integer voucherType);

    ReceiveVoucherDTO getByIdAndFactoryCode(Long receiveId,String factoryCode);

    void priceImport(MultipartFile file);

    List<ReceiveVoucherDTO> findByPoAndAsNoNotNull(String poCode, String poItemNo,String factoryCode);
    List<ReceiveVoucherDTO> findByPoAndItemNo(String poCode, String poItemNo,String factoryCode);

    /**
     * 更新凭证信息
     *
     * @param receiveVoucherId 凭证ID
     * @param factoryCode 工厂编码
     * @param invoiceVoucher 凭证号
     * @param paymentExpireDate 付款到期日
     */
    void updateInvoiceVoucherAndPaymentExpireDate(Long receiveVoucherId, String factoryCode, String invoiceVoucher, String paymentExpireDate);

    List<ReceiveVoucherDTO> getReturnVoucherData(String supplierCode, String factoryCode);
    BigDecimal getPoReturnVoucherData(String supplierCode, String factoryCode,String companyCode);

    /**
     * 获取在途退款金额
     *
     * @param supplierCode 供应商编码
     * @param factoryCode 工厂编码
     * @return 退款金额
     */
    BigDecimal getReturnVoucherRefundAmount(String supplierCode, String factoryCode,String companyCode,Boolean deductionFlag);
}
