Exemplo n.º 1
0
    def get_orders(self):
        with open("./data/Orders.csv", "r") as Order_file:
            csv_reader = csv.reader(Order_file)
            next(csv_reader)
            self.order_dict = {}
            for line in csv_reader:
                plate_num,pick_up_date,drop_off_date,order_num,cust_email = line
                existing_order = Order(order_num, pick_up_date,drop_off_date,plate_num,cust_email)
                key = existing_order.get_plate_number() 
                if key in self.order_dict.keys():
                    self.order_dict[key].append(existing_order)
                else:
                     self.order_dict[key] = [existing_order]

        return self.order_dict
 def createOrder(self, order_id, car_reg, customer_SSN, date_from, date_to,
                 price):
     newOrder = Order(order_id, car_reg, customer_SSN, date_from, date_to,
                      price)
     self.__Orders.append(newOrder)
     self.save()
     return newOrder
 def getOrders(self, by_dates=False):
     if by_dates:
         sorted_orders = sorted(self.__Orders,
                                key=lambda Order: Order.getDateFrom())
         return sorted_orders
     else:
         return self.__Orders
Exemplo n.º 4
0
 def confirmOrder(self):
     time = datetime.datetime.now()
     id = str(time.day) + str(time.month) + str(time.year) + str(
         time.hour) + str(time.minute) + str(time.second)
     DB.add_order(Order(id, str(time)[:19], self.bill))
     self.bill.clear()
     self.ui.billTableWidget.setRowCount(0)
 def __init__(self):
     self.__Orders_Data = GetData(ORDER_FILE).readData()
     self.__Orders = []
     self.__DataSaver = SaveData(ORDER_FILE)
     for order in self.__Orders_Data:
         newOrder = Order(order[0], order[1], order[2], order[3], order[4],
                          order[5])  #TODO: Add constants
         self.__Orders.append(newOrder)
 def __init__(self):
     self.__Orders_Data = GetData(ORDER_FILE).readData()
     self.__Orders = []
     self.__DataSaver = SaveData(ORDER_FILE)
     for order in self.__Orders_Data:
         newOrder = Order(order[ORDER_ID], order[CAR_REG],
                          order[CUSTOMER_SSN], order[DATE_FROM],
                          order[DATE_TO], order[PRICE])
         self.__Orders.append(newOrder)
Exemplo n.º 7
0
def get_search_orders():
    from json import dumps

    if request.method == 'GET':
        orders = Order.get_orders_by_stage(OrderStage.SEARCH)
        resp = [i.to_marketplace_format() for i in orders]

        return Response(dumps(resp))

    return Response('marketplace.html')
Exemplo n.º 8
0
 def get_order(id):
     bill = Bill()
     collection = dbHandler.db["order" + id].find()
     for section_doc in collection:
         dish = Dish(section_doc["type"], section_doc["name"],
                     section_doc["price"], section_doc["energy"],
                     section_doc["output"])
         section = Section(dish)
         section.number = section_doc["number"]
         bill.add(section)
     time = dbHandler.db["orders"].find_one({"id": id})["time"]
     return Order(id, time, bill)
Exemplo n.º 9
0
def my_requests():
    if request.method == "POST":
        data = request.get_json(silent=True)
        orders = {
            "orders": [{
                "task": order.task,
                "description": order.description,
                "stage": order.stage.name
            } for order in Order.get_user_orders(data["email"])]
        }
        return jsonify(orders)
    return Response("my_requests.html")
Exemplo n.º 10
0
def get_board():
    orders = {}
    for stage in OrderStage:
        stage_orders = []
        for order in Order.get_orders_by_stage(stage):
            stage_orders.append({
                "id": str(order.id),
                "task": order.task,
                "description": order.description,
                "email": order.customer_email
            })
        if len(stage_orders) != 0:
            orders.update({stage.stage_name(): stage_orders})
    return orders
Exemplo n.º 11
0
    def add_order_to_dict(self, booking_num, email, plate_num, date_list):
        new_pick_up, drop_off = date_list
        new_order = Order(booking_num, new_pick_up, drop_off, plate_num, email)
        order_dict = self.order_repo.get_orders()
        if order_dict != {}:
            for key, values in order_dict.items():
                if key == plate_num:
                    values.append(new_order)
                    break
                elif plate_num not in order_dict:
                    order_dict[plate_num] = [new_order]
                    break
        else:
            order_dict[plate_num] = [new_order]

        self.order_repo.update_order_file(order_dict)
Exemplo n.º 12
0
    def add_order_to_dict(self, booking_num, email, plate_num, date_list):
        """Adds order to order dictionary with all the information from the user input. Also updates order repository with
        the new dictionary"""
        new_pick_up, drop_off = date_list
        new_order = Order(booking_num, new_pick_up, drop_off, plate_num, email)
        order_dict = self.order_repo.get_orders()
        if order_dict != {}:
            for key, values in order_dict.items():
                if key == plate_num:
                    values.append(new_order)
                    break
                elif plate_num not in order_dict:
                    order_dict[plate_num] = [new_order]
                    break
        else:
            order_dict[plate_num] = [new_order]

        self.order_repo.update_order_file(order_dict)
Exemplo n.º 13
0
 def createOrder(self, productId, userId, quantity):
     order = Order(userId=userId,
                   productId=productId,
                   totalQuantity=quantity,
                   status=OrderStatus['AWAIT_PRODUCT_QUANTITY_CHECK'])
     db.session.add(order)
     db.session.commit()
     command = CheckProductQuantity(order.id, order.productId,
                                    order.totalQuantity)
     publish('product/order_created', command.to_string())
     payload = {
         "userId": userId,
         "productId": productId,
         "totalQuantity": quantity,
         "orderId": order.id,
     }
     self.saveEvent(payload, 'createOrder')
     return order
Exemplo n.º 14
0
    def print_order_car_menu(self):
        """Prentar út pöntunarskjá fyrir pöntun"""

        passport = input("\n\tVegabréfsnúmer: ").upper()
        #sækir find customer fallið og skila gildum sem notuð eru til að geyma gögn
        customer, passport, kredit = self.__customer.find_customer(passport)

        if customer == 0:
            print("\n\tEngin viðskiptavinur er skráður á þetta númer!\n")
            print("\t1. Nýskrá viðskiptavin")
            print("\t2. Slá inn nýtt vegabréfsnúmer")
            choice = input("\n\tValmöguleiki: ")
            if choice == "1":
                self.add_new_customer()
            elif choice == "2":
                self.print_order_car_menu()
            else:
                self.print_order_car_menu()

        if customer == 1:
            print(
                "\n\tEkki rétt skráð inn! \n\tVegabréfsnúmer á að vera 8 letur á lengd"
            )
            self.print_order_menu()
            return
        fullprice, today, someday, carchoice, extraprice = self.__ordercar.order_price(
        )
        if today == 0:
            self.print_order_car_menu()
        print("\n\t\tHeildarverð: {:,}".format(fullprice + extraprice))
        new_order = Order(passport, today, someday, fullprice, carchoice,
                          extraprice)
        fullprice = int(fullprice)
        if fullprice < 10000:
            print("\n\tDagsetning skrifuð vitlaus inn: ")
            self.print_order_car_menu()
        else:
            self.__ordercar.get_car_order(new_order)
            print("\n\tPöntun hefur verið skráð!")

        self.__printrepo.send_email(customer, today, someday)
        self.main_menu()
Exemplo n.º 15
0
def getOrderBooks(algorithm, size):
    """ recommended size (orders amount per page) is above 1000"""
    headers = {'algorithm': algorithm, 'size': size}
    r = requests.get(NicehashURIs.hashPowerOrderBook.value, headers)

    orderBooks = []
    date = getServerTime()
    data = r.json()['stats']
    for marketRegion, orderBook in data.items():
        tempOrderBook = OrderBook(algorithm, date, marketRegion)
        for order in orderBook.get('orders'):
            orderType = OrderType[order.get('type')]
            price = order.get('price')
            limit = order.get('limit')
            rigsCount = order.get('rigsCount')
            isAlive = order.get('alive')
            orderId = order.get('id')
            tempOrderBook.addOrder(
                Order(orderType, price, limit, rigsCount, isAlive, orderId))
        orderBooks.append(tempOrderBook)
    return orderBooks
Exemplo n.º 16
0
    def fetch_items_by_id(self, id):
        baseUrl = f'https://www.novaragnarok.com/data/cache/ajax/item_{id}.json'
        response = requests.get(baseUrl)
        dPrideURL = f'https://www.divine-pride.net/api/database/Item/{id}?apiKey={DIVINE_PRIDE_KEY}'
        dPrideResponse = requests.get(dPrideURL)
        name = ''

        if dPrideResponse.status_code == 200:
            data = json.loads(dPrideResponse.text)
            name = data['name']
        else:
            name = 'Name Not Found'

        item = Item(id, name)

        if response.status_code == 200:
            json_data = json.loads(response.text)
            data = json_data['data']

            for i in data:
                price = 0
                location = ''
                qty = 1
                refine = 0

                if 'price' in i['orders']:
                    price = int(i['orders']['price'])
                if 'location' in i['orders']:
                    location = i['orders']['location'][:-1]
                if 'qty' in i['orders']:
                    qty = int(i['orders']['qty'])
                if 'refine' in i['orders']:
                    refine = int(i['orders']['refine'])

                order = Order(price, location, qty)
                item.orders.append(order)

            return item
        else:
            return None
Exemplo n.º 17
0
def board():
    if request.method == "POST":
        data = request.get_json(silent=True)
        if data["action"] == "get":
            user = UserCompany(data["email"], data["password"])
            if user.verify():
                return jsonify(get_board())
        elif data["action"] == "del":
            order = Order()
            order.retrieve(data["id"])
            order.remove()
            user = UserCompany(data["email"], data["password"])
            if user.verify():
                return jsonify(get_board())
        elif data["action"] == "up":
            order = Order()
            order.retrieve(data["id"])
            order.move_stage_next()
            user = UserCompany(data["email"], data["password"])
            if user.verify():
                return jsonify(get_board())
        elif data["action"] == "down":
            order = Order()
            order.retrieve(data["id"])
            order.move_stage_back()
            user = UserCompany(data["email"], data["password"])
            if user.verify():
                return jsonify(get_board())
    return Response("board.html")