含税不含税转换

来自ling
跳转至: 导航搜索
//不含税转变为含税
			if(YesOrNoEnums.NO.getValue().equals(pool.getIsTax())){
				BigDecimal percent = new BigDecimal(pool.getTaxRate()).divide(new BigDecimal(100));			
				BigDecimal vatAmount = pool.getExchangeAmount().multiply(percent);						
				BigDecimal invoiceAmount = pool.getExchangeAmount().add(vatAmount);		
				vatAmount = vatAmount.setScale(2, RoundingMode.HALF_UP);						
				invoiceReqL.setVatAmount(vatAmount);
				invoiceAmount = invoiceAmount.setScale(2, RoundingMode.HALF_UP);
				invoiceReqL.setInvoiceAmount(invoiceAmount);
				invoiceReqL.setAcctdAmountCr(pool.getExchangeAmount());
			}else {
				//含税
				BigDecimal percent = new BigDecimal(pool.getTaxRate()).divide(new BigDecimal(100));
				BigDecimal percentt = BigDecimal.ONE.add(percent);	
				BigDecimal middle = pool.getExchangeAmount().multiply(percent);
				BigDecimal vatAmount = middle.divide(percentt,3);			
				vatAmount = vatAmount.setScale(2, RoundingMode.HALF_UP);						
				invoiceReqL.setVatAmount(vatAmount);			
				invoiceReqL.setInvoiceAmount(pool.getExchangeAmount());
				BigDecimal acctdAmountCr = pool.getExchangeAmount().subtract(vatAmount);
				invoiceReqL.setAcctdAmountCr(acctdAmountCr);
			}