Compare commits
1 Commits
main
...
feature/or
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | 3f5475f743 |
|
@ -0,0 +1,21 @@
|
|||
"""Orders plugin"""
|
||||
|
||||
from flask import Blueprint
|
||||
|
||||
from flaschengeist.plugins import Plugin
|
||||
|
||||
from . import models
|
||||
|
||||
order_bp = Blueprint("orders", __name__)
|
||||
|
||||
|
||||
class OrdersPlugin(Plugin):
|
||||
models = models
|
||||
|
||||
def __init__(self, config):
|
||||
super().__init__(blueprint=order_bp)
|
||||
|
||||
def install(self):
|
||||
from flaschengeist.database import db
|
||||
|
||||
db.create_all()
|
|
@ -0,0 +1,49 @@
|
|||
import datetime
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from flaschengeist.models import ModelSerializeMixin, UtcDateTime
|
||||
from flaschengeist.database import db
|
||||
|
||||
|
||||
class Product(db.Model, ModelSerializeMixin):
|
||||
__tablename__ = "orders_product"
|
||||
id: int = db.Column(db.Integer, primary_key=True)
|
||||
name: str = db.Column(db.String(255))
|
||||
price: float = db.Column(db.Numeric(precision=19, scale=3, asdecimal=False))
|
||||
|
||||
tax_rate: float = db.Column(db.Float)
|
||||
|
||||
|
||||
class Bill(db.Model, ModelSerializeMixin):
|
||||
__tablename__ = "orders_bill"
|
||||
id: int = db.Column(db.Integer, primary_key=True)
|
||||
time: datetime.datetime = db.Column(UtcDateTime, nullable=False)
|
||||
payment = ...
|
||||
payed = db.Column(db.Boolean)
|
||||
cancelled = db.Column(db.Integer, db.ForeignKey("orders_bill.id")) # Cancelled by
|
||||
|
||||
orders = relationship("Order", back_populates="bill")
|
||||
|
||||
|
||||
class Order(db.Model):
|
||||
__tablename__ = "orders_order"
|
||||
id: int = db.Column(db.Integer, primary_key=True)
|
||||
bill = ...
|
||||
product = ...
|
||||
amount = ...
|
||||
price = ...
|
||||
tax_rate = ...
|
||||
discount = ...
|
||||
|
||||
userid: str = ""
|
||||
value: float = db.Column(db.Numeric(precision=3, scale=2, asdecimal=False), nullable=False)
|
||||
|
||||
_job_id = db.Column("job_id", db.Integer, db.ForeignKey("schedule_job.id"), nullable=False, primary_key=True)
|
||||
_user_id = db.Column("user_id", db.Integer, db.ForeignKey("user.id"), nullable=False, primary_key=True)
|
||||
|
||||
user_: User = db.relationship("User")
|
||||
job_ = db.relationship("Job")
|
||||
|
||||
@property
|
||||
def userid(self):
|
||||
return self.user_.userid
|
Loading…
Reference in New Issue