fix:变更单的折扣金额 不需要触发值更新

This commit is contained in:
ljw 2024-10-22 20:54:47 +08:00
parent 881b8073eb
commit 839e6308b7
3 changed files with 145 additions and 51 deletions

View File

@ -318,13 +318,11 @@ public class SalesOrderPJEdit extends AbstractBillPlugIn implements Plugin, Befo
case "yem_sapriceclausebase"://销售单价价格条款本位币
break;
case "yem_disamt"://折扣金额
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
ClientUtils.countFrontDisAmt(model, rowIndex);//折扣前金额
ClientUtils.countAfterFrontAmt(model, rowIndex);//计算折扣后销售金额
ClientUtils.calculateDiscountRate(view, model, rowIndex);//计算折扣率
ClientUtils.addSaAmountTk(model, rowIndex);//销售金额价格条款结算币别
ClientUtils.countPoolAmt(view, model, "yem_es_materialinfo");//汇总折扣金额使用金额
}
ClientUtils.countFrontDisAmt(model, rowIndex);//折扣前金额
ClientUtils.countAfterFrontAmt(model, rowIndex);//计算折扣后销售金额
ClientUtils.calculateDiscountRate(view, model, rowIndex);//计算折扣率
ClientUtils.addSaAmountTk(model, rowIndex);//销售金额价格条款结算币别
ClientUtils.countPoolAmt(view, model, "yem_es_materialinfo");//汇总折扣金额使用金额
break;
case "yem_fundusetype"://资金使用类型
model.setValue("yem_fundpoolamt", BigDecimal.ZERO);
@ -342,11 +340,13 @@ public class SalesOrderPJEdit extends AbstractBillPlugIn implements Plugin, Befo
// useDebcChange(rowIndex);
// break;
case "yem_ifgift":
ClientUtils.empty(model, rowIndex, "yem_es_materialinfo", view);
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_safobamount", "yem_amount");//销售fob金额 汇总表头 fob金额
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额价格条款汇总表头 金额价格条款
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
ClientUtils.empty(model, rowIndex, "yem_es_materialinfo", view);
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_safobamount", "yem_amount");//销售fob金额 汇总表头 fob金额
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额价格条款汇总表头 金额价格条款
// ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_onecarsum", "yem_sumcost");//单车总费用 汇总表头 总费用
ClientUtils.clearRelevantPrice(model, view, rowIndex, "yem_es_materialinfo");
ClientUtils.clearRelevantPrice(model, view, rowIndex, "yem_es_materialinfo");
}
break;
case "yem_transportstyle":
// setInsuranceFeeRate();
@ -357,9 +357,11 @@ public class SalesOrderPJEdit extends AbstractBillPlugIn implements Plugin, Befo
case "yem_afterfrontdisprice"://折扣后销售单价
break;
case "yem_accamtusetype"://配件资金使用方式
ClientUtils.delValue(model, "yem_es_materialinfo");
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
ClientUtils.delValue(model, "yem_es_materialinfo");
// ClientUtils.countDisAmt(model,"yem_es_materialinfo",rowIndex);//计算折扣金额
ClientUtils.calculateDiscountRate(view, model, -1);//计算折扣率
ClientUtils.calculateDiscountRate(view, model, -1);//计算折扣率
}
break;
case "yem_fundpoolamt"://使用额度
ClientUtils.countDisAmt(model, "yem_es_materialinfo", rowIndex, view);//计算折扣金额

View File

@ -36,17 +36,24 @@ import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
import static com.yem.wm.im.clientdemand.utils.ClientUtils.bringProductModelTons;
/**
* 外销合同 表单插件
*/
public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener, HyperLinkClickListener {
private static final Logger log = LoggerFactory.getLogger(SalesOrderZJEdit.class);
@Override
public void afterLoadData(EventObject e) {
super.afterLoadData(e);
@ -85,7 +92,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
OperationStatus status = fsp.getStatus();
String formId = fsp.getFormId();
String appId = fsp.getAppId();
if (OperationStatus.ADDNEW == status&&appId.equals("yem_es")) {
if (OperationStatus.ADDNEW == status && appId.equals("yem_es")) {
SplitContainer splitContainer = this.getControl("yem_splitcontainerap");
splitContainer.setCollapse("yem_splitpanelap1", true);
QFilter qFilter = null;
@ -191,10 +198,15 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
String name = e.getProperty().getName();
ChangeData changeData = e.getChangeSet()[0];
Object oldValue = changeData.getOldValue();
Object newValue = changeData.getNewValue();
int rowIndex = changeData.getRowIndex();
int ParentRow = changeData.getParentRowIndex();
DynamicObject dataEntity = model.getDataEntity();
DynamicObjectCollection materialInfo = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
// log.info("before__当前计算:{}", name);
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 0));
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 1));
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 2));
switch (name) {
case "yem_countexpense":
countExpense();//选择装箱核算运输费用 携带费用信息分录
@ -231,20 +243,24 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
syncDeductionGifts(model, rowIndex);
break;
case "yem_ifgift":
ZJUtils.countOrderSumNumberZJ(model);
ClientUtils.resourceNogLock(view, model, rowIndex);
ClientUtils.empty(model, rowIndex, "yem_es_materialinfo", view);
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_safobamount", "yem_amount");//销售fob金额 汇总表头 fob金额
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额价格条款汇总表头 金额价格条款
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
ZJUtils.countOrderSumNumberZJ(model);
ClientUtils.resourceNogLock(view, model, rowIndex);
ClientUtils.empty(model, rowIndex, "yem_es_materialinfo", view);
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_safobamount", "yem_amount");//销售fob金额 汇总表头 fob金额
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额价格条款汇总表头 金额价格条款
// ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_onecarsum", "yem_sumcost");//单车总费用 汇总表头 总费用
syncDeductionGifts(model, rowIndex);
ClientUtils.clearRelevantPrice(model, view, rowIndex, "yem_es_materialinfo");
syncDeductionGifts(model, rowIndex);
ClientUtils.clearRelevantPrice(model, view, rowIndex, "yem_es_materialinfo");
}
break;
case "yem_productmodel":
setRandomDataTools();//
FunctionalCommon.multiConfig(model, rowIndex);
setGiftGiving();
bringAssemblyAmount(rowIndex, model, "yem_es_materialinfo");
bringProductModelTons(model, rowIndex);
break;
case "yem_isnewagent":
setGiftGiving();
@ -285,6 +301,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
countCalculationAmt();
ClientUtils.changeRate(model, "yem_es_materialinfo");
ClientUtils.clearSalePrice(this.getModel());
ClientUtils.calculateSalesFCAStandardQingdaoUnitPrice(model, rowIndex);//销售FCA标配青岛单价
break;
case "yem_qty":
setRandomDataTools();
@ -301,6 +318,9 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
syncDeductionGifts(model, rowIndex);
ClientUtils.addSaAmountTkZJ(model, rowIndex);//整机合同整机非赠品行销售单价价格条款
ClientUtils.countRealCatAmountZJ(model, rowIndex);//整机合同整机非赠品行实际整车金额
// ClientUtils.calculateSalesFCAStandardQingdaoUnitAmount(model, rowIndex);//销售FCA标配青岛金额
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
ClientUtils.calcInlandTransportationAmt(model, rowIndex);//计算内陆运费
break;
case "yem_saamtpriceclause"://销售金额价格条款
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额价格条款汇总表头 金额价格条款
@ -311,6 +331,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
case "yem_standardprice"://标配FOB青岛价
ClientUtils.fobPriceAdd(model, materialInfo);//FOB单价
ClientUtils.countFobAmtSale(model, rowIndex);//销售FOB标配青岛单价
// ClientUtils.calculateSalesFCAStandardQingdaoUnitPrice(model, rowIndex);//销售FCA标配青岛单价
break;
case "yem_truecarpriceba":
ClientUtils.countRealCatAmountRMB(model, rowIndex);
@ -358,6 +379,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
break;
case "yem_unitsetamount"://单台加价金额
ClientUtils.addSaPrice(model, materialInfo);//销售FOB单价结算币别
ClientUtils.calculateSalesFOBUnitPrice(model, -1);//计算销售FOB单价
break;
case "yem_sapricepriceclause"://销售单价价格条款结算币别
@ -410,6 +432,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
break;
case "yem_transportstyle":
// setInsuranceFeeRate();
// ClientUtils.calcInlandTransportationAmt(model, rowIndex);//计算内陆运费
break;
case "yem_clientcountry":
case "yem_rapstyle":
@ -508,7 +531,53 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
case "yem_interestdays":
ClientUtils.calculateBankInterestCharges(-1, model);//银行利息费
break;
case "yem_sastandardfcaprice":
// ClientUtils.calculateSalesFCAStandardQingdaoUnitAmount(model, rowIndex);//销售FCA标配青岛金额
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
break;
case "yem_fobsubfcaamt":
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
break;
case "yem_tonsqty":
case "yem_port":
case "yem_shippingmethod":
ClientUtils.calcInlandTransportationAmt(model, rowIndex);//计算内陆运费
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
break;
case "yem_padexpense":
DynamicObject padexpense = (DynamicObject) newValue;
if (padexpense != null) {
String number = padexpense.getString("number");
//内陆运输费
if ("FYXM0023.11".equals(number)) {
DynamicObjectCollection entryRows = this.getModel().getEntryEntity("yem_es_materialinfo");
for (int i = 0; i < entryRows.size(); i++) {
ClientUtils.calcInlandTransportationAmt(model, i);//计算内陆运费
}
}
//港杂费
else if ("FYXM0023.6".equals(number)) {
DynamicObjectCollection entryRows = this.getModel().getEntryEntity("yem_es_materialinfo");
for (int i = 0; i < entryRows.size(); i++) {
ClientUtils.calculatePortAmt(model, i);//计算内陆运费
}
}
}
break;
case "yem_squareqty":
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
break;
case "yem_priceitemsp":
ClientUtils.countAfterFrontAmt(model, rowIndex);//计算折扣后销售金额
ClientUtils.calculateSalesFCAStandardQingdaoUnitPrice(model, rowIndex);//销售FCA标配青岛单价
ClientUtils.calculateSalesFOBUnitPrice(model, -1);//计算销售FOB单价
break;
}
// log.info("after__当前计算:{}", name);
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 0));
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 1));
// log.info("yem_safobprice:{}", model.getValue("yem_safobprice", 2));
}
/**
@ -540,6 +609,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
/**
* 选择赠送配件-产品机型汇总明细信息中相同机型的数量
*
* @param rowIndex
*/
private void summarizeModules(int rowIndex) {
@ -568,6 +638,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
/**
* 修改商品明细中数量同步修改礼品赠送中数量
*
* @param model
* @param rowIndex
*/
@ -864,11 +935,15 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
for (int i = 0; i < materialInfoRows; i++) {
BigDecimal amt = (BigDecimal) model.getValue("yem_amt", i);
if (total.compareTo(BigDecimal.ZERO) > 0) {
model.setValue("yem_disamt", amt.divide(total, 2).multiply(fundPoolAmt), i);
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", amt.divide(total, 2).multiply(fundPoolAmt), i);
}
} else {
model.setValue("yem_disamt", BigDecimal.ZERO, i);
}
if (!this.getModel().getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", BigDecimal.ZERO, i);
}
}
}
}
}

View File

@ -1182,7 +1182,9 @@ public class ClientUtils {
model.setValue("yem_truecaramtba", null, row);//实际整车金额人民币
model.setValue("yem_pricefieldaccba", null, row);//资源配件单价
model.setValue("yem_pricefieldaccamt", null, row);//资源配件金额
model.setValue("yem_disamt", null, row);//折扣金额
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", null, row);//折扣金额
}
model.setValue("yem_frontrateentry", null, row);//折扣率%
model.setValue("yem_frontdisprice", null, row);//折扣前销售单价
model.setValue("yem_frontdisamt", null, row);//折扣前销售金额
@ -1515,14 +1517,18 @@ public class ClientUtils {
model.setValue("yem_fundpoolamt", null);
model.setValue("yem_frontrate", null);
for (int i = 0; i < entryRowCount; i++) {
model.setValue("yem_disamt", null, i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", null, i);
}
model.setValue("yem_frontrateentry", null, i);
}
break;
case "B":
model.setValue("yem_fundpoolamt", null);
for (int i = 0; i < entryRowCount; i++) {
model.setValue("yem_disamt", null, i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", null, i);
}
model.setValue("yem_frontrateentry", null, i);
}
break;
@ -1531,7 +1537,9 @@ public class ClientUtils {
model.setValue("yem_fundpoolamt", null);
model.setValue("yem_frontrate", null);
for (int i = 0; i < entryRowCount; i++) {
model.setValue("yem_disamt", null, i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", null, i);
}
model.setValue("yem_frontrateentry", null, i);
}
}
@ -1548,19 +1556,20 @@ public class ClientUtils {
*/
public static void countDisAmt(IDataModel model, String entryKey, int row, IFormView view) {
String accAmtUseType = (String) model.getValue("yem_accamtusetype");
int entryRow = model.getEntryRowCount(entryKey);
if (YEM.isNotEmpty(accAmtUseType)) {
switch (accAmtUseType) {
case "A":
countAmtDisAmt(model, entryKey, view);
break;
case "B":
countRateDisAmt(model, row);
break;
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
String accAmtUseType = (String) model.getValue("yem_accamtusetype");
int entryRow = model.getEntryRowCount(entryKey);
if (YEM.isNotEmpty(accAmtUseType)) {
switch (accAmtUseType) {
case "A":
countAmtDisAmt(model, entryKey, view);
break;
case "B":
countRateDisAmt(model, row);
break;
}
}
}
}
@ -1594,22 +1603,28 @@ public class ClientUtils {
BigDecimal diaAmt = saFobAmount.divide(amount, RoundingMode.HALF_UP).multiply(fundPoolAmt).setScale(2, RoundingMode.HALF_UP);
if (i == seq) {
model.beginInit();
model.setValue("yem_disamt", fundPoolAmt.subtract(fundPoolAmtSum), i);
model.endInit();
view.updateView("yem_disamt", i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", fundPoolAmt.subtract(fundPoolAmtSum), i);
}
model.endInit();
} else {
fundPoolAmtSum = fundPoolAmtSum.add(diaAmt);
model.beginInit();
model.setValue("yem_disamt", diaAmt, i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", diaAmt, i);
view.updateView("yem_disamt", i);
}
model.endInit();
view.updateView("yem_disamt", i);
}
// System.out.printf("++++++++-- i = %s -- seq = %s -- yem_disamt = %s%n", i, seq, model.getValue("yem_disamt", i));
} else {
model.beginInit();
model.setValue("yem_disamt", null, i);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
model.setValue("yem_disamt", null, i);
view.updateView("yem_disamt", i);
}
model.endInit();
view.updateView("yem_disamt", i);
}
ClientUtils.countAfterFrontAmt(model, i);//计算折扣后销售金额
ClientUtils.addSaAmountTk(model, i);//销售金额价格条款结算币别
@ -1631,12 +1646,14 @@ public class ClientUtils {
private static void countRateDisAmt(IDataModel model, int row) {
if (row >= 0) {
Boolean ifGift = (Boolean) model.getValue("yem_ifgift", row);
if (!ifGift) {
BigDecimal frontRateEntry = (BigDecimal) model.getValue("yem_frontrateentry", row);
BigDecimal saFobAmount = (BigDecimal) model.getValue("yem_safobamount", row);
model.setValue("yem_disamt", saFobAmount.multiply(BigDecimal.ONE.subtract(frontRateEntry.divide(new BigDecimal(100)))).setScale(2, RoundingMode.UP), row);
} else {
model.setValue("yem_disamt", null, row);
if (!model.getDataEntityType().getName().equals("yem_es_xsalesorder")) {
if (!ifGift) {
BigDecimal frontRateEntry = (BigDecimal) model.getValue("yem_frontrateentry", row);
BigDecimal saFobAmount = (BigDecimal) model.getValue("yem_safobamount", row);
model.setValue("yem_disamt", saFobAmount.multiply(BigDecimal.ONE.subtract(frontRateEntry.divide(new BigDecimal(100)))).setScale(2, RoundingMode.UP), row);
} else {
model.setValue("yem_disamt", null, row);
}
}
}
}