1.付款申请单实付金额根据付款申请单行号过滤反写功能开发
This commit is contained in:
parent
c467e552df
commit
ed193c4279
|
@ -1,65 +0,0 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.LoadDataEventArgs;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.ec.contract.formplugin.PaymentApplyEditUI;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 重新计算费用申请单的实付金额值
|
||||
*/
|
||||
public class PaymentApplyEditUIExtPlugin extends PaymentApplyEditUI {
|
||||
|
||||
@Override
|
||||
protected void thisApplyOfTaxChanged(ChangeData changeData) {
|
||||
|
||||
this.sumApplyOfTax();
|
||||
this.setRealPayAmt();
|
||||
if (this.getPageCache().get("thisApplyAmountCache") != null) {
|
||||
this.getPageCache().remove("thisApplyAmountCache");
|
||||
} else {
|
||||
int rowIndex = changeData.getRowIndex();
|
||||
if (!this.hasInvoice(rowIndex)) {
|
||||
this.setShouldPayOfTax(rowIndex);
|
||||
BigDecimal applyOfTaxAmount = (BigDecimal)changeData.getNewValue();
|
||||
BigDecimal taxRate = (BigDecimal)this.getModel().getValue("conttaxrate", rowIndex);
|
||||
BigDecimal applyAmount = applyOfTaxAmount.divide(BigDecimal.ONE.add(taxRate.divide(BigDecimal.valueOf(100L), 4)), 10, 5);
|
||||
this.getPageCache().put("thisApplyOfTaxCache", "1");
|
||||
this.getModel().setValue("thisapplyamount", applyAmount, rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setRealPayAmt() {
|
||||
DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity().getDynamicObjectCollection("entryentity");
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
Set<String> contractNo = new HashSet<>();
|
||||
for (DynamicObject dynamicObject : dynamicObjectCollection) {
|
||||
DynamicObject contract = dynamicObject.getDynamicObject("contract");
|
||||
if(contract != null) {
|
||||
String billno = contract.getString("id");
|
||||
if(!contractNo.contains(billno)) {
|
||||
totalAmount = dynamicObject.getBigDecimal("thisrealpayamt");
|
||||
contractNo.add(billno);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getModel().setValue("zcgj_realpayamt", totalAmount);
|
||||
this.getView().updateView("zcgj_realpayamt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLoadData(EventObject e) {
|
||||
this.setRealPayAmt();
|
||||
super.afterLoadData(e);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 反写工程-项目资金-付款申请单的实际付款
|
||||
*/
|
||||
public class PaymentapplySetRealpayamtOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("entryentity");
|
||||
e.getFieldKeys().add("zcgj_realpayamt");
|
||||
e.getFieldKeys().add("sourcebilltype");
|
||||
e.getFieldKeys().add("sourcebillnumber");
|
||||
e.getFieldKeys().add("sourcebillid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
if(dataEntities!=null && dataEntities.length>0){
|
||||
DynamicObject object = dataEntities[0];
|
||||
String sourcebilltype = object.getString("sourcebilltype");
|
||||
if("ec_paymentapply".equals(sourcebilltype)){//如果上游单据是工程-项目资金-付款申请单
|
||||
String sourcebillnumber = object.getString("sourcebillnumber");//源单编码
|
||||
String sourcebillid = object.getString("sourcebillid");//源单id
|
||||
QFilter numberFilter = new QFilter("billno", QCP.equals,sourcebillnumber);//筛选出属性number=zcgjAccounttableNumber的结果
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(sourcebilltype, "id,number,zcgj_realpayamt,entryentity.contract,entryentity.thisrealpayamt", new QFilter[]{numberFilter});
|
||||
DynamicObjectCollection dynamicObjectCollection = dynamicObject.getDynamicObjectCollection("entryentity");
|
||||
Set<String> contractNo = new HashSet<>();
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (DynamicObject entryentity : dynamicObjectCollection) {
|
||||
DynamicObject contract = entryentity.getDynamicObject("contract");
|
||||
if(contract != null) {
|
||||
String billno = contract.getString("id");
|
||||
if(!contractNo.contains(billno)) {
|
||||
totalAmount = entryentity.getBigDecimal("thisrealpayamt");
|
||||
contractNo.add(billno);
|
||||
}
|
||||
}
|
||||
}
|
||||
BigDecimal realpayamt = dynamicObject.getBigDecimal("zcgj_realpayamt");
|
||||
if(realpayamt!=null){
|
||||
totalAmount = totalAmount.add(realpayamt);
|
||||
}
|
||||
dynamicObject.set("zcgj_realpayamt", totalAmount);
|
||||
|
||||
Object[] save = SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue