Our custom ordering system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

109 lines
2.3 KiB

import enum
from datetime import datetime
@enum.unique
class OrderStatus(enum.Enum):
OPEN = 1
APPROVAL = 2
ORDERED = 3
COMPLETED = 4
HOLD = 5
@enum.unique
class OrderCategory(enum.Enum):
DISPOSABLE = 1
SOLVENT = 2
CHEMICAL = 3
BIOLAB = 4
class OrderItem:
""" an ordered item """
# properties
id = None
cas_description = None
catalog_nr = None
vendor = None
category = None
package_size = None
unit_price = None
currency = None
amount = None
account = None
comment = None
# logging status changes of the order
status_log = None
# redundant properties, could be determined from orders log
created_on = None
created_by = None
status = None
def __init__(
self,
id,
cas_description,
catalog_nr,
vendor,
category,
package_size,
unit_price,
amount,
currency="",
account="",
comment="",
):
self.id = id
self.cas_description = cas_description
self.catalog_nr = catalog_nr
self.vendor = vendor
self.category = category
self.package_size = package_size
self.unit_price = unit_price
self.amount = amount
self.currency = currency
self.account = account
self.comment = comment
def __repr__(self):
return f"<ordr3.models.OrderItem id={self.id}>"
@property
def total_price(self):
return self.unit_price * self.amount
def add_to_log(self, log_item):
""" adds a log item to the status log """
if not self.status_log:
self.status_log = []
self.created_by = log_item.by
self.created_on = log_item.date
self.status_log.append(log_item)
self.status = log_item.status
class LogItem:
""" an entry in the order log """
order_id = None
status = None
date = None
by = None
def __init__(self, order, status, by, date=None):
self.order_id = order.id
self.status = status
self.by = by
self.date = date or datetime.now()
class ProposedConsumable:
""" counting orders to find out if they are consumables """
def __init__(self, order):
self.order = order
self.times = 0