From 3c6d06f4afd72906f1ee1cefe10002f261099913 Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Thu, 20 Nov 2025 17:46:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=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/MaterialInbPurchaseApplyPlugin.java | 95 ++++++++++++++++--- 1 file changed, 83 insertions(+), 12 deletions(-) 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 080e8e1..6bc415f 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 @@ -219,7 +219,29 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement if (newValue == null || !newValue.equals(oldValue)) { this.getModel().setValue("zcgj_purchaseapply", null);//清空采购申请 } + if (newValue != null && !newValue.equals(oldValue)) { + DynamicObject fiaccountorg = (DynamicObject) newValue;//财务记账组织新值 + QFilter filter = new QFilter("zcgj_companyblentry.zcgj_org.id", QCP.equals, fiaccountorg.getPkValue()); + filter.and(new QFilter("number", QCP.equals, "001")); + filter.and(new QFilter("zcgj_companyblentry.zcgj_rateway", QCP.equals, true)); + DynamicObject zcgj_companybelong = QueryServiceHelper.queryOne("zcgj_companybelong", "number,zcgj_companyblentry.zcgj_wareunit", new QFilter[]{filter}); + DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息 + if (zcgj_companybelong != null) { + for (DynamicObject entryEntity : entryEntityCollection) { + entryEntity.set("zcgj_invoicetax", BigDecimal.ZERO);//税额 + entryEntity.set("zcgj_invoiceamount", entryEntity.get("zcgj_oftaxinvoiceamount"));//价税合计赋值给金额 + } + } else { + for (DynamicObject entryEntity : entryEntityCollection) { + DynamicObject zcgj_invoice = entryEntity.getDynamicObject("zcgj_invoice");//发票号码 + entryEntity.set("zcgj_invoicetax", zcgj_invoice.getBigDecimal("totaltax"));//税额 + entryEntity.set("zcgj_invoiceamount", zcgj_invoice.getBigDecimal("totalamount"));//金额 + } + } + this.getView().updateView("zcgj_entryentity");//刷新分录 + } updateMeasureUnitEnableState(); + setNewExpenseSummary(); } else if ("zcgj_reqperson".equals(key)) { //物资申请人 ChangeData[] changeSet = e.getChangeSet(); @@ -423,6 +445,18 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement if (!invoiceTypeIdName.contains("专")) { this.getModel().setValue("zcgj_invoicetax", BigDecimal.ZERO, rowIndex); this.getModel().setValue("zcgj_invoiceamount", dataEntity.get("zcgj_oftaxinvoiceamount"), rowIndex); + } else { + DynamicObject fiaccountorg = (DynamicObject) this.getModel().getValue("fiaccountorg");//财务记账组织 + if (fiaccountorg != null) { + QFilter filter = new QFilter("zcgj_companyblentry.zcgj_org.id", QCP.equals, fiaccountorg.getPkValue()); + filter.and(new QFilter("number", QCP.equals, "001")); + filter.and(new QFilter("zcgj_companyblentry.zcgj_rateway", QCP.equals, true)); + DynamicObject zcgj_companybelong = QueryServiceHelper.queryOne("zcgj_companybelong", "number,zcgj_companyblentry.zcgj_wareunit", new QFilter[]{filter}); + if (zcgj_companybelong != null) { + this.getModel().setValue("zcgj_invoicetax", BigDecimal.ZERO, rowIndex); + this.getModel().setValue("zcgj_invoiceamount", dataEntity.get("zcgj_oftaxinvoiceamount"), rowIndex); + } + } } } } @@ -848,31 +882,33 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement // 运费行 - 设置运费发票号码 if (!freightInvoiceNumbers.isEmpty()) { String invoiceNumbersStr = String.join(",", freightInvoiceNumbers); - line.set("zcgj_invoicenoentry", invoiceNumbersStr); + line.set("zcgj_invoicenoentry", invoiceNumbersStr);// 发票号码 // 设置专票和抵扣字段 boolean isSpecialInvoice = checkIfSpecialInvoice(freightInvoiceNumbers, invoiceTypeMap); - line.set("zcgj_isspecialinvoice", isSpecialInvoice); - line.set("zcgj_offset", isSpecialInvoice); + line.set("zcgj_isspecialinvoice", isSpecialInvoice);// 专票 + boolean isSpecialInvoice2 = checkIfSpecialInvoice2(freightInvoiceNumbers, invoiceTypeMap); + line.set("zcgj_offset", isSpecialInvoice2);// 是否抵扣 } else { - line.set("zcgj_invoicenoentry", null); - line.set("zcgj_isspecialinvoice", false); - line.set("zcgj_offset", false); + line.set("zcgj_invoicenoentry", null);// 发票号码 + line.set("zcgj_isspecialinvoice", false);// 专票 + line.set("zcgj_offset", false);// 是否抵扣 } } else { // 非运费行 - 设置非运费发票号码 if (!nonFreightInvoiceNumbers.isEmpty()) { String invoiceNumbersStr = String.join(",", nonFreightInvoiceNumbers); - line.set("zcgj_invoicenoentry", invoiceNumbersStr); + line.set("zcgj_invoicenoentry", invoiceNumbersStr);// 发票号码 // 设置专票和抵扣字段 boolean isSpecialInvoice = checkIfSpecialInvoice(nonFreightInvoiceNumbers, invoiceTypeMap); - line.set("zcgj_isspecialinvoice", isSpecialInvoice); - line.set("zcgj_offset", isSpecialInvoice); + line.set("zcgj_isspecialinvoice", isSpecialInvoice);// 专票 + boolean isSpecialInvoice2 = checkIfSpecialInvoice2(nonFreightInvoiceNumbers, invoiceTypeMap); + line.set("zcgj_offset", isSpecialInvoice2);// 是否抵扣 } else { - line.set("zcgj_invoicenoentry", null); - line.set("zcgj_isspecialinvoice", false); - line.set("zcgj_offset", false); + line.set("zcgj_invoicenoentry", null);// 发票号码 + line.set("zcgj_isspecialinvoice", false);// 专票 + line.set("zcgj_offset", false);// 是否抵扣 } } } @@ -903,6 +939,41 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement return false; } + /** + * 检查发票列表中是否包含专票类型的发票 + * + * @param invoiceNumbers 发票号码列表 + * @param invoiceTypeMap 发票号码到发票对象的映射 + * @return 是否包含专票 + */ + private boolean checkIfSpecialInvoice2(List invoiceNumbers, Map invoiceTypeMap) { + //财务记账组织存在公司归属对应数据中,是否抵扣就全是false + DynamicObject fiaccountorg = (DynamicObject) this.getModel().getValue("fiaccountorg");//财务记账组织 + if (fiaccountorg != null) { + QFilter filter = new QFilter("zcgj_companyblentry.zcgj_org.id", QCP.equals, fiaccountorg.getPkValue()); + filter.and(new QFilter("number", QCP.equals, "001")); + filter.and(new QFilter("zcgj_companyblentry.zcgj_rateway", QCP.equals, true)); + DynamicObject zcgj_companybelong = QueryServiceHelper.queryOne("zcgj_companybelong", "number,zcgj_companyblentry.zcgj_wareunit", new QFilter[]{filter}); + if (zcgj_companybelong != null) { + return false; + } + } + for (String invoiceNumber : invoiceNumbers) { + DynamicObject invoice = invoiceTypeMap.get(invoiceNumber); + if (invoice != null) { + DynamicObject invoiceType = invoice.getDynamicObject("invoicetypeid"); // 发票类型字段 + if (invoiceType != null) { + String invoiceTypeName = invoiceType.getString("name"); // 发票类型名称 + // 当发票类型为"数电发票(增值税专用发票)"或"电子发票专票"时,认为是专票 + if ("数电发票(增值税专用发票)".equals(invoiceTypeName) || "电子发票专票".equals(invoiceTypeName)) { + return true; + } + } + } + } + return false; + } + /** * 按费用项目和税率组合合并费用汇总条目 *