Skip to content

Commit

Permalink
Merge pull request #528 from LaDen2/models/update
Browse files Browse the repository at this point in the history
models:update pos & product
  • Loading branch information
Abdur-rahmaanJ authored Jul 17, 2024
2 parents f2149e6 + 36ceae8 commit 4fcbf8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/shopcube/modules/box__ecommerce/pos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Transaction(db.Model):
time = db.Column(db.DateTime, default=datetime.now())
quantity = db.Column(db.Integer)
price = db.Column(db.Float)
total_amount = db.Column(db.Float)
method_of_payment = db.Column(db.String(50))

product = db.relationship('Product', backref='transaction', lazy=True)

def add(self):
db.session.add(self)
Expand Down
17 changes: 5 additions & 12 deletions src/shopcube/modules/box__ecommerce/product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

# from modules.box__ecommerce.pos.models import Transaction

transaction_helpers = db.Table(
"transaction_helpers",
db.Column("product_barcode", db.Integer, db.ForeignKey("product.id")),
db.Column("transaction_id", db.Integer, db.ForeignKey("transactions.id")),
)



class Product(PkModel):
Expand All @@ -24,20 +20,15 @@ class Product(PkModel):
in_stock = db.Column(db.Integer)
discontinued = db.Column(db.Boolean)
selling_price = db.Column(db.Float)

transaction_id = db.Column(db.Integer, db.ForeignKey('transactions.id'))
is_onsale = db.Column(db.Boolean, default=False)
is_featured = db.Column(db.Boolean, default=False)
subcategory_name = db.relationship(
"SubCategory",
backref=db.backref("subcategory", uselist=False),
overlaps="products,subcategory",
)
transactions = db.relationship(
"Transaction",
secondary=transaction_helpers,
backref="products",
cascade="all, delete",
)

resources = db.relationship(
"Resource", backref="resources", lazy=True, cascade="all, delete"
)
Expand Down Expand Up @@ -108,3 +99,5 @@ class Size(PkModel):
name = db.Column(db.String(100))

product_id = db.Column(db.Integer, db.ForeignKey("product.id"))

product_id = db.Column(db.Integer, db.ForeignKey("product.id"))
2 changes: 1 addition & 1 deletion src/shopcube/static/themes/front/ecommerceus/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ <h4 class="card-title"><a>{{ product.name }}</a></h4>

</div>

<div class="separator">&nbsp;&nbsp;&nbsp;<b>SIGN UP & BE THE FIRST TO KNOW</b>&nbsp;&nbsp;&nbsp;</div>
<div class="separator">&nbsp;&nbsp;&nbsp;<b>SIGN UP & BE THE FIRST TO KNOW </b>&nbsp;&nbsp;&nbsp;</div>

<div class="container">
<form class="row row-cols-lg-auto g-3 align-items-center">
Expand Down

0 comments on commit 4fcbf8d

Please sign in to comment.