feat(backend): 出入库定价字段消歧 + 总利润落库 + 成本仅管理员可见
- 字段重命名(旧列弃用保留,启动幂等回填 BackfillPricingColumns): 入库 unit_price/total_price/total_amount → cost_price/cost_amount/cost_total; 出库同前缀 + 新增 sale_amount(售价小计)/ sale_total(应收)/ profit_total(总利润) - 建单落三值;确认售价联动重算 sale_amount/sale_total/profit_total; 确认进价回填成本后联动重算受影响出库单利润(recalcStockOutProfit) - 出库 List/Get 对 operator/readonly 抹零成本与利润(stripStockOutCost 服务端兜底) - 兼容一版:Create/Update 接受旧 key unit_price 回落(v1.0.87 及之前客户端) - SUM 聚合/价格趋势/导入/种子工具同步切新列;测试全量改名 + 6 个新回归 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
This commit is contained in:
@@ -497,7 +497,7 @@ func (ic *importCtx) writeOrder(
|
||||
TenantBase: model.TenantBase{ShopID: ic.shopID},
|
||||
OrderNo: orderNo, Type: orderType, WarehouseID: ic.whID,
|
||||
PartnerID: partnerID, OperatorID: operatorID, CreatorID: creatorID,
|
||||
ReviewerID: reviewerID, Status: status, OrderDate: orderDate, TotalAmount: totalAmount,
|
||||
ReviewerID: reviewerID, Status: status, OrderDate: orderDate, CostTotal: totalAmount,
|
||||
}
|
||||
if err := tx.Create(&o).Error; err != nil {
|
||||
return err
|
||||
@@ -510,8 +510,8 @@ func (ic *importCtx) writeOrder(
|
||||
Series: get(dr, dCols, "系列"),
|
||||
Spec: get(dr, dCols, "规格"),
|
||||
Quantity: parseFloatLoose(get(dr, dCols, "数量")),
|
||||
UnitPrice: parseFloatLoose(get(dr, dCols, "单价")),
|
||||
TotalPrice: parseFloatLoose(get(dr, dCols, "金额")),
|
||||
CostPrice: parseFloatLoose(get(dr, dCols, "单价")),
|
||||
CostAmount: parseFloatLoose(get(dr, dCols, "金额")),
|
||||
BatchNo: get(dr, dCols, "批次号"),
|
||||
}
|
||||
it.ProductionDate = parseDatePtr(get(dr, dCols, "生产日期"))
|
||||
@@ -529,7 +529,8 @@ func (ic *importCtx) writeOrder(
|
||||
TenantBase: model.TenantBase{ShopID: ic.shopID},
|
||||
OrderNo: orderNo, Type: orderType, WarehouseID: ic.whID,
|
||||
PartnerID: partnerID, OperatorID: operatorID, CreatorID: creatorID,
|
||||
ReviewerID: reviewerID, Status: status, OrderDate: orderDate, TotalAmount: totalAmount,
|
||||
// 忠实导入:源「金额」合计沿旧行为落应收合计(sale_price=0 待定价)
|
||||
ReviewerID: reviewerID, Status: status, OrderDate: orderDate, SaleTotal: totalAmount,
|
||||
}
|
||||
if err := tx.Create(&o).Error; err != nil {
|
||||
return err
|
||||
@@ -542,8 +543,8 @@ func (ic *importCtx) writeOrder(
|
||||
Series: get(dr, dCols, "系列"),
|
||||
Spec: get(dr, dCols, "规格"),
|
||||
Quantity: parseFloatLoose(get(dr, dCols, "数量")),
|
||||
UnitPrice: parseFloatLoose(get(dr, dCols, "单价")),
|
||||
TotalPrice: parseFloatLoose(get(dr, dCols, "金额")),
|
||||
CostPrice: parseFloatLoose(get(dr, dCols, "单价")),
|
||||
CostAmount: parseFloatLoose(get(dr, dCols, "金额")),
|
||||
BatchNo: get(dr, dCols, "批次号"),
|
||||
}
|
||||
it.ProductionDate = parseDatePtr(get(dr, dCols, "生产日期"))
|
||||
|
||||
Reference in New Issue
Block a user