提交审核的时候合同金额问题

master
Harry Yang 2023-01-06 12:31:40 +08:00
parent 01f19c320f
commit b2a9695766
3 changed files with 48 additions and 13 deletions

View File

@ -388,17 +388,7 @@ public class ProcessController {
contract = processService.findProcurementContract(id); contract = processService.findProcurementContract(id);
supplierMaterials = processService.getSupplierMaterials(id); supplierMaterials = processService.getSupplierMaterials(id);
procurementDetails = processService.getProcurementDetails(project.getId(), id); procurementDetails = processService.getProcurementDetails(project.getId(), id);
BigDecimal contractAmount = BigDecimal.ZERO; BigDecimal contractAmount = ProjectProcess.getContractAmount(procurementDetails);
for (ProcurementDetail procurementDetail : procurementDetails) {
if (!CollectionUtils.isEmpty(procurementDetail.getPurchaseDetails())) {
for (BudgetPurchaseDetail purchaseDetail : procurementDetail.getPurchaseDetails()) {
BigDecimal totalTaxInclude = purchaseDetail.getTotalTaxInclude();
if (totalTaxInclude != null) {
contractAmount = contractAmount.add(totalTaxInclude);
}
}
}
}
detail.setContractAmount(contractAmount); detail.setContractAmount(contractAmount);
} }

View File

@ -7,11 +7,14 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.springframework.util.CollectionUtils;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import javax.persistence.Convert; import javax.persistence.Convert;
import javax.persistence.Entity; import javax.persistence.Entity;
@ -129,6 +132,32 @@ public class ProjectProcess implements Serializable {
this.lastUpdateAt = this.createAt; this.lastUpdateAt = this.createAt;
} }
public static BigDecimal getContractAmount(List<ProcurementDetail> procurementDetails) {
BigDecimal contractAmount = BigDecimal.ZERO;
for (ProcurementDetail procurementDetail : procurementDetails) {
if (!CollectionUtils.isEmpty(procurementDetail.getPurchaseDetails())) {
for (BudgetPurchaseDetail purchaseDetail : procurementDetail.getPurchaseDetails()) {
BigDecimal totalTaxInclude = purchaseDetail.getTotalTaxInclude();
if (totalTaxInclude != null) {
contractAmount = contractAmount.add(totalTaxInclude);
}
}
}
}
return contractAmount;
}
public static BigDecimal getContractAmountByPurchaseDetail(List<BudgetPurchaseDetail> purchaseDetails) {
BigDecimal contractAmount = BigDecimal.ZERO;
for (BudgetPurchaseDetail purchaseDetail : purchaseDetails) {
BigDecimal totalTaxInclude = purchaseDetail.getTotalTaxInclude();
if (totalTaxInclude != null) {
contractAmount = contractAmount.add(totalTaxInclude);
}
}
return contractAmount;
}
static class SealTypeArraySerializer extends JsonSerializer<SealTypeArray> { static class SealTypeArraySerializer extends JsonSerializer<SealTypeArray> {
@Override @Override

View File

@ -362,6 +362,13 @@ public class ProjectProcessService {
return query.getResultList(); return query.getResultList();
} }
private List<BudgetPurchaseDetail> getBudgetPurchaseDetailsByProcessId(int processId) {
TypedQuery<BudgetPurchaseDetail> query = entityManager.createQuery(
"from BudgetPurchaseDetail where processId=:processId", BudgetPurchaseDetail.class);
query.setParameter("processId", processId);
return query.getResultList();
}
private ProjectBudgetCostDetail getCostDetailById(int budgetCostId) { private ProjectBudgetCostDetail getCostDetailById(int budgetCostId) {
return entityManager.find(ProjectBudgetCostDetail.class, budgetCostId); return entityManager.find(ProjectBudgetCostDetail.class, budgetCostId);
} }
@ -486,8 +493,17 @@ public class ProjectProcessService {
// 垫资金额 // 垫资金额
BigDecimal repaidAmount = getProjectRepaidAmount(entity.getProjectId()); BigDecimal repaidAmount = getProjectRepaidAmount(entity.getProjectId());
variables.put("repaidAmount", repaidAmount); variables.put("repaidAmount", repaidAmount);
// 合同金额
variables.put("contractAmount", project.getContractAmount() == null ? 0 : project.getContractAmount()); if (entity.getProcessType() == ProcessType.procurement_contract) {
// 合同金额
List<BudgetPurchaseDetail> purchaseDetails = getBudgetPurchaseDetailsByProcessId(entity.getId());
BigDecimal contractAmount = ProjectProcess.getContractAmountByPurchaseDetail(purchaseDetails);
variables.put("contractAmount", contractAmount);
}
else {
// 合同金额
variables.put("contractAmount", project.getContractAmount() == null ? 0 : project.getContractAmount());
}
// 项目类型 // 项目类型
variables.put("projectType", project.getType()); variables.put("projectType", project.getType());
// 合作类型 // 合作类型