Exemplo n.º 1
0
 def perform_invoice(self, db: DBManager, order_id):
     """
     perform invoice PDF file in directory invoices
     :param db:
     :param order_id:
     :return:
     """
     if config.is_company_info():
         info = config.company_info()
         invoice = ReportInvoice()
         invoice.company_info(info)
         order = db.get_order_info(order_id=order_id)
         client = db.get_client(order.client_id)
         invoice.set_order(date=order.order_date,
                           number=order_id,
                           payer=client.title,
                           address=client.address,
                           delivery=order.delivery_cost)
         order_items = db.get_order_items(order_id)
         for item in order_items:
             product = db.select_single_product(item.product_id)
             invoice.add_item(name=product.name,
                              code=product.title,
                              unit='шт.',
                              quantity=item.quantity,
                              price=product.price)
         invoice.make()
         _send_invoice_mail(client, order_id)
Exemplo n.º 2
0
 def _get_store_near(self, db: DBManager):
     client = db.get_client(self._client)
     stores = db.get_stores()
     client_distance = 0.0
     store_distance = 0.0
     store_id = 0
     price_km = 0.0
     client_location = (client.latitude, client.longitude)
     for store in stores:
         store_location = (store.latitude, store.longitude)
         if client_distance == 0.0:
             client_distance = distance(client_location,
                                        store_location).kilometers
             store_id = store.id
             price_km = store.price_km
             continue
         store_distance = distance(client_location,
                                   store_location).kilometers
         if store_distance < client_distance:
             client_distance = store_distance
             store_id = store.id
             price_km = store.price_km
     return client_distance, store_id, price_km