package com.yn.bftl.thirdparty.common.repository;

import com.yn.bftl.common.modules.company.entity.ErpAccountSet;
import com.yn.bftl.common.modules.relation.entity.CreditList;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * ERP账套Repository
 *
 * @author huabiao
 * @create 2022/4/18  14:36
 **/
@Repository
public interface ErpAccountSetRepository extends JpaRepository<ErpAccountSet, Long>, JpaSpecificationExecutor<CreditList> {

    /**
     * ERP账套-查询
     *
     * @param companyId:企业ID
     * @return ErpAccountSet
     * @description 根据企业ID查询默认账套
     * @author huabiao
     * @create 2022/4/18  14:40
     */
    ErpAccountSet findByCompanyIdAndIsDefaultTrue(Long companyId);


    /**
     * ERP账套-根据企业获取第一条
     *
     * @param companyId
     * @return
     */
    ErpAccountSet findFirstByCompanyId(Long companyId);

    /**
     * ERP账套-查询
     *
     * @param code:账套编码
     * @param orgCode:组织编码
     * @return List<ErpAccountSet>
     * @description 根据账套编码和组织编码查询ERP账套
     * @author huabiao
     * @create 2022/5/11  10:09
     */
    List<ErpAccountSet> findAllByCodeAndOrgCode(String code, String orgCode);

    ErpAccountSet findFirstByCode(String code);

    /**
     * ERP账套-根据供货组织编码查询
     *
     * @param supplyOrgCode 供货组织编码
     * @return ERP账套
     * @author huabiao
     * @create 2023/5/31  14:44
     */
    ErpAccountSet findFirstBySupplyOrgCode(String supplyOrgCode);

    List<ErpAccountSet> findAllByCompanyId(Long companyId);
}
