Esempio n. 1
0
def availabe_netStock():
    print('Preparing to calculate net stock:')
    print('Catergories.........')
    displayAllCategories()
    print('Stocks..............')
    displayStocks()
    category_id = input('Please select the category:')
    cid = Category.find(category_id)
    # cate = getCategoriesId(category_id)

    user_choice = input(
        f'Are you sure want to calculatae net amount of stock  net ammount: y/n:'
    )
    if (user_choice == 'y'):
        # increaseAmount = int(input('How do you want to increse :'))

        # cid = int(category_id)
        stock_id = int(
            input('Enter the stock_id for the category that you input above:'))
        sid = Stock.find(stock_id)
        # cursor.execute('SELECT * FROM assignweek3.stocks where categories_id = %s and id = %s;',[cid,s])
        # for sii in cursor.fetchall():
        # sin = sid.stockin
        # sout = sid.stockout
        cid.stock = (int(sid.stockin) + int(cid.stock)) - int(sid.stockout)
        print('This is your update')
        cid.update()
        # mydb.commit()
        print('Categories.....')
        displayAllCategories()
Esempio n. 2
0
    def test_add_stock(self):
        stock = Stock()
        stock.add("MLK")
        value = stock.find("MLK")

        self.assertEqual(value, False)
def getStockByID(id):
    stock = Stock.find(id)
    stock.category = Category.find(stock.category_id)
    return stock