1.付款申请单实付金额根据付款申请单行号过滤反写功能开发
This commit is contained in:
parent
3f1eaa90c1
commit
f574bfb930
|
@ -49,7 +49,7 @@ public class PaymentapplyCopyPlugin extends AbstractBillPlugIn implements Plugi
|
||||||
for (int i = 0; i < entity.size(); i++) {
|
for (int i = 0; i < entity.size(); i++) {
|
||||||
DynamicObject dynamicObject = entity.get(i);
|
DynamicObject dynamicObject = entity.get(i);
|
||||||
DynamicObjectCollection dynamicObjectCollection = dynamicObject.getDynamicObjectCollection("subentryentity");
|
DynamicObjectCollection dynamicObjectCollection = dynamicObject.getDynamicObjectCollection("subentryentity");
|
||||||
if(dynamicObjectCollection != null || !dynamicObjectCollection.isEmpty()){
|
if(dynamicObjectCollection != null && !dynamicObjectCollection.isEmpty()){
|
||||||
this.getView().setEnable(false,i,"thisapplyoftax");
|
this.getView().setEnable(false,i,"thisapplyoftax");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,214 @@
|
||||||
|
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
import kd.bos.entity.EntityMetadataCache;
|
||||||
|
import kd.bos.entity.MainEntityType;
|
||||||
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
|
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.DeleteServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.ec.contract.opplugin.fund.PaymentRegisterFundOp;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PaymentRegisterFundOpExt extends PaymentRegisterFundOp {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(PaymentRegisterFundOpExt.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||||
|
String operationKey = e.getOperationKey();
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
switch (operationKey) {
|
||||||
|
case "audit":
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的审核操作,开始更新合同,付款类型实付金额");
|
||||||
|
this.updateContTypeAmtTotalRealAmt(dataEntities);
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的审核操作,完成更新合同,付款类型实付金额");
|
||||||
|
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的审核操作,开始更新请款单实付金额");
|
||||||
|
this.updateInApplyRealPayAmt(dataEntities, true);
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的审核操作,完成更新请款单实付金额");
|
||||||
|
break;
|
||||||
|
case "unaudit":
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的反审核操作,开始更新合同,付款类型实付金额");
|
||||||
|
this.updateContTypeAmtTotalRealAmtWhenUnAudit(dataEntities);
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的反审核操作,完成更新合同,付款类型实付金额");
|
||||||
|
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的反审核操作,开始更新请款单实付金额");
|
||||||
|
this.updateInApplyRealPayAmt(dataEntities, false);
|
||||||
|
log.info("执行PaymentRegisterFundOpExt的反审核操作,完成更新请款单实付金额");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateInApplyRealPayAmt(DynamicObject[] dataEntities, boolean isAudit) {
|
||||||
|
// super.updateInApplyRealPayAmt(dataEntities, isAudit);
|
||||||
|
BigDecimal ratio = BigDecimal.ONE;
|
||||||
|
if (!isAudit) {
|
||||||
|
ratio = BigDecimal.ZERO.subtract(ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(DynamicObject object : dataEntities) {
|
||||||
|
Long referregisterid = object.getLong("referregisterid");//关联登记单id(付款处理单Id)
|
||||||
|
QFilter paybillFilter = new QFilter("id", "=", referregisterid);
|
||||||
|
//付款处理单
|
||||||
|
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", "entry,entry.e_corebillentryseq", new QFilter[]{paybillFilter});
|
||||||
|
Set<Integer> payBillSer = new HashSet<>();
|
||||||
|
if(paybill!=null){
|
||||||
|
for (DynamicObject dynamicObject : paybill.getDynamicObjectCollection("entry")) {
|
||||||
|
int corebillentryseq = dynamicObject.getInt("e_corebillentryseq");//核心单据行号
|
||||||
|
payBillSer.add(corebillentryseq);
|
||||||
|
log.info("执行PaymentRegisterFundOpExt:付款处理单涉及核心单据行号:"+corebillentryseq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(DynamicObject entry : object.getDynamicObjectCollection("entryentity")) { //付款登记单 付款信息
|
||||||
|
DynamicObject paymentApplyF7 = entry.getDynamicObject("paymentapply");//付款登记单关联 付款申请单
|
||||||
|
DynamicObject contract = entry.getDynamicObject("contract");//付款登记单关联 合同
|
||||||
|
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount"); //付款登记单 本次实付金额
|
||||||
|
|
||||||
|
thisOfTaxAmt = thisOfTaxAmt.multiply(ratio);
|
||||||
|
String payType = entry.getString("paytype"); //支付类型
|
||||||
|
if (paymentApplyF7 != null) {
|
||||||
|
QFilter paymentApplyFilter = new QFilter("id", "=", paymentApplyF7.getLong("id"));
|
||||||
|
DynamicObject paymentApply = BusinessDataServiceHelper.loadSingle("ec_paymentapply", "realpayamt,billcompletepay,ismulticurrency,exchangerate,stdrealpayamt,entryentity,entryentity.seq,contract,paymenttype,applyoftaxamount,thisrealpayamt,thiswaitpayamt,completepay", new QFilter[]{paymentApplyFilter});
|
||||||
|
DynamicObjectCollection paymentEntryCol = paymentApply.getDynamicObjectCollection("entryentity");//付款申请单分录
|
||||||
|
boolean billcompletepay = true;
|
||||||
|
|
||||||
|
for(DynamicObject paymentEntry : paymentEntryCol) {
|
||||||
|
String applyPayType = paymentEntry.getString("paymenttype");
|
||||||
|
DynamicObject applyContract = paymentEntry.getDynamicObject("contract");
|
||||||
|
int seq = paymentEntry.getInt("seq"); //付款申请单分录行号
|
||||||
|
if (contract != null && applyContract != null
|
||||||
|
&& StringUtils.equals(contract.getString("id"), applyContract.getString("id"))
|
||||||
|
&& StringUtils.equals(payType, applyPayType)
|
||||||
|
&& payBillSer.contains(seq)
|
||||||
|
) {
|
||||||
|
log.info("执行PaymentRegisterFundOpExt:付款申请单分录行号和付款处理单核心单据分录行号匹配成功");
|
||||||
|
BigDecimal oldRealPayAmt = paymentEntry.getBigDecimal("thisrealpayamt");
|
||||||
|
BigDecimal applyOfTaxAmount = paymentEntry.getBigDecimal("applyoftaxamount");
|
||||||
|
BigDecimal thisRealPayAmt = oldRealPayAmt.add(thisOfTaxAmt);
|
||||||
|
BigDecimal thisWaitPayAmt = applyOfTaxAmount.subtract(thisRealPayAmt);
|
||||||
|
paymentEntry.set("thisrealpayamt", thisRealPayAmt);
|
||||||
|
paymentEntry.set("thiswaitpayamt", thisWaitPayAmt);
|
||||||
|
if (thisRealPayAmt.compareTo(applyOfTaxAmount) >= 0) {
|
||||||
|
paymentEntry.set("completepay", true);
|
||||||
|
} else {
|
||||||
|
paymentEntry.set("completepay", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal totalRealpayAmt = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
for(DynamicObject inComeEntry : paymentEntryCol) {
|
||||||
|
if (!inComeEntry.getBoolean("completepay")) {
|
||||||
|
billcompletepay = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalRealpayAmt = totalRealpayAmt.add(inComeEntry.getBigDecimal("thisrealpayamt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paymentApply.getBoolean("ismulticurrency")) {
|
||||||
|
BigDecimal exchangerate = paymentApply.getBigDecimal("exchangerate");
|
||||||
|
BigDecimal stdRealPayAmt = totalRealpayAmt.multiply(exchangerate);
|
||||||
|
paymentApply.set("stdrealpayamt", stdRealPayAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
paymentApply.set("realpayamt", totalRealpayAmt);
|
||||||
|
paymentApply.set("billcompletepay", billcompletepay);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{paymentApply});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContTypeAmtTotalRealAmt(DynamicObject[] dataEntities) {
|
||||||
|
//super.updateContTypeAmtTotalRealAmt(dataEntities);
|
||||||
|
for(DynamicObject object : dataEntities) {
|
||||||
|
for(DynamicObject entry : object.getDynamicObjectCollection("entryentity")) {
|
||||||
|
DynamicObject contract = entry.getDynamicObject("contract");
|
||||||
|
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
|
||||||
|
String type = entry.getString("paytype");
|
||||||
|
QFilter contractFilter = new QFilter("contract", "=", contract.getLong("id"));
|
||||||
|
QFilter typeFilter = new QFilter("type", "=", type);
|
||||||
|
DynamicObject node = entry.getDynamicObject("paynode");
|
||||||
|
String nodeText = entry.getString("paynodetext");
|
||||||
|
if (node != null) {
|
||||||
|
typeFilter.and("paynode", "=", node.getPkValue());
|
||||||
|
} else if (StringUtils.isNotEmpty(nodeText)) {
|
||||||
|
typeFilter.and("node", "=", nodeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalrealamt", new QFilter[]{contractFilter, typeFilter});
|
||||||
|
if (contTypeAmts != null && contTypeAmts.length != 0) {
|
||||||
|
for(DynamicObject contTypeAmt : contTypeAmts) {
|
||||||
|
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
|
||||||
|
contTypeAmt.set("totalrealamt", totalRealAmt.add(thisOfTaxAmt));
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveServiceHelper.save(contTypeAmts);
|
||||||
|
} else {
|
||||||
|
BigDecimal payRate = entry.getBigDecimal("controlrate");
|
||||||
|
MainEntityType entityType = EntityMetadataCache.getDataEntityType("ecpf_conttypeamt");
|
||||||
|
DynamicObject newContTypeAmtObj = new DynamicObject(entityType);
|
||||||
|
newContTypeAmtObj.set("contract", contract);
|
||||||
|
newContTypeAmtObj.set("type", type);
|
||||||
|
newContTypeAmtObj.set("ratio", payRate);
|
||||||
|
newContTypeAmtObj.set("totalrealamt", thisOfTaxAmt);
|
||||||
|
newContTypeAmtObj.set("paynode", entry.get("paynode"));
|
||||||
|
newContTypeAmtObj.set("node", entry.get("paynode") == null ? entry.get("paynodetext") : "");
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{newContTypeAmtObj});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContTypeAmtTotalRealAmtWhenUnAudit(DynamicObject[] dataEntities) {
|
||||||
|
//super.updateContTypeAmtTotalRealAmtWhenUnAudit(dataEntities);
|
||||||
|
for(DynamicObject object : dataEntities) {
|
||||||
|
for(DynamicObject entry : object.getDynamicObjectCollection("entryentity")) {
|
||||||
|
DynamicObject contract = entry.getDynamicObject("contract");
|
||||||
|
BigDecimal thisOfTaxAmt = entry.getBigDecimal("thispaymentoftaxamount");
|
||||||
|
String type = entry.getString("paytype");
|
||||||
|
QFilter contractFilter = new QFilter("contract", "=", contract.getLong("id"));
|
||||||
|
QFilter typeFilter = new QFilter("type", "=", type);
|
||||||
|
DynamicObject node = entry.getDynamicObject("paynode");
|
||||||
|
String nodeText = entry.getString("paynodetext");
|
||||||
|
if (node != null) {
|
||||||
|
typeFilter.and("paynode", "=", node.getPkValue());
|
||||||
|
} else if (StringUtils.isNotEmpty(nodeText)) {
|
||||||
|
typeFilter.and("node", "=", nodeText);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject[] contTypeAmts = BusinessDataServiceHelper.load("ecpf_conttypeamt", "totalrealamt,totalshowamt,ratio,source", new QFilter[]{contractFilter, typeFilter});
|
||||||
|
if (contTypeAmts != null && contTypeAmts.length != 0) {
|
||||||
|
for(DynamicObject contTypeAmt : contTypeAmts) {
|
||||||
|
BigDecimal totalRealAmt = contTypeAmt.getBigDecimal("totalrealamt");
|
||||||
|
String source = contTypeAmt.getString("source");
|
||||||
|
contTypeAmt.set("totalrealamt", totalRealAmt.subtract(thisOfTaxAmt));
|
||||||
|
if (StringUtils.isBlank(source) && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalshowamt")) == 0 && BigDecimal.ZERO.compareTo(contTypeAmt.getBigDecimal("totalrealamt")) == 0) {
|
||||||
|
DeleteServiceHelper.delete("ecpf_conttypeamt", new QFilter[]{new QFilter("id", "=", contTypeAmt.getLong("id"))});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveServiceHelper.save(contTypeAmts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue