diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java b/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java index 509a3bd..6b19776 100644 --- a/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java +++ b/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java @@ -278,6 +278,13 @@ public class saveCommitAction extends AbstractNCCRestResource { // // 主含税净价 = 含税单价(原始) // BigDecimal norigtaxnetprice = norigtaxprice; + // 从销售订单中获取币种 + String currencycode = getString_TrimAsNull(value2.get("currencycode")); + otherJson.put("corigcurrencyid", currencycode.isEmpty() ? "CNY" : currencycode); + // 从销售订单中获取折本汇率 + BigDecimal nexchangerate = getUFDouble_NullAsZero(value2.get("nexchangerate")).toBigDecimal(); + otherJson.put("nexchangerate", nexchangerate); + // 输入参数:从你的 item 获取各个字段 BigDecimal nastnum = new BigDecimal(item.getString("nastnum")); // 数量 nastnum = nastnum.setScale(4, RoundingMode.HALF_UP); @@ -309,26 +316,20 @@ public class saveCommitAction extends AbstractNCCRestResource { // 主无税净价(即不含税单价) BigDecimal norignetprice = nqtorigprice; - // 从销售订单中获取币种 - String corigcurrencyid = getString_TrimAsNull(value2.get("corigcurrencyid")); - otherJson.put("corigcurrencyid", "".equals(corigcurrencyid) ? "CNY" : corigcurrencyid); - // 从销售订单中获取折本汇率 - BigDecimal nexchangerate = getUFDouble_NullAsZero(value2.get("nexchangerate")).toBigDecimal(); - otherJson.put("nexchangerate", nexchangerate); - // 单价和金额*汇率 - nqtorigprice = nqtorigprice.multiply(nexchangerate); - norigmny = norigmny.multiply(nexchangerate); - norigtaxmny = norigtaxmny.multiply(nexchangerate); - norigtaxprice = norigtaxprice.multiply(nexchangerate); - norignetprice = norignetprice.multiply(nexchangerate); - nqtorigtaxprice = nqtorigtaxprice.multiply(nexchangerate); - norigtaxnetprice = norigtaxnetprice.multiply(nexchangerate); - + // 本币(人民币)需要处理汇率,金额保留两位小数,单价保留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); itemDetails.put("nqtorigprice", nqtorigprice);//无税单价 itemDetails.put("norigprice", nqtorigprice);//主无税单价 itemDetails.put("norigmny", norigmny);//无税金额 - itemDetails.put("nmny", norigmny);//本币无税金额 + itemDetails.put("nmny", nmny);//本币无税金额 itemDetails.put("norigtaxmny", norigtaxmny);//价税合计 itemDetails.put("norigtaxprice", norigtaxprice);//主含税单价 itemDetails.put("norignetprice", norignetprice);//主无税净价 @@ -336,8 +337,8 @@ public class saveCommitAction extends AbstractNCCRestResource { itemDetails.put("ntax", ntax);//税额 itemDetails.put("ncaltaxmny", ncaltaxmny);//计税金额 itemDetails.put("norigtaxnetprice", norigtaxnetprice);//主含税净价 - itemDetails.put("nnetprice", norignetprice);//主本币无税净价 - itemDetails.put("ntaxmny", norigtaxmny);//本币价税合计 + itemDetails.put("nnetprice", nnetprice);//主本币无税净价 + itemDetails.put("ntaxmny", ntaxmny);//本币价税合计 csaleinvoicebid.add(itemDetails);