From 938f0fbc1c4d608bd361e4f879432b71268da67b Mon Sep 17 00:00:00 2001 From: mzr Date: Sun, 4 May 2025 14:27:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=80=E5=94=AE=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E6=8E=A5=E5=8F=A3=E7=B2=BE=E5=BA=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operator/IAPISaleInvMaitainImpl.java | 92 ++++++++----------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java b/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java index 1eb8408..c1144bb 100644 --- a/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java +++ b/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java @@ -328,62 +328,48 @@ public class IAPISaleInvMaitainImpl { BigDecimal nexchangerate = getUFDouble_NullAsZero(value2.get("nexchangerate")).toBigDecimal(); otherJson.put("nexchangerate", nexchangerate); - // 输入参数:从你的 item 获取各个字段 - /*BigDecimal nastnum = new BigDecimal(item.getString("nnum")); // 数量 - nastnum = nastnum.setScale(4, RoundingMode.HALF_UP); - BigDecimal nqtorigtaxprice = new BigDecimal(item.getString("nqtorigtaxprice")); // 含税单价 - nqtorigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); - BigDecimal ntaxrate = new BigDecimal(item.getString("ntaxrate")).divide(new BigDecimal("100")); // 税率 - ntaxrate = ntaxrate.setScale(4, RoundingMode.HALF_UP); - - // 含税净价 - BigDecimal norigtaxnetprice = nqtorigtaxprice; - // 1. 计算价税合计(含税金额) - BigDecimal norigtaxmny = nastnum.multiply(norigtaxnetprice).setScale(2, RoundingMode.HALF_UP); - // 2. 计算折扣额 - BigDecimal discountAmount = nastnum.multiply(nqtorigtaxprice).subtract(norigtaxmny).setScale(4, - RoundingMode.HALF_UP); - // 3. 计算税额(两种方法:应税外加税和应税内含税) - BigDecimal ntax = norigtaxmny.multiply(ntaxrate).divide(BigDecimal.ONE.add(ntaxrate), 2, - RoundingMode.HALF_UP); // 应税外加税 - BigDecimal taxInclusiveInner = norigtaxmny.multiply(ntaxrate).setScale(4, RoundingMode.HALF_UP); // 应税内含税 - // 4. 计算无税金额 - BigDecimal norigmny = norigtaxmny.subtract(ntax).setScale(2, RoundingMode.HALF_UP); - // 4. 计算无税单价(nqtorigprice = 无税金额 / 数量) - BigDecimal nqtorigprice = norigmny.divide(nastnum, 4, RoundingMode.HALF_UP); - // 计税金额 = 无税金额 - BigDecimal ncaltaxmny = norigmny; - // 主含税单价(即含税单价) - BigDecimal norigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); - // 主无税净价(即不含税单价) - BigDecimal norignetprice = nqtorigprice; - - // 本币(人民币)需要处理汇率,金额保留两位小数,单价保留4位小数 - // 本币无税金额 - BigDecimal nmny = norigmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); - // 主本币无税净价 - BigDecimal nnetprice = norignetprice.multiply(nexchangerate).setScale(4, RoundingMode.HALF_UP); - // 本币价税合计 价税合计*汇率 - BigDecimal ntaxmny = norigtaxmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); - // 税额 - ntax = ntaxmny.subtract(nmny).setScale(2, RoundingMode.HALF_UP);*/ - + // 处理精度:数量(2)、单价(4位)和金额(2位) UFDouble nnum = new UFDouble(item.getString("nnum"));// 主数量 + nnum = nnum.setScale(2, UFDouble.ROUND_HALF_UP); + UFDouble nqtorigprice = new UFDouble(item.getString("nqtorigprice"));// 无税单价 + nqtorigprice = nqtorigprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble norigprice = new UFDouble(item.getString("norigprice"));// 主无税单价 + norigprice = norigprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble norigmny = new UFDouble(item.getString("norigmny"));// 本币无税金额 + norigmny = norigmny.setScale(2, UFDouble.ROUND_HALF_UP); + UFDouble nmny = new UFDouble(item.getString("nmny"));// 本币无税金额 + nmny = nmny.setScale(2, UFDouble.ROUND_HALF_UP); + UFDouble norigtaxmny = new UFDouble(item.getString("norigtaxmny"));// 价税合计 + norigtaxmny = norigtaxmny.setScale(2, UFDouble.ROUND_HALF_UP); + UFDouble norigtaxprice = new UFDouble(item.getString("norigtaxprice"));// 主含税单价 + norigtaxprice = norigtaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble norignetprice = new UFDouble(item.getString("norignetprice"));// 主无税净价 + norignetprice = norignetprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble nqtorigtaxprice = new UFDouble(item.getString("nqtorigtaxprice"));// 含税单价 + nqtorigtaxprice = nqtorigtaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble ntax = new UFDouble(item.getString("ntax"));// 税额 + ntax = ntax.setScale(2, UFDouble.ROUND_HALF_UP); + UFDouble norigtaxnetprice = new UFDouble(item.getString("norigtaxnetprice"));// 主含税净价 + norigtaxnetprice = norigtaxnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble nnetprice = new UFDouble(item.getString("nnetprice"));// 主本币无税净价 + nnetprice = nnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + UFDouble ntaxmny = new UFDouble(item.getString("ntaxmny"));// 本币价税合计 + ntaxmny = ntaxmny.setScale(2, UFDouble.ROUND_HALF_UP); itemDetails.put("nastnum", nnum);// 数量 - // itemDetails.put("nqtorigprice", nqtorigprice);// 无税单价 - // itemDetails.put("norigprice", nqtorigprice);// 主无税单价 - // itemDetails.put("norigmny", norigmny);// 无税金额 - // itemDetails.put("nmny", nmny);// 本币无税金额 - // itemDetails.put("norigtaxmny", norigtaxmny);// 价税合计 - // itemDetails.put("norigtaxprice", norigtaxprice);// 主含税单价 - // itemDetails.put("norignetprice", norignetprice);// 主无税净价 - // itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);// 含税单价 - // itemDetails.put("ntax", ntax);// 税额 - itemDetails.put("ncaltaxmny", new UFDouble(item.getString("nmny")));// 计税金额 - // itemDetails.put("norigtaxnetprice", norigtaxnetprice);// 主含税净价 - // itemDetails.put("nnetprice", nnetprice);// 主本币无税净价 - // itemDetails.put("ntaxmny", ntaxmny);// 本币价税合计 + itemDetails.put("nqtorigprice", nqtorigprice);// 无税单价 + itemDetails.put("norigprice", norigprice);// 主无税单价 + itemDetails.put("norigmny", norigmny);// 无税金额 + itemDetails.put("nmny", nmny);// 本币无税金额 + itemDetails.put("norigtaxmny", norigtaxmny);// 价税合计 + itemDetails.put("norigtaxprice", norigtaxprice);// 主含税单价 + itemDetails.put("norignetprice", norignetprice);// 主无税净价 + itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);// 含税单价 + itemDetails.put("ntax", ntax);// 税额 + itemDetails.put("ncaltaxmny", nmny);// 计税金额 + itemDetails.put("norigtaxnetprice", norigtaxnetprice);// 主含税净价 + itemDetails.put("nnetprice", nnetprice);// 主本币无税净价 + itemDetails.put("ntaxmny", ntaxmny);// 本币价税合计 csaleinvoicebid.add(itemDetails); }