From edbfa6b1a3a45e79cb17b06f3798535c3b1ba395 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期三, 18 十一月 2026 09:12:39 +0800
Subject: [PATCH] 修改了增值税城建税
---
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java | 208 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 143 insertions(+), 65 deletions(-)
diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
index 6bf6c64..29d2ee9 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFunddetailServiceImpl.java
@@ -130,84 +130,132 @@
}
/**
- * 鏍规嵁鍙楃泭浜鸿韩浠借瘉缂栧彿鑾峰彇绋庤垂閲戦
+ * 鏍规嵁鍙楃泭浜鸿韩浠借瘉缂栧彿鑾峰彇绋庤垂閲戦锛堝綍鍏ユ椂鐨勪釜绋庨瑙堬級
+ * <p>
+ * 2026-11-17锛堢疮璁″彛寰勶級锛氬悓涓�韬唤璇�**褰撴湀**鐨勫鍊肩◣銆佸煄寤虹◣銆佷釜绋庨兘鎸夌疮璁¤绠楋紝鏈瑪鍙栧樊棰濓細
+ * <pre>
+ * P绱� = 危褰撴湀绋庡墠 + 鏈锛沄绱� = calcVat(P绱�)锛堣捣寰佺偣鎸夌疮璁″垽鏂級锛汣绱� = calcCityTax(V绱�)
+ * 鏈瑪 V = V绱� 鈭� 危宸茬畻绋庡鍊肩◣锛涙湰绗� C 鍚岀悊锛涙湰绗� L = 鏈瑪 P 鈭� 鏈瑪 V 鈭� 鏈瑪 C
+ * 鏈瑪涓◣ = 涓◣(L绱) 鈭� 危宸茬畻绋庝釜绋�
+ * </pre>
*
- * @param taxMoneyVo
- * @return
+ * @param taxMoneyVo 韬唤璇佸彿 + 鏈鍚◣閲戦
+ * @return 鏈鍔冲姟涓◣
*/
@Override
public Double getTaxByBeneFiciaryNo(TaxMoneyVO taxMoneyVo) {
// 閲戦绱姞蹇呴』鐢� BigDecimal锛歞ouble 绱姞浼氬紩鍏ユ诞鐐瑰熬宸紝瀵艰嚧绠楀嚭鐨勪釜绋庡嚭鐜板垎浠ヤ笅璇樊
- BigDecimal sum = BigDecimal.ZERO;
- BigDecimal totalScore = BigDecimal.ZERO;
+ BigDecimal sumPretax = BigDecimal.ZERO;
+ BigDecimal sumVat = BigDecimal.ZERO;
+ BigDecimal sumCityTax = BigDecimal.ZERO;
+ BigDecimal sumLaborPretax = BigDecimal.ZERO;
+ BigDecimal sumTax = BigDecimal.ZERO;
List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
- //璁$畻鐢宠閲戦鎬诲拰锛屼笉鍖呮嫭褰撳墠浼犺繘鏉ョ殑
- sum = taxationByBeneFiciaryNo.stream()
- .map(ServiceFunddetail::getAmount)
- .filter(java.util.Objects::nonNull)
- .map(BigDecimal::valueOf)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
- //涓嶅姞鏈钖叕鐨勪釜绋�
- totalScore = taxationByBeneFiciaryNo.stream()
- .map(ServiceFunddetail::getTaxamount)
- .filter(java.util.Objects::nonNull)
- .map(BigDecimal::valueOf)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
+ for (ServiceFunddetail detail : taxationByBeneFiciaryNo) {
+ sumPretax = sumPretax.add(toMoney(detail.getAmount()));
+ sumVat = sumVat.add(toMoney(detail.getVatAmount()));
+ sumCityTax = sumCityTax.add(toMoney(detail.getCityTaxAmount()));
+ sumLaborPretax = sumLaborPretax.add(laborPretaxOf(detail));
+ sumTax = sumTax.add(toMoney(detail.getTaxamount()));
+ }
}
- sum = sum.add(new BigDecimal(taxMoneyVo.getMoney()));
- //鍔犱笂鏈钖叕鐨勬�讳釜绋�
- String taxation = TaxtUtils.getTaxation(sum);
+ // 鏈鍚◣閲戦 + 绱锛氭寜绱鍙e緞绠楀鍊肩◣/鍩庡缓绋庯紝鏈瑪鍙栧樊棰�
+ BigDecimal nowPretax = new BigDecimal(taxMoneyVo.getMoney());
+ BigDecimal cumPretax = sumPretax.add(nowPretax);
+ BigDecimal cumVat = VatTaxUtils.calcVat(cumPretax);
+ BigDecimal cumCityTax = VatTaxUtils.calcCityTax(cumVat);
+ BigDecimal nowVat = VatTaxUtils.roundMoney(cumVat.subtract(sumVat));
+ BigDecimal nowCityTax = VatTaxUtils.roundMoney(cumCityTax.subtract(sumCityTax));
+ if (nowVat.signum() < 0) {
+ nowVat = BigDecimal.ZERO;
+ }
+ if (nowCityTax.signum() < 0) {
+ nowCityTax = BigDecimal.ZERO;
+ }
+ BigDecimal nowLaborPretax = VatTaxUtils.roundMoney(nowPretax.subtract(nowVat).subtract(nowCityTax));
+ if (nowLaborPretax.signum() < 0) {
+ // 涓庣畻绋庝竴鑷达細鏈瑪涓嶆墸绋庛�佸樊棰濋『寤�
+ nowVat = BigDecimal.ZERO;
+ nowCityTax = BigDecimal.ZERO;
+ nowLaborPretax = nowPretax;
+ }
- Double tax = new BigDecimal(taxation).subtract(totalScore).doubleValue();
- return tax;
+ BigDecimal cumLaborPretax = sumLaborPretax.add(nowLaborPretax);
+ String taxation = TaxtUtils.getTaxation(cumLaborPretax);
+ return new BigDecimal(taxation).subtract(sumTax).doubleValue();
}
/**
- * 鏍规嵁绋庡悗宸ヨ祫锛岀畻鍑虹◣鍓嶅伐璧�
+ * 鏄庣粏鐨勫姵鍔$◣鍓嶏細浼樺厛鍙栬惤搴撶殑 labor_pretax_amount锛屼负绌烘椂鍥為��鍒扮◣鍓嶉噾棰濓紙鍏煎鏈洖濉幆澧冿級
+ */
+ private static BigDecimal laborPretaxOf(ServiceFunddetail detail) {
+ if (detail.getLaborPretaxAmount() != null) {
+ return BigDecimal.valueOf(detail.getLaborPretaxAmount());
+ }
+ // 娌℃湁鍔冲姟绋庡墠鏃舵寜鈥滃惈绋庨噾棰濆仛浠风◣鍒嗙鈥濆厹搴曪紝淇濊瘉涓庣畻绋庡彛寰勪竴鑷�
+ return detail.getAmount() == null ? BigDecimal.ZERO
+ : VatTaxUtils.calcLaborPretax(BigDecimal.valueOf(detail.getAmount()));
+ }
+
+ /**
+ * 鏍规嵁绋庡悗宸ヨ祫锛岀畻鍑虹◣鍓嶅伐璧勶紙褰曞叆鏃剁殑鈥滅◣鍚� 鈫� 绋庡墠鈥濋瑙堬級
+ * <p>
+ * 2026-11-17锛堢疮璁″彛寰勶級锛氫笌绠楃◣淇濇寔涓�鑷达紝鍏堢敱鈥滅疮璁$◣鍚庘�濆弽绠楃疮璁″姵鍔$◣鍓� L绱紝
+ * 鍐嶈В绱鍚◣绋庡墠 P绱紙P绱� = L绱� + V绱� + C绱紝璧峰緛鐐规寜绱鍒ゆ柇锛夛紝鏈瑪鍧囧彇宸銆�
*
- * @param taxMoneyVo
- * @return
+ * @param taxMoneyVo 韬唤璇佸彿 + 鏈鍔冲姟绋庡悗閲戦
+ * @return 绋庡墠/涓◣绛夐瑙堝��
*/
@Override
public TaxedMoneyVO getTaxBeforeByAfterMoney(TaxMoneyVO taxMoneyVo) {
TaxedMoneyVO taxedMoneyVO = new TaxedMoneyVO();
// 閲戦绱姞蹇呴』鐢� BigDecimal锛岄伩鍏嶆诞鐐瑰熬宸奖鍝嶇◣鍓�/绋庨缁撴灉
- BigDecimal sum = BigDecimal.ZERO;
- BigDecimal totalScore = BigDecimal.ZERO;
+ BigDecimal sumTaxed = BigDecimal.ZERO;
+ BigDecimal sumPretax = BigDecimal.ZERO;
+ BigDecimal sumVat = BigDecimal.ZERO;
+ BigDecimal sumCityTax = BigDecimal.ZERO;
+ BigDecimal sumLaborPretax = BigDecimal.ZERO;
+ BigDecimal sumTax = BigDecimal.ZERO;
List<ServiceFunddetail> taxationByBeneFiciaryNo = serviceFunddetailMapper.getTaxBeforeByBeneFiciaryNo(taxMoneyVo);
if (CollectionUtils.isNotEmpty(taxationByBeneFiciaryNo)) {
- //璁$畻鍑虹◣鍚庢�婚噾棰濓紙涓嶅寘鍚湰娆★級
- sum = taxationByBeneFiciaryNo.stream()
- .map(ServiceFunddetail::getTaxedamount)
- .filter(java.util.Objects::nonNull)
- .map(BigDecimal::valueOf)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
- //姹傚嚭涔嬪墠鐨勬�荤殑涓◣
- totalScore = taxationByBeneFiciaryNo.stream()
- .map(ServiceFunddetail::getTaxamount)
- .filter(java.util.Objects::nonNull)
- .map(BigDecimal::valueOf)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
+ for (ServiceFunddetail detail : taxationByBeneFiciaryNo) {
+ sumTaxed = sumTaxed.add(toMoney(detail.getTaxedamount()));
+ sumPretax = sumPretax.add(toMoney(detail.getAmount()));
+ sumVat = sumVat.add(toMoney(detail.getVatAmount()));
+ sumCityTax = sumCityTax.add(toMoney(detail.getCityTaxAmount()));
+ sumLaborPretax = sumLaborPretax.add(laborPretaxOf(detail));
+ sumTax = sumTax.add(toMoney(detail.getTaxamount()));
+ }
}
- //璁$畻鍑烘�荤殑绋庡悗钖叕锛堝寘鍚湰娆★級
- sum = sum.add(new BigDecimal(taxMoneyVo.getMoney()));
- //绋庡墠鎬婚噾棰�
- String taxationBefore = TaxtUtils.getTaxationBefore(sum);
- //鎬讳釜绋�
- BigDecimal tax = new BigDecimal(taxationBefore).subtract(sum);
- //鏈鐨勭◣鍓嶉噾棰�
- String nowTaxMoney = TaxtUtils.getTaxationBefore(new BigDecimal(taxMoneyVo.getMoney()));
- //鏈鐨勭◣璐�
- BigDecimal subtract = new BigDecimal(nowTaxMoney).subtract(new BigDecimal(taxMoneyVo.getMoney()));
+ // 鍚湰娆$殑绱绋庡悗
+ BigDecimal nowTaxed = new BigDecimal(taxMoneyVo.getMoney());
+ BigDecimal cumTaxed = sumTaxed.add(nowTaxed);
+ // 绱鍔冲姟绋庡墠锛堢敱绱绋庡悗鍙嶇畻锛�
+ BigDecimal cumLaborPretax = new BigDecimal(TaxtUtils.getTaxationBefore(cumTaxed));
+ // 绱涓◣
+ BigDecimal cumTax = VatTaxUtils.roundMoney(cumLaborPretax.subtract(cumTaxed));
+ // 绱鍚◣绋庡墠閲戦锛堝唴閮ㄦ寜绱 P 鍒ゆ柇璧峰緛鐐癸級
+ VatTaxUtils.GrossAmount gross = VatTaxUtils.solveGross(cumLaborPretax);
- taxedMoneyVO.setAllTax(tax.toString());
- taxedMoneyVO.setAllTaxbeforeMoney(taxationBefore);
- taxedMoneyVO.setAllAaxAfterMoney(sum.toString());
- taxedMoneyVO.setNowTaxBeforeMoney(nowTaxMoney);
- taxedMoneyVO.setNowTax(subtract.toString());
+ // 鏈瑪鍏ㄩ儴鍙栧樊棰濓紝涓� calculateTax 鐨勫垎鎽婂彛寰勪竴鑷�
+ BigDecimal nowPretax = VatTaxUtils.roundMoney(gross.getPretax().subtract(sumPretax));
+ BigDecimal nowLaborPretax = VatTaxUtils.roundMoney(cumLaborPretax.subtract(sumLaborPretax));
+ BigDecimal nowTax = VatTaxUtils.roundMoney(cumTax.subtract(sumTax));
+ if (nowTax.signum() < 0) {
+ nowTax = BigDecimal.ZERO;
+ }
+ if (nowPretax.signum() < 0) {
+ nowPretax = nowLaborPretax.add(gross.getVat().subtract(sumVat)).add(gross.getCityTax().subtract(sumCityTax));
+ }
+
+ taxedMoneyVO.setAllTax(cumTax.toString());
+ taxedMoneyVO.setAllTaxbeforeMoney(gross.getPretax().toString());
+ taxedMoneyVO.setAllAaxAfterMoney(cumTaxed.toString());
+ taxedMoneyVO.setNowTaxBeforeMoney(nowPretax.toString());
+ taxedMoneyVO.setNowTax(nowTax.toString());
return taxedMoneyVO;
}
@@ -375,7 +423,7 @@
detail.setLaborPretaxAmount(p.doubleValue());
detail.setTaxamount(0.0);
detail.setTaxedamount(p.doubleValue());
- detail.setTaxVersion(VatTaxUtils.TAX_VERSION_V2);
+ detail.setTaxVersion(VatTaxUtils.TAX_VERSION_CURRENT);
detail.setTaxTime(taxTime);
updateList.add(detail);
@@ -416,7 +464,7 @@
BigDecimal taxedAmount;
if (afterTax) {
- // 5.2.2 绋庡悗褰曞叆锛氬厛鍙嶇畻鍔冲姟绋庡墠锛屽啀寰幆鍙嶈В绋庡墠/澧炲�肩◣/鍩庡缓绋�
+ // 5.2.2 绋庡悗褰曞叆锛氬厛鐢扁�滅疮璁$◣鍚庘�濆弽绠楃疮璁″姵鍔$◣鍓嶏紝鍐嶅弽瑙g疮璁″惈绋庣◣鍓嶏紝鏈�鍚庢寜宸寰楀嚭鏈瑪 V/C/P
taxedAmount = toMoney(detail.getTaxedamount());
BigDecimal sumTaxed = prevTaxed.add(taxedAmount);
BigDecimal sumLaborPretax = new BigDecimal(TaxtUtils.getTaxationBefore(sumTaxed));
@@ -434,17 +482,47 @@
taxAmount = VatTaxUtils.roundMoney(laborPretax.subtract(taxedAmount));
if (taxAmount.signum() < 0) {
taxAmount = BigDecimal.ZERO;
+ taxedAmount = laborPretax;
}
- VatTaxUtils.GrossAmount gross = VatTaxUtils.solveGross(laborPretax);
- pretax = gross.getPretax();
- vat = gross.getVat();
- cityTax = gross.getCityTax();
+ // 绱鍙e緞锛歅绱� = L绱� + V绱� + C绱紙V绱� 鐨勮捣寰佺偣鎸夌疮璁$◣鍓嶅垽鏂級锛屾湰绗斿彇宸
+ VatTaxUtils.GrossAmount gross = VatTaxUtils.solveGross(sumLaborPretax);
+ pretax = VatTaxUtils.roundMoney(gross.getPretax().subtract(prevAmount));
+ vat = VatTaxUtils.roundMoney(gross.getVat().subtract(prevVat));
+ cityTax = VatTaxUtils.roundMoney(gross.getCityTax().subtract(prevCityTax));
+ if (pretax.signum() < 0) {
+ pretax = laborPretax;
+ }
+ if (vat.signum() < 0) {
+ vat = BigDecimal.ZERO;
+ }
+ if (cityTax.signum() < 0) {
+ cityTax = BigDecimal.ZERO;
+ }
} else {
- // 5.2.3 绋庡墠褰曞叆锛氬厛绠楀鍊肩◣/鍩庡缓绋�/鍔冲姟绋庡墠锛屽啀鎸夌疮璁″姵鍔$◣鍓嶇畻鍔冲姟涓◣
+ // 5.2.3 绋庡墠褰曞叆锛氬厛鎸夌疮璁$◣鍓嶇畻绱澧炲�肩◣/鍩庡缓绋庯紝鍐嶆寜宸寰楁湰绗旓紝鏈�鍚庢寜绱鍔冲姟绋庡墠绠椾釜绋�
pretax = toMoney(detail.getAmount());
- vat = VatTaxUtils.calcVat(pretax);
- cityTax = VatTaxUtils.calcCityTax(vat);
+ BigDecimal cumPretax = prevAmount.add(pretax);
+ BigDecimal cumVat = VatTaxUtils.calcVat(cumPretax);
+ BigDecimal cumCityTax = VatTaxUtils.calcCityTax(cumVat);
+ vat = VatTaxUtils.roundMoney(cumVat.subtract(prevVat));
+ cityTax = VatTaxUtils.roundMoney(cumCityTax.subtract(prevCityTax));
+ if (vat.signum() < 0) {
+ vat = BigDecimal.ZERO;
+ }
+ if (cityTax.signum() < 0) {
+ cityTax = BigDecimal.ZERO;
+ }
laborPretax = VatTaxUtils.roundMoney(pretax.subtract(vat).subtract(cityTax));
+ if (laborPretax.signum() < 0) {
+ // 鏋佺杈圭晫锛氱疮璁″垰璺ㄨ繃璧峰緛鐐广�佹湰绗旈噾棰濆皬浜庤烦鍙橀噺銆�
+ // 鏈瑪涓嶆墸绋庛�佸樊棰濋『寤跺埌鍚庣画绗旓紙绱鍙帹杩涘疄闄呭垎鎽婂�硷紝涓嬩竴绗斿樊鍒嗘椂鑷姩琛ュ洖锛�
+ log.warn("绱璺ㄨ捣寰佺偣瀵艰嚧鏈瑪鍔冲姟绋庡墠涓鸿礋锛屾湰绗斾笉鎵g◣銆佸樊棰濋『寤躲�備汉鍛橈細{}锛屾湰绗旂◣鍓�={}锛屾湰绗斿鍊肩◣={}锛�"
+ + "鏈瑪鍩庡缓绋�={}锛岀疮璁$◣鍓�={}",
+ safeName(detail), pretax, vat, cityTax, cumPretax);
+ vat = BigDecimal.ZERO;
+ cityTax = BigDecimal.ZERO;
+ laborPretax = pretax;
+ }
BigDecimal sumLaborPretax = prevLaborPretax.add(laborPretax);
BigDecimal sumTax = new BigDecimal(TaxtUtils.getTaxation(sumLaborPretax));
taxAmount = VatTaxUtils.roundMoney(sumTax.subtract(prevTax));
@@ -460,7 +538,7 @@
detail.setLaborPretaxAmount(laborPretax.doubleValue());
detail.setTaxamount(taxAmount.doubleValue());
detail.setTaxedamount(taxedAmount.doubleValue());
- detail.setTaxVersion(VatTaxUtils.TAX_VERSION_V2);
+ detail.setTaxVersion(VatTaxUtils.TAX_VERSION_CURRENT);
detail.setTaxTime(taxTime);
updateList.add(detail);
@@ -494,7 +572,7 @@
serviceFund.setLaborPretaxCost(laborPretaxTotal.doubleValue());
serviceFund.setTaxcost(taxTotal.doubleValue());
serviceFund.setTaxedcost(taxedTotal.doubleValue());
- serviceFund.setTaxVersion(VatTaxUtils.TAX_VERSION_V2);
+ serviceFund.setTaxVersion(VatTaxUtils.TAX_VERSION_CURRENT);
serviceFund.setFundtaxtime(taxTime);
serviceFund.setIstax(1);
serviceFundMapper.updateById(serviceFund);
--
Gitblit v1.9.3