From d5f7bfed3c053e6399237f5e1da02e11800e6805 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Wed, 30 Apr 2025 15:07:32 +0800 Subject: [PATCH] =?UTF-8?q?-SAP=E6=8B=89=E5=8F=96,=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=8D=95,=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1,=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=BB=93=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit s --- .../fi/fi/plugin/form/SappzFormPlugin.java | 98 ++++++++++++------- .../task/QuerySapCreatePayApplyTask.java | 31 ++++-- .../fi/webapi/ApplyAdjustBillControler.java | 36 +++++-- 3 files changed, 116 insertions(+), 49 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/SappzFormPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/SappzFormPlugin.java index ca8435f..a7f08aa 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/SappzFormPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/SappzFormPlugin.java @@ -146,9 +146,38 @@ public class SappzFormPlugin extends AbstractFormPlugin { if (StringUtils.isNotEmpty(kunnr)) { this.getModel().setValue("shjh_payee", "客户", i);//往来类型 this.getModel().setValue("shjh_payeebanknum", kunnr, i);//往来户名称 + //结算方式:银企直连 + this.getModel().setValue("shjh_paymenttypenumber", "T", i);//结算方式 + this.getModel().setValue("shjh_paymenttype", "银企直连", i);//结算方式 }else { this.getModel().setValue("shjh_payee", "供应商", i); - this.getModel().setValue("shjh_payeebanknum", lifnr, i);//往来户名称 + this.getModel().setValue("shjh_payeebanknum", lifnr, i); // 往来户名称 + QFilter Q3 = new QFilter("number", QCP.equals, lifnr); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(BD_SUPPLIER, new QFilter[]{Q3}); + // 用于标记是否找到合适的结算方式 + boolean foundSettlementType = false; + if (dynamicObject != null) { + DynamicObjectCollection shjhEntrySap = dynamicObject.getDynamicObjectCollection("shjh_entry_sap"); + if (!shjhEntrySap.isEmpty()) { + for (DynamicObject object : shjhEntrySap) { + if (it_list.getString("BUKRS").equals(object.getString("shjh_companynum"))) { + DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype", + new QFilter[]{new QFilter("number", QCP.equals, object.getString("shjh_companynum"))}); + if (settlementtype != null) { + this.getModel().setValue("shjh_paymenttypenumber", object.getString("shjh_companynum"), i); // 结算方式 + this.getModel().setValue("shjh_paymenttype", settlementtype.getString("name"), i); // 结算方式 + foundSettlementType = true; + break; + } + } + } + } + } + // 如果没找到合适的结算方式,使用默认值 + if (!foundSettlementType) { + this.getModel().setValue("shjh_paymenttypenumber", "T", i); // 结算方式 + this.getModel().setValue("shjh_paymenttype", "银企直连", i); // 结算方式 + } } this.getModel().setValue("shjh_description", it_list.getString("BVTYP"), i);//合作银行类型.合作银行类型 this.getModel().setValue("shjh_reasoncode", it_list.getString("RSTGR"), i);//原因码 @@ -158,39 +187,40 @@ public class SappzFormPlugin extends AbstractFormPlugin { this.getModel().setValue("shjh_isselfprocurment", it_list.getString("ZZXCG_FLAG"), i);//是否自行采购 this.getModel().setValue("shjh_paymentcurrency", it_list.getString("WAERS"), i);//付款币别编号CNY,货币码 this.getModel().setValue("shjh_settlementcurrency", it_list.getString("WAERS"), i);//结算币别编号,货币码 - this.getModel().setValue("shjh_paymenttypenumber", it_list.getString("ZLSCH"), i);//付款方式 - switch (it_list.getString("ZLSCH")) { - case "B": - this.getModel().setValue("shjh_paymenttype", "汇票", i);//付款方式 - break; - case "C": - this.getModel().setValue("shjh_paymenttype", "支票", i);//付款方式 - break; - case "D": - this.getModel().setValue("shjh_paymenttype", "贷记凭证", i);//付款方式 - break; - case "E": - this.getModel().setValue("shjh_paymenttype", "现金", i);//付款方式 - break; - case "F": - this.getModel().setValue("shjh_paymenttype", "EPIC-中信银行", i);//付款方式 - break; - case "G": - this.getModel().setValue("shjh_paymenttype", "EPIC_线下付款方式", i);//付款方式 - break; - case "P": - this.getModel().setValue("shjh_paymenttype", "POS机", i);//付款方式 - break; - case "T": - this.getModel().setValue("shjh_paymenttype", "银企直连", i);//付款方式 - break; - case "U": - this.getModel().setValue("shjh_paymenttype", "网银及柜台付款", i);//付款方式 - break; - case "Y": - this.getModel().setValue("shjh_paymenttype", "自动扣款", i);//付款方式 - break; - } +// this.getModel().setValue("shjh_paymenttypenumber", it_list.getString("ZLSCH"), i);//付款方式 +// switch (it_list.getString("ZLSCH")) { +// case "B": +// this.getModel().setValue("shjh_paymenttype", "汇票", i);//付款方式 +// break; +// case "C": +// this.getModel().setValue("shjh_paymenttype", "支票", i);//付款方式 +// break; +// case "D": +// this.getModel().setValue("shjh_paymenttype", "贷记凭证", i);//付款方式 +// break; +// case "E": +// this.getModel().setValue("shjh_paymenttype", "现金", i);//付款方式 +// break; +// case "F": +// this.getModel().setValue("shjh_paymenttype", "EPIC-中信银行", i);//付款方式 +// break; +// case "G": +// this.getModel().setValue("shjh_paymenttype", "EPIC_线下付款方式", i);//付款方式 +// break; +// case "P": +// this.getModel().setValue("shjh_paymenttype", "POS机", i);//付款方式 +// break; +// case "T": +// this.getModel().setValue("shjh_paymenttype", "银企直连", i);//付款方式 +// break; +// case "U": +// this.getModel().setValue("shjh_paymenttype", "网银及柜台付款", i);//付款方式 +// break; +// case "Y": +// this.getModel().setValue("shjh_paymenttype", "自动扣款", i);//付款方式 +// break; +// } + String uuid = it_list.getString("XBLNR"); this.getModel().setValue("shjh_uuid", uuid, i);//单据号 /** diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/task/QuerySapCreatePayApplyTask.java b/main/java/shjh/jhzj7/fi/fi/plugin/task/QuerySapCreatePayApplyTask.java index df8afe1..9167f67 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/task/QuerySapCreatePayApplyTask.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/task/QuerySapCreatePayApplyTask.java @@ -374,13 +374,32 @@ public class QuerySapCreatePayApplyTask extends AbstractTask { ap_payapply.set("shjh_bookkeepingdate", BUDATs); //凭证日期 ap_payapply.set("shjh_documentdate", BLDATs); + //结算方式 + DynamicObject settlementtypes = BusinessDataServiceHelper.loadSingle("bd_settlementtype", + new QFilter[]{new QFilter("number", QCP.equals, "T")});//银企直连 + // 标记是否设置了结算方式 + boolean isSettlementSet = false; - String zlsch = it_list.getString("ZLSCH");//付款方式 - // 结算方式(付款方式) - DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype", - new QFilter[]{new QFilter("number", QCP.equals, zlsch)}); - if (null != settlementtype) { - ap_payapply_entry.set("e_settlementtype", settlementtype); + if ("供应商".equals(shjh_payee)) { + DynamicObjectCollection shjhEntrySap = party.getDynamicObjectCollection("shjh_entry_sap"); + if (!shjhEntrySap.isEmpty()) { + for (DynamicObject object : shjhEntrySap) { + if (org.getString("number").equals(object.getString("shjh_companynum"))) { + // 结算方式(付款方式) + DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype", + new QFilter[]{new QFilter("number", QCP.equals, object.getString("shjh_companynum"))}); + if (settlementtype != null) { + ap_payapply_entry.set("e_settlementtype", settlementtype); + isSettlementSet = true; + break; + } + } + } + } + } + // 如果未设置结算方式,则使用默认的银企直连 + if (!isSettlementSet) { + ap_payapply_entry.set("e_settlementtype", settlementtypes); } String uuid = it_list.getString("XBLNR");//单据号 // 设置付款类型 //付款类型 外部系统单据类型 diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/ApplyAdjustBillControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/ApplyAdjustBillControler.java index 3ed3978..bd4eb43 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/ApplyAdjustBillControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/ApplyAdjustBillControler.java @@ -422,7 +422,7 @@ public class ApplyAdjustBillControler { String accountingsubject = it_list.getString("SAKNR");//会计科目:1001,总帐科目编号 BigDecimal outstandingamount = new BigDecimal(it_list.getString("WRBTR"));//未清金额,凭证货币金额 BigDecimal KURSF = new BigDecimal(it_list.getString("KURSF")); - String zlsch = it_list.getString("ZLSCH");//付款方式 +// String zlsch = it_list.getString("ZLSCH");//付款方式(结算方式) if (KURSF.compareTo(BigDecimal.ZERO) == 0) { KURSF = BigDecimal.ONE; } @@ -458,6 +458,7 @@ public class ApplyAdjustBillControler { } else { asstacttype = "供应商"; asstact = lifnr; + } // String assacct = it_list.getString("BVTYP");//合作银行类型.合作银行类型 A String assacct = "A";//合作银行类型.合作银行类型 A @@ -544,7 +545,7 @@ public class ApplyAdjustBillControler { } // 设置明细信息 - String s1 = setEntryInfo(ap_payapply, asstacttype, asstact, assacct, duedate, outstandingamount, fkBillNum,zlsch); + String s1 = setEntryInfo(ap_payapply, asstacttype, asstact, assacct, duedate, outstandingamount, fkBillNum,org); if (StringUtils.isNotEmpty(s1)) { return s1; } @@ -619,7 +620,7 @@ public class ApplyAdjustBillControler { * 付款方式 _结算 * @return 操作是否成功 */ - private String setEntryInfo(DynamicObject ap_payapply, String asstacttype, String asstact, String assacct, Date duedate, BigDecimal outstandingamount, String fkBillNum,String zlsch) { + private String setEntryInfo(DynamicObject ap_payapply, String asstacttype, String asstact, String assacct, Date duedate, BigDecimal outstandingamount, String fkBillNum,DynamicObject org) { DynamicObjectCollection entry = ap_payapply.getDynamicObjectCollection("entry"); entry.clear(); DynamicObject ap_payapply_entry = entry.addNew(); @@ -678,12 +679,29 @@ public class ApplyAdjustBillControler { return "同步失败, 供应商的合作银行类型 " + assacct + " 不存在"; } } - - // 结算方式(付款方式) - DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype", - new QFilter[]{new QFilter("number", QCP.equals, zlsch)}); - if (null != settlementtype) { - ap_payapply_entry.set("e_settlementtype", settlementtype); + //结算方式 + DynamicObject settlementtypes = BusinessDataServiceHelper.loadSingle("bd_settlementtype", + new QFilter[]{new QFilter("number", QCP.equals, "T")});//银企直连 + boolean isSettlementTypeSet = false; + if ("供应商".equals(asstacttype) && party != null) { + DynamicObjectCollection shjhEntrySap = party.getDynamicObjectCollection("shjh_entry_sap"); + if (!shjhEntrySap.isEmpty()) { + for (DynamicObject object : shjhEntrySap) { + if (org.getString("number").equals(object.getString("shjh_companynum"))) { + // 结算方式(付款方式) + DynamicObject settlementtype = BusinessDataServiceHelper.loadSingle("bd_settlementtype", + new QFilter[]{new QFilter("number", QCP.equals, object.getString("shjh_companynum"))}); + if (settlementtype != null) { + ap_payapply_entry.set("e_settlementtype", settlementtype); + isSettlementTypeSet = true; + break; + } + } + } + } + } + if (!isSettlementTypeSet) { + ap_payapply_entry.set("e_settlementtype", settlementtypes); // 银企直连 } //到期日