出库单优化单价(不含税)字段逻辑

This commit is contained in:
xuhaihui 2025-10-22 17:09:54 +08:00
parent 0c152a9e6f
commit cfc9ec22b0
1 changed files with 10 additions and 2 deletions

View File

@ -165,6 +165,7 @@ public class MaterialOutBillPlugin extends AbstractBillPlugIn implements BeforeF
DynamicObject ecma_matinventory = BusinessDataServiceHelper.loadSingle("ecma_matinventory", new QFilter[]{qFilters});//即时库存
if (ecma_matinventory != null) {
BigDecimal qty = ecma_matinventory.getBigDecimal("qty");//即时库存-可用数量
BigDecimal price2 = ecma_matinventory.getBigDecimal("price");//即时库存-当前成本单价
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//出库单分录
BigDecimal totalQty = BigDecimal.ZERO;//修改行相同的资源编码数量
BigDecimal totalAmount = BigDecimal.ZERO;//修改行不相同的资源编码数量
@ -180,13 +181,20 @@ public class MaterialOutBillPlugin extends AbstractBillPlugIn implements BeforeF
continue;
}
totalQty = totalQty.add(qty1);
if (rowIndex == i){
if (rowIndex == i) {
continue;
}
totalAmount = totalAmount.add(amount);
}
if (totalQty.compareTo(qty) == 0) {
this.getModel().setValue("amount", ecma_matinventory.getBigDecimal("amount").subtract(totalAmount), rowIndex);//金额
BigDecimal amount = ecma_matinventory.getBigDecimal("amount").subtract(totalAmount);
this.getModel().setValue("amount", amount, rowIndex);//金额
BigDecimal price1 = amount.divide(qty, 2, RoundingMode.HALF_UP);
this.getModel().setValue("price", price1, rowIndex);//单价不含税
} else {
this.getModel().setValue("price", price2, rowIndex);//单价不含税
BigDecimal result1 = newValue.multiply(price2).setScale(2, RoundingMode.HALF_UP);
this.getModel().setValue("amount", result1, rowIndex);//金额
}
}
}