|  | @@ -0,0 +1,328 @@
 | 
	
		
			
				|  |  | +package nc.bs.arap.plugin;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import nc.bs.arap.bill.ArapBillPubUtil;
 | 
	
		
			
				|  |  | +import nc.itf.arap.fieldmap.IBillFieldGet;
 | 
	
		
			
				|  |  | +import nc.itf.fi.pub.Currency;
 | 
	
		
			
				|  |  | +import nc.itf.fi.pub.SysInit;
 | 
	
		
			
				|  |  | +import nc.pubitf.uapbd.CurrencyRateUtil;
 | 
	
		
			
				|  |  | +import nc.vo.arap.basebill.BaseAggVO;
 | 
	
		
			
				|  |  | +import nc.vo.arap.basebill.BaseBillVO;
 | 
	
		
			
				|  |  | +import nc.vo.arap.basebill.BaseItemVO;
 | 
	
		
			
				|  |  | +import nc.vo.arap.pay.PayBillItemVO;
 | 
	
		
			
				|  |  | +import nc.vo.arap.pay.PayBillVO;
 | 
	
		
			
				|  |  | +import nc.vo.arap.pub.BillEnumCollection;
 | 
	
		
			
				|  |  | +import nc.vo.arap.sysinit.SysinitConst;
 | 
	
		
			
				|  |  | +import nc.vo.bd.currinfo.CurrinfoVO;
 | 
	
		
			
				|  |  | +import nc.vo.fipub.exception.ExceptionHandler;
 | 
	
		
			
				|  |  | +import nc.vo.pub.BusinessException;
 | 
	
		
			
				|  |  | +import nc.vo.pub.lang.UFBoolean;
 | 
	
		
			
				|  |  | +import nc.vo.pub.lang.UFDate;
 | 
	
		
			
				|  |  | +import nc.vo.pub.lang.UFDouble;
 | 
	
		
			
				|  |  | +import nc.vo.pubapp.pattern.exception.ExceptionUtils;
 | 
	
		
			
				|  |  | +import nc.vo.pubapp.pattern.pub.MathTool;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +public class ArapExpPfxxValidater {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private final static ArapExpPfxxValidater instance = new ArapExpPfxxValidater();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public static ArapExpPfxxValidater getInstance() {
 | 
	
		
			
				|  |  | +		return instance;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public void validate(BaseAggVO vo) {
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			this.checkLocalRate(vo);// 本币汇率 以及 计算本币
 | 
	
		
			
				|  |  | +			this.checkTax(vo);// 税率+ 税金=金额
 | 
	
		
			
				|  |  | +			this.checkBalMny(vo);// 设置单据余额与占用金额
 | 
	
		
			
				|  |  | +			this.checkSumMny(vo);// 校验表头金额合计
 | 
	
		
			
				|  |  | +			this.checkGroupGlobal(vo); //校验集团本币和全局本币启用
 | 
	
		
			
				|  |  | +			this.checkLocalRange(vo); //校验组织本币误差范围
 | 
	
		
			
				|  |  | +		} catch (BusinessException e) {
 | 
	
		
			
				|  |  | +			ExceptionUtils.wrappException(e);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkGroupGlobal(BaseAggVO vo) throws BusinessException {
 | 
	
		
			
				|  |  | +		BaseItemVO[] items = vo.getItems();
 | 
	
		
			
				|  |  | +		BaseBillVO headVO = vo.getHeadVO();
 | 
	
		
			
				|  |  | +		String pk_group=headVO.getPk_group();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			String NC002 = SysInit.getParaString(IBillFieldGet.PK_GLOBAL, "NC002");
 | 
	
		
			
				|  |  | +			String NC001 = SysInit.getParaString(pk_group, "NC001");
 | 
	
		
			
				|  |  | +			for(BaseItemVO item:items){
 | 
	
		
			
				|  |  | +				if(NC001.equals(SysinitConst.NC001_NOT_USED)){
 | 
	
		
			
				|  |  | +					item.setGrouprate(null);
 | 
	
		
			
				|  |  | +					item.setGroupdebit(null);
 | 
	
		
			
				|  |  | +					item.setGroupcrebit(null);
 | 
	
		
			
				|  |  | +//					UFDouble grouprate = item.getGrouprate();
 | 
	
		
			
				|  |  | +//					UFDouble groupmoney=null;
 | 
	
		
			
				|  |  | +//					if (headVO.getBillclass().equals(IBillFieldGet.YS) || headVO.getBillclass().equals(IBillFieldGet.FK) || headVO.getBillclass().equals(IBillFieldGet.ZS)) {
 | 
	
		
			
				|  |  | +//						groupmoney=item.getGroupdebit();
 | 
	
		
			
				|  |  | +//					} else {
 | 
	
		
			
				|  |  | +//						groupmoney=item.getGroupcrebit();
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					if(grouprate!=null && grouprate.compareTo(UFDouble.ZERO_DBL)!=0){
 | 
	
		
			
				|  |  | +//						throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub0322_0","02006pub0322-0020")/*@res "未启用集团本位币,集团汇率不能赋值,保存失败!"*/);
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					if(groupmoney!=null && groupmoney.compareTo(UFDouble.ZERO_DBL)!=0){
 | 
	
		
			
				|  |  | +//						throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub0322_0","02006pub0322-0021")/*@res "未启用集团本位币,集团本币不能赋值,保存失败!"*/);
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(NC002.equals(SysinitConst.NC002_NOT_USED)){
 | 
	
		
			
				|  |  | +					item.setGlobalrate(null);
 | 
	
		
			
				|  |  | +					item.setGlobaldebit(null);
 | 
	
		
			
				|  |  | +					item.setGlobalcrebit(null);
 | 
	
		
			
				|  |  | +//					UFDouble globalrate = item.getGlobalrate();
 | 
	
		
			
				|  |  | +//					UFDouble globalmoney=null;
 | 
	
		
			
				|  |  | +//					if (headVO.getBillclass().equals(IBillFieldGet.YS) || headVO.getBillclass().equals(IBillFieldGet.FK) || headVO.getBillclass().equals(IBillFieldGet.ZS)) {
 | 
	
		
			
				|  |  | +//						globalmoney=item.getGlobaldebit();
 | 
	
		
			
				|  |  | +//					} else {
 | 
	
		
			
				|  |  | +//						globalmoney=item.getGlobalcrebit();
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					if(globalrate!=null && globalrate.compareTo(UFDouble.ZERO_DBL)!=0){
 | 
	
		
			
				|  |  | +//						throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub0322_0","02006pub0322-0022")/*@res "未启用全局本位币,全局汇率不能赋值,保存失败!"*/);
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					if(globalmoney!=null && globalmoney.compareTo(UFDouble.ZERO_DBL)!=0){
 | 
	
		
			
				|  |  | +//						throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub0322_0","02006pub0322-0023")/*@res "未启用全局本位币,全局本币不能赋值,保存失败!"*/);
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} catch (BusinessException e) {
 | 
	
		
			
				|  |  | +			ExceptionHandler.handleException(e);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkLocalRange(BaseAggVO vo) throws BusinessException {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		BaseItemVO[] items = vo.getItems();
 | 
	
		
			
				|  |  | +		BaseBillVO headVO = vo.getHeadVO();
 | 
	
		
			
				|  |  | +		for(BaseItemVO item:items){
 | 
	
		
			
				|  |  | +			String currType = item.getPk_currtype();
 | 
	
		
			
				|  |  | +			// 组织PK
 | 
	
		
			
				|  |  | +			String pk_org = headVO.getPk_org();
 | 
	
		
			
				|  |  | +			// 组织本币
 | 
	
		
			
				|  |  | +			String destCurrType = null;
 | 
	
		
			
				|  |  | +			try {
 | 
	
		
			
				|  |  | +				destCurrType = Currency.getLocalCurrPK(pk_org);
 | 
	
		
			
				|  |  | +			} catch (BusinessException e2) {
 | 
	
		
			
				|  |  | +				ExceptionUtils.wrappException(e2);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (currType.equals(destCurrType))
 | 
	
		
			
				|  |  | +//				return;
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +			try {
 | 
	
		
			
				|  |  | +				CurrencyRateUtil rateUtil = nc.pubitf.uapbd.CurrencyRateUtil.getInstanceByOrg(pk_org);
 | 
	
		
			
				|  |  | +				if (null == rateUtil) {// 获取默认的汇率方案
 | 
	
		
			
				|  |  | +					String schemePK = nc.pubitf.uapbd.CurrencyRateUtil.getDefaultExchangeSchemePk();
 | 
	
		
			
				|  |  | +					// 根据外币汇率方案获取实例
 | 
	
		
			
				|  |  | +					rateUtil = nc.pubitf.uapbd.CurrencyRateUtil.getInstanceByExrateScheme(schemePK);
 | 
	
		
			
				|  |  | +					// 根据源币种主键,目的币种主键,查询指定日期的汇率
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				UFDouble outrate = item.getRate();
 | 
	
		
			
				|  |  | +				CurrinfoVO currinfo = rateUtil.getCurrinfoVO(currType, destCurrType);
 | 
	
		
			
				|  |  | +				if (null == currinfo)
 | 
	
		
			
				|  |  | +					return ;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				UFDouble money = UFDouble.ZERO_DBL;
 | 
	
		
			
				|  |  | +				UFDouble localMoney = UFDouble.ZERO_DBL;
 | 
	
		
			
				|  |  | +				if (headVO.getBillclass().equals(IBillFieldGet.YS) || headVO.getBillclass().equals(IBillFieldGet.FK) || headVO.getBillclass().equals(IBillFieldGet.ZS)) {
 | 
	
		
			
				|  |  | +					money=item.getMoney_de();
 | 
	
		
			
				|  |  | +					localMoney = item.getLocal_money_de();
 | 
	
		
			
				|  |  | +				} else {
 | 
	
		
			
				|  |  | +					money=item.getMoney_cr();
 | 
	
		
			
				|  |  | +					localMoney = item.getLocal_money_cr();
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if (null == money) {
 | 
	
		
			
				|  |  | +					return ;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				UFDouble amountByOpp = Currency.getAmountByOpp(pk_org, currType, destCurrType, money, outrate, headVO.getBilldate());
 | 
	
		
			
				|  |  | +				if (((amountByOpp).sub(localMoney).abs().compareTo(currinfo.getMaxconverr()) > 0)) {
 | 
	
		
			
				|  |  | +					throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub0322_0","02006pub0322-0024")/*@res "本币变动超过最大折算误差,不能保存!"*/);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}catch(Exception e){
 | 
	
		
			
				|  |  | +				ExceptionHandler.handleException(e);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkSumMny(BaseAggVO vo) throws BusinessException {
 | 
	
		
			
				|  |  | +		if (vo.getHeadVO().getBillclass().equals(IBillFieldGet.YS) || vo.getHeadVO().getBillclass().equals(IBillFieldGet.FK) || vo.getHeadVO().getBillclass().equals(IBillFieldGet.ZS)) {
 | 
	
		
			
				|  |  | +			UFDouble money = ArapBillPubUtil.sumB(IBillFieldGet.MONEY_DE, vo.getItems());
 | 
	
		
			
				|  |  | +			UFDouble sum = vo.getHeadVO().getMoney();
 | 
	
		
			
				|  |  | +			if (sum.compareTo(money) != 0) {
 | 
	
		
			
				|  |  | +				throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0018")/*@res "原币金额合计错误!"*/);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			UFDouble local_money = ArapBillPubUtil.sumB(IBillFieldGet.LOCAL_MONEY_DE, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setLocal_money(local_money);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UFDouble group_money = ArapBillPubUtil.sumB(IBillFieldGet.GROUPDEBIT, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setGrouplocal(group_money);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UFDouble global_money = ArapBillPubUtil.sumB(IBillFieldGet.GLOBALDEBIT, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setGloballocal(global_money);
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UFDouble money = ArapBillPubUtil.sumB(IBillFieldGet.MONEY_CR, vo.getItems());
 | 
	
		
			
				|  |  | +			UFDouble sum = vo.getHeadVO().getMoney();
 | 
	
		
			
				|  |  | +			if (sum.compareTo(money) != 0) {
 | 
	
		
			
				|  |  | +				throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0018")/*@res "原币金额合计错误!"*/);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			UFDouble local_money = ArapBillPubUtil.sumB(IBillFieldGet.LOCAL_MONEY_CR, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setLocal_money(local_money);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UFDouble group_money = ArapBillPubUtil.sumB(IBillFieldGet.GROUPCREBIT, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setGrouplocal(group_money);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UFDouble global_money = ArapBillPubUtil.sumB(IBillFieldGet.GLOBALCREBIT, vo.getItems());
 | 
	
		
			
				|  |  | +			vo.getHeadVO().setGloballocal(global_money);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkBalMny(BaseAggVO vo) {
 | 
	
		
			
				|  |  | +		for (BaseItemVO item : vo.getItems()) {
 | 
	
		
			
				|  |  | +			if (vo.getHeadVO().getBillclass().equals(IBillFieldGet.YS) || vo.getHeadVO().getBillclass().equals(IBillFieldGet.FK) || vo.getHeadVO().getBillclass().equals(IBillFieldGet.ZS)) {
 | 
	
		
			
				|  |  | +				item.setMoney_bal(item.getMoney_de());
 | 
	
		
			
				|  |  | +				item.setLocal_money_bal(item.getLocal_money_de());
 | 
	
		
			
				|  |  | +				item.setGroupbalance(item.getGroupdebit());
 | 
	
		
			
				|  |  | +				item.setGlobalbalance(item.getGlobaldebit());
 | 
	
		
			
				|  |  | +				item.setOccupationmny(item.getMoney_bal());
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				item.setMoney_bal(item.getMoney_cr());
 | 
	
		
			
				|  |  | +				item.setLocal_money_bal(item.getLocal_money_cr());
 | 
	
		
			
				|  |  | +				item.setGroupbalance(item.getGroupcrebit());
 | 
	
		
			
				|  |  | +				item.setGlobalbalance(item.getGlobalcrebit());
 | 
	
		
			
				|  |  | +				item.setOccupationmny(item.getMoney_bal());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkTax(BaseAggVO vo) throws BusinessException {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		for (BaseItemVO item : vo.getItems()) {
 | 
	
		
			
				|  |  | +			String billclass = vo.getHeadVO().getBillclass();
 | 
	
		
			
				|  |  | +			if(IBillFieldGet.YS.equals(billclass)||IBillFieldGet.YF.equals(billclass)||
 | 
	
		
			
				|  |  | +					IBillFieldGet.ZS.equals(billclass)||IBillFieldGet.ZF.equals(billclass)	){
 | 
	
		
			
				|  |  | +				if(null ==item.getBuysellflag() ){
 | 
	
		
			
				|  |  | +					throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0059")/*@res "购销类型不能为空!"*/);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			if( BillEnumCollection.BuySellType.IN_SELL.VALUE.intValue() != item.getBuysellflag().intValue() &&
 | 
	
		
			
				|  |  | +				BillEnumCollection.BuySellType.IN_BUY.VALUE.intValue() != item.getBuysellflag().intValue() &&
 | 
	
		
			
				|  |  | +				BillEnumCollection.BuySellType.OUT_SELL.VALUE.intValue() != item.getBuysellflag().intValue() &&
 | 
	
		
			
				|  |  | +				BillEnumCollection.BuySellType.OUT_BUY.VALUE.intValue() != item.getBuysellflag().intValue() &&
 | 
	
		
			
				|  |  | +				BillEnumCollection.BuySellType.DEFAULT_TYPE.VALUE.intValue() != item.getBuysellflag().intValue() ){
 | 
	
		
			
				|  |  | +				throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0059")/*@res "购销类型不能为空!"*/);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				 if(BillEnumCollection.BuySellType.OUT_SELL.VALUE.intValue() == item.getBuysellflag().intValue() ||
 | 
	
		
			
				|  |  | +						 BillEnumCollection.BuySellType.OUT_BUY.VALUE.intValue() == item.getBuysellflag().intValue()){ // 国外 无税 = 价税
 | 
	
		
			
				|  |  | +					 this.checkTaxByOut( item);
 | 
	
		
			
				|  |  | +				 }else{//国内   本税 + 税金 = 价税
 | 
	
		
			
				|  |  | +					 this.checkTaxByIn(item);
 | 
	
		
			
				|  |  | +				 }
 | 
	
		
			
				|  |  | +			}else if(IBillFieldGet.SK.equals(billclass)||IBillFieldGet.FK.equals(billclass)){// 收款、付款  无税 = 价税
 | 
	
		
			
				|  |  | +				this.checkTaxByOut( item);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkTaxByOut(BaseItemVO item) throws BusinessException {
 | 
	
		
			
				|  |  | +		UFDouble localnotax_cr = item.getLocal_notax_cr();
 | 
	
		
			
				|  |  | +		UFDouble localmoney_cr = item.getLocal_money_cr() == null ? UFDouble.ZERO_DBL : item.getLocal_money_cr();
 | 
	
		
			
				|  |  | +		if (localmoney_cr.compareTo( localnotax_cr) != 0) {
 | 
	
		
			
				|  |  | +			//throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0060")/*@res "组织本币无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		UFDouble localnotax_de = item.getLocal_notax_de();
 | 
	
		
			
				|  |  | +		UFDouble localmoney_de = item.getLocal_money_de() == null ? UFDouble.ZERO_DBL : item.getLocal_money_de();
 | 
	
		
			
				|  |  | +		if (localmoney_de.compareTo( localnotax_de) != 0) {
 | 
	
		
			
				|  |  | +			//throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0060")/*@res "组织本币无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		UFDouble groupnotax_cr = item.getGroupnotax_cre();
 | 
	
		
			
				|  |  | +		UFDouble groupmoney_cr = item.getGroupcrebit() == null ? UFDouble.ZERO_DBL : item.getGroupcrebit();
 | 
	
		
			
				|  |  | +		if (groupmoney_cr.compareTo( groupnotax_cr) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0061")/*@res "集团无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		UFDouble groupnotax_de = item.getGroupnotax_de();
 | 
	
		
			
				|  |  | +		UFDouble groupmoney_de = item.getGroupdebit() == null ? UFDouble.ZERO_DBL : item.getGroupdebit();
 | 
	
		
			
				|  |  | +		if (groupmoney_de.compareTo(groupnotax_de) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0061")/*@res "集团无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		UFDouble globalnotax_cr = item.getGlobalnotax_cre();
 | 
	
		
			
				|  |  | +		UFDouble globalmoney_cr = item.getGlobalcrebit() == null ? UFDouble.ZERO_DBL : item.getGlobalcrebit();
 | 
	
		
			
				|  |  | +		if (globalmoney_cr.compareTo( globalnotax_cr) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0062")/*@res "全局无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		UFDouble globalnotax_de = item.getGlobalnotax_de();
 | 
	
		
			
				|  |  | +		UFDouble globalmoney_de = item.getGlobaldebit() == null ? UFDouble.ZERO_DBL : item.getGlobaldebit();
 | 
	
		
			
				|  |  | +		if (globalmoney_de.compareTo( globalnotax_de) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0062")/*@res "全局无税金额不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkTaxByIn(BaseItemVO item) throws BusinessException {
 | 
	
		
			
				|  |  | +		UFDouble localtax_cr = item.getLocal_tax_cr();
 | 
	
		
			
				|  |  | +		UFDouble localnotax_cr = item.getLocal_notax_cr();
 | 
	
		
			
				|  |  | +		UFDouble localmoney_cr = item.getLocal_money_cr() == null ? UFDouble.ZERO_DBL : item.getLocal_money_cr();
 | 
	
		
			
				|  |  | +		if (localmoney_cr.compareTo(MathTool.add(localtax_cr, localnotax_cr)) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0019")/*@res "组织本币无税金额与税金之和不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		UFDouble localtax_de = item.getLocal_tax_de();
 | 
	
		
			
				|  |  | +		UFDouble localnotax_de = item.getLocal_notax_de();
 | 
	
		
			
				|  |  | +		UFDouble localmoney_de = item.getLocal_money_de() == null ? UFDouble.ZERO_DBL : item.getLocal_money_de();
 | 
	
		
			
				|  |  | +		if (localmoney_de.compareTo(MathTool.add(localtax_de, localnotax_de)) != 0) {
 | 
	
		
			
				|  |  | +			throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0019")/*@res "组织本币无税金额与税金之和不等于价税合计!"*/);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void checkLocalRate(BaseAggVO vo) throws BusinessException {
 | 
	
		
			
				|  |  | +		for (BaseItemVO item : vo.getItems()) {
 | 
	
		
			
				|  |  | +			String pk_org = item.getPk_org();
 | 
	
		
			
				|  |  | +			if (null == pk_org) {
 | 
	
		
			
				|  |  | +				pk_org = vo.getHeadVO().getPk_org();
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			String local_currtype = Currency.getLocalCurrPK(pk_org);
 | 
	
		
			
				|  |  | +			String pk_currtype = item.getPk_currtype();
 | 
	
		
			
				|  |  | +			if (null == pk_currtype) {
 | 
	
		
			
				|  |  | +				throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0022")/*@res "表体币种为空!"*/);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (null == local_currtype) {
 | 
	
		
			
				|  |  | +				throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("2006arappub0316_0","02006arappub0316-0023")/*@res "未找到组织本位币,请检查财务组织!"*/);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (local_currtype.equals(pk_currtype)) {
 | 
	
		
			
				|  |  | +				if(item.getRate() == null || UFDouble.ZERO_DBL.equals(item.getRate())){
 | 
	
		
			
				|  |  | +					item.setRate(UFDouble.ONE_DBL);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_money_cr() == null || UFDouble.ZERO_DBL.equals(item.getLocal_money_cr())){
 | 
	
		
			
				|  |  | +					item.setLocal_money_cr(item.getMoney_cr());
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_notax_cr() == null || UFDouble.ZERO_DBL.equals(item.getLocal_notax_cr())){
 | 
	
		
			
				|  |  | +					item.setLocal_notax_cr(item.getNotax_cr());
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				if(item.getLocal_money_de() == null || UFDouble.ZERO_DBL.equals(item.getLocal_money_de())){
 | 
	
		
			
				|  |  | +					item.setLocal_money_de(item.getMoney_de());
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_notax_de() == null || UFDouble.ZERO_DBL.equals(item.getLocal_notax_de())){
 | 
	
		
			
				|  |  | +					item.setLocal_notax_de(item.getNotax_de());
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}else{
 | 
	
		
			
				|  |  | +				if(item.getLocal_money_cr() == null || UFDouble.ZERO_DBL.equals(item.getLocal_money_cr())){
 | 
	
		
			
				|  |  | +					item.setLocal_money_cr(Currency.getAmountByOpp(pk_org, pk_currtype, local_currtype, item.getMoney_cr(), item.getRate(), vo.getHeadVO().getBilldate()));
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_notax_cr() == null || UFDouble.ZERO_DBL.equals(item.getLocal_notax_cr())){
 | 
	
		
			
				|  |  | +					item.setLocal_notax_cr(Currency.getAmountByOpp(pk_org, pk_currtype, local_currtype, item.getNotax_cr(), item.getRate(), vo.getHeadVO().getBilldate()));
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_money_de() == null || UFDouble.ZERO_DBL.equals(item.getLocal_money_de())){
 | 
	
		
			
				|  |  | +					item.setLocal_money_de(Currency.getAmountByOpp(pk_org, pk_currtype, local_currtype, item.getMoney_de(), item.getRate(), vo.getHeadVO().getBilldate()));
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(item.getLocal_notax_de() == null || UFDouble.ZERO_DBL.equals(item.getLocal_notax_de())){
 | 
	
		
			
				|  |  | +					item.setLocal_notax_de(Currency.getAmountByOpp(pk_org, pk_currtype, local_currtype, item.getNotax_de(), item.getRate(), vo.getHeadVO().getBilldate()));
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 |