From 272f4a9eff53028bc620f5a678dad53d3634e7ef Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Wed, 12 Nov 2025 15:07:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E5=87=BA=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/form/CostAllocatorBillPlugin.java | 74 ++++++++++--------- .../operate/OutContractSettleOpExt.java | 12 ++- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java index e5c8e30..903c607 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/CostAllocatorBillPlugin.java @@ -107,24 +107,6 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin { QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber); DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单 if (ecma_materialInBill != null) { - DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 - for (DynamicObject entryEntity : entryEntityCollection) { - DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); - newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("oftaxamount"));//价税合计-含税金额 - newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("notaxamount"));//不含税金额-金额 - newProcessAllocEntity.set("zcgj_rateval", entryEntity.getDynamicObject("entrytaxrate").get("taxrate"));//税率(%)-税率名称(值 - newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("taxamount"));//税额-税额 - - DynamicObject expenseItem = null; - DynamicObject material = entryEntity.getDynamicObject("material");//入库单分录-资源编码 - if (material != null) { - DynamicObject resource = material.getDynamicObject("resource");//入库单分录-资源编码-清单分类 - expenseItem = getExpenseItemByResource(resource); - } - newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 - - processAllocEntityCollection.add(newProcessAllocEntity); - } if (zcgj_transset) { DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总 for (DynamicObject entryEntity : expensesummaryCollection) { @@ -139,6 +121,25 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin { newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额 newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目 + processAllocEntityCollection.add(newProcessAllocEntity); + } + } else { + DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 + for (DynamicObject entryEntity : entryEntityCollection) { + DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); + newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("oftaxamount"));//价税合计-含税金额 + newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("notaxamount"));//不含税金额-金额 + newProcessAllocEntity.set("zcgj_rateval", entryEntity.getDynamicObject("entrytaxrate").get("taxrate"));//税率(%)-税率名称(值 + newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("taxamount"));//税额-税额 + + DynamicObject expenseItem = null; + DynamicObject material = entryEntity.getDynamicObject("material");//入库单分录-资源编码 + if (material != null) { + DynamicObject resource = material.getDynamicObject("resource");//入库单分录-资源编码-清单分类 + expenseItem = getExpenseItemByResource(resource); + } + newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 + processAllocEntityCollection.add(newProcessAllocEntity); } } @@ -246,24 +247,6 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin { QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber); DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单 if (ecma_materialInBill != null) { - DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 - for (DynamicObject entryEntity : entryEntityCollection) { - DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); - newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("oftaxamount"));//价税合计-含税金额 - newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("notaxamount"));//不含税金额-金额 - newProcessAllocEntity.set("zcgj_rateval", entryEntity.getDynamicObject("entrytaxrate").get("taxrate"));//税率(%)-税率名称(值 - newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("taxamount"));//税额-税额 - - DynamicObject expenseItem = null; - DynamicObject material = entryEntity.getDynamicObject("material");//入库单分录-资源编码 - if (material != null) { - DynamicObject resource = material.getDynamicObject("resource");//入库单分录-资源编码-清单分类 - expenseItem = getExpenseItemByResource(resource); - } - newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 - - processAllocEntityCollection.add(newProcessAllocEntity); - } if (zcgj_transset) { DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总 for (DynamicObject entryEntity : expensesummaryCollection) { @@ -278,6 +261,25 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin { newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额 newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目 + processAllocEntityCollection.add(newProcessAllocEntity); + } + } else { + DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 + for (DynamicObject entryEntity : entryEntityCollection) { + DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); + newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("oftaxamount"));//价税合计-含税金额 + newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("notaxamount"));//不含税金额-金额 + newProcessAllocEntity.set("zcgj_rateval", entryEntity.getDynamicObject("entrytaxrate").get("taxrate"));//税率(%)-税率名称(值 + newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("taxamount"));//税额-税额 + + DynamicObject expenseItem = null; + DynamicObject material = entryEntity.getDynamicObject("material");//入库单分录-资源编码 + if (material != null) { + DynamicObject resource = material.getDynamicObject("resource");//入库单分录-资源编码-清单分类 + expenseItem = getExpenseItemByResource(resource); + } + newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 + processAllocEntityCollection.add(newProcessAllocEntity); } } diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleOpExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleOpExt.java index a80319d..829ff19 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleOpExt.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/OutContractSettleOpExt.java @@ -34,6 +34,9 @@ import kd.ec.contract.opplugin.validator.OutContractSettleReferValidator; import kd.ec.contract.opplugin.validator.OutContractSettleTimeValidator; import kd.ec.contract.opplugin.validator.OutContractSettleValidator; +/** + * 支出合同结算审核反审核系统插件二开 + */ public class OutContractSettleOpExt extends AbstractContractSettleOp { public OutContractSettleOpExt() { } @@ -122,6 +125,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp { boolean isSettleByMatIn = dataArr[i].getBoolean("issettlebymatin"); boolean isSettleByReconciliation = dataArr[i].getBoolean("issettlebyreconc"); boolean isSettleByEquipment = dataArr[i].getBoolean("iseqsettle"); + boolean zcgj_transset = dataArr[i].getBoolean("zcgj_transset");//按入库运费结算//二开添加 Set materialInBillIds = new HashSet(16); Set reconciliationBillIds = new HashSet(16); Set equipmentBillIds = new HashSet(16); @@ -151,7 +155,8 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp { materialInBillIds.addAll(matInBillIdList); } - if (isSettleByMatIn) { +// if (isSettleByMatIn) {//系统代码 + if (isSettleByMatIn || zcgj_transset) {//二开修改 dynamicObjects = dataArr[i].getDynamicObjectCollection("materialinentry"); for (j = 0; j < dynamicObjects.size(); ++j) { @@ -236,7 +241,6 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp { bill.set("settlestatus", "0"); }*///系统代码 //二开修改↓ - boolean zcgj_transset = dataArr[i].getBoolean("zcgj_transset");//按入库运费结算 if (StringUtils.equals("audit", operationKey)) { if (zcgj_transset) { bill.set("zcgj_settlestatus", "1");//运费已结算 @@ -304,7 +308,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp { public void afterExecuteOperationTransaction(AfterOperationArgs e) { super.afterExecuteOperationTransaction(e); - String operation = e.getOperationKey(); +/* String operation = e.getOperationKey(); DynamicObject[] settleBills = e.getDataEntities(); List settleBillList = Arrays.asList(settleBills); List listingEntrys = (List) settleBillList.stream().flatMap((settleBill) -> { @@ -318,7 +322,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp { this.updateListing(listingEntrys, true); } else if ("unaudit".equals(operation)) { this.updateListing(listingEntrys, false); - } + }*///二开注释掉的 } From 6cbc0c2b21c5a0f723521f69231b7e85b498a530 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Wed, 12 Nov 2025 15:07:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/MaterialInBillEditPluginExt.java | 9 +- .../form/MaterialInbPurchaseApplyPlugin.java | 95 ++++++++++++------- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInBillEditPluginExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInBillEditPluginExt.java index 1c09ccc..c63bc39 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInBillEditPluginExt.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInBillEditPluginExt.java @@ -1755,13 +1755,16 @@ public class MaterialInBillEditPluginExt extends AbstractEcmaBillPlugin implemen this.clearHead(); this.sumMaoftaxAmount(); this.sumMaTaxAmount(); + Object splitType = this.getModel().getValue("splittype");//分摊类型 EntryGrid grid = (EntryGrid) this.getControl("entryentity"); BigDecimal sum = grid.getSum("ftransamount");//入库单-运费金额合计 - this.getModel().setValue("transamount", sum);//总运费 BigDecimal zcgj_transtaxamount = grid.getSum("zcgj_transtaxamount");//入库单-运费税额合计 - this.getModel().setValue("transtaxamount", zcgj_transtaxamount);//运费总税额 BigDecimal taxtransamount = grid.getSum("taxtransamount");//入库单-含税运费 - this.getModel().setValue("transoftaxamount", taxtransamount);//含税总运费 + if (splitType != null && !splitType.equals("3")) { + this.getModel().setValue("transamount", sum);//总运费 + this.getModel().setValue("transtaxamount", zcgj_transtaxamount);//运费总税额 + this.getModel().setValue("transoftaxamount", taxtransamount);//含税总运费 + } this.getView().updateView("matamount"); this.getView().updateView("matoftaxamount"); this.getView().updateView("mataxamount"); diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java index a02b4af..d55ff12 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java @@ -406,7 +406,7 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement DynamicObject purchaseApplyEntry = purchaseApplyEntryCollection.get(i); DynamicObject zcgj_purchaseapply_f7 = purchaseApplyEntry.getDynamicObject("zcgj_purchaseapply_f7");//采购申请 if (zcgj_purchaseapply_f7 != null) { - if (row == i){ + if (row == i) { continue; } qFilters.add(new QFilter("id", QCP.not_equals, zcgj_purchaseapply_f7.get("id"))); @@ -628,6 +628,12 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement * @param expenseSummaryCollection 费用汇总分录集合 */ private void handleUnsplitFreightLine(DynamicObjectCollection expenseSummaryCollection) { + // 判断是否存在运费,如果运费为0或空则不创建运费行 + BigDecimal transAmount = (BigDecimal) getModel().getValue("transamount"); // 总运费 + if (transAmount == null || transAmount.compareTo(BigDecimal.ZERO) == 0) { + return; // 无运费时不创建运费行 + } + DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType()); // 设置运费行标识 @@ -635,7 +641,6 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement // 使用单据头上的字段(汇总值) BigDecimal transSoftTaxAmount = (BigDecimal) getModel().getValue("transoftaxamount"); // 含税运费 - BigDecimal transAmount = (BigDecimal) getModel().getValue("transamount"); // 总运费 BigDecimal transtaxAmount = (BigDecimal) getModel().getValue("transtaxamount"); // 运费总税额 DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate"); // 运费税率 @@ -667,57 +672,77 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement * @param expenseSummaryCollection 费用汇总分录集合 */ private void handleSplitFreightLines(DynamicObjectCollection entryEntityCollection, DynamicObjectCollection expenseSummaryCollection) { + boolean hasFreight = false; + + // 先检查是否存在运费 + for (DynamicObject entryEntity : entryEntityCollection) { + BigDecimal ftransamount = (BigDecimal) entryEntity.get("ftransamount"); // 运费 + if (ftransamount != null && ftransamount.compareTo(BigDecimal.ZERO) > 0) { + hasFreight = true; + break; + } + } + + // 如果没有运费则不创建运费行 + if (!hasFreight) { + return; + } + // 获取单据头上的税率 DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate"); BigDecimal rateValue = taxRate != null ? (BigDecimal) taxRate.get("taxrate") : BigDecimal.ZERO; - // 遍历入库单明细,为每条记录创建一条运费行 + // 遍历入库单明细,为每条有运费的记录创建一条运费行 for (DynamicObject entryEntity : entryEntityCollection) { - DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType()); - - // 设置运费行标识 - newFreightLine.set("zcgj_isfreightline", true); - - // 获取运费相关字段 BigDecimal ftransamount = (BigDecimal) entryEntity.get("ftransamount"); // 运费 - BigDecimal zcgj_transtaxamount = (BigDecimal) entryEntity.get("zcgj_transtaxamount"); // 运费税额 - BigDecimal taxtransamount = (BigDecimal) entryEntity.get("taxtransamount"); // 含税运费 + // 只有当运费大于0时才创建运费行 + if (ftransamount != null && ftransamount.compareTo(BigDecimal.ZERO) > 0) { + DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType()); - // 计算含税运费(运费 + 运费税额) - BigDecimal calculatedTaxTransAmount = ftransamount.add(zcgj_transtaxamount); + // 设置运费行标识 + newFreightLine.set("zcgj_isfreightline", true); - // 价税合计-含税运费 - newFreightLine.set("zcgj_pa_amount", calculatedTaxTransAmount); + // 获取运费相关字段 + BigDecimal zcgj_transtaxamount = (BigDecimal) entryEntity.get("zcgj_transtaxamount"); // 运费税额 + BigDecimal taxtransamount = (BigDecimal) entryEntity.get("taxtransamount"); // 含税运费 - // 不含税金额-运费 - newFreightLine.set("zcgj_amountnotax", ftransamount); + // 计算含税运费(运费 + 运费税额) + BigDecimal calculatedTaxTransAmount = ftransamount.add(zcgj_transtaxamount); - // 税额-运费税额 - newFreightLine.set("zcgj_taxamt", zcgj_transtaxamount); + // 价税合计-含税运费 + newFreightLine.set("zcgj_pa_amount", calculatedTaxTransAmount); - // 设置税率 - newFreightLine.set("zcgj_rateval", rateValue); + // 不含税金额-运费 + newFreightLine.set("zcgj_amountnotax", ftransamount); - // 设置费用项目 - 根据入库单明细中的资源编码获取对应的费用项目 - DynamicObject material = entryEntity.getDynamicObject("material"); - if (material != null) { - DynamicObject resource = material.getDynamicObject("resource"); - if (resource != null) { - String resourceNumber = resource.getString("number"); - DynamicObject ecbd_resource = BusinessDataServiceHelper.loadSingle("ecbd_resource", - "id,zcgj_expenseitem", new QFilter[]{new QFilter("number", QCP.equals, resourceNumber)}); - if (ecbd_resource != null) { - DynamicObject expenseItem = ecbd_resource.getDynamicObject("zcgj_expenseitem"); - newFreightLine.set("zcgj_expenseitem", expenseItem); + // 税额-运费税额 + newFreightLine.set("zcgj_taxamt", zcgj_transtaxamount); + + // 设置税率 + newFreightLine.set("zcgj_rateval", rateValue); + + // 设置费用项目 - 根据入库单明细中的资源编码获取对应的费用项目 + DynamicObject material = entryEntity.getDynamicObject("material"); + if (material != null) { + DynamicObject resource = material.getDynamicObject("resource"); + if (resource != null) { + String resourceNumber = resource.getString("number"); + DynamicObject ecbd_resource = BusinessDataServiceHelper.loadSingle("ecbd_resource", + "id,zcgj_expenseitem", new QFilter[]{new QFilter("number", QCP.equals, resourceNumber)}); + if (ecbd_resource != null) { + DynamicObject expenseItem = ecbd_resource.getDynamicObject("zcgj_expenseitem"); + newFreightLine.set("zcgj_expenseitem", expenseItem); + } } } - } - // 添加到费用汇总分录 - expenseSummaryCollection.add(newFreightLine); + // 添加到费用汇总分录 + expenseSummaryCollection.add(newFreightLine); + } } } + /** * 获取运费对应的费用项目 *