支出合同结算单冲销功能开发

This commit is contained in:
zhangzhiguo 2025-06-03 17:51:23 +08:00
parent cafbb26049
commit 52de5652ce
5 changed files with 194 additions and 5 deletions

View File

@ -6,23 +6,19 @@ import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.BizDataEventArgs;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.Control;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.events.HyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickListener;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.report.ReportList;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.contract.common.enums.DirectionEnum;
import kd.sdk.plugin.Plugin;
import javax.swing.event.HyperlinkListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.EventObject;

View File

@ -0,0 +1,75 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.BillShowParameter;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
/**
* 支出合同结算-冲销操作插件
*/
public class OutContractSettleReversalListPlugin extends AbstractListPlugin implements Plugin {
private static final Log log = LogFactory.getLog(OutContractSettleReversalListPlugin.class);
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
String itemKey = evt.getItemKey();
if("zcgj_reversal".equals(itemKey)) {
BillList billList = this.getView().getControl(AbstractListPlugin.BILLLISTID);
//获取到选中行的数据
ListSelectedRowCollection selectedRows = billList.getSelectedRows();
if(selectedRows.isEmpty()){
this.getView().showTipNotification(String.format("请选择要冲销的数据。"));
return;
}
if(selectedRows.size() > 1){
this.getView().showTipNotification(String.format("请选择单个数据进行冲销操作。。"));
return;
}
for (ListSelectedRow selectedRow : selectedRows) {
BillShowParameter showParameter = new BillShowParameter();
String billStatus = selectedRow.getBillStatus();
if("C".equals(billStatus)){
Long contractSettleId = (Long)selectedRow.getPrimaryKeyValue();//支出合同结算id
String billNo = selectedRow.getBillNo();
QFilter accountTableFilter = new QFilter("zcgj_reversabillid", QCP.equals,String.valueOf(contractSettleId));
DynamicObject data = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", "id,number,zcgj_is_reversabillid", new QFilter[]{accountTableFilter});
if(data != null){ //财务确认单
this.getView().showTipNotification(String.format("当前结算单已冲销,无法再次冲销。"));
return;
}else{
QFilter idFilter = new QFilter("id", QCP.equals,contractSettleId);
DynamicObject selectData = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", "id,number,zcgj_is_reversabillid", new QFilter[]{idFilter});
if(selectData.getBoolean("zcgj_is_reversabillid")){
this.getView().showTipNotification(String.format("当前为冲销单据,无法再次冲销。"));
return;
}
showParameter.setCustomParam("reversabillid", contractSettleId);
//showParameter.setPkId(contractSettleId);
showParameter.setFormId("ec_out_contract_settle");
showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); //打开方式
getView().showForm(showParameter);
}
}else{
this.getView().showTipNotification(String.format("只有已审核通过的数据才可进行冲销操作。"));
return;
}
}
}
}
}

View File

@ -0,0 +1,105 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.bill.BillShowParameter;
import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.events.HyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickListener;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.contract.common.enums.DirectionEnum;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.EventObject;
/**
* 支出合同结算单冲销
*/
public class OutContractSettleReversalPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
//如果是新增时
BillShowParameter bsp=(BillShowParameter)this.getView().getFormShowParameter();
if(bsp.getStatus()== OperationStatus.ADDNEW ){
// 获取当前页面的FormShowParameter对象
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
if(formShowParameter.getCustomParam("reversabillid")!=null){
// 获取自定义参数
Object contractSettleIdObj = formShowParameter.getCustomParam("reversabillid");
if (contractSettleIdObj != null) {
initData(contractSettleIdObj);
this.getView().setEnable(false,"contract","org","period","begindate","enddate");
//this.getView().invokeOperation("save");
}
}
}
}
public void initData(Object contractSettleIdObj){
QFilter accountTableFilter = new QFilter("id", QCP.equals,(Long)contractSettleIdObj);
DynamicObject ecoutcontractsettle = BusinessDataServiceHelper.loadSingle("ec_out_contract_settle", new QFilter[]{accountTableFilter});
getModel().setValue("zcgj_reversabillid",ecoutcontractsettle.getLong("id"));
getModel().setValue("billname",ecoutcontractsettle.getString("billname")+"-冲销");
getModel().setValue("contract",ecoutcontractsettle.getDynamicObject("contract"));
getModel().setValue("contattr",ecoutcontractsettle.getDynamicObject("contattr"));
getModel().setValue("project",ecoutcontractsettle.getDynamicObject("project"));
getModel().setValue("period",ecoutcontractsettle.getDynamicObject("period"));
getModel().setValue("begindate",ecoutcontractsettle.getDate("begindate"));
getModel().setValue("enddate",ecoutcontractsettle.getDate("enddate"));
getModel().setValue("conttotaloftaxamount",ecoutcontractsettle.getBigDecimal("conttotaloftaxamount"));
getModel().setValue("description","冲销-"+ecoutcontractsettle.getString("billno"));
getModel().setValue("currency",ecoutcontractsettle.getDynamicObject("currency"));
getModel().setValue("zcgj_jscustomer",ecoutcontractsettle.getDynamicObject("zcgj_jscustomer"));
getModel().setValue("isonlist",ecoutcontractsettle.getBoolean("isonlist"));
getModel().setValue("isincost",ecoutcontractsettle.getBoolean("isincost"));
getModel().setValue("zcgj_adjustmounttax",ecoutcontractsettle.getBoolean("zcgj_adjustmounttax"));
getModel().setValue("zcgj_is_reversabillid",true);
DynamicObjectCollection itementry = ecoutcontractsettle.getDynamicObjectCollection("itementry");
////DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("zcgj_itementry");
DynamicObjectCollection entryEntity1 = this.getModel().getDataEntity(true).getDynamicObjectCollection("itementry");
entryEntity1.clear();
BigDecimal settleamount = BigDecimal.ZERO;
BigDecimal taxamount = BigDecimal.ZERO;
BigDecimal settleoftaxamount = BigDecimal.ZERO;
for (DynamicObject dynamicObject : itementry) {
DynamicObject item = entryEntity1.addNew();
item.set("payitem",dynamicObject.getDynamicObject("payitem"));
BigDecimal oftaxamount = dynamicObject.getBigDecimal("oftaxamount").multiply(new BigDecimal("-1"));
item.set("oftaxamount",oftaxamount);
BigDecimal amount = dynamicObject.getBigDecimal("amount").multiply(new BigDecimal("-1"));
item.set("amount",amount);
item.set("rate",dynamicObject.getBigDecimal("rate"));
BigDecimal taxamt = dynamicObject.getBigDecimal("taxamt").multiply(new BigDecimal("-1"));
item.set("taxamt",taxamt);
item.set("remark",dynamicObject.getString("remark"));
settleamount = settleamount.add(amount);
taxamount = taxamount.add(taxamt);
settleoftaxamount = settleoftaxamount.add(oftaxamount);
}
getModel().setValue("settleamount",settleamount);
getModel().setValue("taxamount",taxamount);
getModel().setValue("settleoftaxamount",settleoftaxamount);
if(ecoutcontractsettle.getBoolean("isonlist")){
this.getView().setVisible(false,"zcgj_adjustmounttax");
}
this.getView().updateView("itementry");
}
}

View File

@ -2,7 +2,9 @@ package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.ec.basedata.business.model.BaseConstant;
import kd.ec.contract.opplugin.OutContractSettleOp;
import kd.ec.contract.opplugin.validator.OutContractSettleValidator;
@ -10,6 +12,13 @@ import java.util.List;
public class OutContractSettlementOp extends OutContractSettleOp {
@Override
public void onPreparePropertys(PreparePropertysEventArgs e) {
super.onPreparePropertys(e);
List<String> fields = e.getFieldKeys();
fields.add("zcgj_is_reversabillid");
}
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);

View File

@ -20,7 +20,11 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
@Override
protected boolean validateSettleAmount(ExtendedDataEntity dataEntity) {
{
DynamicObject dataEntity1 = dataEntity.getDataEntity();
if(dataEntity1.getBoolean("zcgj_is_reversabillid")){
return true;
}
DynamicObjectCollection listmodelentrys = dataEntity1.getDynamicObjectCollection("listmodelentry");//分录
for (DynamicObject payitemdetailentry : dataEntity1.getDynamicObjectCollection("payitemdetailentry")) {
long referbillid = payitemdetailentry.getLong("referbillid");
@ -87,7 +91,7 @@ public class OutContractSettlementValidator extends OutContractSettleValidator {
}
}
}
OperationResult saveOperationResult = SaveServiceHelper.saveOperate(dataEntity1.getDataEntityType().getName(), new DynamicObject[]{dataEntity1}, null);//项目实体
// OperationResult saveOperationResult = SaveServiceHelper.saveOperate(dataEntity1.getDataEntityType().getName(), new DynamicObject[]{dataEntity1}, null);//项目实体
BigDecimal settleOfTaxAmount = dataEntity.getDataEntity().getBigDecimal("settleoftaxamount");
DynamicObject contractTemp = dataEntity.getDataEntity().getDynamicObject("contract");