Пример #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)
Пример #2
0
 def _load(self, db: DBManager, order_spec):
     products = db.get_order_items(order_spec.id)
     number = 0
     for order in products:
         number += 1
         order_item = OrderItem(order_spec=order_spec,
                                number=number,
                                is_current=order.is_current,
                                product_id=order.product_id,
                                quantity=order.quantity,
                                item_id=order.id)
         order_item.order_id = order.order_id
         self._orders[order_item.product_id] = order_item