1.重写合同看板拉去合同结算数据逻辑
This commit is contained in:
parent
c342e7ca0a
commit
0aabbc73de
|
@ -0,0 +1,101 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.basedata.common.enums.DirectionEnum;
|
||||
import kd.ec.contract.common.enums.BillStatusEnum;
|
||||
import kd.ec.contract.common.enums.PayDirectionEnum;
|
||||
import kd.ec.contract.formplugin.DynamicContractViewUI;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DynamicContractViewUIExt extends DynamicContractViewUI {
|
||||
|
||||
/**
|
||||
* 重写合同看板拉去合同结算数据逻辑
|
||||
* @param contractId
|
||||
* @param payDirection
|
||||
*/
|
||||
@Override
|
||||
protected void updateSettle(Long contractId, String payDirection) {
|
||||
this.getModel().deleteEntryData("settleEntry");
|
||||
String settleBillId;
|
||||
String finalSettleBillId;
|
||||
if (PayDirectionEnum.IN.getValue().equals(payDirection)) {
|
||||
settleBillId = "ec_in_contract_settle";
|
||||
finalSettleBillId = "ec_in_finalsettle";
|
||||
} else {
|
||||
settleBillId = "ec_out_contract_settle";
|
||||
finalSettleBillId = "ec_out_finalsettle";
|
||||
}
|
||||
|
||||
QFilter finalSettleFilter = new QFilter("billstatus", "=", BillStatusEnum.AUDIT.getValue());
|
||||
finalSettleFilter.and("contract", "=", contractId);
|
||||
DynamicObject[] finalSettles = BusinessDataServiceHelper.load(finalSettleBillId, "id", new QFilter[]{finalSettleFilter});
|
||||
if (finalSettles != null && finalSettles.length > 0) {
|
||||
int index = this.getModel().createNewEntryRow("settleEntry");
|
||||
DynamicObject finalSettleBill = BusinessDataServiceHelper.loadSingle(finalSettles[0].getPkValue(), finalSettleBillId);
|
||||
DynamicObjectCollection settleDetailEntries = finalSettleBill.getDynamicObjectCollection("settledetailentry");
|
||||
BigDecimal thisSettleAmount = BigDecimal.ZERO;
|
||||
BigDecimal thisSettleOfTax = BigDecimal.ZERO;
|
||||
|
||||
for(DynamicObject settleDetailEntry : settleDetailEntries) {
|
||||
DynamicObject payItem = settleDetailEntry.getDynamicObject("payitem");
|
||||
BigDecimal coe = BigDecimal.ONE;
|
||||
if (payItem != null) {
|
||||
String direction = payItem.getString("direction");
|
||||
if (StringUtils.equals(direction, DirectionEnum.NON.getValue())) {
|
||||
coe = BigDecimal.ZERO;
|
||||
} else if (StringUtils.equals(direction, DirectionEnum.SUB.getValue())) {
|
||||
coe = coe.negate();
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal finalSettleAmount = settleDetailEntry.getBigDecimal("payitemfinalsettleamt");
|
||||
BigDecimal finalSettleOfTax = settleDetailEntry.getBigDecimal("payitemsettleoftax");
|
||||
BigDecimal settleAmount = settleDetailEntry.getBigDecimal("payitemsettleamt");
|
||||
BigDecimal settleOfTax = settleDetailEntry.getBigDecimal("itemsettleoftax");
|
||||
thisSettleAmount = thisSettleAmount.add(finalSettleAmount.subtract(settleAmount).multiply(coe));
|
||||
thisSettleOfTax = thisSettleOfTax.add(finalSettleOfTax.subtract(settleOfTax).multiply(coe));
|
||||
}
|
||||
|
||||
this.getModel().setValue("settleperiod", ResManager.loadKDString("合同决算", "DynamicContractViewUI_21", "ec-contract-formplugin", new Object[0]), index);
|
||||
this.getModel().setValue("settlenum", finalSettleBill.get("billno"), index);
|
||||
this.getModel().setValue("settlename", finalSettleBill.get("name"), index);
|
||||
this.getModel().setValue("settleamount", thisSettleAmount, index);
|
||||
this.getModel().setValue("settletax", thisSettleOfTax.subtract(thisSettleAmount), index);
|
||||
this.getModel().setValue("oftaxsettleamount", thisSettleOfTax, index);
|
||||
this.getModel().setValue("settlecreator", finalSettleBill.get("creator"), index);
|
||||
this.getModel().setValue("settlecreatdate", finalSettleBill.get("createtime"), index);
|
||||
this.getModel().setValue("isfinalsettle", true, index);
|
||||
}
|
||||
|
||||
QFilter filter = new QFilter("contract.id", "=", contractId);
|
||||
List<String> billstatusList = new ArrayList<>();
|
||||
billstatusList.add("C");
|
||||
billstatusList.add("D");
|
||||
filter.and(new QFilter("billstatus", QCP.in,billstatusList));
|
||||
DynamicObject[] settleContractCols = BusinessDataServiceHelper.load(settleBillId, "period.number,billno,billname,settleamount,taxamount,settleoftaxamount,creator,createtime", new QFilter[]{filter});
|
||||
|
||||
for(int i = 0; i < settleContractCols.length; ++i) {
|
||||
int index = this.getModel().createNewEntryRow("settleEntry");
|
||||
DynamicObject settleInfo = settleContractCols[i];
|
||||
this.getModel().setValue("settleperiod", settleInfo.get("period.number"), index);
|
||||
this.getModel().setValue("settlenum", settleInfo.get("billno"), index);
|
||||
this.getModel().setValue("settlename", settleInfo.get("billname"), index);
|
||||
this.getModel().setValue("settleamount", settleInfo.get("settleamount"), index);
|
||||
this.getModel().setValue("settletax", settleInfo.get("taxamount"), index);
|
||||
this.getModel().setValue("oftaxsettleamount", settleInfo.get("settleoftaxamount"), index);
|
||||
this.getModel().setValue("settlecreator", settleInfo.get("creator"), index);
|
||||
this.getModel().setValue("settlecreatdate", settleInfo.get("createtime"), index);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue