|
@@ -2,5 +2,40 @@ package scmc.sm.webapi;
|
|
|
|
|
|
import kd.bos.openapi.api.plugin.ApiSavePlugin;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
public class SalorderTfDataWebApiPlugin implements ApiSavePlugin {
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
|
|
+ for (Map<String, Object> map : reqData) {
|
|
|
+ if(map.get("billentry")!=null) {
|
|
|
+ List<Map> entryList = (ArrayList) map.get("billentry");
|
|
|
+ for(Map entryObj : entryList){
|
|
|
+ //含税单价
|
|
|
+ BigDecimal priceandtax = new BigDecimal(0);
|
|
|
+ if (entryObj.get("priceandtax") != null || !"".equals(map.get("priceandtax"))) {
|
|
|
+ priceandtax = new BigDecimal(entryObj.get("priceandtax").toString());
|
|
|
+ }
|
|
|
+ //折后含税单价
|
|
|
+ BigDecimal pznm_discpriceandtax = new BigDecimal(0);
|
|
|
+ if (entryObj.get("pznm_discpriceandtax") != null || !"".equals(map.get("pznm_discpriceandtax"))) {
|
|
|
+ pznm_discpriceandtax = new BigDecimal(entryObj.get("pznm_discpriceandtax").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal cal = priceandtax.subtract(pznm_discpriceandtax);
|
|
|
+ if (cal.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ entryObj.put("discounttype", "C");//折扣方式
|
|
|
+ entryObj.put("discountamount", cal);//折扣额
|
|
|
+ } else {
|
|
|
+ entryObj.put("discounttype", "NULL");//折扣方式
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return reqData;
|
|
|
+ }
|
|
|
}
|