Changeset - 6a99ff5db23a
[Not reviewed]
0 2 0
Lance Edgar (lance) - 12 years ago 2012-07-26 16:02:35
lance@edbob.org
add Employee class, Product price fields
2 files changed with 42 insertions and 9 deletions:
0 comments (0 inline, 0 general)
rattail/db/extension/enum.py
Show inline comments
 
@@ -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
rattail/db/extension/model.py
Show inline comments
 
@@ -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 "<Employee: %s>" % self.person
 

	
 
    def __unicode__(self):
 
        return unicode(self.person)
0 comments (0 inline, 0 general)