传BIP逻辑修改
This commit is contained in:
parent
26450f80d0
commit
19d5ef28d2
|
@ -4,10 +4,15 @@ import kd.bos.bill.AbstractBillPlugIn;
|
|||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.form.events.ClientCallBackEvent;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.macc.sca.algox.task.ServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +36,8 @@ public class SumInvoiceEntryPlugin extends AbstractBillPlugIn implements Plugin
|
|||
BigDecimal notaxamt = inventry_invoicebill.getBigDecimal("notaxamt");
|
||||
BigDecimal tax = inventry_invoicebill.getBigDecimal("tax");
|
||||
BigDecimal amount = inventry_invoicebill.getBigDecimal("amount");
|
||||
//新增字段赋值
|
||||
addFieldsRule(dynamicObject,inventry_invoicebill);
|
||||
dynamicObject.set("qeug_notaxamt",notaxamt);
|
||||
dynamicObject.set("qeug_tax",tax);
|
||||
dynamicObject.set("qeug_amount",amount);
|
||||
|
@ -39,6 +46,30 @@ public class SumInvoiceEntryPlugin extends AbstractBillPlugIn implements Plugin
|
|||
}
|
||||
}
|
||||
|
||||
private void addFieldsRule(DynamicObject dynamicObject,DynamicObject invoiceBill) {
|
||||
//本次核销不含税金额
|
||||
BigDecimal notTaxAmount;
|
||||
//本次核销金额的税额
|
||||
BigDecimal taxAmount;
|
||||
Object pkValue = invoiceBill.getPkValue();
|
||||
BigDecimal hasWriteOffAmt = dynamicObject.getBigDecimal("inventry_haswriteoffamt");
|
||||
DynamicObject reconInvoiceBill = BusinessDataServiceHelper.loadSingle(pkValue, "recon_invoicebill");
|
||||
if (reconInvoiceBill != null) {
|
||||
DynamicObjectCollection invoiceDetails = reconInvoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||
if (invoiceDetails!=null && invoiceDetails.size()!=0){
|
||||
DynamicObject entry_taxrate = invoiceDetails.get(0).getDynamicObject("entry_taxrate");
|
||||
BigDecimal taxrate = entry_taxrate.getBigDecimal("taxrate");
|
||||
//本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率)
|
||||
notTaxAmount=hasWriteOffAmt.divide(taxrate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP);
|
||||
//本次核销金额的税额=含税金额(本次核销金额) - 本次核销不含税金额
|
||||
taxAmount = hasWriteOffAmt.subtract(notTaxAmount).setScale(2, RoundingMode.HALF_UP);
|
||||
dynamicObject.set("qeug_amountfield",notTaxAmount);
|
||||
dynamicObject.set("qeug_inventry_haswriteoff",taxAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
||||
super.afterDoOperation(args);
|
||||
|
|
|
@ -652,61 +652,66 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
items.put("notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额
|
||||
items.put("local_notax_de",payRequestInfo.getBigDecimal("notaxamt").toString());//组织本币无税金额
|
||||
} else {
|
||||
// 税额
|
||||
// 税额=本次核销税额累加(只针对专票);
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
//无税金额(专普混合:专票无税+普票价税合计)
|
||||
//不含税金额(专普混合:专票本次核销不含税金额累加+普票用本次核销金额进行累加)
|
||||
BigDecimal notTaxAmount = BigDecimal.ZERO;
|
||||
// 税率相关变量
|
||||
BigDecimal commonTaxRate = null;
|
||||
Long commonTaxRateId = null;
|
||||
boolean hasDifferentTaxRates = false;
|
||||
//本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率)
|
||||
BigDecimal entryNotTaxAmount;
|
||||
//本次核销金额的税额=含税金额(本次核销金额) - 本次核销不含税金额
|
||||
//BigDecimal entryTaxAmount = BigDecimal.ZERO;
|
||||
|
||||
// 遍历发票
|
||||
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||
DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill");
|
||||
if (invoiceBillF7!=null){
|
||||
if (invoiceBillF7!=null) {
|
||||
Object pkValue = invoiceBillF7.getPkValue();
|
||||
DynamicObject invoiceBill = BusinessDataServiceHelper.loadSingle(pkValue, "recon_invoicebill");
|
||||
if (invoiceBill != null) {
|
||||
//表头不含税
|
||||
BigDecimal notTax=invoiceBill.getBigDecimal("notaxamt");
|
||||
//表头价税合计
|
||||
BigDecimal amount=invoiceBill.getBigDecimal("amount");
|
||||
//本次核销金额
|
||||
BigDecimal hasWriteOffAmt = invoiceObj.getBigDecimal("inventry_haswriteoffamt");
|
||||
|
||||
// 判断【发票登记-发票类型-名称】
|
||||
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||
if (invoice != null) {
|
||||
String invoiceName = invoice.getString("name");
|
||||
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||
notTaxAmount=notTaxAmount.add(notTax);
|
||||
// 发票登记-发票明细
|
||||
|
||||
taxAmount = taxAmount.add(hasWriteOffAmt);
|
||||
|
||||
|
||||
// 发票登记-发票明细————————只有一行
|
||||
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||
if (invoiceDetails != null && invoiceDetails.size() != 0) {
|
||||
for (DynamicObject invoiceDetail : invoiceDetails) {
|
||||
BigDecimal entryTax = invoiceDetail.getBigDecimal("entry_tax");
|
||||
// 税额累加
|
||||
taxAmount = taxAmount.add(entryTax);
|
||||
// 处理税率
|
||||
DynamicObject entryTaxRate = invoiceDetails.get(0).getDynamicObject("entry_taxrate");
|
||||
if (entryTaxRate != null) {
|
||||
Long currentTaxRateId = (Long) entryTaxRate.getPkValue();
|
||||
BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate");
|
||||
//本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率)
|
||||
entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP);
|
||||
// 专票不含税=本次核销不含税金额累加
|
||||
// 本次核销不含税金额累加
|
||||
notTaxAmount=notTaxAmount.add(entryNotTaxAmount);
|
||||
|
||||
// 处理税率
|
||||
DynamicObject entryTaxRate = invoiceDetail.getDynamicObject("entry_taxrate");
|
||||
if (entryTaxRate != null) {
|
||||
Long currentTaxRateId = (Long) entryTaxRate.getPkValue();
|
||||
BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate");
|
||||
|
||||
// 第一次遇到税率,记录下来
|
||||
if (commonTaxRateId == null) {
|
||||
commonTaxRateId = currentTaxRateId;
|
||||
commonTaxRate = currentTaxRate;
|
||||
}
|
||||
// 后续遇到不同的税率,标记为不一致
|
||||
else if (!commonTaxRateId.equals(currentTaxRateId)) {
|
||||
hasDifferentTaxRates = true;
|
||||
}
|
||||
// 第一次遇到税率,记录下来
|
||||
if (commonTaxRateId == null) {
|
||||
commonTaxRateId = currentTaxRateId;
|
||||
commonTaxRate = currentTaxRate;
|
||||
}
|
||||
// 后续遇到不同的税率,标记为不一致
|
||||
else if (!commonTaxRateId.equals(currentTaxRateId)) {
|
||||
hasDifferentTaxRates = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
notTaxAmount=notTaxAmount.add(amount);
|
||||
}
|
||||
}else{
|
||||
notTaxAmount=notTaxAmount.add(hasWriteOffAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -773,14 +778,18 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
}
|
||||
}
|
||||
else {
|
||||
// 税额
|
||||
// 税额=本次核销税额累加(只针对专票);
|
||||
BigDecimal taxAmount = BigDecimal.ZERO;
|
||||
//无税金额(专普混合:专票无税+普票价税合计)
|
||||
//不含税金额(专普混合:专票本次核销不含税金额累加+普票用本次核销金额进行累加)
|
||||
BigDecimal notTaxAmount = BigDecimal.ZERO;
|
||||
// 税率相关变量
|
||||
BigDecimal commonTaxRate = null;
|
||||
Long commonTaxRateId = null;
|
||||
boolean hasDifferentTaxRates = false;
|
||||
//本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率)
|
||||
BigDecimal entryNotTaxAmount;
|
||||
//本次核销金额的税额=含税金额(本次核销金额) - 本次核销不含税金额
|
||||
//BigDecimal entryTaxAmount = BigDecimal.ZERO;
|
||||
|
||||
// 遍历发票
|
||||
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||
|
@ -789,29 +798,31 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
Object pkValue = invoiceBillF7.getPkValue();
|
||||
DynamicObject invoiceBill = BusinessDataServiceHelper.loadSingle(pkValue, "recon_invoicebill");
|
||||
if (invoiceBill != null) {
|
||||
//表头不含税
|
||||
BigDecimal notTax=invoiceBill.getBigDecimal("notaxamt");
|
||||
//表头价税合计
|
||||
BigDecimal amount=invoiceBill.getBigDecimal("amount");
|
||||
//本次核销金额
|
||||
BigDecimal hasWriteOffAmt = invoiceObj.getBigDecimal("inventry_haswriteoffamt");
|
||||
|
||||
// 判断【发票登记-发票类型-名称】
|
||||
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||
if (invoice != null) {
|
||||
String invoiceName = invoice.getString("name");
|
||||
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||
notTaxAmount=notTaxAmount.add(notTax);
|
||||
// 发票登记-发票明细
|
||||
|
||||
taxAmount = taxAmount.add(hasWriteOffAmt);
|
||||
|
||||
|
||||
// 发票登记-发票明细————————只有一行
|
||||
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||
if (invoiceDetails != null && invoiceDetails.size() != 0) {
|
||||
for (DynamicObject invoiceDetail : invoiceDetails) {
|
||||
BigDecimal entryTax = invoiceDetail.getBigDecimal("entry_tax");
|
||||
// 税额累加
|
||||
taxAmount = taxAmount.add(entryTax);
|
||||
// 处理税率
|
||||
DynamicObject entryTaxRate = invoiceDetail.getDynamicObject("entry_taxrate");
|
||||
DynamicObject entryTaxRate = invoiceDetails.get(0).getDynamicObject("entry_taxrate");
|
||||
if (entryTaxRate != null) {
|
||||
Long currentTaxRateId = (Long) entryTaxRate.getPkValue();
|
||||
BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate");
|
||||
//本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率)
|
||||
entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP);
|
||||
// 专票不含税=本次核销不含税金额累加
|
||||
// 本次核销不含税金额累加
|
||||
notTaxAmount=notTaxAmount.add(entryNotTaxAmount);
|
||||
|
||||
// 第一次遇到税率,记录下来
|
||||
if (commonTaxRateId == null) {
|
||||
|
@ -823,10 +834,10 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
|||
hasDifferentTaxRates = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
notTaxAmount=notTaxAmount.add(amount);
|
||||
notTaxAmount=notTaxAmount.add(hasWriteOffAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue