From 4cf9f1ffaa8db4fac2a396367723d72c2d67e7da Mon Sep 17 00:00:00 2001 From: LaDen2 Date: Thu, 18 Jul 2024 12:06:24 +0400 Subject: [PATCH 1/2] add invoice file --- .../modules/box__ecommerce/invoice/forms.py | 0 .../modules/box__ecommerce/invoice/info.json | 12 ++++++++ .../modules/box__ecommerce/invoice/models.py | 1 + .../templates/invoice/blocks/sidebar.html | 0 .../invoice/templates/invoice/dashboard.html | 19 ++++++++++++ .../invoice/tests/test_invoice_functional.py | 1 + .../invoice/tests/test_invoice_models.py | 1 + .../modules/box__ecommerce/invoice/view.py | 30 +++++++++++++++++++ 8 files changed, 64 insertions(+) create mode 100755 src/shopcube/modules/box__ecommerce/invoice/forms.py create mode 100755 src/shopcube/modules/box__ecommerce/invoice/info.json create mode 100755 src/shopcube/modules/box__ecommerce/invoice/models.py create mode 100755 src/shopcube/modules/box__ecommerce/invoice/templates/invoice/blocks/sidebar.html create mode 100755 src/shopcube/modules/box__ecommerce/invoice/templates/invoice/dashboard.html create mode 100755 src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_functional.py create mode 100755 src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_models.py create mode 100755 src/shopcube/modules/box__ecommerce/invoice/view.py diff --git a/src/shopcube/modules/box__ecommerce/invoice/forms.py b/src/shopcube/modules/box__ecommerce/invoice/forms.py new file mode 100755 index 00000000..e69de29b diff --git a/src/shopcube/modules/box__ecommerce/invoice/info.json b/src/shopcube/modules/box__ecommerce/invoice/info.json new file mode 100755 index 00000000..b2479b49 --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/info.json @@ -0,0 +1,12 @@ +{ + "author": { + "mail": "", + "name": "", + "website": "" + }, + "display_string": "Invoice", + "fa-icon": "fa fa-store", + "module_name": "invoice", + "type": "show", + "url_prefix": "/invoice" +} \ No newline at end of file diff --git a/src/shopcube/modules/box__ecommerce/invoice/models.py b/src/shopcube/modules/box__ecommerce/invoice/models.py new file mode 100755 index 00000000..d3f5a12f --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/models.py @@ -0,0 +1 @@ + diff --git a/src/shopcube/modules/box__ecommerce/invoice/templates/invoice/blocks/sidebar.html b/src/shopcube/modules/box__ecommerce/invoice/templates/invoice/blocks/sidebar.html new file mode 100755 index 00000000..e69de29b diff --git a/src/shopcube/modules/box__ecommerce/invoice/templates/invoice/dashboard.html b/src/shopcube/modules/box__ecommerce/invoice/templates/invoice/dashboard.html new file mode 100755 index 00000000..5e7626bd --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/templates/invoice/dashboard.html @@ -0,0 +1,19 @@ +{% extends "base/module_base.html" %} +{% set active_page = info['display_string']+' dashboard' %} +{% block pagehead %} + + +{% endblock %} +{% block sidebar %} +{% include info['module_name']+'/blocks/sidebar.html' %} +{% endblock %} +{% block content %} +
+ +
+
+ +
+
+{% endblock %} diff --git a/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_functional.py b/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_functional.py new file mode 100755 index 00000000..73951848 --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_functional.py @@ -0,0 +1 @@ +# Please add your functional tests to this file. diff --git a/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_models.py b/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_models.py new file mode 100755 index 00000000..9b287179 --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/tests/test_invoice_models.py @@ -0,0 +1 @@ +# Please add your models tests to this file. diff --git a/src/shopcube/modules/box__ecommerce/invoice/view.py b/src/shopcube/modules/box__ecommerce/invoice/view.py new file mode 100755 index 00000000..8a6925c7 --- /dev/null +++ b/src/shopcube/modules/box__ecommerce/invoice/view.py @@ -0,0 +1,30 @@ +from shopyo.api.module import ModuleHelp +# from flask import render_template +# from flask import url_for +# from flask import redirect +# from flask import flash +# from flask import request + +# from shopyo.api.html import notify_success +# from shopyo.api.forms import flash_errors + +mhelp = ModuleHelp(__file__, __name__) +globals()[mhelp.blueprint_str] = mhelp.blueprint +module_blueprint = globals()[mhelp.blueprint_str] + + +@module_blueprint.route("/") +def index(): + return "usama" + +# If "dashboard": "/dashboard" is set in info.json +# +# @module_blueprint.route("/dashboard", methods=["GET"]) +# def dashboard(): + +# context = mhelp.context() + +# context.update({ + +# }) +# return mhelp.render('dashboard.html', **context) From 2895d1023dbfca2e6b9a66258b620c951c607e28 Mon Sep 17 00:00:00 2001 From: LaDen2 Date: Wed, 2 Oct 2024 22:01:15 +0400 Subject: [PATCH 2/2] feat: invoice + transaction modifs --- .../modules/box__ecommerce/invoice/models.py | 56 +++++++++++++++++++ .../modules/box__ecommerce/pos/models.py | 5 ++ 2 files changed, 61 insertions(+) diff --git a/src/shopcube/modules/box__ecommerce/invoice/models.py b/src/shopcube/modules/box__ecommerce/invoice/models.py index d3f5a12f..420a7b50 100755 --- a/src/shopcube/modules/box__ecommerce/invoice/models.py +++ b/src/shopcube/modules/box__ecommerce/invoice/models.py @@ -1 +1,57 @@ +from datetime import datetime +from init import db + +class Invoice(db.Model): + __tablename__ = "invoices" + + id = db.Column(db.Integer, primary_key=True) + invoice_number = db.Column(db.String(100), unique=True, nullable=True) + invoice_date = db.Column(db.DateTime, default=datetime.now, nullable=True) + due_date = db.Column(db.DateTime, nullable=True) + + # Company Info + company_name = db.Column(db.String(100), nullable=True) + company_address = db.Column(db.String(300), nullable=True) + company_contact = db.Column(db.String(100), nullable=True) + + # Customer Information + customer_name = db.Column(db.String(100), nullable=True) + customer_address = db.Column(db.String(300), nullable=True) + customer_contact = db.Column(db.String(100), nullable=True) + + # Transaction Details + transaction_id = db.Column(db.Integer, db.ForeignKey('transactions.id'), nullable=True) + #transaction = db.relationship('Transaction', back_populates='invoice', lazy=True) + + # Pricing Summary + subtotal = db.Column(db.Float, nullable=True) + discount = db.Column(db.Float, nullable=True, default=0.0) + taxes = db.Column(db.Float, nullable=True, default=0.0) + shipping = db.Column(db.Float, nullable=True, default=0.0) + total_amount = db.Column(db.Float, nullable=True) + + # Payment Information + payment_method = db.Column(db.String(50), nullable=True) + payment_status = db.Column(db.String(50), nullable=True) + payment_reference_number = db.Column(db.String(100), nullable=True) + + # Additional Information + terms_and_conditions = db.Column(db.Text, nullable=True) + notes = db.Column(db.Text, nullable=True) + return_policy = db.Column(db.Text, nullable=True) + po_number = db.Column(db.String(100), nullable=True) + + def add(self): + db.session.add(self) + + def insert(self): + db.session.add(self) + db.session.commit() + + def update(self): + db.session.commit() + + def delete(self): + db.session.delete(self) + db.session.commit() diff --git a/src/shopcube/modules/box__ecommerce/pos/models.py b/src/shopcube/modules/box__ecommerce/pos/models.py index 959c64c6..c86a17b5 100644 --- a/src/shopcube/modules/box__ecommerce/pos/models.py +++ b/src/shopcube/modules/box__ecommerce/pos/models.py @@ -12,6 +12,11 @@ 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) + invoice = db.relationship('Invoice', backref='trsanctions', uselist=False) def add(self): db.session.add(self)