mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-19 12:50:11 -05:00
feat: add devaluation support to stock movements
- Add 'devaluation' to stock movement types - Add validation to ensure trackable items for devaluation - Improve error handling for devaluation operations
This commit is contained in:
@@ -13,7 +13,7 @@ class StockMovement(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
movement_type = db.Column(
|
||||
db.String(20), nullable=False, index=True
|
||||
) # 'adjustment', 'transfer', 'sale', 'rent', 'purchase', 'return', 'waste'
|
||||
) # 'adjustment', 'transfer', 'sale', 'rent', 'purchase', 'return', 'waste', 'devaluation'
|
||||
stock_item_id = db.Column(db.Integer, db.ForeignKey("stock_items.id"), nullable=False, index=True)
|
||||
warehouse_id = db.Column(db.Integer, db.ForeignKey("warehouses.id"), nullable=False, index=True)
|
||||
quantity = db.Column(db.Numeric(10, 2), nullable=False) # Positive for additions, negative for removals
|
||||
|
||||
@@ -983,6 +983,9 @@ def new_movement():
|
||||
|
||||
# Process devaluation if enabled
|
||||
if devalue_enabled:
|
||||
if not item.is_trackable:
|
||||
raise ValueError(_("Stock item is not trackable. Devaluation requires trackable items."))
|
||||
|
||||
base_cost = item.default_cost or Decimal("0")
|
||||
if base_cost <= 0:
|
||||
raise ValueError(_("Stock item must have a default cost to perform devaluation"))
|
||||
|
||||
Reference in New Issue
Block a user