付款单推送sap的时候,外币修改clear里面的金额
This commit is contained in:
		
							parent
							
								
									8f7144baba
								
							
						
					
					
						commit
						c951a96d1d
					
				|  | @ -111,8 +111,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                 DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle("gl_voucher", | ||||
|                         "id,description,shjh_fjz,sourcebill,entries,entries.account,entries.debitlocal," + | ||||
|                                 "entries.creditlocal,entries.entrydc,entries.edescription,vouchertype,entries.assgrp," + | ||||
|                                 "entries.debitori,entries.creditori", | ||||
|                         new QFilter[]{q1, q2}); | ||||
|                                 "entries.debitori,entries.creditori", new QFilter[]{q1, q2}); | ||||
|                 if (null == gl_voucher) { | ||||
|                     OperateErrorInfo operateErrorInfo = new OperateErrorInfo(); | ||||
|                     operateErrorInfo.setMessage("推送SAP凭证接口失败,原因:金蝶凭证未生成或未审核"); | ||||
|  | @ -121,11 +120,12 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                     this.operationResult.addErrorInfo(operateErrorInfo); | ||||
|                     return; | ||||
|                 } | ||||
|                 boolean iswbflag = isWB(bill); | ||||
|                 JSONArray IT_CLEAR = new JSONArray();//清账数据,参考《IT_CLEAR》,仅清账需要输入 | ||||
|                 JSONArray IT_ITEM = new JSONArray(); | ||||
|                 //解析付款凭证分录行组装成map,票据在贷方(客户编号+金额,行摘要),sap应付在借方(科目编号+金额,行摘要) | ||||
|                 Map<String, String> voucherMap = getVoucherTypeMap(gl_voucher); | ||||
|                 // 票据信息 | ||||
|                 //票据信息 | ||||
|                 DynamicObjectCollection casDraftinfos = bill.getDynamicObjectCollection("cas_draftinfo"); | ||||
|                 if (!casDraftinfos.isEmpty()) { | ||||
|                     isHeader.put("BLART", gl_voucher.getString("vouchertype.number"));//凭证类型-从金蝶凭证中获取 | ||||
|  | @ -141,7 +141,6 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                     } | ||||
|                     //若任意一行中存在SAP凭证号:clear:遍历明细,拿号调方法(W);遍历票据分录,拿票据号,查收款单(将表头凭证信息)_无行编号, | ||||
|                     // SAP会计科目(从收款单对应凭证取借方),清张金额取票据(转让金额) | ||||
| 
 | ||||
|                     if (isSAP) { | ||||
|                         //1.遍历明细 | ||||
|                         for (DynamicObject entry : entrys) { | ||||
|  | @ -175,7 +174,10 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             } | ||||
|                             jsonObject.put("HKONT", HKONT);//总账科目 | ||||
|                             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|                             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_实付金额 | ||||
|                             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_分录实付金额 | ||||
|                             if(iswbflag){ | ||||
|                                 jsonObject.put("DMBTR1", entry.getBigDecimal("e_payablelocamt"));//清账金额_分录应付折本币 | ||||
|                             } | ||||
|                             //以HKONT+金额作为key,将voucherMap的value放入行项目文本(sap应付行) | ||||
|                             jsonObject.put("SGTXT", voucherMap.get(HKONT+jsonObject.getString("DMBTR1"))); | ||||
|                             IT_CLEAR.add(jsonObject); | ||||
|  | @ -256,7 +258,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                             } | ||||
|                                         } | ||||
|                                     } | ||||
|                                     //清张金额取票据(转让金额) | ||||
|                                     //清账金额取票据(转让金额) | ||||
|                                     jsonObject.put("DMBTR1",casDraftinfo.getBigDecimal("transamount"));//清账金额 | ||||
|                                     //以收款单凭证行的客户编号+清账金额作为key,将voucherMap的value放入行项目文本(票据行) | ||||
|                                     jsonObject.put("SGTXT", voucherMap.get(jsonObject.getString("KUNNR")+jsonObject.getString("DMBTR1"))); | ||||
|  | @ -271,16 +273,13 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                 return; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     //若无SAP凭证号:联查凭证(遍历,借方iteam{SGTXT:凭证行摘要},遍历票_查收款单(将表头凭证信息):行没有) | ||||
|                     else { | ||||
| 
 | ||||
|                     } else { | ||||
|                         //若无SAP凭证号:联查凭证(遍历,借方iteam{SGTXT:凭证行摘要},遍历票_查收款单(将表头凭证信息):行没有) | ||||
|                         DynamicObjectCollection entries = gl_voucher.getDynamicObjectCollection("entries"); | ||||
|                         for (DynamicObject entry : entries) { | ||||
|                             String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方) | ||||
|                             if ("1".equals(entrydc)) { | ||||
|                                 //iteam | ||||
|                                 //todo:对header 凭证类型重新赋值 | ||||
|                                 //iteam 对header 凭证类型重新赋值 | ||||
|                                 isHeader.put("BLART", gl_voucher.getString("vouchertype.number"));//凭证类型-从金蝶凭证中获取 | ||||
|                                 if(!JhzjUtils.isEmpty(gl_voucher.getString("description"))){ | ||||
|                                     isHeader.put("BKTXT", gl_voucher.getString("description"));//凭证抬头文本-从金蝶凭证中获取 | ||||
|  | @ -384,7 +383,6 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                     } | ||||
|                                     IT_ITEMS.put("DMBTR", String.valueOf(amountToPut)); | ||||
|                                 } | ||||
| 
 | ||||
|                                 IT_ITEM.add(IT_ITEMS); | ||||
|                             } | ||||
|                         } | ||||
|  | @ -425,8 +423,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                 DynamicObject gl_vouchers = BusinessDataServiceHelper.loadSingle("gl_voucher", | ||||
|                                         "id,description,shjh_fjz,sourcebill,entries,entries.account," + | ||||
|                                                 "entries.debitlocal,entries.creditlocal,entries.entrydc,entries.edescription," + | ||||
|                                                 "vouchertype,entries.assgrp,entries.seq", | ||||
|                                         new QFilter[]{q3, q4}); | ||||
|                                                 "vouchertype,entries.assgrp,entries.seq", new QFilter[]{q3, q4}); | ||||
|                                 //SAP会计科目(从收款单对应凭证取借方) | ||||
|                                 if (null != gl_vouchers) { | ||||
|                                     DynamicObjectCollection entriess = gl_vouchers.getDynamicObjectCollection("entries"); | ||||
|  | @ -483,10 +480,8 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                         } | ||||
|                     } | ||||
|                 }else { | ||||
|     //				非票: | ||||
|     //				1.来源SAP :(付款单查凭证:遍历分录:if贷iteam{钱取贷方} 遍历明细clear{}) | ||||
|     //				非票: 1.来源SAP :(付款单查凭证:遍历分录:if贷iteam{钱取贷方} 遍历明细clear{}) | ||||
|     //				2.else(item:付款单联查凭证:遍历分录{原逻辑}) | ||||
| 
 | ||||
|                     isHeader.put("BLART", gl_voucher.getString("vouchertype.number"));//凭证类型-从金蝶凭证中获取 | ||||
|                     boolean isSAP = false; | ||||
|                     //明细 | ||||
|  | @ -504,8 +499,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                         for (DynamicObject entry : entries) { | ||||
|                             String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方) | ||||
|                             if ("-1".equals(entrydc)) { | ||||
|                                 //iteam | ||||
|                                 //todo:对header 凭证类型重新赋值 | ||||
|                                 //iteam 对header 凭证类型重新赋值 | ||||
|                                 isHeader.put("BLART", gl_voucher.getString("vouchertype.number"));//凭证类型-从金蝶凭证中获取 | ||||
|                                 if(!JhzjUtils.isEmpty(gl_voucher.getString("description"))){ | ||||
|                                     isHeader.put("BKTXT", gl_voucher.getString("description"));//凭证抬头文本-从金蝶凭证中获取 | ||||
|  | @ -645,6 +639,9 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                             jsonObject.put("HKONT", HKONT);//总账科目 | ||||
|                             jsonObject.put("UMSKZ", JhzjUtils.getUMSKZ(HKONT));//特殊总账标识 | ||||
|                             jsonObject.put("DMBTR1", entry.getBigDecimal("e_actamt"));//清账金额_实付金额 | ||||
|                             if(iswbflag){ | ||||
|                                 jsonObject.put("DMBTR1", entry.getBigDecimal("e_payablelocamt"));//清账金额_分录应付折本币 | ||||
|                             } | ||||
|                             //以HKONT+金额作为key,将voucherMap的value放入行项目文本(sap应付行) | ||||
|                             jsonObject.put("SGTXT", voucherMap.get(HKONT+jsonObject.getString("DMBTR1"))); | ||||
|                             IT_CLEAR.add(jsonObject); | ||||
|  | @ -655,8 +652,7 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                         for (DynamicObject entry : entries) { | ||||
|                             String entrydc = (String) entry.get("entrydc");//分录方向(1.借方,-1.贷方) | ||||
| //                            if ("-1".equals(entrydc)) { | ||||
|                                 //iteam | ||||
|                                 //todo:对header 凭证类型重新赋值 | ||||
|                                 //iteam :对header 凭证类型重新赋值 | ||||
|                                 isHeader.put("BLART", gl_voucher.getString("vouchertype.number"));//凭证类型-从金蝶凭证中获取 | ||||
|                                 if(!JhzjUtils.isEmpty(gl_voucher.getString("description"))){ | ||||
|                                     isHeader.put("BKTXT", gl_voucher.getString("description"));//凭证抬头文本-从金蝶凭证中获取 | ||||
|  | @ -712,7 +708,6 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|                                                     new QFilter[]{new QFilter("id", QCP.equals, glassistbd.getLong("assval"))});//维度值 | ||||
|                                             IT_ITEMS.put("RSTGR",hsxminfo.getString("number")); | ||||
|                                         } | ||||
| 
 | ||||
|                                     } | ||||
| 
 | ||||
|                                     gl_assist_bd = QueryServiceHelper.query("gl_assist_txt", "asstype,assval", | ||||
|  | @ -827,6 +822,15 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean isWB(DynamicObject bill){ | ||||
|         //如果(“异币种支付”=是 )或(“异币种支付”=否 ,且付款币种不等于人民币),取明细行中的 应付折本币 | ||||
|         if(bill.getBoolean("isdiffcur") || !"CNY".equals(bill.getString("currency.number"))){ | ||||
|             //如果是外币支付,则取分录应付折本币字段作为总金额和未清金额,已清金额为0;前台已设置外币不允许合并排程 | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     private JSONObject getIS_HEADER(DynamicObject bill) { | ||||
|         JSONObject IS_HEADER = new JSONObject();//抬头 | ||||
|         String BUKRS = ""; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue