diff --git a/rattail/db/extension/enum.py b/rattail/db/extension/enum.py index 25b0fa3bf28a903b902fc5b67cde9c02ae79214d..4be5d72824bbaba49a2fde8f9df1f7bf41eb1c44 100644 --- a/rattail/db/extension/enum.py +++ b/rattail/db/extension/enum.py @@ -23,7 +23,7 @@ ################################################################################ """ -``rattail.enum`` -- Enumerations +``rattail.db.extension.enum`` -- Enumerations """ @@ -49,13 +49,13 @@ BATCH_ACTION_TYPE = { # } -# EMPLOYEE_STATUS_CURRENT = 1 -# EMPLOYEE_STATUS_FORMER = 2 +EMPLOYEE_STATUS_CURRENT = 1 +EMPLOYEE_STATUS_FORMER = 2 -# EMPLOYEE_STATUS = { -# EMPLOYEE_STATUS_CURRENT : "current", -# EMPLOYEE_STATUS_FORMER : "former", -# } +EMPLOYEE_STATUS = { + EMPLOYEE_STATUS_CURRENT : "current", + EMPLOYEE_STATUS_FORMER : "former", + } # VENDOR_CATALOG_NOT_PARSED = 1 diff --git a/rattail/db/extension/model.py b/rattail/db/extension/model.py index a19397753a56caa5cf67b0052b39fbc60feb1f9f..88aed840fd66783d9fb58413eda8d3e1483c8655 100644 --- a/rattail/db/extension/model.py +++ b/rattail/db/extension/model.py @@ -33,14 +33,17 @@ import re from sqlalchemy import (Column, String, Integer, Date, DateTime, Boolean, Text, ForeignKey, BigInteger, Numeric) from sqlalchemy.orm import relationship, object_session +from sqlalchemy.ext.associationproxy import association_proxy import edbob from edbob.db.model import Base, uuid_column +from edbob.db.extensions.auth import Person __all__ = ['SilColumn', 'BatchDictionaryColumn', 'BatchDictionary', 'BatchTerminalColumn', 'BatchTerminal', 'BatchColumn', - 'Batch', 'Brand', 'Department', 'Category', 'Product'] + 'Batch', 'Brand', 'Department', 'Category', 'Product', + 'Employee'] sil_type_pattern = re.compile(r'^(CHAR|NUMBER)\((\d+(?:\,\d+)?)\)$') @@ -561,13 +564,18 @@ class Product(Base): __tablename__ = 'products' uuid = uuid_column() - upc = Column(BigInteger) + upc = Column(BigInteger, index=True) department_uuid = Column(String(32), ForeignKey('departments.uuid')) category_uuid = Column(String(32), ForeignKey('categories.uuid')) brand_uuid = Column(String(32), ForeignKey('brands.uuid')) description = Column(String(60)) description2 = Column(String(60)) size = Column(String(30)) + regular_price = Column(Numeric(10,4)) + package_price = Column(Numeric(10,4)) + package_price_quantity = Column(Integer) + sale_price = Column(Numeric(10,4)) + sale_price_quantity = Column(Integer) department = relationship(Department) category = relationship(Category) @@ -578,3 +586,28 @@ class Product(Base): def __str__(self): return str(self.description or '') + + +class Employee(Base): + """ + Represents an employee within the organization. + """ + + __tablename__ = 'employees' + + uuid = uuid_column() + id = Column(Integer) + person_uuid = Column(String(32), ForeignKey('people.uuid')) + status = Column(Integer) + + person = relationship(Person) + + first_name = association_proxy('person', 'first_name') + last_name = association_proxy('person', 'last_name') + display_name = association_proxy('person', 'display_name') + + def __repr__(self): + return "" % self.person + + def __unicode__(self): + return unicode(self.person)