def create_snapshot(cls, **kwargs):
     snapshot = StockItemSnapshot(
         stock_item_id=kwargs['stock_item_id'],
         maintainer_id=kwargs['maintainer_id'],
         unit_of_measure_id=kwargs['unit_of_measure_id'],
         quantity=kwargs['quantity'])
     save(snapshot)
Beispiel #2
0
 def create_stock(cls, **kwargs):
     '''Create a new `Stock` record
 
 kwargs:
   stock_name: str - The name of the stock.
 '''
     stock = Stock(name=kwargs['stock_name'])
     save(stock)
Beispiel #3
0
 def update_stock(cls, **kwargs):
     '''Update a `Stock` record associated with a given stock id.
 
 kwargs:
   stock_id: str - The id of the stock record to update.
   stock_name: str (optional) - The name of the stock.
 
 Discussion:
   If any optional kwarg is not provided, that column value will remain unchanged 
 '''
     stock = Stock.query.get(kwargs['stock_id'])
     stock.name = kwargs.get('stock_name', stock.name)
     save(stock)
Beispiel #4
0
 def create_item(cls, **kwargs):
     stock_item = StockItem(stock_id=kwargs['stock_id'],
                            item_id=kwargs['item_id'])
     save(stock_item)
Beispiel #5
0
 def update_item(cls, **kwargs):
     stock_item = StockItem.query.get(kwargs['stock_item_id'])
     stock_item.stock_id = kwargs.get('stock_id', stock_item.stock_id)
     stock_item.item_id = kwargs.get('item_id', stock_item.item_id)
     save(stock_item)
 def add_stock_maintainer(cls, **kwargs):
     stock = Stock.query.get(kwargs['stock_id'])
     maintainer = Maintainer.query.get(kwargs['maintainer_id'])
     stock.maintainers.append(maintainer)
     save(stock)
 def remove_stock_maintainer(cls, **kwargs):
     stock = Stock.query.get(kwargs['stock_id'])
     maintainer = Maintainer.query.get(kwargs['maintainer_id'])
     stock.maintainers.remove(maintainer)
     save(stock)