예제 #1
0
def create_incoming_stock(**kwargs):
    """Takes arguments and create a new record for incoming stocks."""
    db.connect()

    IncomingStock.create(stock=kwargs['stock'], date=kwargs['date'],
                         quantity=kwargs['quantity'], price=kwargs['price'],
                         cost=kwargs['quantity']*kwargs['price'])

    db.close()
예제 #2
0
파일: test.py 프로젝트: dsantosp12/NapAdmin
    def test_create_incoming(self):
        """Create an incoming record."""
        Category.create(category_id='001', description='Testing Stock')
        create_stock('001', 'Testing stock', 1, '001', 9.99)
        create_incoming_stock(stock="001", date="2015-07-22", quantity=13, price=13.99)
        p = IncomingStock.select().where(IncomingStock.stock == '001')
        q = IncomingStock.delete().where(IncomingStock.stock == '001')
        q.execute()
        s = Stock.select().where(Stock.stock_id == '001')
        t = Stock.delete().where(Stock.stock_id == '001')
        t.execute()
        t = Category.delete().where(Category.category_id == '001')
        t.execute()

        self.assertEqual(str(p), ("<class 'models.IncomingStock'> SELECT `t1`.`id`, `t1`.`stock_id`, "
                                  "`t1`.`date`, `t1`.`price`, `t1`.`cost` FROM `incomingstock` AS t1 WHERE "
                                  "(`t1`.`stock_id` = %s) ['001']"))