结算接口
This commit is contained in:
parent
9e941f281b
commit
2efcf9557f
|
|
@ -0,0 +1,87 @@
|
||||||
|
package tqq9.lc123.cloud.app.plugin.operate.ap;
|
||||||
|
|
||||||
|
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.fi.arapcommon.api.param.ServiceNameEnum;
|
||||||
|
import kd.fi.arapcommon.api.param.SettleResult;
|
||||||
|
import kd.fi.arapcommon.api.settle.ISettleService;
|
||||||
|
import kd.fi.arapcommon.factory.ArApServiceAPIFactory;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 财务应付单审核调用接口结算
|
||||||
|
*/
|
||||||
|
public class ApFinApBillOp extends AbstractOperationServicePlugIn {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
e.getFieldKeys().add("org");
|
||||||
|
e.getFieldKeys().add("planentity.plancorebilltype");
|
||||||
|
e.getFieldKeys().add("planentity.plancorebillno");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||||
|
super.afterExecuteOperationTransaction(e);
|
||||||
|
DynamicObject[] dataEntities1 = e.getDataEntities();
|
||||||
|
for (DynamicObject dynamicObject : dataEntities1) {
|
||||||
|
DynamicObject org = dynamicObject.getDynamicObject("org");
|
||||||
|
//财务应付-付款计划
|
||||||
|
DynamicObjectCollection planentity = dynamicObject.getDynamicObjectCollection("planentity");
|
||||||
|
String orderBillbo = null;
|
||||||
|
for (DynamicObject object : planentity) {
|
||||||
|
String plancorebilltype = object.getString("plancorebilltype");//核心单据类型
|
||||||
|
if ("pm_purorderbill".equals(plancorebilltype)) {
|
||||||
|
String plancorebillno = object.getString("plancorebillno");//核心单据号
|
||||||
|
orderBillbo = plancorebillno;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//付款处理
|
||||||
|
//采购订单
|
||||||
|
DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle("pm_purorderbill", "id,billno,purbillentry_pay.tqq9_settleamount,purbillentry_pay.tqq9_paybillno"
|
||||||
|
, new QFilter[]{new QFilter("billno", QCP.equals, orderBillbo)});
|
||||||
|
if (null != pm_purorderbill) {
|
||||||
|
//付款计划
|
||||||
|
DynamicObjectCollection purbillentry_pay = pm_purorderbill.getDynamicObjectCollection("purbillentry_pay");
|
||||||
|
String casPayBillno = null;
|
||||||
|
BigDecimal settleAmount = BigDecimal.ZERO;
|
||||||
|
for (DynamicObject object : purbillentry_pay) {
|
||||||
|
//本次结算金额
|
||||||
|
BigDecimal amount = object.getBigDecimal("tqq9_settleamount") == null ? BigDecimal.ZERO : object.getBigDecimal("tqq9_settleamount");
|
||||||
|
settleAmount = amount;
|
||||||
|
//付款单
|
||||||
|
String tqq9_paybillno = object.getString("tqq9_paybillno");
|
||||||
|
casPayBillno = tqq9_paybillno;
|
||||||
|
}
|
||||||
|
DynamicObject cas_paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", "id",
|
||||||
|
new QFilter[]{new QFilter("billno", QCP.equals, casPayBillno)});//"SHPV2511270001"
|
||||||
|
if (null != cas_paybill) {
|
||||||
|
//应付付款结算,指定金额,按单据头指定
|
||||||
|
ISettleService settleService = ArApServiceAPIFactory.getSettleService(ServiceNameEnum.APPAYSETTLE.getValue());
|
||||||
|
SettleResult settleResult = settleService.assignSettle(org.getLong("id"), dynamicObject.getLong("id"),
|
||||||
|
settleAmount, cas_paybill.getLong("id"), settleAmount);
|
||||||
|
|
||||||
|
|
||||||
|
//未结算金额-采购订单上面选择的付款单的本次结算金额
|
||||||
|
//已结算金额+采购订单上面选择的付款单的本次结算金额
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue