Fx.tail:和CRM尾差操作相关的API
1. checkTailDiff 尾差校验
https://lexiangla.com/teams/k100014/docs/2248ccc46efa11eeb410a216a7ac9cce?company_from=050524eee61811e783175254005b9a60
Fx.tail.checkTailDiff(<String sourceObjApiName>, <String sourceCheckFieldApiName>, <String sourceConditionFieldApiName>, <String targetObjApiName>, <String targetCheckFieldApiName>, <String targetConditionFieldApiName>, <String targetObjReferenceFieldApiName>, <List targetDetailDataList>, <String fillTailDiffApiName>, <Boolean includeCurrentBill>)
参数说明
参数 | 类型 | 说明 |
---|---|---|
sourceObjApiName | String | 源单对象apiName |
sourceCheckFieldApiName | String | 源单核实字段apiName |
sourceConditionFieldApiName | String | 源单条件字段apiName |
targetObjApiName | String | 目标对象apiName |
targetCheckFieldApiName | String | 目标对象核实字段apiName |
targetConditionFieldApiName | String | 目标对象条件字段apiName |
targetObjReferenceFieldApiName | String | 目标对象与源单对象存在关联(lookup、md)关系的字段apiName |
targetDetailDataList | List | 目标对象数据List |
fillTailDiffApiName | String | 算出尾差后,将尾差填充到指定的字段,非必填,如果不传则不填充 |
includeCurrentBill | Boolean | 是否统计当前单据(后校验函数,需要传false;前校验函数,需要传true) |
返回值类型
APIResult
返回值说明
返回的数据类型: Map < String, BigDecimal > //key 为"2.7" 字段所对应的值,value 为计算出来的尾差值,对应的行无尾差,则该行无记录
Groovy举例
String sourceObjApiName = "SalesOrderProductObj";
String sourceCheckFieldApiName = "subtotal";
String sourceConditionFieldApiName = "quantity";
String targetObjApiName = "object_0m3Rs__c";
String targetCheckFieldApiName = "field_Pj469__c";
String targetConditionFieldApiName = "field_7poFS__c";
String targetObjReferenceFieldApiName = "field_qi2s4__c";
String fillTailDiffApiName = "field_5Z31P__c";
Map result = [:];
def(boolean error, Map data, String message) = Fx.tail.checkTailDiff(sourceObjApiName, sourceCheckFieldApiName, sourceConditionFieldApiName,
targetObjApiName, targetCheckFieldApiName, targetConditionFieldApiName, targetObjReferenceFieldApiName, context.details[targetObjApiName] as List ,
fillTailDiffApiName, true);
if(error) {
log.info("错误信息:"+error+"\t"+message);
} else {
log.info("接口返回数据:"+data);
result = data;
}
log.info("尾差检查map:"+result);
if(result != null&&result.size()>0) {
List details = context.details[targetObjApiName] as List;
details.each {item->String referenceValue = item[targetObjReferenceFieldApiName] as String;
BigDecimal tailDiffValue = 0;
if(result[referenceValue] != null) {
tailDiffValue = result[referenceValue] as BigDecimal;
BigDecimal sourceValue = item[targetCheckFieldApiName] as BigDecimal;
item[fillTailDiffApiName] = tailDiffValue;
item[targetCheckFieldApiName] = sourceValue.add(tailDiffValue);
}
}
context.details[targetObjApiName] = details;
log.info("保存前的details:"+details);
}
return ["error": false, "errorMessage":"成功"];