diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillSubmitValidatorOp.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillSubmitValidatorOp.java index 8a8292c..50154e6 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillSubmitValidatorOp.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/operate/MaterialInBillSubmitValidatorOp.java @@ -12,7 +12,8 @@ import java.math.BigDecimal; /** * 入库单提交操作校验插件 - * 说明:校验存在发票时,看无运费发票按钮是否开启,不开启校验含运费金额,开启只校验金额 + * 说明:1:校验存在发票时,看无运费发票按钮是否开启,不开启校验含运费金额,开启只校验金额 + * 2:上传的发票中含有普票时,提交时校验入库单明细中必须有“增值税0%”的税率 */ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlugIn { public void onPreparePropertys(PreparePropertysEventArgs e) { @@ -35,6 +36,8 @@ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlu e.getFieldKeys().add("mataxamount"); e.getFieldKeys().add("zcgj_freight_invoice"); e.getFieldKeys().add("zcgj_no_invoice"); + e.getFieldKeys().add("zcgj_invoice"); + e.getFieldKeys().add("entrytaxrate"); } @Override @@ -52,6 +55,31 @@ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlu boolean zcgj_no_invoice = ecma_MaterialInBill.getBoolean("zcgj_no_invoice");//无物资发票 DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息 DynamicObjectCollection entryEntity2Collection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录 + + int zeroTaxRateEntryCount = 0; + boolean hasNonSpecialInvoice = false; + for (DynamicObject entryEntity : entryEntityCollection) { + DynamicObject invoice = entryEntity.getDynamicObject("zcgj_invoice"); // 发票号码 + if (invoice == null) continue; + DynamicObject invoiceTypeId = invoice.getDynamicObject("invoicetypeid"); // 发票类型 + if (invoiceTypeId == null) continue; + String invoiceTypeIdName = invoiceTypeId.getString("name"); + if (!invoiceTypeIdName.contains("专")) { + hasNonSpecialInvoice = true; + for (DynamicObject entryEntity2 : entryEntity2Collection) { + DynamicObject entryTaxRate = entryEntity2.getDynamicObject("entrytaxrate"); // 税率名称 + if (entryTaxRate != null && "增值税0%".equals(entryTaxRate.getString("name"))) { + zeroTaxRateEntryCount++; + break; + } + } + } + } + if (hasNonSpecialInvoice && zeroTaxRateEntryCount == 0) { + this.addFatalErrorMessage(extendedDataEntity, "系统检测到上传的发票中存在普通发票,入库单明细中凡是涉及普票的物资,”税率名称“请选择”增值税0%”!!"); + } + + if (!zcgj_no_invoice && entryEntity2Collection != null && entryEntity2Collection.size() > 0) { String invoice_type = ecma_MaterialInBill.getString("zcgj_invoice_type");//发票类型 boolean zcgj_notraninvoice = ecma_MaterialInBill.getBoolean("zcgj_notraninvoice");//无运费发票 @@ -103,7 +131,7 @@ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlu BigDecimal invoiceTax = entryEntity.getBigDecimal("zcgj_invoicetax"); // 合同进项发票信息-税额 boolean zcgj_freight_invoice = entryEntity.getBoolean("zcgj_freight_invoice"); //运费发票 if (zcgj_freight_invoice) { - break; + continue; } if (invoiceTotal != null) { totalInvoiceTotal = totalInvoiceTotal.add(invoiceTotal);