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 ProjectBudgetCostDetailRepository extends JpaRepository<ProjectBudgetCostDetail,Integer> {
    List<ProjectBudgetCostDetail> findAllByProjectIdEquals(int id);

    @Query(value = "select sum(amount) from project_budget_cost_detail where project_id = ?1", nativeQuery = true)
    BigDecimal findAmountByProject(int projectId);

    @Query(value = "select sum(pay_amount) from project_budget_cost_detail where project_id = ?1", nativeQuery = true)
    BigDecimal findPayAmountByProject(int id);

    @Query(value = "select sum(underwritten_amount) from project_budget_cost_detail where project_id = ?1", nativeQuery = true)
    BigDecimal findUnderwrittenAmountByProject(int id);
}
