package com.jwipc.finance.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.finance.entity.PaymentAdvanceApply;
import com.jwipc.finance.entity.PaymentAdvanceApplyDetail;
import com.jwipc.finance.entity.PaymentCodApplyDetail;
import com.jwipc.finance.model.po.CreatePcaDetailPO;
import com.jwipc.finance.model.po.PaymentAdvanceApplyPO;
import com.jwipc.finance.model.po.PaymentAdvanceRefundTransferApplyPO;
import com.jwipc.finance.model.query.PaymentApplyHeadQuery;
import com.jwipc.finance.entity.PaymentAdvanceApply;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwipc.finance.model.query.PaymentApplyItemQuery;

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

/**
 * <p>
 * 预付款申请主表 服务类
 * </p>
 *
 * @author WT
 * @since 2024-03-08
 */
public interface IPaymentAdvanceApplyService extends IService<PaymentAdvanceApply> {
    /**
     * 查询列表
     * @param dbPage
     * @param query
     * @return
     */
    List<PaymentAdvanceApply> selectListByPage(Page<PaymentAdvanceApply> dbPage, PaymentApplyHeadQuery query);

    void checkAmount(List<PaymentAdvanceApplyDetail> pcaDetailList, List<Long> delItemIdList) throws Exception;

    /**
     * 创建预付款申请单
     *
     * @param headData 预付款申请单主表数据
     * @param pcaDetailList 预付款申请单明细数据
     * @param isPushOa 是否推送OA 0:否 1:是
     * @param adviceFjid
     * @return 结果 "":操作成功 其他:推送OA异常
     */
    String createAdvanceApply(PaymentAdvanceApply headData, List<PaymentAdvanceApplyDetail> pcaDetailList, Integer isPushOa, String adviceFjid) throws Exception;
    /**
     * 编辑预付款申请单
     *
     * @param headData 预付款申请主表数据
     * @param pcaDetailList 预付申请单明细数据
     * @param delItemIdList 待删除明细ID
     * @param isPushOa 是否推送OA 0:否 1:是
     * @param adviceFjid
     * @return 结果 "":操作成功 其他:推送OA异常
     */
    String editAdvanceApply(PaymentAdvanceApply headData, List<PaymentAdvanceApplyDetail> pcaDetailList, List<Long> delItemIdList, Integer isPushOa, String adviceFjid);

    /**
     * 查询数据根据id
     * @param id
     * @return
     */
    PaymentAdvanceApplyPO selectById(Long id);

    /**
     * 查找预付款数据
     * @param applyIdList
     * @return
     */
    List<PaymentAdvanceApply> findDataStatusByIdList(List<Long> applyIdList);

    List<CreatePcaDetailPO> findByQuery(PaymentApplyItemQuery query);

    List<PaymentAdvanceRefundTransferApplyPO> paaOrderListByPage(Page<PaymentAdvanceRefundTransferApplyPO> dbPage, PaymentApplyHeadQuery query);

    void initPaymentPlanSummary(PaymentAdvanceApply headData, int action);
    String initPaymentPlanSummary(PaymentAdvanceApply headData, Boolean flag);

    List<PaymentAdvanceApplyDetail> findDataBySupplierAndPoCodeAndAmount(String supplierCode, String poCode, BigDecimal budOutMoney,Long id);

    BigDecimal getUnCleared1(String supplierCode);

    BigDecimal getUnCleared2(String supplierCode);

    BigDecimal getUnCleared3(String supplierCode);

    BigDecimal getUnCleared4(String supplierCode);

    BigDecimal getInPaymentAmount(String supplierCode,String companyCode);
}
