forked from erp-dev/erp
fix: stock-snapshots api and service calc wrong result
This commit is contained in:
@@ -815,7 +815,6 @@ def create_stock_snapshot(stock_change_detail: models.StockChangeDetail, invento
|
||||
raise ValueError("无效的库存变动明细记录")
|
||||
|
||||
delta = stock_change_detail.quantity if stock_change_detail.stock_change_record.is_incoming else -stock_change_detail.quantity
|
||||
rolls_delta = 1 if stock_change_detail.stock_change_record.is_incoming else -1
|
||||
|
||||
# 必须在库存变动发生后创建快照
|
||||
snapshot = models.StockSnapshot(
|
||||
@@ -827,7 +826,7 @@ def create_stock_snapshot(stock_change_detail: models.StockChangeDetail, invento
|
||||
quantity_after=inventory.quantity,
|
||||
stock_change_record_id=stock_change_detail.stock_change_record.id,
|
||||
unit=stock_change_detail.unit,
|
||||
num_of_rolls=inventory.num_of_rolls + rolls_delta,
|
||||
num_of_rolls=inventory.num_of_rolls,
|
||||
)
|
||||
snapshot.save()
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user