更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -10,15 +10,14 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// Movement 一次库存变动的入参。库存结存只能由本引擎经流水驱动。
|
||||
type Movement struct {
|
||||
TenantID string
|
||||
ProductID uint64
|
||||
WarehouseID uint64
|
||||
BatchNo string
|
||||
Direction int8 // models.ErpStockIn / ErpStockOut
|
||||
Direction int8
|
||||
Qty float64
|
||||
UnitCost float64 // 入库=进价/成本;出库传 0 表示按当前加权成本
|
||||
UnitCost float64
|
||||
DocType string
|
||||
DocID uint64
|
||||
DocNo string
|
||||
@@ -26,12 +25,10 @@ type Movement struct {
|
||||
OperatorID string
|
||||
OperatorName string
|
||||
Remark string
|
||||
// 批次效期随入库流水落地,出库/调拨沿用同批次快照
|
||||
ProductionDate *time.Time
|
||||
ExpireDate *time.Time
|
||||
}
|
||||
|
||||
// StockError 库存不足等业务错误(调用方可据 ErrInsufficientStock 区分文案)。
|
||||
type StockError struct {
|
||||
ProductName string
|
||||
Requested float64
|
||||
@@ -46,13 +43,6 @@ func (e *StockError) Error() string {
|
||||
return fmt.Sprintf("商品「%s」库存异常", e.ProductName)
|
||||
}
|
||||
|
||||
// ApplyMovement 在事务内执行一条库存变动:
|
||||
// 1. 定位/创建结存行(tenant+product+warehouse+batch 唯一);
|
||||
// 2. 出库时校验可用量(负库存开关取自基础设置);
|
||||
// 3. 入库按移动加权平均重算单位成本;出库成本=出库时加权成本(记入流水,毛利口径);
|
||||
// 4. 写库存流水 + 更新结存。
|
||||
//
|
||||
// 返回出库时点的单位成本(销售成本/退货回冲依据)。
|
||||
func ApplyMovement(o orm.QueryExecutor, mv *Movement) (float64, error) {
|
||||
if mv.Qty <= 0 {
|
||||
return 0, fmt.Errorf("库存变动数量必须大于0")
|
||||
@@ -95,7 +85,7 @@ func ApplyMovement(o orm.QueryExecutor, mv *Movement) (float64, error) {
|
||||
before := stock.Quantity
|
||||
dir := mv.Direction
|
||||
unitCost := mv.UnitCost
|
||||
outCost := stock.CostPrice // 出库成本口径:当前加权成本
|
||||
outCost := stock.CostPrice
|
||||
|
||||
if dir == models.ErpStockOut {
|
||||
if !settings.NegativeAllowed && before-mv.Qty < -0.000001 {
|
||||
@@ -120,7 +110,6 @@ func ApplyMovement(o orm.QueryExecutor, mv *Movement) (float64, error) {
|
||||
return unitCost, nil
|
||||
}
|
||||
|
||||
// 入库:移动加权平均
|
||||
if unitCost <= 0 {
|
||||
unitCost = product.PurchasePrice
|
||||
}
|
||||
@@ -157,7 +146,6 @@ func writeLedger(o orm.QueryExecutor, mv *Movement, dir int8, before, after, uni
|
||||
return nil
|
||||
}
|
||||
|
||||
// RefOutboundCost 取某条出库流水记录的出库成本(销售退货回冲入库成本用)。
|
||||
func RefOutboundCost(o orm.QueryExecutor, tenantID string, docItemID uint64) float64 {
|
||||
if docItemID == 0 {
|
||||
return 0
|
||||
|
||||
Reference in new issue
Block a user