入库单优化提交校验逻辑
This commit is contained in:
parent
8f1137f022
commit
bb78e36319
|
|
@ -12,7 +12,7 @@ import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库单提交操作校验插件
|
* 入库单提交操作校验插件
|
||||||
* 说明:校验存在发票时,发票分录中的金额税额和价税合计与入库单明细中的金额税额和含税金额是否一致
|
* 说明:校验存在发票时,看无运费发票按钮是否开启,不开启校验含运费金额,开启只校验金额
|
||||||
*/
|
*/
|
||||||
public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlugIn {
|
public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlugIn {
|
||||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
|
@ -29,6 +29,11 @@ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlu
|
||||||
e.getFieldKeys().add("totaltaxamount");
|
e.getFieldKeys().add("totaltaxamount");
|
||||||
e.getFieldKeys().add("totaloftaxamount");
|
e.getFieldKeys().add("totaloftaxamount");
|
||||||
e.getFieldKeys().add("zcgj_invoice_type");
|
e.getFieldKeys().add("zcgj_invoice_type");
|
||||||
|
e.getFieldKeys().add("zcgj_notraninvoice");
|
||||||
|
e.getFieldKeys().add("matoftaxamount");
|
||||||
|
e.getFieldKeys().add("matamount");
|
||||||
|
e.getFieldKeys().add("mataxamount");
|
||||||
|
e.getFieldKeys().add("zcgj_freight_invoice");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -45,57 +50,81 @@ public class MaterialInBillSubmitValidatorOp extends AbstractOperationServicePlu
|
||||||
DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity();
|
DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity();
|
||||||
DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息
|
DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("zcgj_entryentity");//合同进项发票信息
|
||||||
DynamicObjectCollection entryEntity2Collection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
|
DynamicObjectCollection entryEntity2Collection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
|
||||||
String invoice_type = ecma_MaterialInBill.getString("zcgj_invoice_type");//发票类型
|
|
||||||
if (entryEntityCollection != null && entryEntityCollection.size() > 0 && entryEntity2Collection != null && entryEntity2Collection.size() > 0) {
|
if (entryEntityCollection != null && entryEntityCollection.size() > 0 && entryEntity2Collection != null && entryEntity2Collection.size() > 0) {
|
||||||
|
String invoice_type = ecma_MaterialInBill.getString("zcgj_invoice_type");//发票类型
|
||||||
|
boolean zcgj_notraninvoice = ecma_MaterialInBill.getBoolean("zcgj_notraninvoice");//无运费发票
|
||||||
|
|
||||||
BigDecimal totalInvoiceAmount = BigDecimal.ZERO; // 发票总金额(不含税
|
if (!zcgj_notraninvoice) {
|
||||||
BigDecimal totalInvoiceTax = BigDecimal.ZERO; // 发票总税额
|
BigDecimal totalInvoiceTotal = BigDecimal.ZERO; // 发票总价税合计
|
||||||
BigDecimal totalInvoiceTotal = BigDecimal.ZERO; // 发票总价税合计
|
BigDecimal totalInvoiceAmount = BigDecimal.ZERO; // 发票总金额(不含税
|
||||||
|
BigDecimal totalInvoiceTax = BigDecimal.ZERO; // 发票总税额
|
||||||
|
BigDecimal totalEntryTotal = ecma_MaterialInBill.getBigDecimal("totaloftaxamount"); // 入库含税总金额
|
||||||
|
BigDecimal totalEntryAmount = ecma_MaterialInBill.getBigDecimal("totalamount"); // 入库总金额(不含税
|
||||||
|
BigDecimal totalEntryTax = ecma_MaterialInBill.getBigDecimal("totaltaxamount"); // 入库单总税额
|
||||||
|
|
||||||
BigDecimal totalEntryAmount = ecma_MaterialInBill.getBigDecimal("totalamount"); // 入库总金额(不含税
|
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||||
BigDecimal totalEntryTax = ecma_MaterialInBill.getBigDecimal("totaltaxamount"); // 入库单总税额
|
BigDecimal invoiceTotal = entryEntity.getBigDecimal("zcgj_oftaxinvoiceamount"); // 合同进项发票信息-价税合计
|
||||||
BigDecimal totalEntryTotal = ecma_MaterialInBill.getBigDecimal("totaloftaxamount"); // 入库含税总金额
|
BigDecimal invoiceAmount = entryEntity.getBigDecimal("zcgj_invoiceamount"); // 合同进项发票信息-金额
|
||||||
|
BigDecimal invoiceTax = entryEntity.getBigDecimal("zcgj_invoicetax"); // 合同进项发票信息-税额
|
||||||
for (DynamicObject entryEntity : entryEntityCollection) {
|
if (invoiceTotal != null) {
|
||||||
BigDecimal invoiceAmount = entryEntity.getBigDecimal("zcgj_invoiceamount"); // 合同进项发票信息-金额
|
totalInvoiceTotal = totalInvoiceTotal.add(invoiceTotal);
|
||||||
BigDecimal invoiceTax = entryEntity.getBigDecimal("zcgj_invoicetax"); // 合同进项发票信息-税额
|
}
|
||||||
BigDecimal invoiceTotal = entryEntity.getBigDecimal("zcgj_oftaxinvoiceamount"); // 合同进项发票信息-价税合计
|
if (invoiceAmount != null) {
|
||||||
if (invoiceAmount != null) {
|
totalInvoiceAmount = totalInvoiceAmount.add(invoiceAmount);
|
||||||
totalInvoiceAmount = totalInvoiceAmount.add(invoiceAmount);
|
}
|
||||||
|
if (invoiceTax != null) {
|
||||||
|
totalInvoiceTax = totalInvoiceTax.add(invoiceTax);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (invoiceTax != null) {
|
if (totalInvoiceTotal.compareTo(totalEntryTotal) != 0) {
|
||||||
totalInvoiceTax = totalInvoiceTax.add(invoiceTax);
|
this.addFatalErrorMessage(extendedDataEntity, "入库含税总金额与合同进项发票信息价税合计汇总不匹配!");
|
||||||
}
|
}
|
||||||
if (invoiceTotal != null) {
|
if (invoice_type != null && invoice_type.equals("1")) {
|
||||||
totalInvoiceTotal = totalInvoiceTotal.add(invoiceTotal);
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (totalInvoiceAmount.compareTo(totalEntryAmount) != 0) {
|
||||||
/* for (DynamicObject entryEntity2 : entryEntity2Collection) {
|
this.addFatalErrorMessage(extendedDataEntity, "入库总金额与合同进项发票信息金额汇总不匹配!");
|
||||||
BigDecimal notaxAmount = entryEntity2.getBigDecimal("amount"); // 入库单-含运费金额(不含税)
|
|
||||||
BigDecimal taxAmount = entryEntity2.getBigDecimal("taxamount").add(entryEntity2.getBigDecimal("zcgj_transtaxamount")); // 入库单-税额+运费税额
|
|
||||||
BigDecimal oftaxAmount = entryEntity2.getBigDecimal("amount").add(entryEntity2.getBigDecimal("taxtransamount")); // 入库单-含税金额+含税运费
|
|
||||||
|
|
||||||
if (notaxAmount != null) {
|
|
||||||
totalEntryAmount = totalEntryAmount.add(notaxAmount);
|
|
||||||
}
|
}
|
||||||
if (taxAmount != null) {
|
if (totalInvoiceTax.compareTo(totalEntryTax) != 0) {
|
||||||
totalEntryTax = totalEntryTax.add(taxAmount);
|
this.addFatalErrorMessage(extendedDataEntity, "税额与合同进项发票信息税额汇总不匹配!");
|
||||||
}
|
}
|
||||||
if (oftaxAmount != null) {
|
} else {
|
||||||
totalEntryTotal = totalEntryTotal.add(oftaxAmount);
|
BigDecimal totalInvoiceTotal = BigDecimal.ZERO; // 发票总价税合计(不含运费发票
|
||||||
|
BigDecimal totalInvoiceAmount = BigDecimal.ZERO; // 发票总金额(不含税)(不含运费发票
|
||||||
|
BigDecimal totalInvoiceTax = BigDecimal.ZERO; // 发票总税额(不含运费发票
|
||||||
|
BigDecimal totalEntryTotal = ecma_MaterialInBill.getBigDecimal("matoftaxamount"); // 材料含税总金额
|
||||||
|
BigDecimal totalEntryAmount = ecma_MaterialInBill.getBigDecimal("matamount"); // 材料总金额
|
||||||
|
BigDecimal totalEntryTax = ecma_MaterialInBill.getBigDecimal("mataxamount"); // 材料总税额
|
||||||
|
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||||
|
BigDecimal invoiceTotal = entryEntity.getBigDecimal("zcgj_oftaxinvoiceamount"); // 合同进项发票信息-价税合计
|
||||||
|
BigDecimal invoiceAmount = entryEntity.getBigDecimal("zcgj_invoiceamount"); // 合同进项发票信息-金额
|
||||||
|
BigDecimal invoiceTax = entryEntity.getBigDecimal("zcgj_invoicetax"); // 合同进项发票信息-税额
|
||||||
|
boolean zcgj_freight_invoice = entryEntity.getBoolean("zcgj_freight_invoice"); //运费发票
|
||||||
|
if (zcgj_freight_invoice) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (invoiceTotal != null) {
|
||||||
|
totalInvoiceTotal = totalInvoiceTotal.add(invoiceTotal);
|
||||||
|
}
|
||||||
|
if (invoiceAmount != null) {
|
||||||
|
totalInvoiceAmount = totalInvoiceAmount.add(invoiceAmount);
|
||||||
|
}
|
||||||
|
if (invoiceTax != null) {
|
||||||
|
totalInvoiceTax = totalInvoiceTax.add(invoiceTax);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (totalInvoiceTotal.compareTo(totalEntryTotal) != 0) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "入库含税总金额与合同进项发票信息价税合计汇总不匹配!");
|
||||||
|
}
|
||||||
|
if (invoice_type != null && invoice_type.equals("1")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (totalInvoiceAmount.compareTo(totalEntryAmount) != 0) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "入库总金额与合同进项发票信息金额汇总不匹配!");
|
||||||
|
}
|
||||||
|
if (totalInvoiceTax.compareTo(totalEntryTax) != 0) {
|
||||||
|
this.addFatalErrorMessage(extendedDataEntity, "税额与合同进项发票信息税额汇总不匹配!");
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
if (totalInvoiceTotal.compareTo(totalEntryTotal) != 0) {
|
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "入库含税总金额与合同进项发票信息价税合计汇总不匹配!");
|
|
||||||
}
|
|
||||||
if (invoice_type != null && invoice_type.equals("1")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (totalInvoiceAmount.compareTo(totalEntryAmount) != 0) {
|
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "入库总金额与合同进项发票信息金额汇总不匹配!");
|
|
||||||
}
|
|
||||||
if (totalInvoiceTax.compareTo(totalEntryTax) != 0) {
|
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "税额与合同进项发票信息税额汇总不匹配!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue