Example #1
0
def stockList(id):
    productStock = ProductStock.getStockByProduct(id)
    productStockList = []
    for i in productStock:
        productStockList.append({'dimension': Dimension.get_dimension(i.dimension_id).name, 'quantity': i.quantity,
                                 'dimension_id': i.dimension_id})
    product = ({"name": Product.get_product(id).name, "description": Product.get_product(id).description,
                "price": str(Product.get_product(id).price)})
    return make_response(jsonify(productStock=productStockList, product=product), 200)
Example #2
0
def validate_quantity(product_id, dimension_id, quantity, check):
    if not ProductStock.get_quantity_result(product_id, dimension_id, quantity, check):
        raise ValidationException(
            "Sorry, there are no such quantity = "
            + str(quantity)
            + " with this dimension"
            + " where item number = "
            + str(product_id)
            + " in the stock."
        )
Example #3
0
Product.add_product('apple', 'russian apple', 0.5)
Product.add_product('orange', 'italian orange', 15.0)
Product.add_product('apple', 'sweet apple', 11.3)
Product.add_product('banana', 'brazilian banana', 12.1)
Product.add_product('tomato', 'ukrainian tomato', 5.8)
Product.add_product('mango', 'fresh mango', 7.5)
Product.add_product('lemon', 'indian lemon', 4.4)

Security.add_security(0, 5)

UserLevel.add_user_level('Standard', 0, 0)
UserLevel.add_user_level('Silver', 1000, 5)
UserLevel.add_user_level('Gold', 3000, 10)
UserLevel.add_user_level('Platinum', 10000, 15)

ProductStock.add_new_record(1,1,55)
ProductStock.add_new_record(2,1,310)
ProductStock.add_new_record(3,3,115)
ProductStock.add_new_record(4,1,118)
ProductStock.add_new_record(5,2,115)
ProductStock.add_new_record(6,1,125)
ProductStock.add_new_record(11,1,115)
ProductStock.add_new_record(11,2,115)
ProductStock.add_new_record(1,2,110)
ProductStock.add_new_record(3,1,115)
ProductStock.add_new_record(1,3,55)
ProductStock.add_new_record(2,2,310)
ProductStock.add_new_record(3,2,115)
ProductStock.add_new_record(4,2,118)
ProductStock.add_new_record(5,1,115)
ProductStock.add_new_record(6,2,125)
Example #4
0
def updateStock():
    js = request.json
    ProductStock.updateProductStock(js['product_id'], js['dimension_id'], js['quantity'])
    return make_response(jsonify({'message':'success'}),200)