|
@@ -272,6 +272,13 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
}
|
|
|
|
|
|
+ //合同台账
|
|
|
+ DynamicObject contractInfo = null;
|
|
|
+ if(!StringUtils.isEmpty(contract)) {
|
|
|
+ qFilter = new QFilter("contractcode", QCP.equals, contract);
|
|
|
+ contractInfo = BusinessDataServiceHelper.loadSingle("er_contractbill", qFilter.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
DynamicObject bizAcctOutBill = BusinessDataServiceHelper.newDynamicObject(ENTITY_PUBLICPAY);
|
|
|
Date bizDate = new Date();
|
|
|
try {
|
|
@@ -307,6 +314,10 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
bizAcctOutBill.set("ispush", "false");//合同下推生成
|
|
|
bizAcctOutBill.set("nckd_srmstatus", "1");//srm状态,1:SRM已推送;2:已退回SRM;3:已反写SRM;4:反写SRM失败
|
|
|
bizAcctOutBill.set("nckd_duigong", "01");//是否对公业务
|
|
|
+ setDefaultMultViewType(bizAcctOutBill);//多选页面类型
|
|
|
+ bizAcctOutBill.set("isbeforeshare", "0");//费用分摊
|
|
|
+ bizAcctOutBill.set("sharerule", "orgrule");//
|
|
|
+ bizAcctOutBill.set("sharemethod", "rate");//
|
|
|
|
|
|
// String[] typeStrings = new String[]{"1008", "1009"};
|
|
|
// QFilter qFilter111 = new QFilter("number", QCP.in, typeStrings);
|
|
@@ -358,7 +369,17 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
}
|
|
|
|
|
|
- DynamicObject projectInfo = CommonHelperUtils.queryBaseDynamicObject("bd_project", "number", xsproject);
|
|
|
+ //替换连接符
|
|
|
+ xsproject = xsproject.replace("-", ".");
|
|
|
+
|
|
|
+ QFilter projectFilter = new QFilter("status", QCP.equals, "C");
|
|
|
+ projectFilter.and(new QFilter("enable", QCP.equals, "1"));
|
|
|
+ projectFilter.and(new QFilter("number", QCP.equals, xsproject));
|
|
|
+ projectFilter.and(new QFilter("createorg.id", QCP.equals, costCompany.getLong("id")));
|
|
|
+
|
|
|
+ DynamicObject projectInfo = BusinessDataServiceHelper.loadSingle("bd_project", projectFilter.toArray());
|
|
|
+
|
|
|
+// DynamicObject projectInfo = CommonHelperUtils.queryBaseDynamicObject("bd_project", "number", xsproject);
|
|
|
if(projectInfo == null){
|
|
|
returnMessage = "项目(" + xsproject + ")在星瀚系统中未匹配到数据!";
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
@@ -383,7 +404,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
if(currency.getLong("id") != 1L){
|
|
|
exchangeRate = CommonHelperUtils.getExchangeRate(exchangeTableId, currency.getLong("id"), 1L, bizDate);
|
|
|
}
|
|
|
-
|
|
|
+ entry.set("exchangerate", exchangeRate);//汇率
|
|
|
entry.set("expquotetype", "0");//换算方式
|
|
|
entry.set("currexpenseamount", amountOri.multiply(exchangeRate).setScale(2, BigDecimal.ROUND_HALF_UP));//报销金额本位币
|
|
|
entry.set("expeapprovecurramount", amountOri.multiply(exchangeRate).setScale(2, BigDecimal.ROUND_HALF_UP));//核定金额本位币
|
|
@@ -406,6 +427,8 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
qFilter = new QFilter("number", QCP.equals, "BANK");
|
|
|
|
|
|
DynamicObject settleType = BusinessDataServiceHelper.loadSingle("bd_settlementtype", qFilter.toArray());
|
|
|
+ DynamicObject supplier = null;
|
|
|
+
|
|
|
DynamicObjectCollection accountEntry = bizAcctOutBill.getDynamicObjectCollection("accountentry");
|
|
|
type = accountEntry.getDynamicObjectType();
|
|
|
JSONArray bizAccountOutBillAccountEntry = inputData.getJSONArray("bizAccountOutBillAccountEntry");
|
|
@@ -427,7 +450,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
}
|
|
|
|
|
|
- DynamicObject supplier = CommonHelperUtils.queryBaseDynamicObject("bd_supplier", "societycreditcode", payerName);
|
|
|
+ supplier = CommonHelperUtils.queryBaseDynamicObject("bd_supplier", "societycreditcode", payerName);
|
|
|
if(supplier == null){
|
|
|
returnMessage = "供应商(" + payerName + ")在星瀚系统中未匹配到数据!";
|
|
|
return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
@@ -468,6 +491,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
}
|
|
|
|
|
|
entry.set("accountcurrency", currency);//币别
|
|
|
+ entry.set("accexchangerate", exchangeRate);//汇率
|
|
|
entry.set("orireceiveamount", amountOri);//收款金额
|
|
|
entry.set("receiveamount", amountOriLocal);//收款金额本位币
|
|
|
entry.set("oriaccnotpayamount", amountOri);//未付金额
|
|
@@ -723,6 +747,80 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
}
|
|
|
bizAcctOutBill.set("invoiceentry", invoiceEntry);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //合同信息
|
|
|
+ if(contractInfo != null){
|
|
|
+ DynamicObjectCollection contractEntry = bizAcctOutBill.getDynamicObjectCollection("contractentry");
|
|
|
+ type = contractEntry.getDynamicObjectType();
|
|
|
+
|
|
|
+ DynamicObject currency = contractInfo.getDynamicObject("contractcurrency");
|
|
|
+ currency = CommonHelperUtils.queryBaseDynamicObject("bd_currency", "number", currency.getString("number"));
|
|
|
+
|
|
|
+ if(currency == null){
|
|
|
+ returnMessage = "币别(" + orgUnit + ")在星瀚系统中未匹配到数据!";
|
|
|
+ return buildReturnData(code, srmBillNo, returnMessage, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal exchangeRate = BigDecimal.ONE;
|
|
|
+ if(currency.getLong("id") != 1L){
|
|
|
+ exchangeRate = CommonHelperUtils.getExchangeRate(exchangeTableId, currency.getLong("id"), 1L, bizDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal contractAmount = contractInfo.getBigDecimal("contractamount");//合同总额(初始)
|
|
|
+ BigDecimal oriapplyAmount = contractInfo.getBigDecimal("oriapplyamount");//合同总额(变更后)
|
|
|
+
|
|
|
+ DynamicObjectCollection contractPartyEntry = contractInfo.getDynamicObjectCollection("contractpartyentry"); //
|
|
|
+ if(contractPartyEntry.size() > 0){
|
|
|
+ for(DynamicObject partyEntry : contractPartyEntry){
|
|
|
+ DynamicObject entry = new DynamicObject(type);
|
|
|
+
|
|
|
+ DynamicObject contractparty = partyEntry.getDynamicObject("contractparty");
|
|
|
+ if(contractparty.getLong("id") != supplier.getLong("id")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ entry.set("seq", 1);
|
|
|
+ entry.set("contractcode", contract);//合同号
|
|
|
+ entry.set("contractname", contractInfo.getString("contractname"));//合同名称
|
|
|
+ entry.set("signdate", contractInfo.getDate("signdate"));//签订日期
|
|
|
+ entry.set("contractdescription", contractInfo.getString("description"));//合同说明
|
|
|
+ entry.set("contractapplier", contractInfo.getDynamicObject("applier"));//经办人
|
|
|
+ entry.set("contractcostorg", contractInfo.getDynamicObject("costcompany"));//核算组织
|
|
|
+ entry.set("contractparta", contractInfo.getDynamicObject("parta"));//甲方old
|
|
|
+ entry.set("contractpartbtype", "bd_supplier");//乙方类型
|
|
|
+ entry.set("contractpartb", contractparty);//乙方
|
|
|
+
|
|
|
+ DynamicObjectCollection payplanEntrys = contractInfo.getDynamicObjectCollection("expenseentryentity");
|
|
|
+ if(payplanEntrys.size() > 0){
|
|
|
+ DynamicObject planEntry = payplanEntrys.get(0);
|
|
|
+
|
|
|
+ entry.set("contractexppaytypeid", planEntry.getDynamicObject("paymenttypeid"));//付款类型
|
|
|
+ entry.set("contractexphappendate", planEntry.getDate("happendate"));//预计付款日期
|
|
|
+ entry.set("contractexpproject", planEntry.getDynamicObject("std_project"));//项目
|
|
|
+ entry.set("contractexpenseitem", planEntry.getDynamicObject("expenseitem"));//费用项目
|
|
|
+ entry.set("contractexpcurrency", planEntry.getDynamicObject("entrycurrency"));//币种
|
|
|
+ entry.set("contractexpchangerate", planEntry.getBigDecimal("exchangerate"));//汇率
|
|
|
+ entry.set("contractexpquotetype", "0");//换算方式
|
|
|
+ entry.set("contractnotpayamount", planEntry.getBigDecimal("expnotpayamount"));//未付金额本位币
|
|
|
+ entry.set("contractcanloanamount", planEntry.getBigDecimal("canloanamount"));//可预付金额
|
|
|
+ entry.set("concurrcanloanamount", planEntry.getBigDecimal("canloancurramount"));//可预付金额本位币
|
|
|
+ }
|
|
|
+
|
|
|
+ entry.set("contractpartatypenew", "bos_org");//甲方类型
|
|
|
+ entry.set("contractpartanew", costCompany);//甲方
|
|
|
+ entry.set("nckd_contractamt", contractAmount);//合同总额(初始)
|
|
|
+ entry.set("nckd_oriapplyamt", oriapplyAmount);//合同总额(变更后)
|
|
|
+
|
|
|
+ contractEntry.add(entry);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bizAcctOutBill.set("contractentry", contractEntry);
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
//新增保存供应商对象
|
|
|
OperationResult resultSave = SaveServiceHelper.saveOperate(ENTITY_PUBLICPAY, new DynamicObject[]{bizAcctOutBill}, OperateOption.create());
|
|
@@ -896,7 +994,8 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
dailyLoanBill.set("nckd_srmstatus", "1");//srm状态,1:SRM已推送;2:已退回SRM;3:已反写SRM;4:反写SRM失败
|
|
|
// dailyLoanBill.set("repaymentdate", repaymentDate);//预计冲销日期
|
|
|
dailyLoanBill.set("nckd_duigong", "01");//是否对公业务
|
|
|
-// dailyLoanBill.set("nckd_payviewtypemul", getDefaultMultViewType());//多选页面类型
|
|
|
+
|
|
|
+ setDefaultMultViewType(dailyLoanBill);//多选页面类型
|
|
|
|
|
|
BigDecimal totalReimburseAmount = BigDecimal.ZERO;//报销金额合计
|
|
|
|
|
@@ -931,6 +1030,7 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
entry.set("entrycostdept", dept);//费用承担部门
|
|
|
entry.set("entrycostcompany", costCompany);//费用承担公司
|
|
|
entry.set("entrycurrency", currency);//币别
|
|
|
+ entry.set("exchangerate", exchangeRate);//预付汇率
|
|
|
entry.set("expenseamount", amountOri);//申请金额
|
|
|
entry.set("expeapproveamount", amountOri);//核定金额
|
|
|
entry.set("orgiexpebalanceamount", amountOri);//未核销金额
|
|
@@ -1201,19 +1301,22 @@ public class SRMSynPayApiPlugin implements Serializable {
|
|
|
* 默认多选页面类型
|
|
|
* @return
|
|
|
*/
|
|
|
- private Object[] getDefaultMultViewType(){
|
|
|
+ private void setDefaultMultViewType(DynamicObject objectInfo){
|
|
|
String[] typeStrings = new String[]{"1008", "1009"};
|
|
|
|
|
|
QFilter qFilter = new QFilter("number", QCP.in, typeStrings);
|
|
|
DynamicObject[] viewTypeCols = BusinessDataServiceHelper.load("nckd_payviewtype", "id, number, name", qFilter.toArray());
|
|
|
if(viewTypeCols != null && viewTypeCols.length > 0){
|
|
|
- List<Long> idList = Arrays.stream(viewTypeCols)
|
|
|
- .map(type -> type.getLong("id"))
|
|
|
- .collect(Collectors.toList());
|
|
|
- Object[] basedataIds = idList.toArray();
|
|
|
- return basedataIds;
|
|
|
- }
|
|
|
+ DynamicObjectCollection veiwTypeMulColl = objectInfo.getDynamicObjectCollection("nckd_payviewtypemul");
|
|
|
+
|
|
|
+ for (DynamicObject viewType : viewTypeCols) {
|
|
|
+ DynamicObject newViewTypeMul = new DynamicObject(veiwTypeMulColl.getDynamicObjectType());
|
|
|
+ newViewTypeMul.set("fbasedataId", viewType);
|
|
|
|
|
|
- return null;
|
|
|
+ veiwTypeMulColl.add(newViewTypeMul);
|
|
|
+ }
|
|
|
+
|
|
|
+ objectInfo.set("nckd_payviewtypemul", veiwTypeMulColl);
|
|
|
+ }
|
|
|
}
|
|
|
}
|