Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__pycache__/
*.pyc
*.pyo
*.pyd
.pytest_cache/
.DS_Store
.env
node_modules/
dist/
build/
Binary file removed balancer/__pycache__/core.cpython-311.pyc
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions balancer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

class InventoryItem:
def __init__(self, sku: str, batch_id: str, current_stock: int, expiry_date: datetime.date, daily_burn_rate: float):
if not sku or not isinstance(sku, str):
raise ValueError("SKU must be a non-empty string.")
if not batch_id or not isinstance(batch_id, str):
raise ValueError("Batch ID must be a non-empty string.")
if not isinstance(current_stock, int) or current_stock < 0:
raise ValueError("Current stock must be a non-negative integer.")
if not isinstance(expiry_date, datetime.date):
raise TypeError("Expiry date must be a datetime.date object.")
if not isinstance(daily_burn_rate, (int, float)) or daily_burn_rate < 0:
raise ValueError("Daily burn rate must be a non-negative number.")

self.sku = sku
self.batch_id = batch_id
self.current_stock = current_stock
Expand Down