feat(backend): 入库「确认进价」前向补偿(暂估价→真实价)

调货 0 价入库并已审核/出库后,价格确定时补填真实进价:一事务内
回填入库明细/库存批次/已出库成本快照,重算入库单总额,按差额补
应付流水,同步参考进价。按 product_id 精确命中(序列号 1:1),
不动售价/应收。仅 approved 单、管理员/超管,差额幂等可重复确认。

新增 POST /stock-in/orders/:id/confirm-cost 及 4 个测试用例。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-23 20:07:49 +08:00
parent 7969bb41e3
commit 3625240839
5 changed files with 337 additions and 0 deletions
+2
View File
@@ -157,6 +157,8 @@ func Setup(r *gin.Engine, db *gorm.DB) {
stockIn.PUT("/orders/:id/withdraw", stockInH.Withdraw)
// 退单(已审核单退货,库存删除+冲应付):仅管理员/超管(service 内判权)
stockIn.POST("/orders/:id/return", stockInH.Return)
// 确认进价(暂估0价→真实价,前向补偿):仅管理员/超管(service 内判权)
stockIn.POST("/orders/:id/confirm-cost", stockInH.ConfirmCost)
}
// 出库