1.采购订单,成本重算
This commit is contained in:
parent
f76ab6753b
commit
0e21d309f4
|
|
@ -2,6 +2,7 @@ package tqq9.lc123.cloud.app.plugin.form.pm;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
|
import kd.bos.dataentity.OperateOption;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.dataentity.utils.StringUtils;
|
import kd.bos.dataentity.utils.StringUtils;
|
||||||
|
|
@ -16,8 +17,7 @@ import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.QueryServiceHelper;
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
import kd.sdk.scmc.im.utils.DateUtils;
|
|
||||||
import tqq9.lc123.cloud.app.eip.iscb.LCLogService;
|
import tqq9.lc123.cloud.app.eip.iscb.LCLogService;
|
||||||
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
import tqq9.lc123.cloud.app.eip.iscb.impl.LCLogServiceImpl;
|
||||||
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
||||||
|
|
@ -25,7 +25,10 @@ import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购订单
|
* 采购订单
|
||||||
|
|
@ -376,17 +379,14 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn {
|
||||||
if (i == seqs.size() - 1) {
|
if (i == seqs.size() - 1) {
|
||||||
//如果是最后一行
|
//如果是最后一行
|
||||||
this.getModel().setValue("tqq9_disamount", remainRefundAmt_yh, seq);//明细优惠金额
|
this.getModel().setValue("tqq9_disamount", remainRefundAmt_yh, seq);//明细优惠金额
|
||||||
// this.getModel().setValue("discountamount", remainRefundAmt_yh, seq);//明细折扣额
|
|
||||||
} else {
|
} else {
|
||||||
//如果不是最后一行
|
//如果不是最后一行
|
||||||
BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
|
BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
|
||||||
if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
|
if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
this.getModel().setValue("tqq9_disamount", BigDecimal.ZERO, seq);//明细优惠金额
|
this.getModel().setValue("tqq9_disamount", BigDecimal.ZERO, seq);//明细优惠金额
|
||||||
// this.getModel().setValue("discountamount", BigDecimal.ZERO, seq);//
|
|
||||||
} else {
|
} else {
|
||||||
BigDecimal tqq9_disamount = tqq9_discountamount.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
|
BigDecimal tqq9_disamount = tqq9_discountamount.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
|
||||||
this.getModel().setValue("tqq9_disamount", tqq9_disamount, seq);//明细优惠金额
|
this.getModel().setValue("tqq9_disamount", tqq9_disamount, seq);//明细优惠金额
|
||||||
// this.getModel().setValue("discountamount", tqq9_disamount, seq);//
|
|
||||||
remainRefundAmt_yh = remainRefundAmt_yh.subtract(tqq9_disamount);
|
remainRefundAmt_yh = remainRefundAmt_yh.subtract(tqq9_disamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,47 +429,8 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn {
|
||||||
getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex);
|
getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OperateOption operateOption = OperateOption.create();
|
||||||
//物料值改变事件,获取过去6个月事件内的最低成本单价
|
OperationServiceHelper.executeOperate("pricequery",dataEntity.getDynamicObjectType().getName(),new DynamicObject[]{dataEntity},operateOption);
|
||||||
Date sixMonthsAgo = DateUtils.addMonth((Date) getModel().getValue("biztime"), -6);
|
|
||||||
QFilter q1 = new QFilter("biztime", ">=", sixMonthsAgo);// 时间 大于等于 六个月
|
|
||||||
QFilter q2 = new QFilter("billentry.material.masterid.id", "=", bd_material.getPkValue());//物料与当前行的物料相同
|
|
||||||
QFilter q3 = new QFilter("billentry.tqq9_disandrefoundprice", "!=", 0);//明细-有优惠有返利单价不等于0
|
|
||||||
QFilter q4 = new QFilter("billentry.tqq9_hfamount", "=", 0);// 明细-的货返金额等于0
|
|
||||||
DynamicObjectCollection dymObjectCollerction = QueryServiceHelper.query("pm_purorderbill",
|
|
||||||
"id,billentry,billentry.tqq9_disandrefoundprice,billentry.tqq9_hfamount,billentry.tqq9_disprice,billentry.material.id",
|
|
||||||
new QFilter[]{q1,q2,q3,q4}, "billentry.tqq9_disprice asc", 1);
|
|
||||||
List<DynamicObject> menuNotes = new ArrayList<>();
|
|
||||||
|
|
||||||
if(dymObjectCollerction != null && dymObjectCollerction.size() > 0){
|
|
||||||
DynamicObject doj = dymObjectCollerction.get(0);
|
|
||||||
BigDecimal tqq9_disprice = doj.getBigDecimal("billentry.tqq9_disprice");
|
|
||||||
getModel().setValue("tqq9_costprice", tqq9_disprice, rowIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// for (DynamicObject doj : dymObjectCollerction) {
|
|
||||||
// if (doj.getBigDecimal("billentry.tqq9_disandrefoundprice").compareTo(BigDecimal.ZERO) != 0
|
|
||||||
// && doj.getBigDecimal("billentry.tqq9_hfamount").compareTo(BigDecimal.ZERO) == 0) {
|
|
||||||
// menuNotes.add(doj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 冒泡排序升序排列
|
|
||||||
// for (int i = 0; i < menuNotes.size() - 1; i++) {
|
|
||||||
// for (int j = 0; j < menuNotes.size() - 1 - i; j++) {
|
|
||||||
// BigDecimal price1 = menuNotes.get(j).getBigDecimal("billentry.tqq9_disprice");
|
|
||||||
// BigDecimal price2 = menuNotes.get(j + 1).getBigDecimal("billentry.tqq9_disprice");
|
|
||||||
// if (price1 == null) price1 = BigDecimal.ZERO;
|
|
||||||
// if (price2 == null) price2 = BigDecimal.ZERO;
|
|
||||||
// if (price1.compareTo(price2) > 0) {
|
|
||||||
// // 交换元素
|
|
||||||
// DynamicObject temp = menuNotes.get(j);
|
|
||||||
// menuNotes.set(j, menuNotes.get(j + 1));
|
|
||||||
// menuNotes.set(j + 1, temp);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// DynamicObject minPricesObj = menuNotes.get(0);
|
|
||||||
// getModel().setValue("tqq9_costprice", minPricesObj.getBigDecimal("billentry.tqq9_disprice"), rowIndex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.equals("priceandtax", name)) {
|
if (StringUtils.equals("priceandtax", name)) {
|
||||||
|
|
@ -483,6 +444,17 @@ public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn {
|
||||||
this.getView().showErrorNotification("物料明细分录行" + seq + "含税单价超过最高采购限价,请修改");
|
this.getView().showErrorNotification("物料明细分录行" + seq + "含税单价超过最高采购限价,请修改");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(StringUtils.equals("tqq9_amount",name)){
|
||||||
|
DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry");
|
||||||
|
for (int i = 0; i < billentries.size(); i++) {
|
||||||
|
DynamicObject billentry = billentries.get(i);
|
||||||
|
BigDecimal tqq9_amount = billentry.getBigDecimal("tqq9_amount");//折扣前价税合计
|
||||||
|
BigDecimal tqq9_disamount = billentry.getBigDecimal("tqq9_disamount");//优惠(折扣)金额
|
||||||
|
BigDecimal amountandtax = tqq9_amount.subtract(tqq9_disamount);//折扣后价税合计
|
||||||
|
getModel().setValue("amountandtax", amountandtax,i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
if (StringUtils.equals("supplier", name)) {
|
if (StringUtils.equals("supplier", name)) {
|
||||||
LCLogService lcLogService = new LCLogServiceImpl();
|
LCLogService lcLogService = new LCLogServiceImpl();
|
||||||
HashMap<String, String> tokenMap = new HashMap<String, String>();
|
HashMap<String, String> tokenMap = new HashMap<String, String>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue