diff --git a/brewman/brewman/__init__.py b/brewman/brewman/__init__.py
index 0c6ff811..bdf757ec 100644
--- a/brewman/brewman/__init__.py
+++ b/brewman/brewman/__init__.py
@@ -78,8 +78,8 @@ def main(global_config, **settings):
config.add_route('journal', '/Journal')
config.add_route('purchase_id', '/Purchase/{id}')
config.add_route('purchase', '/Purchase')
- config.add_route('purchase_return_id', '/PurchaseReturn/{id}')
- config.add_route('purchase_return', '/PurchaseReturn')
+ config.add_route('purchase_return_id', '/Return/{id}')
+ config.add_route('purchase_return', '/Return')
config.add_route('payment_id', '/Payment/{id}')
config.add_route('payment', '/Payment')
config.add_route('receipt_id', '/Receipt/{id}')
diff --git a/brewman/brewman/models/auth.py b/brewman/brewman/models/auth.py
index dff7ec1c..096b68e0 100644
--- a/brewman/brewman/models/auth.py
+++ b/brewman/brewman/models/auth.py
@@ -1,9 +1,11 @@
+import random
+import string
import uuid
from sqlalchemy.schema import ForeignKey, Table
from brewman.models.guidtype import GUID
from hashlib import md5
-from sqlalchemy import Column, Boolean, Unicode
+from sqlalchemy import Column, Boolean, Unicode, Integer
from sqlalchemy.orm import synonym, relationship
@@ -14,12 +16,50 @@ def encrypt(val):
return md5(val.encode('utf-8') + "Salt".encode('utf-8')).hexdigest()
-#class UserGroup(Base):
-# __tablename__ = 'auth_usergroups'
-#
-# id = Column('UserGroupID', GUID(), primary_key=True)
-# user_id = Column('UserID', GUID(), ForeignKey('auth_users.UserID'))
-# group_id = Column('GroupID', GUID(), ForeignKey('auth_groups.GroupID'))
+class Client(Base):
+ __tablename__ = 'auth_clients'
+
+ id = Column('ClientID', GUID(), primary_key=True, default=uuid.uuid4)
+ code = Column('Code', Integer, unique=True, nullable=False)
+ name = Column('Name', Unicode(255), unique=True, nullable=False)
+ enabled = Column('Enabled', Boolean, nullable=False)
+ otp = Column('OTP', Integer)
+
+ def __init__(self, code=None, name=None, enabled=False, otp=None):
+ self.code = code
+ self.name = name
+ self.enabled = enabled
+ self.otp = otp
+
+ @classmethod
+ def by_id(cls, id):
+ if not isinstance(id, uuid.UUID):
+ id = uuid.UUID(id)
+ return DBSession.query(cls).filter(cls.id == id).first()
+
+ @classmethod
+ def by_code(cls, code):
+ if not isinstance(code, int):
+ code = int(code)
+ return DBSession.query(cls).filter(cls.code == code).first()
+
+ @classmethod
+ def list(cls):
+ return DBSession.query(cls).order_by(cls.name).all()
+
+ @classmethod
+ def enabled_list(cls):
+ return DBSession.query(cls).filter(cls.enabled == True).order_by(cls.name).all()
+
+ @classmethod
+ def create(cls):
+ client_code = random.randint(1000, 9999)
+ otp = random.randint(1000, 9999)
+ name = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(6))
+# name = str(client_code)
+ client = Client(client_code, name, False, otp)
+ DBSession.add(client)
+ return client
user_group = Table(
@@ -27,7 +67,7 @@ user_group = Table(
Column('UserGroupID', GUID(), primary_key=True, default=uuid.uuid4),
Column('UserID', GUID(), ForeignKey('auth_users.UserID')),
Column('GroupID', GUID(), ForeignKey('auth_groups.GroupID'))
- )
+)
#class RoleGroup(Base):
# __tablename__ = 'auth_rolegroups'
@@ -37,12 +77,12 @@ user_group = Table(
# group_id = Column('GroupID', GUID(), ForeignKey('auth_groups.GroupID'))
-role_group = Table (
+role_group = Table(
'auth_rolegroups', Base.metadata,
Column('RoleGroupID', GUID(), primary_key=True, default=uuid.uuid4),
Column('RoleID', GUID(), ForeignKey('auth_roles.RoleID')),
Column('GroupID', GUID(), ForeignKey('auth_groups.GroupID'))
- )
+)
class User(Base):
diff --git a/brewman/brewman/models/master.py b/brewman/brewman/models/master.py
index 62761b43..b03b10e8 100644
--- a/brewman/brewman/models/master.py
+++ b/brewman/brewman/models/master.py
@@ -160,6 +160,7 @@ class LedgerBase(Base):
type = Column('Type', Integer, nullable=False)
ledger_type = Column('ledger_type', Unicode(50), nullable=False)
is_active = Column('IsActive', Boolean)
+ is_reconcilable = Column('IsReconcilable', Boolean)
costcenter_id = Column('CostCenterID', GUID(), ForeignKey('entities_costcenters.CostCenterID'))
__mapper_args__ = {'polymorphic_on': ledger_type}
@@ -174,11 +175,12 @@ class LedgerBase(Base):
def type_object(self):
return LedgerType.by_id(self.type)
- def __init__(self, code=None, name=None, type=None, is_active=None, costcenter_id=None):
+ def __init__(self, code=None, name=None, type=None, is_active=None, is_reconcilable=False, costcenter_id=None):
self.code = code
self.name = name
self.type = type
self.is_active = is_active
+ self.is_reconcilable = is_reconcilable
self.costcenter_id = costcenter_id
@classmethod
@@ -253,7 +255,8 @@ class Employee(LedgerBase):
self.service_points = service_points
self.joining_date = joining_date
self.leaving_date = leaving_date
- super().__init__(code, name, 10, is_active, costcenter_id)
+ super().__init__(code=code, name=name, type=10, is_active=is_active, is_reconcilable=False,
+ costcenter_id=costcenter_id)
def create(self):
code = DBSession.query(func.max(LedgerBase.code)).filter(LedgerBase.type == self.type).one()[0]
@@ -341,14 +344,14 @@ class LedgerType:
list.append(LedgerType(5, 'Capital', True, False, False, 70, True))
list.append(LedgerType(6, 'Debtors', True, True, True, 30, True))
list.append(LedgerType(7, 'Expenses', False, True, True, 40, True))
-# list.append(LedgerType(8, 'Discount', False, False, True, 30, True))
+ # list.append(LedgerType(8, 'Discount', False, False, True, 30, True))
list.append(LedgerType(9, 'Creditors', True, False, True, 60, True))
list.append(LedgerType(10, 'Salary', True, True, True, 40, False))
list.append(LedgerType(11, 'Liabilities', True, False, True, 50, True))
list.append(LedgerType(12, 'Revenue', False, False, True, 30, True))
-# list.append(LedgerType(13, 'Tax', True, False, True, 80, True))
-# list.append(LedgerType(14, 'Total', False, False, False, 900, False))
-# list.append(LedgerType(15, 'Net', False, False, False, 1000, False))
+ # list.append(LedgerType(13, 'Tax', True, False, True, 80, True))
+ # list.append(LedgerType(14, 'Total', False, False, False, 900, False))
+ # list.append(LedgerType(15, 'Net', False, False, False, 1000, False))
return list
diff --git a/brewman/brewman/static/partial/account-detail.html b/brewman/brewman/static/partial/account-detail.html
index 28848762..2fe0698a 100644
--- a/brewman/brewman/static/partial/account-detail.html
+++ b/brewman/brewman/static/partial/account-detail.html
@@ -30,6 +30,9 @@
+
diff --git a/brewman/brewman/static/partial/account-list.html b/brewman/brewman/static/partial/account-list.html
index aab1086e..9daa1fd8 100644
--- a/brewman/brewman/static/partial/account-list.html
+++ b/brewman/brewman/static/partial/account-list.html
@@ -5,6 +5,7 @@
Name |
Type |
Is Active? |
+ Is Reconcilable? |
Cost Center |
@@ -13,6 +14,7 @@
{{item.Name}} |
{{item.Type}} |
{{item.IsActive}} |
+ {{item.IsReconcilable}} |
{{item.CostCenter}} |
diff --git a/brewman/brewman/static/partial/issue.html b/brewman/brewman/static/partial/issue.html
index 8fa0a5cf..6b80873d 100644
--- a/brewman/brewman/static/partial/issue.html
+++ b/brewman/brewman/static/partial/issue.html
@@ -67,14 +67,14 @@
diff --git a/brewman/brewman/static/partial/journal.html b/brewman/brewman/static/partial/journal.html
index 68a27fe2..36622f08 100644
--- a/brewman/brewman/static/partial/journal.html
+++ b/brewman/brewman/static/partial/journal.html
@@ -15,7 +15,7 @@
-
+
-
+
@@ -38,18 +38,18 @@
- | Debit |
- Name |
- Amount |
- Delete |
+ Debit |
+ Name |
+ Amount |
+ Delete |
- | {{journal.Debit | debit}} |
- {{journal.Ledger.Name}} |
- {{journal.Amount}} |
-
+ | {{journal.Debit | debit}} |
+ {{journal.Ledger.Name}} |
+ {{journal.Amount}} |
+
Delete
diff --git a/brewman/brewman/static/partial/payment-modal.html b/brewman/brewman/static/partial/payment-modal.html
new file mode 100644
index 00000000..fcc0b12f
--- /dev/null
+++ b/brewman/brewman/static/partial/payment-modal.html
@@ -0,0 +1,23 @@
+
diff --git a/brewman/brewman/static/partial/payment.html b/brewman/brewman/static/partial/payment.html
index 1843a8f8..a2daaf14 100644
--- a/brewman/brewman/static/partial/payment.html
+++ b/brewman/brewman/static/partial/payment.html
@@ -27,18 +27,17 @@
@@ -59,7 +58,17 @@
| {{journal.Ledger.Name}} |
{{journal.Amount}} |
-
+
|
diff --git a/brewman/brewman/static/partial/purchase-return.html b/brewman/brewman/static/partial/purchase-return.html
new file mode 100644
index 00000000..c74eaea6
--- /dev/null
+++ b/brewman/brewman/static/partial/purchase-return.html
@@ -0,0 +1,104 @@
+
\ No newline at end of file
diff --git a/brewman/brewman/static/partial/purchase.html b/brewman/brewman/static/partial/purchase.html
index 8dc60227..ddb9250c 100644
--- a/brewman/brewman/static/partial/purchase.html
+++ b/brewman/brewman/static/partial/purchase.html
@@ -44,7 +44,7 @@
placeholder="Tax" ng-model="tax"/>
-