Compare commits

...

2 Commits

Author SHA1 Message Date
xuhaihui 6cbc0c2b21 入库单优化 2025-11-12 15:07:58 +08:00
xuhaihui 272f4a9eff 支出合同结算优化 2025-11-12 15:07:28 +08:00
4 changed files with 112 additions and 78 deletions

View File

@ -107,6 +107,23 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber); QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber);
DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单 DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单
if (ecma_materialInBill != null) { if (ecma_materialInBill != null) {
if (zcgj_transset) {
DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总
for (DynamicObject entryEntity : expensesummaryCollection) {
boolean zcgj_isfreightline = entryEntity.getBoolean("zcgj_isfreightline");//运费行
if (!zcgj_isfreightline) {
continue;
}
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("zcgj_pa_amount"));//价税合计-价税合计
newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("zcgj_amountnotax"));//不含税金额-不含税金额
newProcessAllocEntity.set("zcgj_rateval", entryEntity.get("zcgj_rateval"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额
newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目
processAllocEntityCollection.add(newProcessAllocEntity);
}
} else {
DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录
for (DynamicObject entryEntity : entryEntityCollection) { for (DynamicObject entryEntity : entryEntityCollection) {
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
@ -123,22 +140,6 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
} }
newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目
processAllocEntityCollection.add(newProcessAllocEntity);
}
if (zcgj_transset) {
DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总
for (DynamicObject entryEntity : expensesummaryCollection) {
boolean zcgj_isfreightline = entryEntity.getBoolean("zcgj_isfreightline");//运费行
if (!zcgj_isfreightline) {
continue;
}
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("zcgj_pa_amount"));//价税合计-价税合计
newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("zcgj_amountnotax"));//不含税金额-不含税金额
newProcessAllocEntity.set("zcgj_rateval", entryEntity.get("zcgj_rateval"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额
newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目
processAllocEntityCollection.add(newProcessAllocEntity); processAllocEntityCollection.add(newProcessAllocEntity);
} }
} }
@ -246,6 +247,23 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber); QFilter qFilter = new QFilter("billno", QCP.equals, matInNumber);
DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单 DynamicObject ecma_materialInBill = BusinessDataServiceHelper.loadSingle("ecma_materialinbill", new QFilter[]{qFilter});//入库单
if (ecma_materialInBill != null) { if (ecma_materialInBill != null) {
if (zcgj_transset) {
DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总
for (DynamicObject entryEntity : expensesummaryCollection) {
boolean zcgj_isfreightline = entryEntity.getBoolean("zcgj_isfreightline");//运费行
if (!zcgj_isfreightline) {
continue;
}
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("zcgj_pa_amount"));//价税合计-价税合计
newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("zcgj_amountnotax"));//不含税金额-不含税金额
newProcessAllocEntity.set("zcgj_rateval", entryEntity.get("zcgj_rateval"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额
newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目
processAllocEntityCollection.add(newProcessAllocEntity);
}
} else {
DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录 DynamicObjectCollection entryEntityCollection = ecma_materialInBill.getDynamicObjectCollection("entryentity");//入库单分录
for (DynamicObject entryEntity : entryEntityCollection) { for (DynamicObject entryEntity : entryEntityCollection) {
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType); DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
@ -262,22 +280,6 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
} }
newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目 newProcessAllocEntity.set("zcgj_expenseitem", expenseItem);//费用项目-对应费用项目
processAllocEntityCollection.add(newProcessAllocEntity);
}
if (zcgj_transset) {
DynamicObjectCollection expensesummaryCollection = ecma_materialInBill.getDynamicObjectCollection("zcgj_expensesummary");//费用汇总
for (DynamicObject entryEntity : expensesummaryCollection) {
boolean zcgj_isfreightline = entryEntity.getBoolean("zcgj_isfreightline");//运费行
if (!zcgj_isfreightline) {
continue;
}
DynamicObject newProcessAllocEntity = new DynamicObject(processAllocEntityType);
newProcessAllocEntity.set("zcgj_pa_amount", entryEntity.get("zcgj_pa_amount"));//价税合计-价税合计
newProcessAllocEntity.set("zcgj_amountnotax", entryEntity.get("zcgj_amountnotax"));//不含税金额-不含税金额
newProcessAllocEntity.set("zcgj_rateval", entryEntity.get("zcgj_rateval"));//税率%-税率%
newProcessAllocEntity.set("zcgj_taxamt", entryEntity.get("zcgj_taxamt"));//税额-税额
newProcessAllocEntity.set("zcgj_expenseitem", entryEntity.get("zcgj_expenseitem"));//费用项目-费用项目
processAllocEntityCollection.add(newProcessAllocEntity); processAllocEntityCollection.add(newProcessAllocEntity);
} }
} }

View File

@ -1755,13 +1755,16 @@ public class MaterialInBillEditPluginExt extends AbstractEcmaBillPlugin implemen
this.clearHead(); this.clearHead();
this.sumMaoftaxAmount(); this.sumMaoftaxAmount();
this.sumMaTaxAmount(); this.sumMaTaxAmount();
Object splitType = this.getModel().getValue("splittype");//分摊类型
EntryGrid grid = (EntryGrid) this.getControl("entryentity"); EntryGrid grid = (EntryGrid) this.getControl("entryentity");
BigDecimal sum = grid.getSum("ftransamount");//入库单-运费金额合计 BigDecimal sum = grid.getSum("ftransamount");//入库单-运费金额合计
this.getModel().setValue("transamount", sum);//总运费
BigDecimal zcgj_transtaxamount = grid.getSum("zcgj_transtaxamount");//入库单-运费税额合计 BigDecimal zcgj_transtaxamount = grid.getSum("zcgj_transtaxamount");//入库单-运费税额合计
this.getModel().setValue("transtaxamount", zcgj_transtaxamount);//运费总税额
BigDecimal taxtransamount = grid.getSum("taxtransamount");//入库单-含税运费 BigDecimal taxtransamount = grid.getSum("taxtransamount");//入库单-含税运费
if (splitType != null && !splitType.equals("3")) {
this.getModel().setValue("transamount", sum);//总运费
this.getModel().setValue("transtaxamount", zcgj_transtaxamount);//运费总税额
this.getModel().setValue("transoftaxamount", taxtransamount);//含税总运费 this.getModel().setValue("transoftaxamount", taxtransamount);//含税总运费
}
this.getView().updateView("matamount"); this.getView().updateView("matamount");
this.getView().updateView("matoftaxamount"); this.getView().updateView("matoftaxamount");
this.getView().updateView("mataxamount"); this.getView().updateView("mataxamount");

View File

@ -406,7 +406,7 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
DynamicObject purchaseApplyEntry = purchaseApplyEntryCollection.get(i); DynamicObject purchaseApplyEntry = purchaseApplyEntryCollection.get(i);
DynamicObject zcgj_purchaseapply_f7 = purchaseApplyEntry.getDynamicObject("zcgj_purchaseapply_f7");//采购申请 DynamicObject zcgj_purchaseapply_f7 = purchaseApplyEntry.getDynamicObject("zcgj_purchaseapply_f7");//采购申请
if (zcgj_purchaseapply_f7 != null) { if (zcgj_purchaseapply_f7 != null) {
if (row == i){ if (row == i) {
continue; continue;
} }
qFilters.add(new QFilter("id", QCP.not_equals, zcgj_purchaseapply_f7.get("id"))); qFilters.add(new QFilter("id", QCP.not_equals, zcgj_purchaseapply_f7.get("id")));
@ -628,6 +628,12 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
* @param expenseSummaryCollection 费用汇总分录集合 * @param expenseSummaryCollection 费用汇总分录集合
*/ */
private void handleUnsplitFreightLine(DynamicObjectCollection expenseSummaryCollection) { private void handleUnsplitFreightLine(DynamicObjectCollection expenseSummaryCollection) {
// 判断是否存在运费如果运费为0或空则不创建运费行
BigDecimal transAmount = (BigDecimal) getModel().getValue("transamount"); // 总运费
if (transAmount == null || transAmount.compareTo(BigDecimal.ZERO) == 0) {
return; // 无运费时不创建运费行
}
DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType()); DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType());
// 设置运费行标识 // 设置运费行标识
@ -635,7 +641,6 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
// 使用单据头上的字段汇总值 // 使用单据头上的字段汇总值
BigDecimal transSoftTaxAmount = (BigDecimal) getModel().getValue("transoftaxamount"); // 含税运费 BigDecimal transSoftTaxAmount = (BigDecimal) getModel().getValue("transoftaxamount"); // 含税运费
BigDecimal transAmount = (BigDecimal) getModel().getValue("transamount"); // 总运费
BigDecimal transtaxAmount = (BigDecimal) getModel().getValue("transtaxamount"); // 运费总税额 BigDecimal transtaxAmount = (BigDecimal) getModel().getValue("transtaxamount"); // 运费总税额
DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate"); // 运费税率 DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate"); // 运费税率
@ -667,19 +672,37 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
* @param expenseSummaryCollection 费用汇总分录集合 * @param expenseSummaryCollection 费用汇总分录集合
*/ */
private void handleSplitFreightLines(DynamicObjectCollection entryEntityCollection, DynamicObjectCollection expenseSummaryCollection) { private void handleSplitFreightLines(DynamicObjectCollection entryEntityCollection, DynamicObjectCollection expenseSummaryCollection) {
boolean hasFreight = false;
// 先检查是否存在运费
for (DynamicObject entryEntity : entryEntityCollection) {
BigDecimal ftransamount = (BigDecimal) entryEntity.get("ftransamount"); // 运费
if (ftransamount != null && ftransamount.compareTo(BigDecimal.ZERO) > 0) {
hasFreight = true;
break;
}
}
// 如果没有运费则不创建运费行
if (!hasFreight) {
return;
}
// 获取单据头上的税率 // 获取单据头上的税率
DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate"); DynamicObject taxRate = (DynamicObject) getModel().getValue("taxrate");
BigDecimal rateValue = taxRate != null ? (BigDecimal) taxRate.get("taxrate") : BigDecimal.ZERO; BigDecimal rateValue = taxRate != null ? (BigDecimal) taxRate.get("taxrate") : BigDecimal.ZERO;
// 遍历入库单明细为每条记录创建一条运费行 // 遍历入库单明细为每条有运费的记录创建一条运费行
for (DynamicObject entryEntity : entryEntityCollection) { for (DynamicObject entryEntity : entryEntityCollection) {
BigDecimal ftransamount = (BigDecimal) entryEntity.get("ftransamount"); // 运费
// 只有当运费大于0时才创建运费行
if (ftransamount != null && ftransamount.compareTo(BigDecimal.ZERO) > 0) {
DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType()); DynamicObject newFreightLine = new DynamicObject(expenseSummaryCollection.getDynamicObjectType());
// 设置运费行标识 // 设置运费行标识
newFreightLine.set("zcgj_isfreightline", true); newFreightLine.set("zcgj_isfreightline", true);
// 获取运费相关字段 // 获取运费相关字段
BigDecimal ftransamount = (BigDecimal) entryEntity.get("ftransamount"); // 运费
BigDecimal zcgj_transtaxamount = (BigDecimal) entryEntity.get("zcgj_transtaxamount"); // 运费税额 BigDecimal zcgj_transtaxamount = (BigDecimal) entryEntity.get("zcgj_transtaxamount"); // 运费税额
BigDecimal taxtransamount = (BigDecimal) entryEntity.get("taxtransamount"); // 含税运费 BigDecimal taxtransamount = (BigDecimal) entryEntity.get("taxtransamount"); // 含税运费
@ -717,6 +740,8 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
expenseSummaryCollection.add(newFreightLine); expenseSummaryCollection.add(newFreightLine);
} }
} }
}
/** /**
* 获取运费对应的费用项目 * 获取运费对应的费用项目

View File

@ -34,6 +34,9 @@ import kd.ec.contract.opplugin.validator.OutContractSettleReferValidator;
import kd.ec.contract.opplugin.validator.OutContractSettleTimeValidator; import kd.ec.contract.opplugin.validator.OutContractSettleTimeValidator;
import kd.ec.contract.opplugin.validator.OutContractSettleValidator; import kd.ec.contract.opplugin.validator.OutContractSettleValidator;
/**
* 支出合同结算审核反审核系统插件二开
*/
public class OutContractSettleOpExt extends AbstractContractSettleOp { public class OutContractSettleOpExt extends AbstractContractSettleOp {
public OutContractSettleOpExt() { public OutContractSettleOpExt() {
} }
@ -122,6 +125,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp {
boolean isSettleByMatIn = dataArr[i].getBoolean("issettlebymatin"); boolean isSettleByMatIn = dataArr[i].getBoolean("issettlebymatin");
boolean isSettleByReconciliation = dataArr[i].getBoolean("issettlebyreconc"); boolean isSettleByReconciliation = dataArr[i].getBoolean("issettlebyreconc");
boolean isSettleByEquipment = dataArr[i].getBoolean("iseqsettle"); boolean isSettleByEquipment = dataArr[i].getBoolean("iseqsettle");
boolean zcgj_transset = dataArr[i].getBoolean("zcgj_transset");//按入库运费结算//二开添加
Set<Long> materialInBillIds = new HashSet(16); Set<Long> materialInBillIds = new HashSet(16);
Set<Long> reconciliationBillIds = new HashSet(16); Set<Long> reconciliationBillIds = new HashSet(16);
Set<Long> equipmentBillIds = new HashSet(16); Set<Long> equipmentBillIds = new HashSet(16);
@ -151,7 +155,8 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp {
materialInBillIds.addAll(matInBillIdList); materialInBillIds.addAll(matInBillIdList);
} }
if (isSettleByMatIn) { // if (isSettleByMatIn) {//系统代码
if (isSettleByMatIn || zcgj_transset) {//二开修改
dynamicObjects = dataArr[i].getDynamicObjectCollection("materialinentry"); dynamicObjects = dataArr[i].getDynamicObjectCollection("materialinentry");
for (j = 0; j < dynamicObjects.size(); ++j) { for (j = 0; j < dynamicObjects.size(); ++j) {
@ -236,7 +241,6 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp {
bill.set("settlestatus", "0"); bill.set("settlestatus", "0");
}*///系统代码 }*///系统代码
//二开修改 //二开修改
boolean zcgj_transset = dataArr[i].getBoolean("zcgj_transset");//按入库运费结算
if (StringUtils.equals("audit", operationKey)) { if (StringUtils.equals("audit", operationKey)) {
if (zcgj_transset) { if (zcgj_transset) {
bill.set("zcgj_settlestatus", "1");//运费已结算 bill.set("zcgj_settlestatus", "1");//运费已结算
@ -304,7 +308,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp {
public void afterExecuteOperationTransaction(AfterOperationArgs e) { public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e); super.afterExecuteOperationTransaction(e);
String operation = e.getOperationKey(); /* String operation = e.getOperationKey();
DynamicObject[] settleBills = e.getDataEntities(); DynamicObject[] settleBills = e.getDataEntities();
List<DynamicObject> settleBillList = Arrays.asList(settleBills); List<DynamicObject> settleBillList = Arrays.asList(settleBills);
List<DynamicObject> listingEntrys = (List) settleBillList.stream().flatMap((settleBill) -> { List<DynamicObject> listingEntrys = (List) settleBillList.stream().flatMap((settleBill) -> {
@ -318,7 +322,7 @@ public class OutContractSettleOpExt extends AbstractContractSettleOp {
this.updateListing(listingEntrys, true); this.updateListing(listingEntrys, true);
} else if ("unaudit".equals(operation)) { } else if ("unaudit".equals(operation)) {
this.updateListing(listingEntrys, false); this.updateListing(listingEntrys, false);
} }*///二开注释掉的
} }