问题:调用ERP接口报错:交货明细的数量与订单明细的数量不一致

调用ERP接口报错:交货明细的数量与订单明细的数量不一致

问题场景:
销售订单同步 CRM->ERP,提示交货明细数量与订单明细数量不一致,
1、登录金蝶webapi,得知交货明细是订单下的从对象,且保存后是放在订单明细中的字段,且是数组(只支持订单明细一对一交货明细,不支持一对多)。
2、CRM没有配置交货明细从对象,只有通过同步中函数增加映射的字段。报错截图:
(调用ERP接口报错: 调用外部http接口失败,错误信息:FPlanQty,第1行分录,交货明细的数量与订单明细的数量不一致,请检查.[errCode:5001,J-E.592739.-10000-sync142408-SalesOrderObj_627df9760df66d000144a3fe])
处理步骤:
1、同步中函数增加要同步的字段,交货明细
2、映射中配置交货明细字段,设置固定值
Map objectData = syncArg.objectData as Map; Map detailsData = syncArg.details as Map List detailsList = detailsData["SAL_SaleOrder.SaleOrderEntry"] as List // 从对象的明细List DateTime now = DateTime.now() now = now+1.days String nowString = now as String nowString = nowString+":01" log.info("时间=="+nowString) Map newDetailsData = [:] List newDetailsList = [] detailsList.each{ item -> Map detailsListData = item as Map // 每条明细数据 BigDecimal FQty = item["FQty"] as BigDecimal // 数量 BigDecimal NewFQty = FQty.setScale(2, BigDecimal.ROUND_UP) String NewFQtyString = NewFQty as String log.info("数量=="+NewFQty) Map jiaohuo = ["FPlanDate":nowString,"FPlanQty":NewFQty] log.info("交货明细数据=="+jiaohuo) detailsListData.put("FOrderEntryPlan",[jiaohuo]) newDetailsList.add(detailsListData) } newDetailsData.put("SAL_SaleOrder.SaleOrderEntry",newDetailsList) log.info("新的明细数据=="+newDetailsData) Map map = ["details":newDetailsData, "objectData":syncArg.objectData]; syncArg =map;syncArg["isCover"]="true"; return syncArg;
2024-05-22
0 0