From 4cfab31123f2531153972b38196488299e37ba37 Mon Sep 17 00:00:00 2001 From: mzr Date: Tue, 22 Apr 2025 19:19:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8E=A5=E5=8F=A3-=E5=8D=95=E4=BB=B7=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E7=AD=89=E5=AD=97=E6=AE=B5=E5=8F=96=E5=80=BC=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/so/m30/APISaleOrderMaitainImpl.java | 282 ++++++++++++------ 1 file changed, 197 insertions(+), 85 deletions(-) diff --git a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java index 5a6c200..002d34f 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -146,106 +146,108 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { ExceptionUtils.wrappBusinessException( NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0024")/* @res "请先选择交易类型!" */); } - // 1.缓存交易类型VO SaleOrderBVO[] vbos = ordervo.getChildrenVO(); UFDouble sumnum = UFDouble.ZERO_DBL; UFDouble sumnny = UFDouble.ZERO_DBL; - String ybpk = ordervo.getParentVO().getCorigcurrencyid(); for (int i = 0; i < vbos.length; i++) { SaleOrderBVO childrenVO = vbos[i]; - String zbbz = childrenVO.getCcurrencyid(); - childrenVO.setFtaxtypeflag(1); - // 得到税率 - UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(childrenVO.getNtaxrate()); - - // 折本汇率 - UFDouble nexchangerate = childrenVO.getNexchangerate(); - nexchangerate = getUFDouble_NullAsOne(nexchangerate); + UFDouble nexchangerate = getUFDouble_NullAsOne(childrenVO.getNexchangerate()); + childrenVO.setNexchangerate(nexchangerate); + // 处理单价(4位)和金额(2位) // 含税单价 UFDouble nqtorigtaxprice = childrenVO.getNqtorigtaxprice(); + nqtorigtaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtorigtaxprice(nqtorigtaxprice); // 无税单价 - UFDouble nqtorigprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); - // 价税合计 - // UFDouble norigtaxmny=nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()); - UFDouble norigtaxmny = nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()).setScale(2, 4); - childrenVO.setNorigtaxmny(norigtaxmny); - // 无税金额 - UFDouble norigmny = nqtorigprice.multiply(childrenVO.getNqtunitnum()); - - childrenVO.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny)); - // 税额 - childrenVO.setNqtorigprice(nqtorigprice.setScale(4, 4)); - - // 无税本币金额单价 - UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); - - sumnum = sumnum.add(childrenVO.getNastnum()); - sumnny = sumnny.add(childrenVO.getNorigtaxmny()); - - nqtorigprice = nqtorigprice.setScale(4, 4); - // nqtorigtaxnetprc--含税净价 - childrenVO.setNqtorigtaxnetprc(nqtorigtaxprice); - // ,nqtorignetprice --无税净价 - childrenVO.setNqtorignetprice(nqtorigprice); - String Vqtunitrate = childrenVO.getVqtunitrate(); - UFDouble dVqtunitrate = UFDouble.ONE_DBL; - if (Vqtunitrate != null) { - dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]); - } - // ,norigtaxprice --主含税单价 - - UFDouble wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()); - if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(childrenVO.getCqtunitid()) - .equals(BFPubTools.getString_TrimAsNull(childrenVO.getCastunitid()))) { - wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()); - } - - wsje = Currency.getFormaUfValue(zbbz, wsje); + UFDouble nqtorigprice = childrenVO.getNqtorigprice(); + nqtorigprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtorigprice(nqtorigprice); + // 含税净价 + UFDouble nqtorigtaxnetprc = childrenVO.getNqtorigtaxnetprc(); + nqtorigtaxnetprc.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtorigtaxnetprc(nqtorigtaxnetprc); + // 无税净价 + UFDouble nqtorignetprice = childrenVO.getNqtorignetprice(); + nqtorignetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtorignetprice(nqtorignetprice); + // 主含税单价 + UFDouble norigtaxprice = childrenVO.getNorigtaxprice(); + norigtaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNorigtaxprice(norigtaxprice); + // 主无税单价 + UFDouble norigprice = childrenVO.getNorigprice(); + norigprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNorigprice(norigprice); + // 主含税净价 + UFDouble norigtaxnetprice = childrenVO.getNorigtaxnetprice(); + norigtaxnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNorigtaxnetprice(norigtaxnetprice); + // 主无税净价 + UFDouble norignetprice = childrenVO.getNorignetprice(); + norignetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNorignetprice(norignetprice); // 本币无税金额 - childrenVO.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4)); - // ,norigprice --主无税单价 - childrenVO.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4)); - // ,norigtaxnetprice --主含税净价 - childrenVO.setNorigtaxnetprice(childrenVO.getNorigtaxprice()); - // ,norignetprice --主无税净价 - childrenVO.setNorignetprice(childrenVO.getNorigprice()); - // ncaltaxmny --计税金额 + UFDouble nmny = childrenVO.getNmny(); + nmny.setScale(2, UFDouble.ROUND_HALF_UP); + childrenVO.setNmny(nmny); + // 本币价税合计 + UFDouble ntaxmny = childrenVO.getNtaxmny(); + ntaxmny.setScale(2, UFDouble.ROUND_HALF_UP); + childrenVO.setNtaxmny(ntaxmny); + // 税额 + UFDouble ntax = childrenVO.getNtax(); + ntax.setScale(2, UFDouble.ROUND_HALF_UP); + childrenVO.setNtax(ntax); + // 无税金额 + UFDouble norigmny = childrenVO.getNorigmny(); + norigmny.setScale(2, UFDouble.ROUND_HALF_UP); + childrenVO.setNorigmny(norigmny); + // 价税合计 + UFDouble norigtaxmny = childrenVO.getNorigtaxmny(); + norigtaxmny.setScale(2, UFDouble.ROUND_HALF_UP); + childrenVO.setNorigtaxmny(norigtaxmny); + // 本币含税单价 + UFDouble nqttaxprice = childrenVO.getNqttaxprice(); + nqttaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqttaxprice(nqttaxprice); + // 本币无税单价 + UFDouble nqtprice = childrenVO.getNqtprice(); + nqtprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtprice(nqtprice); + // 本币含税净价 + UFDouble nqttaxnetprice = childrenVO.getNqttaxnetprice(); + nqttaxnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqttaxnetprice(nqttaxnetprice); + // 本币无税净价 + UFDouble nqtnetprice = childrenVO.getNqtnetprice(); + nqtnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNqtnetprice(nqtnetprice); + // 主本币含税单价 + UFDouble ntaxprice = childrenVO.getNtaxprice(); + ntaxprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNtaxprice(ntaxprice); + // 主本币无税单价 + UFDouble nprice = childrenVO.getNprice(); + nprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNprice(nprice); + // 主本币含税净价 + UFDouble ntaxnetprice = childrenVO.getNtaxnetprice(); + ntaxnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNtaxnetprice(ntaxnetprice); + // 主本币无税净价 + UFDouble nnetprice = childrenVO.getNnetprice(); + nnetprice.setScale(4, UFDouble.ROUND_HALF_UP); + childrenVO.setNnetprice(nnetprice); + + UFDouble nastnum = childrenVO.getNastnum(); + sumnum = sumnum.add(nastnum); + sumnny = sumnny.add(norigtaxmny); - // ,nqttaxprice --本币含税单价 - childrenVO.setNqttaxprice(nqtorigtaxprice.multiply(nexchangerate)); - // ,nqtprice --本币无税单价 - UFDouble bbwsd = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate); - childrenVO.setNqtprice(bbwsd.setScale(4, 4)); - // , nqttaxnetprice --本币含税净价 - childrenVO.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate)); - // ,nqtnetprice --本币无税净价 - UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate); - childrenVO.setNqtnetprice(Nqtnetprice.setScale(4, 4)); - // ,ntaxprice --主本币含税单价 , nprice --主本币无税单价 - childrenVO.setNtaxprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4)); - UFDouble Nprice = nqtorigtaxprice.div(dVqtunitrate).div(UFDouble.ONE_DBL.add(ntaxrate.div(100))) - .multiply(nexchangerate); - childrenVO.setNprice(Nprice.setScale(4, 4)); - // ,ntaxnetprice --主本币含税净价 - // ,nnetprice --主本币无税净价 - childrenVO.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4)); - UFDouble Nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate); - childrenVO.setNnetprice(Nnetprice.multiply(nexchangerate).setScale(4, 4)); -// ,nmny --本币无税金额 -// ,ntaxmny --本币价税合计 - childrenVO.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate))); - childrenVO.setNtaxmny( - nqtorigtaxprice.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()).setScale(2, 4)); -// childrenVO.setNtaxmny(nqtorigtaxprice.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum())); - childrenVO.setNcaltaxmny(wsje); - UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje); - childrenVO.setNtax(ntax.setScale(2, 4)); } ordervo.getParentVO().setNtotalnum(sumnum); -// ordervo.getParentVO().setNtotalorigmny(sumnny); ordervo.getParentVO().setNtotalorigmny(sumnny.setScale(2, 4)); } @@ -1072,4 +1074,114 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { return new UFDouble(value.toString().trim()); } + public void calculatorPrice1(SaleOrderVO ordervo) throws BusinessException { + + IKeyValue keyValue = new VOKeyValue(ordervo); + + String ctrantypeid = keyValue.getHeadStringValue(SaleOrderHVO.CTRANTYPEID); + if (StringUtil.isEmptyTrimSpace(ctrantypeid)) { + ExceptionUtils.wrappBusinessException( + NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0024")/* @res "请先选择交易类型!" */); + } + // 1.缓存交易类型VO + + SaleOrderBVO[] vbos = ordervo.getChildrenVO(); + UFDouble sumnum = UFDouble.ZERO_DBL; + UFDouble sumnny = UFDouble.ZERO_DBL; + String ybpk = ordervo.getParentVO().getCorigcurrencyid(); + + for (int i = 0; i < vbos.length; i++) { + SaleOrderBVO childrenVO = vbos[i]; + String zbbz = childrenVO.getCcurrencyid(); + + childrenVO.setFtaxtypeflag(1); + // 得到税率 + UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(childrenVO.getNtaxrate()); + + // 折本汇率 + UFDouble nexchangerate = childrenVO.getNexchangerate(); + nexchangerate = getUFDouble_NullAsOne(nexchangerate); + // 含税单价 + UFDouble nqtorigtaxprice = childrenVO.getNqtorigtaxprice(); + // 无税单价 + UFDouble nqtorigprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); + // 价税合计 + // UFDouble norigtaxmny=nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()); + UFDouble norigtaxmny = nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()).setScale(2, 4); + childrenVO.setNorigtaxmny(norigtaxmny); + // 无税金额 + UFDouble norigmny = nqtorigprice.multiply(childrenVO.getNqtunitnum()); + + childrenVO.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny)); + // 税额 + childrenVO.setNqtorigprice(nqtorigprice.setScale(4, 4)); + + // 无税本币金额单价 + UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); + + sumnum = sumnum.add(childrenVO.getNastnum()); + sumnny = sumnny.add(childrenVO.getNorigtaxmny()); + + nqtorigprice = nqtorigprice.setScale(4, 4); + // nqtorigtaxnetprc--含税净价 + childrenVO.setNqtorigtaxnetprc(nqtorigtaxprice); + // nqtorignetprice --无税净价 + childrenVO.setNqtorignetprice(nqtorigprice); + String Vqtunitrate = childrenVO.getVqtunitrate(); + UFDouble dVqtunitrate = UFDouble.ONE_DBL; + if (Vqtunitrate != null) { + dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]); + } + // norigtaxprice --主含税单价 + + UFDouble wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()); + if (ybpk.equals(zbbz) && BFPubTools.getString_TrimAsNull(childrenVO.getCqtunitid()) + .equals(BFPubTools.getString_TrimAsNull(childrenVO.getCastunitid()))) { + wsje = taxspric.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()); + } + + wsje = Currency.getFormaUfValue(zbbz, wsje); + // 本币无税金额 + childrenVO.setNorigtaxprice(nqtorigtaxprice.div(dVqtunitrate).setScale(4, 4)); + // norigprice --主无税单价 + childrenVO.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4)); + // norigtaxnetprice --主含税净价 + childrenVO.setNorigtaxnetprice(childrenVO.getNorigtaxprice()); + // norignetprice --主无税净价 + childrenVO.setNorignetprice(childrenVO.getNorigprice()); + // ncaltaxmny --计税金额 + + // nqttaxprice --本币含税单价 + childrenVO.setNqttaxprice(nqtorigtaxprice.multiply(nexchangerate)); + // nqtprice --本币无税单价 + UFDouble bbwsd = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate); + childrenVO.setNqtprice(bbwsd.setScale(4, 4)); + // nqttaxnetprice --本币含税净价 + childrenVO.setNqttaxnetprice(nqtorigtaxprice.multiply(nexchangerate)); + // nqtnetprice --本币无税净价 + UFDouble Nqtnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).multiply(nexchangerate); + childrenVO.setNqtnetprice(Nqtnetprice.setScale(4, 4)); + // ntaxprice --主本币含税单价 , nprice --主本币无税单价 + childrenVO.setNtaxprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4)); + UFDouble Nprice = nqtorigtaxprice.div(dVqtunitrate).div(UFDouble.ONE_DBL.add(ntaxrate.div(100))) + .multiply(nexchangerate); + childrenVO.setNprice(Nprice.setScale(4, 4)); + // ntaxnetprice --主本币含税净价 + // nnetprice --主本币无税净价 + childrenVO.setNtaxnetprice(nqtorigtaxprice.div(dVqtunitrate).multiply(nexchangerate).setScale(4, 4)); + UFDouble Nnetprice = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))).div(dVqtunitrate); + childrenVO.setNnetprice(Nnetprice.multiply(nexchangerate).setScale(4, 4)); + // nmny --本币无税金额 + childrenVO.setNmny(Currency.getFormaUfValue(zbbz, norigmny.multiply(nexchangerate))); + // ntaxmny--本币价税合计 + childrenVO.setNtaxmny( + nqtorigtaxprice.multiply(nexchangerate).multiply(childrenVO.getNqtunitnum()).setScale(2, 4)); + childrenVO.setNcaltaxmny(wsje); + UFDouble ntax = norigtaxmny.multiply(nexchangerate).sub(wsje); + childrenVO.setNtax(ntax.setScale(2, 4)); + } + ordervo.getParentVO().setNtotalnum(sumnum); + ordervo.getParentVO().setNtotalorigmny(sumnny.setScale(2, 4)); + } + }