Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model update #536

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
12 changes: 12 additions & 0 deletions src/shopcube/modules/box__ecommerce/invoice/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"author": {
"mail": "",
"name": "",
"website": ""
},
"display_string": "Invoice",
"fa-icon": "fa fa-store",
"module_name": "invoice",
"type": "show",
"url_prefix": "/invoice"
}
57 changes: 57 additions & 0 deletions src/shopcube/modules/box__ecommerce/invoice/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base/module_base.html" %}
{% set active_page = info['display_string']+' dashboard' %}
{% block pagehead %}
<title></title>
<style>
</style>
{% endblock %}
{% block sidebar %}
{% include info['module_name']+'/blocks/sidebar.html' %}
{% endblock %}
{% block content %}
<br>

<div class="card">
<div class="card-body">

</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Please add your functional tests to this file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Please add your models tests to this file.
30 changes: 30 additions & 0 deletions src/shopcube/modules/box__ecommerce/invoice/view.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 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,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)
Expand Down