入库单下推对公报销单发票信息补充
This commit is contained in:
parent
80e310deea
commit
48c0e86ff4
|
|
@ -7,9 +7,13 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.entity.ExtendedDataEntity;
|
import kd.bos.entity.ExtendedDataEntity;
|
||||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -37,12 +41,10 @@ public class MaterialinbillToNoContractBotpPlugin extends AbstractConvertPlugIn
|
||||||
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
||||||
Map<String,Long> invoiceEntryMap = new HashMap<String, Long>();//发票信息分录
|
Map<String,Long> invoiceEntryMap = new HashMap<String, Long>();//发票信息分录
|
||||||
Map<String,Long> expensEntryMap = new HashMap<String, Long>();//费用明细分录
|
Map<String,Long> expensEntryMap = new HashMap<String, Long>();//费用明细分录
|
||||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
Map<String,DynamicObject> invoiceDataEntryMap = new HashMap<String, DynamicObject>();//费用明细分录
|
||||||
for (DynamicObject invoice : invoiceentry) {
|
Map<String,DynamicObject> rimInvoiceDataEntryMap = new HashMap<String, DynamicObject>();//费用明细分录
|
||||||
String invoiceno = invoice.getString("invoiceno");
|
|
||||||
long aLong = invoice.getLong("id");
|
//费用明细信息分录
|
||||||
invoiceEntryMap.put(invoiceno, aLong);
|
|
||||||
}
|
|
||||||
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");
|
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");
|
||||||
for (DynamicObject expenseentry : expenseentryentity) {
|
for (DynamicObject expenseentry : expenseentryentity) {
|
||||||
String invoiceno = expenseentry.getString("invoiceno_entry");
|
String invoiceno = expenseentry.getString("invoiceno_entry");
|
||||||
|
|
@ -50,17 +52,82 @@ public class MaterialinbillToNoContractBotpPlugin extends AbstractConvertPlugIn
|
||||||
long aLong = expenseentry.getLong("id");
|
long aLong = expenseentry.getLong("id");
|
||||||
for (String invoiceNo : invoiceNos) {
|
for (String invoiceNo : invoiceNos) {
|
||||||
expensEntryMap.put(invoiceNo, aLong);
|
expensEntryMap.put(invoiceNo, aLong);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//发票信息分录
|
||||||
|
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||||
|
for (DynamicObject invoice : invoiceentry) {
|
||||||
|
String invoiceno = invoice.getString("invoiceno");
|
||||||
|
long aLong = invoice.getLong("id");
|
||||||
|
invoiceEntryMap.put(invoiceno, aLong);
|
||||||
|
invoiceDataEntryMap.put(invoiceno, invoice);
|
||||||
|
String serialno = invoice.getString("serialno");
|
||||||
|
DynamicObject rimInvoice = BusinessDataServiceHelper.loadSingle("rim_invoice", "id,unitprice,invoice_amount,total_tax_amount,deduction_flag",
|
||||||
|
new QFilter[]{new QFilter("serial_no","=",serialno)});
|
||||||
|
if(rimInvoice != null){
|
||||||
|
rimInvoiceDataEntryMap.put(invoiceno, rimInvoice);
|
||||||
|
String deductionFlag = rimInvoice.getString("deduction_flag");
|
||||||
|
if("1".equals(deductionFlag)){//可抵扣
|
||||||
|
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||||
|
invoice.set("offset_invoice",true);
|
||||||
|
}else{
|
||||||
|
invoice.set("offset_invoice",false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//发票明细分录
|
//发票明细分录
|
||||||
DynamicObjectCollection invoiceitementry = dataEntity.getDynamicObjectCollection("invoiceitementry");
|
DynamicObjectCollection invoiceitementry = dataEntity.getDynamicObjectCollection("invoiceitementry");
|
||||||
for (String invoiceno : expensEntryMap.keySet()) {
|
for (String invoiceno : invoiceEntryMap.keySet()) {//以发票信息为主
|
||||||
Long itemid = expensEntryMap.get(invoiceno);//费用明细分录id
|
Long itemid = expensEntryMap.get(invoiceno);//费用明细分录id
|
||||||
Long invoiceId = invoiceEntryMap.get(invoiceno);//发票信息分录id
|
Long invoiceId = invoiceEntryMap.get(invoiceno);//发票信息分录id
|
||||||
DynamicObject dynamicObject = invoiceitementry.addNew();//发票明细,费用明细和发票信息关联关系
|
DynamicObject dynamicObject = invoiceitementry.addNew();//发票明细,费用明细和发票信息关联关系
|
||||||
dynamicObject.set("itementryid", itemid);
|
dynamicObject.set("itementryid", itemid);
|
||||||
dynamicObject.set("invoiceheadentryid", invoiceId);
|
dynamicObject.set("invoiceheadentryid", invoiceId);
|
||||||
|
DynamicObject invoiceData = invoiceDataEntryMap.get(invoiceno);
|
||||||
|
DynamicObject rimInvoice = rimInvoiceDataEntryMap.get(invoiceno);
|
||||||
|
if(rimInvoice!=null){
|
||||||
|
BigDecimal invoiceAmount = rimInvoice.getBigDecimal("invoice_amount");//发票金额-不含税金额
|
||||||
|
|
||||||
|
//不含税单价 unitprice
|
||||||
|
dynamicObject.set("unitprice", invoiceAmount);
|
||||||
|
|
||||||
|
//不含税金额 excludeamount
|
||||||
|
dynamicObject.set("excludeamount", invoiceAmount);
|
||||||
|
|
||||||
|
//税额 invoiceitemtaxamout 发票信息
|
||||||
|
BigDecimal totalTaxAmount = rimInvoice.getBigDecimal("total_tax_amount");//发票税额
|
||||||
|
dynamicObject.set("invoiceitemtaxamout", totalTaxAmount);
|
||||||
|
|
||||||
|
//税率 invoiceitemtaxrate = 税额 ÷ 不含税金额
|
||||||
|
if(invoiceAmount.compareTo(BigDecimal.ZERO)!=0){
|
||||||
|
BigDecimal taxRate = totalTaxAmount.divide(invoiceAmount, 2, RoundingMode.HALF_UP);
|
||||||
|
dynamicObject.set("invoiceitemtaxrate", taxRate);
|
||||||
|
}
|
||||||
|
String deductionFlag = rimInvoice.getString("deduction_flag");
|
||||||
|
if("1".equals(deductionFlag)){//可抵扣
|
||||||
|
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||||
|
dynamicObject.set("invoiceitemoffset",true);
|
||||||
|
//发票抵扣 invoicecloudoffset 发票信息-是否抵扣 offset_invoice
|
||||||
|
dynamicObject.set("invoicecloudoffset",true);
|
||||||
|
}else{
|
||||||
|
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||||
|
dynamicObject.set("invoiceitemoffset",false);
|
||||||
|
//发票抵扣 invoicecloudoffset 发票信息-是否抵扣 offset_invoice
|
||||||
|
dynamicObject.set("invoicecloudoffset",false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//商品名称 goodsname 发票信息-商品名称 invoicegoodsname
|
||||||
|
String invoicegoodsname = invoiceData.getString("invoicegoodsname");
|
||||||
|
dynamicObject.set("goodsname", invoicegoodsname);
|
||||||
|
//税收分类编码 goodscode - 通过发票信息invoicealltaxcode 税收分类编码 查询 税收分类编码基础资料-合并编码er_taxclasscode-mergecode
|
||||||
|
//发票来源 invoicefrom1 发票信息-发票来源 1-发票云,2-OCR识别,3-商旅月结,5-采购商城
|
||||||
|
dynamicObject.set("invoicefrom1",invoiceData.getString("invoicefrom"));
|
||||||
|
|
||||||
}
|
}
|
||||||
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue