package cn.palmte.work.model;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

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

public interface ProjectBudgetIncomeRepository extends JpaRepository<ProjectBudgetIncome,Integer> {
    List<ProjectBudgetIncome> findAllByProjectIdEquals(int id);

    @Query(value = "select sum(income_tax_include) from project_budget_income where type = ?", nativeQuery = true)
    BigDecimal incomeTaxIncludeSum(int type);

    @Query(value = "select sum(income_tax_exclude) from project_budget_income where type = ?", nativeQuery = true)
    BigDecimal incomeTaxExcludeSum(int type);

    @Query(value = "select * from project_budget_income where project_id in ?1", nativeQuery = true)
    List<ProjectBudgetIncome> findAllByProjectIds(List<Integer> projectInt);
}
