From bb309726b6def2871a1f0fd56c871b5f17410f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=B0=8F=E4=BC=9F?= Date: Tue, 13 May 2025 11:30:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=20=E5=80=99=E8=A1=A5=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/SupplementInvoiceBillPlugin.java | 103 ++++++++++-------- 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/SupplementInvoiceBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/SupplementInvoiceBillPlugin.java index 1e87d23..6b8bdbc 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/SupplementInvoiceBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/SupplementInvoiceBillPlugin.java @@ -7,6 +7,7 @@ import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.resource.ResManager; import kd.bos.entity.datamodel.ListSelectedRow; import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.CloseCallBack; import kd.bos.form.ShowFormHelper; @@ -64,49 +65,43 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI { } int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity"); DynamicObject rowEntity = this.getModel().getEntryRowEntity("entryentity", rowIndex);//获取对应行的单据体 - BigDecimal applyoftaxamount = rowEntity.getBigDecimal("thisapplyoftax");//获取单据体对应的 本次申请金额⑫ - BigDecimal totalAmount = this.getSum1("subentryentity", "applyinvoftaxamt");//算出子单据申请金额总和 - if(applyoftaxamount.compareTo(totalAmount)!=0){ - this.getView().showTipNotification( - "合同付款信息的 本次申请金额\n" + - " 不等于 合同进项发票的 本次申请金额总和 ,请重写填写合同进项发票的申请金额",5000); - this.getView().showTipNotification("发票保存失败!",5000); - args.setCancel(true); - }else { -// int rowCount = this.getModel().getEntryRowCount("subentryentity");//获取子单据体分录行数 - DynamicObject[] invArr = new DynamicObject[rowCount];//用于存储发票 +// BigDecimal applyoftaxamount = rowEntity.getBigDecimal("thisapplyoftax");//获取单据体对应的 本次申请金额⑫ +// BigDecimal totalAmount = this.getSum1("subentryentity", "applyinvoftaxamt");//算出子单据申请金额总和 +// if(applyoftaxamount.compareTo(totalAmount)!=0){ +// this.getView().showTipNotification( +// "合同付款信息的 本次申请金额\n" + +// " 不等于 合同进项发票的 本次申请金额总和 ,请重写填写合同进项发票的申请金额"); +// this.getView().showTipNotification("发票保存失败!"); +// args.setCancel(true); +// } +// DynamicObject[] invArr = new DynamicObject[rowCount];//用于存储发票 - DynamicObjectCollection subentryentitys = rowEntity.getDynamicObjectCollection("subentryentity"); - for (int i = 0; i < subentryentitys.size(); i++) { - Object invoiceNum = subentryentitys.get(i).get("invoice"); - if(invoiceNum!=null){ - DynamicObject invObj = (DynamicObject)invoiceNum; - log.info("SupplementInvoiceBillPlugin:获取第"+(i+1)+"行发票号"+invObj.getLong("id")); - DynamicObject invoice = BusinessDataServiceHelper.loadSingle(invObj.getLong("id"), "ec_in_invoice"); - log.info("SupplementInvoiceBillPlugin:数据库搜索进项发票"+invoice.getPkValue().toString()); - BigDecimal applyinvoftaxamt = (BigDecimal)this.getModel().getValue("applyinvoftaxamt", i);//获取申请金额 - log.info("SupplementInvoiceBillPlugin:本次申请金额"+applyinvoftaxamt); - BigDecimal unapplyinvoftaxamt = (BigDecimal)this.getModel().getValue("unapplyinvoftaxamt", i);//获取未申请金额 - log.info("SupplementInvoiceBillPlugin:未申请金额="+unapplyinvoftaxamt); - unapplyinvoftaxamt = unapplyinvoftaxamt.subtract(applyinvoftaxamt);//未申请金额-申请金额 - log.info("SupplementInvoiceBillPlugin:未申请金额-申请金额="+unapplyinvoftaxamt); - if(unapplyinvoftaxamt.compareTo(BigDecimal.ZERO)>=0){ - this.getModel().setValue("unapplyinvoftaxamt", unapplyinvoftaxamt,i); - invoice.set("unapplyamount",unapplyinvoftaxamt); - invArr[i] = invoice; - SaveServiceHelper.save(new DynamicObject[]{invoice}); - this.getView().showSuccessNotification("第"+(i+1)+"行发票保存成功",1000); - }else { - this.getView().showTipNotification("合同进项发票信息第"+(i+1)+"行的 本次申请金额不能大于未申请含税金额。",5000); - this.getView().showTipNotification("发票保存失败!",5000); - args.setCancel(true); - } + DynamicObjectCollection subentryentitys = rowEntity.getDynamicObjectCollection("subentryentity"); + for (int i = 0; i < subentryentitys.size(); i++) { + Object invoiceNum = subentryentitys.get(i).get("invoice"); + if(invoiceNum!=null){ + DynamicObject invObj = (DynamicObject)invoiceNum; + log.info("SupplementInvoiceBillPlugin:获取第"+(i+1)+"行发票号"+invObj.getLong("id")); + DynamicObject invoice = BusinessDataServiceHelper.loadSingle(invObj.getLong("id"), "ec_in_invoice"); + log.info("SupplementInvoiceBillPlugin:数据库搜索进项发票"+invoice.getPkValue().toString()); +// BigDecimal applyinvoftaxamt = (BigDecimal)this.getModel().getValue("applyinvoftaxamt", i);//获取申请金额 +// log.info("SupplementInvoiceBillPlugin:本次申请金额"+applyinvoftaxamt); + BigDecimal unapplyinvoftaxamt = (BigDecimal)this.getModel().getValue("unapplyinvoftaxamt", i);//获取未申请金额 + log.info("SupplementInvoiceBillPlugin:未申请金额="+unapplyinvoftaxamt); +// unapplyinvoftaxamt = unapplyinvoftaxamt.subtract(applyinvoftaxamt);//未申请金额-申请金额 +// log.info("SupplementInvoiceBillPlugin:未申请金额-申请金额="+unapplyinvoftaxamt); + if(unapplyinvoftaxamt.compareTo(BigDecimal.ZERO)>=0){ +// this.getModel().setValue("unapplyinvoftaxamt", unapplyinvoftaxamt,i); + invoice.set("unapplyamount",unapplyinvoftaxamt); +// invArr[i] = invoice; + SaveServiceHelper.save(new DynamicObject[]{invoice}); + this.getView().showSuccessNotification("第"+(i+1)+"行发票保存成功"); + }else { + this.getView().showTipNotification("合同进项发票信息第"+(i+1)+"行的 本次申请金额不能大于未申请含税金额。"); + this.getView().showTipNotification("发票保存失败!"); + args.setCancel(true); } - - } - - } } @@ -125,15 +120,16 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI { // int rowIndex = e.getChangeSet()[0].getRowIndex(); log.info("SupplementInvoiceBillPlugin:发生变动的字段:"+key); if(StringUtil.equals("applyinvoftaxamt", key)) { - log.info("SupplementInvoiceBillPlugin:发票申请金额发生变动,与合同的申请金额进行比较"); - this.compareApplyInvoftaxamt1(); + log.info("SupplementInvoiceBillPlugin:发票申请金额发生变动,与未申请金额进行比较"); + this.compareApplyInvoftaxamt1(e); } } } - private void compareApplyInvoftaxamt1() { + private void compareApplyInvoftaxamt1(PropertyChangedArgs e) { + this.subtractUnapplyAmount(e); int rowIndex = this.getModel().getEntryCurrentRowIndex("entryentity"); DynamicObject rowEntity = this.getModel().getEntryRowEntity("entryentity", rowIndex);//获取对应行的单据体 BigDecimal applyoftaxamount = rowEntity.getBigDecimal("thisapplyoftax");//获取单据体对应的 本次申请金额⑫ @@ -141,7 +137,26 @@ public class SupplementInvoiceBillPlugin extends PaymentApplyEditUI { if(applyoftaxamount.compareTo(totalAmount)!=0){ this.getView().showTipNotification( "合同付款信息的 本次申请金额\n" + - " 不等于 合同进项发票的 本次申请金额总和 ,请重写填写合同进项发票的申请金额",10000); + " 不等于 合同进项发票的 本次申请金额总和 ,请重写填写合同进项发票的申请金额"); + } + } + + private void subtractUnapplyAmount(PropertyChangedArgs e) { + ChangeData changeData = e.getChangeSet()[0]; + int rowIndex = changeData.getRowIndex(); + BigDecimal oldValue = (BigDecimal)changeData.getOldValue(); + log.info("SupplementInvoiceBillPlugin:申请金额旧值:"+oldValue); + BigDecimal newValue = (BigDecimal) changeData.getNewValue(); + log.info("SupplementInvoiceBillPlugin:申请金额新值:"+newValue); + BigDecimal changeValue = newValue.subtract(oldValue); + BigDecimal unapplyamount = (BigDecimal)this.getModel().getValue("unapplyinvoftaxamt",rowIndex); + log.info("SupplementInvoiceBillPlugin:未申请金额:"+unapplyamount); + unapplyamount = unapplyamount.subtract(changeValue); + log.info("SupplementInvoiceBillPlugin:扣减后的未申请金额:"+unapplyamount); + if (unapplyamount.compareTo(BigDecimal.ZERO) >= 0) { + this.getModel().setValue("unapplyinvoftaxamt", unapplyamount,rowIndex); + }else{ + this.getView().showTipNotification("合同进项发票信息第"+(rowIndex+1)+"行的 本次申请金额不能大于未申请含税金额。"); } }