feat(inventory): add mandatory per-section date pickers, prevent future dates, sync transfer dates, and sort by transaction_date
This commit is contained in:
@@ -217,6 +217,7 @@ def transaction_to_dict(tx: InventoryTransaction, wh: Warehouse | None = None) -
|
||||
"performed_by": tx.performed_by,
|
||||
"delivered_to": tx.delivered_to,
|
||||
"transaction_date": to_iso(tx.transaction_date),
|
||||
"created_at": to_iso(tx.created_at) if hasattr(tx, "created_at") and tx.created_at else None,
|
||||
"note": tx.note,
|
||||
}
|
||||
|
||||
@@ -461,7 +462,10 @@ async def list_transactions(
|
||||
InventoryTransaction.transaction_date
|
||||
< datetime.fromisoformat(date_to).replace(tzinfo=timezone.utc) + timedelta(days=1)
|
||||
)
|
||||
stmt = sort_query(stmt, InventoryTransaction, sort, default="-transaction_date")
|
||||
if not sort or sort == "-transaction_date":
|
||||
stmt = stmt.order_by(InventoryTransaction.transaction_date.desc(), InventoryTransaction.created_at.desc())
|
||||
else:
|
||||
stmt = sort_query(stmt, InventoryTransaction, sort, default="-transaction_date")
|
||||
items, meta = await paginate(stmt, page, page_size, db)
|
||||
|
||||
# Enrich: warehouse name + material/brand/specs/unit for the UI rows.
|
||||
|
||||
Reference in New Issue
Block a user