yxh
3 天以前 68b49efb4da346edb42a5d8ebb39af47207402bd
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -136,21 +136,30 @@
     */
    @Override
    public Double getTaxByBeneFiciaryNo(TaxMoneyVO taxMoneyVo) {
        Double sum = 0.00;
        Double totalScore = 0.00;
        // 金额累加必须用 BigDecimal:double 累加会引入浮点尾差,导致算出的个税出现分以下误差
        BigDecimal sum = BigDecimal.ZERO;
        BigDecimal totalScore = BigDecimal.ZERO;
        List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
        if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
            //计算申请金额总和,不包括当前传进来的
            sum = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getAmount).sum();
            sum = taxationByBeneFiciaryNo.stream()
                    .map(ServiceFunddetail::getAmount)
                    .filter(java.util.Objects::nonNull)
                    .map(BigDecimal::valueOf)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            //不加本次薪酬的个税
            totalScore = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxamount).sum();
            totalScore = taxationByBeneFiciaryNo.stream()
                    .map(ServiceFunddetail::getTaxamount)
                    .filter(java.util.Objects::nonNull)
                    .map(BigDecimal::valueOf)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
        }
        sum = sum + new Double(taxMoneyVo.getMoney());
        sum = sum.add(new BigDecimal(taxMoneyVo.getMoney()));
        //加上本次薪酬的总个税
        String taxation = TaxtUtils.getTaxation(new BigDecimal(sum));
        String taxation = TaxtUtils.getTaxation(sum);
        Double tax = Double.valueOf(taxation) - totalScore;
        Double tax = new BigDecimal(taxation).subtract(totalScore).doubleValue();
        return tax;
    }
@@ -163,21 +172,30 @@
    @Override
    public TaxedMoneyVO getTaxBeforeByAfterMoney(TaxMoneyVO taxMoneyVo) {
        TaxedMoneyVO taxedMoneyVO = new TaxedMoneyVO();
        Double sum = 0.00;
        Double totalScore = 0.00;
        // 金额累加必须用 BigDecimal,避免浮点尾差影响税前/税额结果
        BigDecimal sum = BigDecimal.ZERO;
        BigDecimal totalScore = BigDecimal.ZERO;
        List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
        if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
            //计算出税后总金额(不包含本次)
            sum = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxedamount).sum();
            sum = taxationByBeneFiciaryNo.stream()
                    .map(ServiceFunddetail::getTaxedamount)
                    .filter(java.util.Objects::nonNull)
                    .map(BigDecimal::valueOf)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            //求出之前的总的个税
            totalScore = taxationByBeneFiciaryNo.stream().mapToDouble(ServiceFunddetail::getTaxamount).sum();
            totalScore = taxationByBeneFiciaryNo.stream()
                    .map(ServiceFunddetail::getTaxamount)
                    .filter(java.util.Objects::nonNull)
                    .map(BigDecimal::valueOf)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
        }
        //计算出总的税后薪酬(包含本次)
        sum = sum + Double.valueOf(taxMoneyVo.getMoney());
        sum = sum.add(new BigDecimal(taxMoneyVo.getMoney()));
        //税前总金额
        String taxationBefore = TaxtUtils.getTaxationBefore(new BigDecimal(sum));
        String taxationBefore = TaxtUtils.getTaxationBefore(sum);
        //总个税
        BigDecimal tax = new BigDecimal(taxationBefore).subtract(new BigDecimal(sum));
        BigDecimal tax = new BigDecimal(taxationBefore).subtract(sum);
        //本次的税前金额
        String nowTaxMoney = TaxtUtils.getTaxationBefore(new BigDecimal(taxMoneyVo.getMoney()));