优化企业成本核算
This commit is contained in:
parent
c260c57ac7
commit
38c396170d
|
|
@ -277,8 +277,8 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements Before
|
||||||
if (costType1 == null) return -1;
|
if (costType1 == null) return -1;
|
||||||
if (costType2 == null) return 1;
|
if (costType2 == null) return 1;
|
||||||
|
|
||||||
String str1 = costType1.toString().trim();
|
String str1 = cleanCostType(costType1.toString().trim());
|
||||||
String str2 = costType2.toString().trim();
|
String str2 = cleanCostType(costType2.toString().trim());
|
||||||
|
|
||||||
Integer sortValue1 = COST_TYPE_SORT_MAP.get(str1);
|
Integer sortValue1 = COST_TYPE_SORT_MAP.get(str1);
|
||||||
Integer sortValue2 = COST_TYPE_SORT_MAP.get(str2);
|
Integer sortValue2 = COST_TYPE_SORT_MAP.get(str2);
|
||||||
|
|
@ -289,14 +289,31 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements Before
|
||||||
|
|
||||||
return sortValue1.compareTo(sortValue2);
|
return sortValue1.compareTo(sortValue2);
|
||||||
});
|
});
|
||||||
|
// 手动将 "10." 的条目移到最前面
|
||||||
|
List<DynamicObject> firstEntries = new ArrayList<>();
|
||||||
|
List<DynamicObject> otherEntries = new ArrayList<>();
|
||||||
|
|
||||||
// 按排序后的顺序添加数据,且跳过成本项为空的分录行
|
|
||||||
for (DynamicObject entry : sortedEntries) {
|
for (DynamicObject entry : sortedEntries) {
|
||||||
|
Object costtype = entry.get("costtype");
|
||||||
|
String cleaned = cleanCostType(costtype != null ? costtype.toString() : "");
|
||||||
|
if ("10.".equals(cleaned)) {
|
||||||
|
firstEntries.add(entry);
|
||||||
|
} else {
|
||||||
|
otherEntries.add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并:先放 "10." 的条目,再放其他
|
||||||
|
List<DynamicObject> finalEntries = new ArrayList<>();
|
||||||
|
finalEntries.addAll(firstEntries);
|
||||||
|
finalEntries.addAll(otherEntries);
|
||||||
|
|
||||||
|
// 按排序后的顺序添加数据
|
||||||
|
for (DynamicObject entry : finalEntries) {
|
||||||
Object costtype = entry.get("costtype");
|
Object costtype = entry.get("costtype");
|
||||||
if (costtype == null) {
|
if (costtype == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
entry.set("comment", costtype);
|
|
||||||
entryCollection.add(entry);
|
entryCollection.add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,4 +360,21 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn implements Before
|
||||||
COST_TYPE_SORT_MAP.put("90.", 90);//财务费用
|
COST_TYPE_SORT_MAP.put("90.", 90);//财务费用
|
||||||
COST_TYPE_SORT_MAP.put("100.", 100);//研发支出
|
COST_TYPE_SORT_MAP.put("100.", 100);//研发支出
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String cleanCostType(String type) {
|
||||||
|
if (type == null || type.isEmpty()) return "";
|
||||||
|
// 去除前后空格
|
||||||
|
type = type.trim();
|
||||||
|
// 如果是 "10.0"、"10.00" 等,转换为 "10."
|
||||||
|
if (type.matches("^\\d+\\.\\d+$")) {
|
||||||
|
String[] parts = type.split("\\.");
|
||||||
|
return parts[0] + ".";
|
||||||
|
}
|
||||||
|
// 如果是纯数字,加个点
|
||||||
|
if (type.matches("^\\d+$")) {
|
||||||
|
return type + ".";
|
||||||
|
}
|
||||||
|
// 其他情况保持原样
|
||||||
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue