企业成本核算表单插件获取数据优化子分录取数与分录取数逻辑
This commit is contained in:
parent
b18d4b68ee
commit
8a8d012064
|
@ -61,6 +61,12 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
Map<String, DynamicObject> summaryMap = new HashMap<>();
|
||||
|
||||
for (DynamicObject rptAssistBalanceGx : rptAssistBalanceGxCollection) {
|
||||
Object debitLocal = rptAssistBalanceGx.get("zcgj_debitlocal");//本期发生借方
|
||||
if (debitLocal == null ||
|
||||
(debitLocal instanceof BigDecimal && ((BigDecimal) debitLocal).compareTo(BigDecimal.ZERO) <= 0) ||
|
||||
(debitLocal instanceof String && ((String) debitLocal).equals("0"))) {
|
||||
continue;
|
||||
}
|
||||
QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, rptAssistBalanceGx.get("zcgj_account"))};//科目ID
|
||||
DynamicObject bd_accountview = BusinessDataServiceHelper.loadSingle("bd_accountview",
|
||||
"id,number,name", qFilter);//"会计科目"
|
||||
|
@ -103,12 +109,18 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
if (existingEntry != null) {
|
||||
// 如果已存在相同key的记录,则累加成本金额
|
||||
Object existingAmount = existingEntry.get("costamount");
|
||||
Object newAmount = rptAssistBalanceGx.get("zcgj_debitlocal");
|
||||
Object newAmount = rptAssistBalanceGx.get("zcgj_debitlocal");//本期发生借方
|
||||
|
||||
// 进行金额累加
|
||||
BigDecimal totalAmount = new BigDecimal(existingAmount != null ? existingAmount.toString() : "0")
|
||||
.add(new BigDecimal(newAmount != null ? newAmount.toString() : "0"));
|
||||
existingEntry.set("costamount", totalAmount);
|
||||
|
||||
// 同时更新子分录的金额
|
||||
DynamicObject subEntry = existingEntry.getDynamicObjectCollection("zcgj_subentryentity").get(0);
|
||||
if (subEntry != null) {
|
||||
subEntry.set("zcgj_costamount", totalAmount);
|
||||
}
|
||||
} else {
|
||||
// 如果不存在相同key的记录,则创建新记录
|
||||
DynamicObject newEntry = new DynamicObject(entryType);
|
||||
|
@ -146,6 +158,7 @@ public class EntCostSplitBillPlugin extends AbstractBillPlugIn {
|
|||
newEntrySubEntryEntity.set("zcgj_sectype1", zcgj_accountcost.get("zcgj_acccostentry.zcgj_sectype"));//二级分类
|
||||
}
|
||||
newEntry.set("costamount", rptAssistBalanceGx.get("zcgj_debitlocal"));//成本金额
|
||||
newEntrySubEntryEntity.set("zcgj_costamount", rptAssistBalanceGx.get("zcgj_debitlocal"));//成本金额
|
||||
|
||||
summaryMap.put(uniqueKey, newEntry);
|
||||
subEntryEntityCollection.add(newEntrySubEntryEntity);
|
||||
|
|
Loading…
Reference in New Issue