销售订单保存接口-单价金额等字段取值调整

This commit is contained in:
mzr 2025-04-22 19:19:06 +08:00
parent cbeb3380b2
commit 4cfab31123
1 changed files with 197 additions and 85 deletions

View File

@ -146,106 +146,108 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
ExceptionUtils.wrappBusinessException( ExceptionUtils.wrappBusinessException(
NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0024")/* @res "请先选择交易类型!" */); NCLangRes4VoTransl.getNCLangRes().getStrByID("4006013_0", "04006013-0024")/* @res "请先选择交易类型!" */);
} }
// 1.缓存交易类型VO
SaleOrderBVO[] vbos = ordervo.getChildrenVO(); SaleOrderBVO[] vbos = ordervo.getChildrenVO();
UFDouble sumnum = UFDouble.ZERO_DBL; UFDouble sumnum = UFDouble.ZERO_DBL;
UFDouble sumnny = UFDouble.ZERO_DBL; UFDouble sumnny = UFDouble.ZERO_DBL;
String ybpk = ordervo.getParentVO().getCorigcurrencyid();
for (int i = 0; i < vbos.length; i++) { for (int i = 0; i < vbos.length; i++) {
SaleOrderBVO childrenVO = vbos[i]; SaleOrderBVO childrenVO = vbos[i];
String zbbz = childrenVO.getCcurrencyid();
childrenVO.setFtaxtypeflag(1); childrenVO.setFtaxtypeflag(1);
// 得到税率 UFDouble nexchangerate = getUFDouble_NullAsOne(childrenVO.getNexchangerate());
UFDouble ntaxrate = BFPubTools.getUFDouble_NullAsZero(childrenVO.getNtaxrate()); childrenVO.setNexchangerate(nexchangerate);
// 处理单价(4位)和金额(2位)
// 折本汇率
UFDouble nexchangerate = childrenVO.getNexchangerate();
nexchangerate = getUFDouble_NullAsOne(nexchangerate);
// 含税单价 // 含税单价
UFDouble nqtorigtaxprice = childrenVO.getNqtorigtaxprice(); 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 nqtorigprice = childrenVO.getNqtorigprice();
// 价税合计 nqtorigprice.setScale(4, UFDouble.ROUND_HALF_UP);
// UFDouble norigtaxmny=nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()); childrenVO.setNqtorigprice(nqtorigprice);
UFDouble norigtaxmny = nqtorigtaxprice.multiply(childrenVO.getNqtunitnum()).setScale(2, 4); // 含税净价
childrenVO.setNorigtaxmny(norigtaxmny); UFDouble nqtorigtaxnetprc = childrenVO.getNqtorigtaxnetprc();
// 无税金额 nqtorigtaxnetprc.setScale(4, UFDouble.ROUND_HALF_UP);
UFDouble norigmny = nqtorigprice.multiply(childrenVO.getNqtunitnum()); childrenVO.setNqtorigtaxnetprc(nqtorigtaxnetprc);
// 无税净价
childrenVO.setNorigmny(Currency.getFormaUfValue(ybpk, norigmny)); UFDouble nqtorignetprice = childrenVO.getNqtorignetprice();
// 税额 nqtorignetprice.setScale(4, UFDouble.ROUND_HALF_UP);
childrenVO.setNqtorigprice(nqtorigprice.setScale(4, 4)); childrenVO.setNqtorignetprice(nqtorignetprice);
// 主含税单价
// 无税本币金额单价 UFDouble norigtaxprice = childrenVO.getNorigtaxprice();
UFDouble taxspric = nqtorigtaxprice.div(UFDouble.ONE_DBL.add(ntaxrate.div(100))); norigtaxprice.setScale(4, UFDouble.ROUND_HALF_UP);
childrenVO.setNorigtaxprice(norigtaxprice);
sumnum = sumnum.add(childrenVO.getNastnum()); // 主无税单价
sumnny = sumnny.add(childrenVO.getNorigtaxmny()); UFDouble norigprice = childrenVO.getNorigprice();
norigprice.setScale(4, UFDouble.ROUND_HALF_UP);
nqtorigprice = nqtorigprice.setScale(4, 4); childrenVO.setNorigprice(norigprice);
// nqtorigtaxnetprc--含税净价 // 主含税净价
childrenVO.setNqtorigtaxnetprc(nqtorigtaxprice); UFDouble norigtaxnetprice = childrenVO.getNorigtaxnetprice();
// ,nqtorignetprice --无税净价 norigtaxnetprice.setScale(4, UFDouble.ROUND_HALF_UP);
childrenVO.setNqtorignetprice(nqtorigprice); childrenVO.setNorigtaxnetprice(norigtaxnetprice);
String Vqtunitrate = childrenVO.getVqtunitrate(); // 主无税净价
UFDouble dVqtunitrate = UFDouble.ONE_DBL; UFDouble norignetprice = childrenVO.getNorignetprice();
if (Vqtunitrate != null) { norignetprice.setScale(4, UFDouble.ROUND_HALF_UP);
dVqtunitrate = BFPubTools.getUFDouble_NullAsZero(Vqtunitrate.split("/")[0]); childrenVO.setNorignetprice(norignetprice);
}
// ,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)); UFDouble nmny = childrenVO.getNmny();
// ,norigprice --主无税单价 nmny.setScale(2, UFDouble.ROUND_HALF_UP);
childrenVO.setNorigprice(nqtorigprice.div(dVqtunitrate).setScale(4, 4)); childrenVO.setNmny(nmny);
// ,norigtaxnetprice --主含税净价 // 本币价税合计
childrenVO.setNorigtaxnetprice(childrenVO.getNorigtaxprice()); UFDouble ntaxmny = childrenVO.getNtaxmny();
// ,norignetprice --主无税净价 ntaxmny.setScale(2, UFDouble.ROUND_HALF_UP);
childrenVO.setNorignetprice(childrenVO.getNorigprice()); childrenVO.setNtaxmny(ntaxmny);
// ncaltaxmny --计税金额 // 税额
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().setNtotalnum(sumnum);
// ordervo.getParentVO().setNtotalorigmny(sumnny);
ordervo.getParentVO().setNtotalorigmny(sumnny.setScale(2, 4)); ordervo.getParentVO().setNtotalorigmny(sumnny.setScale(2, 4));
} }
@ -1072,4 +1074,114 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
return new UFDouble(value.toString().trim()); return new UFDouble(value.toString().trim());
} }
public void calculatorPrice1(SaleOrderVO ordervo) throws BusinessException {
IKeyValue keyValue = new VOKeyValue<SaleOrderVO>(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));
}
} }