Commit 9573dd18 by liuyang

2024-08-05 销售开票本次开票金额加累计开票金额不能超出销售合同金额20%,如果要超出20%需要提示业务新增补充协议

parent 90b1b389
......@@ -320,20 +320,28 @@ public class HGCWTools {
List<HGCW002> results = DaoBase.getInstance().query(HGCW002.QUERY,new HashMap<String,Object>(){
{put("contractNumber",contractNumber);}
});
BigDecimal totalAmount = HgCw011.sumSettlementNumber(contractNumber);
if (CollectionUtils.isEmpty(results)) {
throw new PlatException("找不到对应的合同!");
}
BigDecimal totalAmount = HgCw011.sumSettlementNumber(contractNumber); //获取累计开票金额
DecimalFormat decimalFormat = new DecimalFormat("#.000");
HGCW002 hgcw002 = results.get(0);
BigDecimal remaining = hgcw002.getTotalContractPriceIncluding();
if(hgcw002.getContractType() == 1 || hgcw002.getContractType() == 5){
//获取销售合同金额和补充协议金额
List<HGCW002> hgcw002List = DaoBase.getInstance().query("HGCW010D.sumContractPrice",new HashMap<String,Object>(){
{put("contractNumberStr",contractNumber);}
});
BigDecimal remaining = hgcw002List.get(0).getTotalContractPriceIncluding().add(hgcw002List.get(0).getTotalContractPriceIncluding().multiply(new BigDecimal("0.2")));
//计算销售合同金额的20%的总金额 总金额=合同金额+合同金额的20%
remaining = hgcw002List.get(0).getTotalContractPriceIncluding().add(hgcw002List.get(0).getTotalContractPriceIncluding().multiply(new BigDecimal("0.2")));
}
//合同总金额-(累计开票金额+本次来票金额)
BigDecimal remainingAmount = new BigDecimal(decimalFormat.format(remaining.subtract(deductionAmount.add(totalAmount))));
if (remainingAmount.compareTo(new BigDecimal(BigInteger.ZERO)) < 0) {
throw new PlatException("本次开票金额加累计开票金额超出销售合同金额20%,超出20%需要业务新增补充协议");
throw new PlatException("本次开票金额加累计开票金额超出销售合同金额20%,超出20%需要业务新增补充协议");
}
BigDecimal remainingCount = new BigDecimal(decimalFormat.format(hgcw002.getRemainingAmount().subtract(deductionAmount)));
hgcw002.setRemainingAmount(remainingCount);
DaoUtils.update("HGCW002.updateDeductionAmount", hgcw002);
......@@ -723,6 +731,11 @@ public class HGCWTools {
return results;
}
/**
* 根据来源单号获取总金额
* @param settlementNumber 来源单号
* @return
*/
public static BigDecimal sumSettlementNumber(String settlementNumber) {
AssertUtils.isNull(settlementNumber, "来源单号不能为空!");
List<HGCW011> results = DaoBase.getInstance().query(HGCW011.QUERY,new HashMap<String,Object>(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment