Kaynağa Gözat

编辑后事件

pancy 1 yıl önce
ebeveyn
işleme
1491bc58c2

+ 68 - 11
pu/pu/src/client/nc/ui/pu/m25/editor/card/afteredit/body/Vbdef20.java

@@ -2,6 +2,7 @@ package nc.ui.pu.m25.editor.card.afteredit.body;
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.BeanProcessor;
+import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.ui.pub.bill.BillCardPanel;
 import nc.ui.bd.pubinfo.BillItem;
 import nc.ui.cm.costtrandef.RefMoreSelectedUtils;
@@ -10,9 +11,12 @@ import nc.ui.pub.beans.UIRefPane;
 import nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent;
 import nc.vo.bd.defdoc.DefdocVO;
 import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFDate;
 import nc.vo.pub.lang.UFDouble;
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
 
 public class Vbdef20 implements ICardBodyAfterEditEventListener {
+	IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 
 	@Override
 	public void afterEdit(CardBodyAfterEditEvent arg0) {
@@ -33,34 +37,87 @@ public class Vbdef20 implements ICardBodyAfterEditEventListener {
 		UFDouble SumAmount = new UFDouble(0);//不含税
 		UFDouble SumTotal = new UFDouble(0);//价税合计
 		UFDouble SumTax = new UFDouble(0);//税额
+		String shuilv = "";//记录第一条税率,和后面进行对比,若不同则报错不允许保存
+		Object shuilvpk = "";
+		if(pks.length > 1){			
+			for(int j = 0;j < pks.length;j++){
+				String pk = pks[j];
+				String qrysql = "select * from bd_defdoc where dr=0 and pk_defdoc = '"+pk+"'";
+				DefdocVO defdocvo;
+				try {
+					defdocvo = (DefdocVO) iuap.executeQuery(qrysql, new BeanProcessor(DefdocVO.class));
+					Object shortname6 = defdocvo.getShortname6();
+					if(shortname6 == null){
+						ExceptionUtils.wrappBusinessException("所选发票税率为空,不能保存!");
+						return;
+					}
+					if(j == 0 && shortname6 != null){
+						shuilv = shortname6.toString();
+					}
+					if(j != 0 && !shortname6.toString().equals(shuilv)){
+						ExceptionUtils.wrappBusinessException("所选发票税率不同,不能保存!");
+						return;
+					}
+					
+				} catch (BusinessException e) {
+					// TODO 自动生成的 catch 块
+					ExceptionUtils.wrappBusinessException(e.getMessage());
+				}
+			}
+		}
+		
+		
 		for(int i = 0;i < pks.length;i++){
 			String pk = pks[i];
 			String qrysql = "select * from bd_defdoc where dr=0 and pk_defdoc = '"+pk+"'";
-			IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 			DefdocVO defdocvo;
 			try {
 				defdocvo = (DefdocVO) iuap.executeQuery(qrysql, new BeanProcessor(DefdocVO.class));
-				arg0.getBillCardPanel().setHeadItem("vbillcode", defdocvo.getMemo());
+				String qryshuilv = "select pk_taxcode from bd_taxrate where nvl(dr,0) = 0 and pk_taxcode not in (select pk_taxcode from bd_taxcode where code = '0') and taxrate = '"+defdocvo.getShortname6()+"'";
+				try {
+					shuilvpk = iuap.executeQuery(qryshuilv, new ColumnProcessor());
+					if(shuilvpk == null){
+						ExceptionUtils.wrappBusinessException("税率没有对应税码,请检查!");
+						return;
+					}
+				} catch (BusinessException e1) {
+					// TODO 自动生成的 catch 块
+					ExceptionUtils.wrappBusinessException(e1.getMessage());
+				}
+				arg0.getBillCardPanel().setHeadItem("vbillcode", defdocvo.getName());//发票号
+				arg0.getBillCardPanel().setHeadItem("vdef19", defdocvo.getName4());//开票方
+				arg0.getBillCardPanel().setHeadItem("dbilldate", new UFDate(defdocvo.getShortname4()));//发票日期
+				arg0.getBillCardPanel().setBodyValueAt(defdocvo.getShortname5(), 0, "vbdef17");//发票分类
+				arg0.getBillCardPanel().setBodyValueAt(defdocvo.getShortname6(), 0, "ntaxrate");//税率
+				arg0.getBillCardPanel().setBodyValueAt(shuilvpk, 0, "ctaxcodeid");//税码
 				Object shortname = defdocvo.getShortname();
 				if(shortname != null && shortname.toString() != ""){
-					SumAmount.add(new UFDouble(shortname.toString()));
+					SumAmount = SumAmount.add(new UFDouble(shortname.toString()));
 				}
-				Object shortname2 = defdocvo.getShortname();
+				Object shortname2 = defdocvo.getShortname2();
 				if(shortname2 != null && shortname2.toString() != ""){
-					SumTotal.add(new UFDouble(shortname2.toString()));
+					SumTotal = SumTotal.add(new UFDouble(shortname2.toString()));
 				}
-				Object shortname3 = defdocvo.getShortname();
+				Object shortname3 = defdocvo.getShortname3();
 				if(shortname3 != null && shortname3.toString() != ""){
-					SumTax.add(new UFDouble(shortname3.toString()));
+					SumTax = SumTax.add(new UFDouble(shortname3.toString()));
 				}
 			} catch (BusinessException e) {
 				// TODO 自动生成的 catch 块
-				e.printStackTrace();
+				ExceptionUtils.wrappBusinessException(e.getMessage());
 			}
 		}
-		arg0.getBillCardPanel().setBodyValueAt(SumAmount, 10, "norigmny");
-		arg0.getBillCardPanel().setBodyValueAt(SumTotal, 10, "norigtaxmny");
-		arg0.getBillCardPanel().setBodyValueAt(SumTax, 10, "ntax");
+		arg0.getBillCardPanel().setBodyValueAt(1, 0, "nastnum");//数量
+		arg0.getBillCardPanel().setBodyValueAt(1, 0, "nnum");//主数量
+		arg0.getBillCardPanel().setBodyValueAt(SumAmount, 0, "nastorigprice");//无税单价
+		arg0.getBillCardPanel().setBodyValueAt(SumAmount, 0, "nastprice");//本币无税单价
+		arg0.getBillCardPanel().setBodyValueAt(SumAmount, 0, "norigmny");//无税金额
+		arg0.getBillCardPanel().setBodyValueAt(SumAmount, 0, "nmny");//本币无税金额
+		arg0.getBillCardPanel().setBodyValueAt(SumTotal, 0, "nastorigtaxprice");//含税单价
+		arg0.getBillCardPanel().setBodyValueAt(SumTotal, 0, "nasttaxprice");//本币含税单价
+		arg0.getBillCardPanel().setBodyValueAt(SumTotal, 0, "norigtaxmny");//价税合计
+		arg0.getBillCardPanel().setBodyValueAt(SumTotal, 0, "ntaxmny");//本币价税合计
+		arg0.getBillCardPanel().setBodyValueAt(SumTax, 0, "ntax");//税额