发票信息传输BIP新增发票类型+发票号码拼接
This commit is contained in:
parent
9cca6ddc84
commit
8c4261311f
|
@ -25,6 +25,10 @@ import okhttp3.*;
|
||||||
import shkd.utils.DobeDWUtils;
|
import shkd.utils.DobeDWUtils;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -661,6 +665,8 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
Long commonTaxRateId = null;
|
Long commonTaxRateId = null;
|
||||||
boolean hasDifferentTaxRates = false;
|
boolean hasDifferentTaxRates = false;
|
||||||
|
|
||||||
|
// 新增:用于存储发票类型和号码的映射关系
|
||||||
|
Map<String, Set<String>> invoiceTypeToNumbersMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
// 遍历发票
|
// 遍历发票
|
||||||
for (DynamicObject invoiceObj : invoiceEntry) {
|
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||||
|
@ -676,6 +682,14 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||||
if (invoice != null) {
|
if (invoice != null) {
|
||||||
String invoiceName = invoice.getString("name");
|
String invoiceName = invoice.getString("name");
|
||||||
|
String invoiceNo = invoiceBill.getString("invoiceno");
|
||||||
|
// 新增:收集发票类型和号码信息
|
||||||
|
if (invoiceName != null && invoiceNo != null) {
|
||||||
|
// 专票在前处理:如果包含"专用"则放在前面,否则放在后面
|
||||||
|
String typeKey = invoiceName.contains("专用") ? "1_" + invoiceName : "2_" + invoiceName;
|
||||||
|
invoiceTypeToNumbersMap.computeIfAbsent(typeKey, k -> new LinkedHashSet<>()).add(invoiceNo);
|
||||||
|
}
|
||||||
|
|
||||||
if (invoiceName != null && invoiceName.contains("专用")) {
|
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||||
// 发票登记-发票明细————————只有一行
|
// 发票登记-发票明细————————只有一行
|
||||||
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||||
|
@ -741,6 +755,30 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
items.put("taxcodeid", "CN07");
|
items.put("taxcodeid", "CN07");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增:构建发票类型和号码的拼接字符串
|
||||||
|
if (!invoiceTypeToNumbersMap.isEmpty()) {
|
||||||
|
StringBuilder def4Builder = new StringBuilder();
|
||||||
|
|
||||||
|
// 按照排序处理(专票在前)
|
||||||
|
invoiceTypeToNumbersMap.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.comparingByKey())
|
||||||
|
.forEach(entry -> {
|
||||||
|
String typeName = entry.getKey().substring(2); // 去掉排序前缀
|
||||||
|
Set<String> numbers = entry.getValue();
|
||||||
|
|
||||||
|
if (def4Builder.length() > 0) {
|
||||||
|
def4Builder.append(",");
|
||||||
|
}
|
||||||
|
def4Builder.append(typeName).append(":").append(String.join(",", numbers));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 截取200字符
|
||||||
|
String def4Value = def4Builder.toString();
|
||||||
|
if (def4Value.length() > 200) {
|
||||||
|
def4Value = def4Value.substring(0, 200);
|
||||||
|
}
|
||||||
|
items.put("def4", def4Value);
|
||||||
|
}
|
||||||
|
|
||||||
if("unaudit".equals(eventName)){
|
if("unaudit".equals(eventName)){
|
||||||
//如果此时是反审核,则需要将金额置为负数
|
//如果此时是反审核,则需要将金额置为负数
|
||||||
|
@ -782,6 +820,9 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
Long commonTaxRateId = null;
|
Long commonTaxRateId = null;
|
||||||
boolean hasDifferentTaxRates = false;
|
boolean hasDifferentTaxRates = false;
|
||||||
|
|
||||||
|
// 新增:用于存储发票类型和号码的映射关系
|
||||||
|
Map<String, Set<String>> invoiceTypeToNumbersMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
// 遍历发票
|
// 遍历发票
|
||||||
for (DynamicObject invoiceObj : invoiceEntry) {
|
for (DynamicObject invoiceObj : invoiceEntry) {
|
||||||
DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill");
|
DynamicObject invoiceBillF7 = invoiceObj.getDynamicObject("inventry_invoicebill");
|
||||||
|
@ -795,6 +836,13 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
DynamicObject invoice = invoiceBill.getDynamicObject("invoice");
|
||||||
if (invoice != null) {
|
if (invoice != null) {
|
||||||
String invoiceName = invoice.getString("name");
|
String invoiceName = invoice.getString("name");
|
||||||
|
String invoiceNo = invoiceBill.getString("invoiceno");
|
||||||
|
// 新增:收集发票类型和号码信息
|
||||||
|
if (invoiceName != null && invoiceNo != null) {
|
||||||
|
// 专票在前处理:如果包含"专用"则放在前面,否则放在后面
|
||||||
|
String typeKey = invoiceName.contains("专用") ? "1_" + invoiceName : "2_" + invoiceName;
|
||||||
|
invoiceTypeToNumbersMap.computeIfAbsent(typeKey, k -> new LinkedHashSet<>()).add(invoiceNo);
|
||||||
|
}
|
||||||
if (invoiceName != null && invoiceName.contains("专用")) {
|
if (invoiceName != null && invoiceName.contains("专用")) {
|
||||||
// 发票登记-发票明细————————只有一行
|
// 发票登记-发票明细————————只有一行
|
||||||
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry");
|
||||||
|
@ -860,6 +908,32 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen
|
||||||
items.put("taxcodeid", "CN07");
|
items.put("taxcodeid", "CN07");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增:构建发票类型和号码的拼接字符串
|
||||||
|
if (!invoiceTypeToNumbersMap.isEmpty()) {
|
||||||
|
StringBuilder def4Builder = new StringBuilder();
|
||||||
|
|
||||||
|
// 按照排序处理(专票在前)
|
||||||
|
invoiceTypeToNumbersMap.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.comparingByKey())
|
||||||
|
.forEach(entry -> {
|
||||||
|
String typeName = entry.getKey().substring(2); // 去掉排序前缀
|
||||||
|
Set<String> numbers = entry.getValue();
|
||||||
|
|
||||||
|
if (def4Builder.length() > 0) {
|
||||||
|
def4Builder.append(",");
|
||||||
|
}
|
||||||
|
def4Builder.append(typeName).append(":").append(String.join(",", numbers));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 截取200字符
|
||||||
|
String def4Value = def4Builder.toString();
|
||||||
|
if (def4Value.length() > 200) {
|
||||||
|
def4Value = def4Value.substring(0, 200);
|
||||||
|
}
|
||||||
|
items.put("def4", def4Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if("unaudit".equals(eventName)){
|
if("unaudit".equals(eventName)){
|
||||||
//如果此时是反审核,则需要将金额置为负数
|
//如果此时是反审核,则需要将金额置为负数
|
||||||
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
items.put("local_tax_de","-"+items.getString("local_tax_de"));
|
||||||
|
|
Loading…
Reference in New Issue