|
@@ -0,0 +1,88 @@
|
|
|
+package nc.bs.ic.base;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import nc.bs.businessevent.IBusinessEvent;
|
|
|
+import nc.bs.businessevent.IBusinessListener;
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.pu.event.PUBusinessEvent;
|
|
|
+import nc.itf.uap.IUAPQueryBS;
|
|
|
+import nc.jdbc.framework.processor.MapListProcessor;
|
|
|
+import nc.vo.pu.m25.entity.InvoiceItemVO;
|
|
|
+import nc.vo.pu.m25.entity.InvoiceVO;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.lang.UFDateTime;
|
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
|
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|
|
+
|
|
|
+public class InvoiceAfterCheckEvent implements IBusinessListener{
|
|
|
+
|
|
|
+
|
|
|
+ IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doAction(IBusinessEvent event) throws BusinessException {
|
|
|
+ if (event instanceof PUBusinessEvent) {
|
|
|
+ PUBusinessEvent busiEvent = (PUBusinessEvent)event;
|
|
|
+ Object[] obj = busiEvent.getObjs();
|
|
|
+ if (obj == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (obj instanceof InvoiceVO[]) {
|
|
|
+ InvoiceVO InvoiceVO = (InvoiceVO) obj[0];
|
|
|
+ InvoiceItemVO[] invoiceItemListVO = (InvoiceItemVO[]) InvoiceVO.getChildren(InvoiceItemVO.class);
|
|
|
+ UFDateTime date = new UFDateTime(System.currentTimeMillis());
|
|
|
+ UFDateTime date2 = new UFDateTime("2023-01-01 00:00:01");
|
|
|
+ //当年只能报销当年的控制
|
|
|
+ if(date.getYear() != date2.getYear()) {
|
|
|
+ ExceptionUtils.wrappBusinessException("不能跨年报销发票!");
|
|
|
+ }
|
|
|
+ //参照上游单据的信息和发票信息一致性校验(抬头、税率)
|
|
|
+ //发票金额不可超过采购合同/订单金额
|
|
|
+ //购买方发票抬头、税号准确性
|
|
|
+ //来源单据类型
|
|
|
+ String csourcetypecode = invoiceItemListVO[0].getCsourcetypecode();
|
|
|
+ //来源单据主键
|
|
|
+ String csourceid = invoiceItemListVO[0].getCsourceid();
|
|
|
+ //来源单据是采购订单
|
|
|
+ if("21".equals(csourcetypecode)) {
|
|
|
+ String sql = "select po_order_b.pk_order_b,po_order_b.norigtaxmny,po_order_b.ntaxrate from po_order po_order" +
|
|
|
+ " left join po_order_b po_order_b on po_order_b.pk_order = po_order.pk_order" +
|
|
|
+ " where po_order.pk_order='"+csourceid+"'";
|
|
|
+ List<Map<Object, Object>> listMap = (List<Map<Object, Object>>) bs.executeQuery(sql, new MapListProcessor());
|
|
|
+ for (InvoiceItemVO invoiceItemVO : invoiceItemListVO) {
|
|
|
+ for (Map<Object, Object> map : listMap) {
|
|
|
+ if (invoiceItemVO.getCsourcebid().equals(map.get("pk_order_b"))) {
|
|
|
+ UFDouble norigtaxmny1 = invoiceItemVO.getNorigtaxmny();
|
|
|
+ UFDouble norigtaxmny2 = new UFDouble(map.get("norigtaxmny").toString());
|
|
|
+ //比较价税合计
|
|
|
+ if(norigtaxmny1.compareTo(norigtaxmny2) == 1) {
|
|
|
+ ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"不可超过采购订单价税合计金额!");
|
|
|
+ }
|
|
|
+ //比较税率
|
|
|
+ UFDouble ntaxrate1 = invoiceItemVO.getNtaxrate();
|
|
|
+ UFDouble ntaxrate2 = new UFDouble(map.get("ntaxrate").toString());
|
|
|
+ if(ntaxrate1.compareTo(ntaxrate2) != 0) {
|
|
|
+ ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"与采购订单税率不同!");
|
|
|
+ }
|
|
|
+ //比较抬头
|
|
|
+
|
|
|
+ //比较纳税人识别号
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //来源单据是入库单
|
|
|
+
|
|
|
+ String str = null;
|
|
|
+ System.out.println(str.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|