Files
bacchus/apps/backend/app/models/delivery.py
2025-09-28 19:13:01 +02:00

23 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from app.core.database import Base
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text
from sqlalchemy.orm import relationship
from datetime import datetime
class Delivery(Base):
__tablename__ = "deliveries"
id = Column(Integer, primary_key=True, index=True)
product_id = Column(Integer, ForeignKey("products.id", ondelete="CASCADE"), nullable=False, index=True)
amount = Column(Integer, nullable=False, default=0) # gelieferte Menge (Stück / Einheiten)
price_cents = Column(Integer, nullable=False, default=0) # Einkaufspreis in Cent (gesamt oder pro Einheit je nach Modell)
delivered_at = Column(DateTime(timezone=True), nullable=True) # Lieferdatum
supplier = Column(String, nullable=True) # Lieferant (frei)
invoice_number = Column(String, nullable=True) # Rechnungsnummer
created_by = Column(Integer, nullable=True) # optional: User-ID, der die Lieferung erfasst hat
deposit_return_cents = Column(Integer, nullable=False, server_default="0")
note = Column(Text, nullable=True) # oder String(1000)
# Rückverknüpfung zum Produkt
product = relationship("Product", back_populates="deliveries")