コード例 #1
0
 def get_processor(self, id_processor):
     proc = session.query(Processor).filter(
         Processor.id == id_processor).first()
     if not proc:
         raise lacksError("Processor does not exists")
     else:
         return proc
コード例 #2
0
    def enough_balance(self, id_client):
        response = session.query(Client, Basket, Order, Processor).filter(
            Client.id == Basket.id_client, Basket.id_order == Order.id,
            Basket.id_processor == Processor.id, Basket.id_client == id_client,
            Order.date_order == None).all()
        if response:
            all_price = 0
            for i in response:
                all_price += i[1].quantity * i[3].price

            if all_price > response[0][0].balance:
                raise lacksError('insufficient funds')
            else:
                return all_price
        else:
            raise lacksError('Order is not exists')
コード例 #3
0
 def check_enough_on_stocks(self, id_client):
     response = session.query(Client, Basket, Order, Processor).filter(
         Client.id == Basket.id_client, Basket.id_order == Order.id,
         Basket.id_processor == Processor.id, Basket.id_client == id_client,
         Order.date_order == None).all()
     for i in response:
         if i[1].quantity > i[3].balance:
             raise lacksError('Insufficient processors in stocks')
コード例 #4
0
 def check_in_the_processors(id_processor):
     if not session.query(Processor).filter(
             Processor.id == id_processor).first():
         raise lacksError("Processor does not exists")
コード例 #5
0
 def check_in_the_clients(id_client):
     if not session.query(Client).filter(Client.id == id_client).first():
         raise lacksError("Client does not exists")