支出合同结算新增合同支付项明细后将对应不同分录拆分至工序分摊中

This commit is contained in:
xuhaihui 2025-08-06 11:15:56 +08:00
parent e8065649b1
commit e404ee6e60
2 changed files with 134 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
@ -49,6 +51,7 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{
DynamicObject contract = (DynamicObject)changeData.getNewValue();
this.clearUnitproject();
this.contractChanged(contract);
this.clearOrNewProcessAlloc();//清除或者新增工序分摊分录
} else if (StringUtils.equals(name, "period")) {
this.periodChanged(changeData);
} else if (!StringUtils.equals(name, "begindate") && !StringUtils.equals(name, "enddate")) {
@ -158,7 +161,7 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{
this.getModel().setValue("taxamt",taxamt,rowIndex);
SettleUpdateAmtUtils.setItemEntrySumAmt(this.getView());
SettleUpdateAmtUtils.calAllTypeAmount(this.getModel());
}
private void clearUnitproject() {
@ -168,4 +171,43 @@ public class ContractSettleBillPlugin extends ContractSettleCommonEditPlugin{
}
private void clearOrNewProcessAlloc() {
DynamicObjectCollection payItemDetailEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("payitemdetailentry");//合同支付项明细
DynamicObjectCollection itemEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//支付项分录
if (itemEntryCollection.size() == 0) {
return;
}
if (payItemDetailEntryCollection.size() > 0) {
for (DynamicObject payItemDetailEntry : payItemDetailEntryCollection) {
DynamicObject itemEntry = itemEntryCollection.get(0);
DynamicObjectCollection processAllocEntityCollection = itemEntry.getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊
DynamicObjectType processAllocEntityType = processAllocEntityCollection.getDynamicObjectType();
long referBillId = payItemDetailEntry.getLong("referbillid");//关联单据id
DynamicObject EcOutContractMeasure = BusinessDataServiceHelper.loadSingle(referBillId, "ec_outcontractmeasure");//支出合同计量
if (EcOutContractMeasure != null) {
DynamicObjectCollection ListModelEntryCollection = EcOutContractMeasure.getDynamicObjectCollection("listmodelentry");//模板分录
for (DynamicObject ListModelEntry : ListModelEntryCollection) {
DynamicObjectCollection listEntryCollection = ListModelEntry.getDynamicObjectCollection("listentry");//清单分录
for (DynamicObject listEntry : listEntryCollection) {
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_process", listEntry.get("listcbs"));//工序-成本分解结构
newProcessAllocEntity.set("zcgj_pa_amount", listEntry.get("thisoftaxmount"));//价税合计-本期计量含税金额
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
processAllocEntityCollection.add(newProcessAllocEntity);
}
}
}
}
this.getView().updateView("zcgj_processallocatentity");//工序分摊
} else {
itemEntryCollection.clear();
this.getView().updateView("itementry");//支付项分录
this.getView().updateView("zcgj_processallocatentity");//工序分摊分录
}
}
}

View File

@ -0,0 +1,91 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
import kd.bos.entity.datamodel.RowDataEntity;
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.EventObject;
/*
* 使用插件注册位置支出合同结算表单插件
* 说明新增合同支付项明细后将对应不同分录拆分至工序分摊中
*/
public class CostAllocatorBillPlugin extends AbstractFormPlugin {
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
this.addItemClickListeners("payitemdetaitoolap");//合同支付项明细工具栏
}
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
String itemKey = evt.getItemKey();
if (itemKey.equals("advconbaritemap3")) {
//合同支付项明细删除按钮
DynamicObjectCollection payItemDetailEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("payitemdetailentry");//合同支付项明细
DynamicObjectCollection itemEntryCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");//支付项分录
if (itemEntryCollection.size() == 0) {
return;
}
if (payItemDetailEntryCollection.size() > 0) {
for (DynamicObject payItemDetailEntry : payItemDetailEntryCollection) {
DynamicObject itemEntry = itemEntryCollection.get(0);
DynamicObjectCollection processAllocEntityCollection = itemEntry.getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊
processAllocEntityCollection.clear();
DynamicObjectType processAllocEntityType = processAllocEntityCollection.getDynamicObjectType();
long referBillId = payItemDetailEntry.getLong("referbillid");//关联单据id
DynamicObject EcOutContractMeasure = BusinessDataServiceHelper.loadSingle(referBillId, "ec_outcontractmeasure");//支出合同计量
if (EcOutContractMeasure != null) {
DynamicObjectCollection ListModelEntryCollection = EcOutContractMeasure.getDynamicObjectCollection("listmodelentry");//模板分录
for (DynamicObject ListModelEntry : ListModelEntryCollection) {
DynamicObjectCollection listEntryCollection = ListModelEntry.getDynamicObjectCollection("listentry");//清单分录
for (DynamicObject listEntry : listEntryCollection) {
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_process", listEntry.get("listcbs"));//工序-成本分解结构
newProcessAllocEntity.set("zcgj_pa_amount", listEntry.get("thisoftaxmount"));//价税合计-本期计量含税金额
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
processAllocEntityCollection.add(newProcessAllocEntity);
}
}
}
}
this.getView().updateView("zcgj_processallocatentity");//工序分摊
} else {
DynamicObjectCollection processAllocEntityCollection = itemEntryCollection.get(0).getDynamicObjectCollection("zcgj_processallocatentity");//工序分摊分录
processAllocEntityCollection.clear();
this.getView().updateView("itementry");//支付项分录
this.getView().updateView("zcgj_processallocatentity");//工序分摊分录
}
}
}
@Override
public void afterAddRow(AfterAddRowEventArgs e) {
super.afterAddRow(e);
// RowDataEntity[] rowDataEntities = e.getRowDataEntities();
// System.out.println();
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
// if ("totalsettleoftaxamount".equals(name)) {
// //关联单据
// System.out.println();
// }
}
}