完善库存统计接口,增加移动平均价的逻辑

This commit is contained in:
jishenghua
2024-05-24 01:22:32 +08:00
parent 0292446e15
commit 28548c7957
9 changed files with 124 additions and 9 deletions

View File

@@ -332,6 +332,7 @@ public class DepotItemController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<>();
try {
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
List<Long> categoryIdList = new ArrayList<>();
if(categoryId != null){
categoryIdList = materialService.getListByParentId(categoryId);
@@ -371,7 +372,11 @@ public class DepotItemController {
item.put("thisSum", thisSum);
//将小单位的库存换算为大单位的库存
item.put("bigUnitStock", materialService.getBigUnitStock(thisSum, diEx.getUnitId()));
item.put("unitPrice", diEx.getPurchaseDecimal());
if(moveAvgPriceFlag) {
item.put("unitPrice", diEx.getCurrentUnitPrice());
} else {
item.put("unitPrice", diEx.getPurchaseDecimal());
}
item.put("thisAllPrice", thisSum.multiply(diEx.getPurchaseDecimal()));
dataArray.add(item);
}
@@ -408,6 +413,7 @@ public class DepotItemController {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<>();
try {
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
List<Long> categoryIdList = new ArrayList<>();
if(categoryId != null){
categoryIdList = materialService.getListByParentId(categoryId);
@@ -423,7 +429,12 @@ public class DepotItemController {
Long mId = diEx.getMId();
BigDecimal thisSum = depotItemService.getStockByParamWithDepotList(depotList,mId,null,endTime);
thisAllStock = thisAllStock.add(thisSum);
BigDecimal unitPrice = diEx.getPurchaseDecimal();
BigDecimal unitPrice = null;
if(moveAvgPriceFlag) {
unitPrice = diEx.getCurrentUnitPrice();
} else {
unitPrice = diEx.getPurchaseDecimal();
}
if(unitPrice == null) {
unitPrice = BigDecimal.ZERO;
}