采购入库-税码赋值调整单价金额(集团补丁patch_2312_采购入库openapi税码编辑事件处理)及合并其它客开代码
This commit is contained in:
parent
55dce7ab89
commit
7635f3466e
|
|
@ -1,20 +1,17 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.pubimpl.ic.api.fill;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import nc.bs.ic.pub.env.ICBSContext;
|
||||
import nc.vo.ic.m45.entity.PurchaseInVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nc.vo.ic.pub.calc.BusiCalculator;
|
||||
import nc.vo.ic.pub.calc.PriceAndMoneyCalculator;
|
||||
import nc.vo.ic.pub.calc.WeightAndVolumeCalc;
|
||||
import nc.vo.ic.pub.calc.PriceAndMoneyCalculator.MnyCalcType;
|
||||
import nc.vo.ic.pub.define.IBizObject;
|
||||
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.CircularlyAccessibleValueObject;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
|
|
@ -22,102 +19,177 @@ import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
|
|||
import nc.vo.pubapp.scale.ScaleUtils;
|
||||
import nc.vo.scmpub.fill.billfill.IBillValueFill;
|
||||
import nc.vo.scmpub.util.ArrayUtil;
|
||||
import nccloud.dto.scmpub.pub.context.BillCardBodyChangedRow;
|
||||
import nccloud.dto.scmpub.pub.context.BillCardBodyEditEvent;
|
||||
import nccloud.pubimpl.ic.pub.operator.bodyafterrule.CtaxcodeEventRule;
|
||||
|
||||
public class ICPriceAndMoneyCalculateBillFill implements IBillValueFill {
|
||||
public ICPriceAndMoneyCalculateBillFill() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractBill[] fillValue(AbstractBill[] billVOs) throws BusinessException {
|
||||
if (ArrayUtil.isEmpty(billVOs)) {
|
||||
return null;
|
||||
} else {
|
||||
List<CircularlyAccessibleValueObject> numNotNull = new ArrayList();
|
||||
List<CircularlyAccessibleValueObject> numNullButAstNumNotNullbodys = new ArrayList();
|
||||
this.putVO(billVOs, numNotNull, numNullButAstNumNotNullbodys);
|
||||
BusiCalculator cal = BusiCalculator.getBusiCalculatorAtBS();
|
||||
if (numNullButAstNumNotNullbodys.size() > 0) {
|
||||
cal.calcNum((CircularlyAccessibleValueObject[])numNullButAstNumNotNullbodys.toArray(new CircularlyAccessibleValueObject[0]), "nassistnum");
|
||||
numNotNull.addAll(numNullButAstNumNotNullbodys);
|
||||
}
|
||||
}
|
||||
|
||||
if (numNotNull.size() == 0) {
|
||||
return billVOs;
|
||||
// 主数量为空的容器
|
||||
List<CircularlyAccessibleValueObject> numNotNull = new ArrayList<CircularlyAccessibleValueObject>();
|
||||
// 主数量不为空的容器
|
||||
List<CircularlyAccessibleValueObject> numNullButAstNumNotNullbodys = new ArrayList<CircularlyAccessibleValueObject>();
|
||||
putVO(billVOs, numNotNull, numNullButAstNumNotNullbodys);
|
||||
|
||||
BusiCalculator cal = BusiCalculator.getBusiCalculatorAtBS();
|
||||
// 1、对于主数量为空,数量非空的,先计算主数量
|
||||
if (numNullButAstNumNotNullbodys.size() > 0) {
|
||||
cal.calcNum(numNullButAstNumNotNullbodys.toArray(new CircularlyAccessibleValueObject[0]),
|
||||
ICPubMetaNameConst.NASSISTNUM);
|
||||
numNotNull.addAll(numNullButAstNumNotNullbodys);
|
||||
}
|
||||
|
||||
if (numNotNull.size() == 0) {
|
||||
return billVOs;
|
||||
}
|
||||
|
||||
CircularlyAccessibleValueObject[] calVOs = numNotNull.toArray(new CircularlyAccessibleValueObject[0]);
|
||||
// 2、再通过换算率计算辅数量
|
||||
cal.calcNum(calVOs, ICPubMetaNameConst.NNUM);
|
||||
cal.calcShouldAstNum(calVOs, ICPubMetaNameConst.VCHANGERATE);
|
||||
|
||||
// 3、再判断是否为销售出、采购入,如果是,则计算数量+金额
|
||||
if (isNeedCalMny(billVOs)) {
|
||||
// if(billVOs[0].getChildrenVO()[0].getAttributeValue("nqtorigprice") != null){
|
||||
// cal.calcMnyNCC(calVOs, "nqtorigprice");
|
||||
// }
|
||||
cal.calcMny(calVOs, ICPubMetaNameConst.NNUM);
|
||||
}
|
||||
|
||||
// 4、计算金额,如果有单价
|
||||
ScaleUtils scaleUtil = ScaleUtils.getScaleUtilAtBS();
|
||||
ICBSContext context = new ICBSContext();
|
||||
PriceAndMoneyCalculator pcalc = new PriceAndMoneyCalculator(scaleUtil, context.getOrgInfo());
|
||||
for (CircularlyAccessibleValueObject bvo : calVOs) {
|
||||
String pk_finance = context.getOrgInfo()
|
||||
.getFinanceOrgIDByCalBodyID((String) bvo.getAttributeValue(ICPubMetaNameConst.PK_ORG));
|
||||
// 如果数量、单价、金额都有值,就重新计算单价
|
||||
if (bvo.getAttributeValue(ICPubMetaNameConst.NCOSTPRICE) != null
|
||||
&& bvo.getAttributeValue(ICPubMetaNameConst.NCOSTMNY) != null) {
|
||||
pcalc.calcPriceMny((IBizObject) bvo, PriceAndMoneyCalculator.MnyCalcType.Mny, pk_finance);
|
||||
} else {
|
||||
CircularlyAccessibleValueObject[] calVOs = (CircularlyAccessibleValueObject[])numNotNull.toArray(new CircularlyAccessibleValueObject[0]);
|
||||
cal.calcNum(calVOs, "nnum");
|
||||
cal.calcShouldAstNum(calVOs, "vchangerate");
|
||||
if (this.isNeedCalMny(billVOs)) {
|
||||
if (billVOs[0].getChildrenVO()[0].getAttributeValue("nqtorigprice") != null) {
|
||||
cal.calcMnyNCC(calVOs, "nqtorigprice");
|
||||
}
|
||||
|
||||
cal.calcMny(calVOs, "nnum");
|
||||
}
|
||||
|
||||
ScaleUtils scaleUtil = ScaleUtils.getScaleUtilAtBS();
|
||||
ICBSContext context = new ICBSContext();
|
||||
PriceAndMoneyCalculator pcalc = new PriceAndMoneyCalculator(scaleUtil, context.getOrgInfo());
|
||||
|
||||
for(CircularlyAccessibleValueObject bvo : calVOs) {
|
||||
String pk_finance = context.getOrgInfo().getFinanceOrgIDByCalBodyID((String)bvo.getAttributeValue("pk_org"));
|
||||
if (bvo.getAttributeValue("ncostprice") != null && bvo.getAttributeValue("ncostmny") != null) {
|
||||
pcalc.calcPriceMny((IBizObject)bvo, MnyCalcType.Mny, pk_finance);
|
||||
} else {
|
||||
pcalc.calcPriceMny((IBizObject)bvo, MnyCalcType.Num, pk_finance);
|
||||
}
|
||||
}
|
||||
|
||||
WeightAndVolumeCalc wcalc = new WeightAndVolumeCalc(scaleUtil);
|
||||
IBizObject[] calVOObjs = new IBizObject[calVOs.length];
|
||||
|
||||
for(int i = 0; i < calVOObjs.length; ++i) {
|
||||
calVOObjs[i] = (IBizObject)calVOs[i];
|
||||
}
|
||||
|
||||
wcalc.calculator(calVOObjs, context.getInvInfo());
|
||||
return billVOs;
|
||||
// 否则,就按照数量进行触发
|
||||
pcalc.calcPriceMny((IBizObject) bvo, PriceAndMoneyCalculator.MnyCalcType.Num, pk_finance);
|
||||
}
|
||||
if( billVOs[0] instanceof PurchaseInVO) {
|
||||
// 双计量计算逻辑
|
||||
doubleUnitidCal(pcalc, pk_finance, bvo);
|
||||
}
|
||||
}
|
||||
|
||||
// 5、重量和体积计算
|
||||
WeightAndVolumeCalc wcalc = new WeightAndVolumeCalc(scaleUtil);
|
||||
IBizObject[] calVOObjs = new IBizObject[calVOs.length];
|
||||
for (int i = 0; i < calVOObjs.length; i++) {
|
||||
calVOObjs[i] = (IBizObject) calVOs[i];
|
||||
}
|
||||
wcalc.calculator(calVOObjs, context.getInvInfo());
|
||||
if (billVOs[0] instanceof PurchaseInVO) {
|
||||
String ntaxcodeid = (String)((PurchaseInVO[])billVOs)[0].getBodys()[0].getAttributeValue("ctaxcodeid");
|
||||
|
||||
for(PurchaseInVO billVO : (PurchaseInVO[])billVOs) {
|
||||
BillCardBodyChangedRow changeRow = new BillCardBodyChangedRow(ntaxcodeid, (Object)null, (String)null);
|
||||
BillCardBodyEditEvent event = new BillCardBodyEditEvent("ntaxcodeid", -1, new BillCardBodyChangedRow[]{changeRow}, (String)null);
|
||||
(new CtaxcodeEventRule()).afterEdit(billVO, event, new HashMap());
|
||||
}
|
||||
}
|
||||
return billVOs;
|
||||
}
|
||||
|
||||
private void putVO(AbstractBill[] billVOs, List<CircularlyAccessibleValueObject> numNotNull, List<CircularlyAccessibleValueObject> numNullButAstNumNotNullbodys) {
|
||||
for(AbstractBill billVO : billVOs) {
|
||||
/**
|
||||
* zhangxinah 采购入库双计量,价税合计逻辑处理 本币价税合计=辅单价*辅数量,拉单的时候
|
||||
* 只能改辅数量,辅单价不能更改,含税单价=本币价税合计/实收主数量
|
||||
*
|
||||
* @param pk_finance
|
||||
* @param bvo
|
||||
* @throws BusinessException
|
||||
*/
|
||||
private void doubleUnitidCal(PriceAndMoneyCalculator pcalc, String pk_finance, CircularlyAccessibleValueObject bvo)
|
||||
throws BusinessException {
|
||||
BusiCalculator cal = BusiCalculator.getBusiCalculatorAtBS();
|
||||
String castunitid = (String) bvo.getAttributeValue("castunitid");
|
||||
String vbdef34 = (String) bvo.getAttributeValue("vbdef34");
|
||||
// 主辅计量一致则不处理
|
||||
if (castunitid.equals(vbdef34)) {
|
||||
return;
|
||||
}
|
||||
if (bvo.getAttributeValue("vbdef35") == null || bvo.getAttributeValue("vbdef36") == null) {
|
||||
throw new BusinessException("双计量需要填写辅单价vbdef35和辅数量vbdef36!");
|
||||
}
|
||||
UFDouble vbdef35 = new UFDouble(bvo.getAttributeValue("vbdef35").toString());
|
||||
UFDouble vbdef36 = new UFDouble(bvo.getAttributeValue("vbdef36").toString());
|
||||
UFDouble norigtaxmny = vbdef35.multiply(vbdef36).setScale(2, UFDouble.ROUND_HALF_UP);
|
||||
UFDouble nnum = (UFDouble) bvo.getAttributeValue("nnum");
|
||||
UFDouble nqtorigtaxprice = norigtaxmny.div(nnum).setScale(6, UFDouble.ROUND_HALF_UP);
|
||||
bvo.setAttributeValue("norigtaxmny", norigtaxmny);
|
||||
bvo.setAttributeValue("nqtorigtaxprice", nqtorigtaxprice);
|
||||
cal.calcNum(new CircularlyAccessibleValueObject[] { bvo }, "nassistnum");
|
||||
cal.calcMnyNCC(new CircularlyAccessibleValueObject[] { bvo }, "norigtaxmny");
|
||||
pcalc.calcPriceMny((IBizObject) bvo, PriceAndMoneyCalculator.MnyCalcType.Num, pk_finance);
|
||||
|
||||
}
|
||||
|
||||
private void putVO(AbstractBill[] billVOs, List<CircularlyAccessibleValueObject> numNotNull,
|
||||
List<CircularlyAccessibleValueObject> numNullButAstNumNotNullbodys) {
|
||||
for (AbstractBill billVO : billVOs) {
|
||||
CircularlyAccessibleValueObject[] bodyVOs = billVO.getAllChildrenVO();
|
||||
if (!ArrayUtil.isEmpty(billVOs)) {
|
||||
for(CircularlyAccessibleValueObject bodyVO : bodyVOs) {
|
||||
int reuslt = this.getNumStatue(bodyVO);
|
||||
switch (reuslt) {
|
||||
case -1:
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
numNotNull.add(bodyVO);
|
||||
break;
|
||||
case 1:
|
||||
numNullButAstNumNotNullbodys.add(bodyVO);
|
||||
break;
|
||||
case 2:
|
||||
numNotNull.add(bodyVO);
|
||||
}
|
||||
if (ArrayUtil.isEmpty(billVOs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CircularlyAccessibleValueObject bodyVO : bodyVOs) {
|
||||
int reuslt = this.getNumStatue(bodyVO);
|
||||
switch (reuslt) {
|
||||
case -1:
|
||||
continue;
|
||||
case 0:
|
||||
numNotNull.add(bodyVO);
|
||||
break;
|
||||
case 1:
|
||||
numNullButAstNumNotNullbodys.add(bodyVO);
|
||||
break;
|
||||
case 2:
|
||||
numNotNull.add(bodyVO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过判断表体数据,确定是否需要重新计算数量
|
||||
*
|
||||
* @param bodyVO
|
||||
* @return -1:主数量和数量都为空;0:主数量非空,数量空;1:主数量空,数量非空;2:主数量和数量都非空
|
||||
*/
|
||||
private int getNumStatue(CircularlyAccessibleValueObject bodyVO) {
|
||||
UFDouble nnum = (UFDouble)bodyVO.getAttributeValue("nnum");
|
||||
UFDouble nastnum = (UFDouble)bodyVO.getAttributeValue("nassistnum");
|
||||
UFDouble nnum = (UFDouble) bodyVO.getAttributeValue(ICPubMetaNameConst.NNUM);
|
||||
UFDouble nastnum = (UFDouble) bodyVO.getAttributeValue(ICPubMetaNameConst.NASSISTNUM);
|
||||
if (nnum == null && nastnum == null) {
|
||||
return -1;
|
||||
} else if (nnum != null && nastnum == null) {
|
||||
return 0;
|
||||
} else if (nnum == null && nastnum != null) {
|
||||
return 1;
|
||||
} else {
|
||||
return nnum == null && nastnum != null ? 1 : 2;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNeedCalMny(AbstractBill[] billVOs) {
|
||||
return billVOs[0] instanceof SaleOutVO || billVOs[0] instanceof PurchaseInVO;
|
||||
if (billVOs[0] instanceof SaleOutVO || billVOs[0] instanceof PurchaseInVO) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,24 +23,51 @@ public class CtaxcodeEventRule implements IBodyAfterRule<AbstractBill> {
|
|||
}
|
||||
|
||||
public AbstractBill afterEdit(AbstractBill billvo, BillCardBodyEditEvent event, Map userobject) {
|
||||
CircularlyAccessibleValueObject child = billvo.getAllChildrenVO()[event.getRow()];
|
||||
String taxcode = child.getAttributeValue("ctaxcodeid") == null ? null : child.getAttributeValue("ctaxcodeid").toString();
|
||||
if (taxcode == null) {
|
||||
child.setAttributeValue("ntaxrate", (Object)null);
|
||||
child.setAttributeValue("nnosubtaxrate", (Object)null);
|
||||
return billvo;
|
||||
} else {
|
||||
UFDate dbizdate = (UFDate)billvo.getParentVO().getAttributeValue("dbilldate");
|
||||
VATInfoByTaxcodeQueryVO queryvo = new VATInfoByTaxcodeQueryVO(taxcode, dbizdate);
|
||||
VATInfoVO[] vatinfovos = VATBDService.queryVATInfo(new VATInfoByTaxcodeQueryVO[]{queryvo});
|
||||
if (ValueCheckUtil.isNullORZeroLength(vatinfovos)) {
|
||||
return null;
|
||||
} else if (vatinfovos[0] == null) {
|
||||
return null;
|
||||
} else {
|
||||
if (-1 == event.getRow()) {
|
||||
for(CircularlyAccessibleValueObject child : billvo.getAllChildrenVO()) {
|
||||
String taxcode = child.getAttributeValue("ctaxcodeid") == null ? null : child.getAttributeValue("ctaxcodeid").toString();
|
||||
if (taxcode == null) {
|
||||
child.setAttributeValue("ntaxrate", (Object)null);
|
||||
child.setAttributeValue("nnosubtaxrate", (Object)null);
|
||||
return billvo;
|
||||
}
|
||||
|
||||
UFDate dbizdate = (UFDate)billvo.getParentVO().getAttributeValue("dbilldate");
|
||||
VATInfoByTaxcodeQueryVO queryvo = new VATInfoByTaxcodeQueryVO(taxcode, dbizdate);
|
||||
VATInfoVO[] vatinfovos = VATBDService.queryVATInfo(new VATInfoByTaxcodeQueryVO[]{queryvo});
|
||||
if (ValueCheckUtil.isNullORZeroLength(vatinfovos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (vatinfovos[0] == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String chgkey = this.setVatRelaInfoAndGetChgKey(vatinfovos[0], child);
|
||||
this.processtaxmny(new AbstractBill[]{billvo}, chgkey);
|
||||
}
|
||||
|
||||
return billvo;
|
||||
} else {
|
||||
CircularlyAccessibleValueObject child = billvo.getAllChildrenVO()[event.getRow()];
|
||||
String taxcode = child.getAttributeValue("ctaxcodeid") == null ? null : child.getAttributeValue("ctaxcodeid").toString();
|
||||
if (taxcode == null) {
|
||||
child.setAttributeValue("ntaxrate", (Object)null);
|
||||
child.setAttributeValue("nnosubtaxrate", (Object)null);
|
||||
return billvo;
|
||||
} else {
|
||||
UFDate dbizdate = (UFDate)billvo.getParentVO().getAttributeValue("dbilldate");
|
||||
VATInfoByTaxcodeQueryVO queryvo = new VATInfoByTaxcodeQueryVO(taxcode, dbizdate);
|
||||
VATInfoVO[] vatinfovos = VATBDService.queryVATInfo(new VATInfoByTaxcodeQueryVO[]{queryvo});
|
||||
if (ValueCheckUtil.isNullORZeroLength(vatinfovos)) {
|
||||
return null;
|
||||
} else if (vatinfovos[0] == null) {
|
||||
return null;
|
||||
} else {
|
||||
String chgkey = this.setVatRelaInfoAndGetChgKey(vatinfovos[0], child);
|
||||
this.processtaxmny(new AbstractBill[]{billvo}, chgkey);
|
||||
return billvo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public class ICNtaxrateFillRule<E extends ICBillVO> extends ICRule<E> {
|
|||
for(ISuperVO body : bodys) {
|
||||
body.setAttributeValue("ftaxtypeflag", EnumDiscounttaxtypeConst.TAXOUT.getValue());
|
||||
body.setAttributeValue("nitemdiscountrate", new UFDouble(100));
|
||||
body.setAttributeValue("bopptaxflag", "N");
|
||||
if (body.getAttributeValue("ctaxcodeid") != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
body.setAttributeValue("ctaxcodeid", ZeroTaxCodeEnum.ZEROTAXCODE.getCode());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue