prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  include iban/swift/bic info on custominvoice pdfs
  
  include iban/swift/bic info on custominvoice pdfs
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/shop/invoiceworker.py`
  Content:
  ```
  1 from django.core.files import File
  2 from utils.pdf import generate_pdf_letter
  3 from shop.email import add_invoice_email, add_creditnote_email
  4 from shop.models import Order, CustomOrder, Invoice, CreditNote
  5 import logging
  6 logging.basicConfig(level=logging.INFO)
  7 logger = logging.getLogger('bornhack.%s' % __name__)
  8 
  9 
  10 def do_work():
  11     """
  12         The invoice worker creates Invoice objects for shop orders and
  13         for custom orders. It also generates PDF files for Invoice objects
  14         that have no PDF. It also emails invoices for shop orders.
  15     """
  16 
  17     # check if we need to generate any invoices for shop orders
  18     for order in Order.objects.filter(paid=True, invoice__isnull=True):
  19         # generate invoice for this Order
  20         Invoice.objects.create(order=order)
  21         logger.info('Generated Invoice object for %s' % order)
  22 
  23     # check if we need to generate any invoices for custom orders
  24     for customorder in CustomOrder.objects.filter(invoice__isnull=True):
  25         # generate invoice for this CustomOrder
  26         Invoice.objects.create(customorder=customorder)
  27         logger.info('Generated Invoice object for %s' % customorder)
  28 
  29     # check if we need to generate any pdf invoices
  30     for invoice in Invoice.objects.filter(pdf=''):
  31         # generate the pdf
  32         try:
  33             if invoice.customorder:
  34                 template = 'pdf/custominvoice.html'
  35             else:
  36                 template = 'pdf/invoice.html'
  37             pdffile = generate_pdf_letter(
  38                 filename=invoice.filename,
  39                 template=template,
  40                 formatdict={
  41                     'invoice': invoice,
  42                 },
  43             )
  44             logger.info('Generated pdf for invoice %s' % invoice)
  45         except Exception as E:
  46             logger.exception('Unable to generate PDF file for invoice #%s. Error: %s' % (invoice.pk, E))
  47             continue
  48 
  49         # update invoice object with the file
  50         invoice.pdf.save(invoice.filename, File(pdffile))
  51         invoice.save()
  52 
  53     # check if we need to send out any invoices (only for shop orders, and only where pdf has been generated)
  54     for invoice in Invoice.objects.filter(order__isnull=False, sent_to_customer=False).exclude(pdf=''):
  55         logger.info("found unmailed Invoice object: %s" % invoice)
  56         # add email to the outgoing email queue
  57         if add_invoice_email(invoice=invoice):
  58             invoice.sent_to_customer = True
  59             invoice.save()
  60             logger.info('OK: Invoice email to {} added to queue.'.format(
  61                 invoice.order.user.email)
  62             )
  63         else:
  64             logger.error('Unable to add email for invoice {} to {}'.format(
  65                     invoice.pk,
  66                     invoice.order.user.email
  67                 )
  68             )
  69 
  70     # check if we need to generate any pdf creditnotes?
  71     for creditnote in CreditNote.objects.filter(pdf=''):
  72         # generate the pdf
  73         try:
  74             pdffile = generate_pdf_letter(
  75                 filename=creditnote.filename,
  76                 template='pdf/creditnote.html',
  77                 formatdict={
  78                     'creditnote': creditnote,
  79                 },
  80             )
  81             logger.info('Generated pdf for creditnote %s' % creditnote)
  82         except Exception as E:
  83             logger.exception('Unable to generate PDF file for creditnote #%s. Error: %s' % (creditnote.pk, E))
  84             continue
  85 
  86         # update creditnote object with the file
  87         creditnote.pdf.save(creditnote.filename, File(pdffile))
  88         creditnote.save()
  89 
  90     # check if we need to send out any creditnotes (only where pdf has been generated and only for creditnotes linked to a user)
  91     for creditnote in CreditNote.objects.filter(sent_to_customer=False).exclude(pdf='').exclude(user=None):
  92         # send the email
  93         if add_creditnote_email(creditnote=creditnote):
  94             logger.info('OK: Creditnote email to %s added' % creditnote.user.email)
  95             creditnote.sent_to_customer = True
  96             creditnote.save()
  97         else:
  98             logger.error('Unable to add creditnote email for creditnote %s to %s' % (creditnote.pk, creditnote.user.email))
  99 
  100
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/shop/invoiceworker.py b/src/shop/invoiceworker.py
  --- a/src/shop/invoiceworker.py
  +++ b/src/shop/invoiceworker.py
  @@ -1,3 +1,4 @@
  +from django.conf import settings
   from django.core.files import File
   from utils.pdf import generate_pdf_letter
   from shop.email import add_invoice_email, add_creditnote_email
  @@ -39,6 +40,11 @@
                   template=template,
                   formatdict={
                       'invoice': invoice,
  +                    'bank': settings.BANKACCOUNT_BANK,
  +                    'bank_iban': settings.BANKACCOUNT_IBAN,
  +                    'bank_bic': settings.BANKACCOUNT_SWIFTBIC,
  +                    'bank_dk_reg': settings.BANKACCOUNT_REG,
  +                    'bank_dk_accno': settings.BANKACCOUNT_ACCOUNT,
                   },
               )
               logger.info('Generated pdf for invoice %s' % invoice)
  
verification_info: {"golden_diff": "diff --git a/src/shop/invoiceworker.py b/src/shop/invoiceworker.py\n--- a/src/shop/invoiceworker.py\n+++ b/src/shop/invoiceworker.py\n@@ -1,3 +1,4 @@\n+from django.conf import settings\n from django.core.files import File\n from utils.pdf import generate_pdf_letter\n from shop.email import add_invoice_email, add_creditnote_email\n@@ -39,6 +40,11 @@\n                 template=template,\n                 formatdict={\n                     'invoice': invoice,\n+                    'bank': settings.BANKACCOUNT_BANK,\n+                    'bank_iban': settings.BANKACCOUNT_IBAN,\n+                    'bank_bic': settings.BANKACCOUNT_SWIFTBIC,\n+                    'bank_dk_reg': settings.BANKACCOUNT_REG,\n+                    'bank_dk_accno': settings.BANKACCOUNT_ACCOUNT,\n                 },\n             )\n             logger.info('Generated pdf for invoice %s' % invoice)\n", "issue": "include iban/swift/bic info on custominvoice pdfs\n\ninclude iban/swift/bic info on custominvoice pdfs\n\n", "before_files": [{"content": "from django.core.files import File\nfrom utils.pdf import generate_pdf_letter\nfrom shop.email import add_invoice_email, add_creditnote_email\nfrom shop.models import Order, CustomOrder, Invoice, CreditNote\nimport logging\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger('bornhack.%s' % __name__)\n\n\ndef do_work():\n    \"\"\"\n        The invoice worker creates Invoice objects for shop orders and\n        for custom orders. It also generates PDF files for Invoice objects\n        that have no PDF. It also emails invoices for shop orders.\n    \"\"\"\n\n    # check if we need to generate any invoices for shop orders\n    for order in Order.objects.filter(paid=True, invoice__isnull=True):\n        # generate invoice for this Order\n        Invoice.objects.create(order=order)\n        logger.info('Generated Invoice object for %s' % order)\n\n    # check if we need to generate any invoices for custom orders\n    for customorder in CustomOrder.objects.filter(invoice__isnull=True):\n        # generate invoice for this CustomOrder\n        Invoice.objects.create(customorder=customorder)\n        logger.info('Generated Invoice object for %s' % customorder)\n\n    # check if we need to generate any pdf invoices\n    for invoice in Invoice.objects.filter(pdf=''):\n        # generate the pdf\n        try:\n            if invoice.customorder:\n                template = 'pdf/custominvoice.html'\n            else:\n                template = 'pdf/invoice.html'\n            pdffile = generate_pdf_letter(\n                filename=invoice.filename,\n                template=template,\n                formatdict={\n                    'invoice': invoice,\n                },\n            )\n            logger.info('Generated pdf for invoice %s' % invoice)\n        except Exception as E:\n            logger.exception('Unable to generate PDF file for invoice #%s. Error: %s' % (invoice.pk, E))\n            continue\n\n        # update invoice object with the file\n        invoice.pdf.save(invoice.filename, File(pdffile))\n        invoice.save()\n\n    # check if we need to send out any invoices (only for shop orders, and only where pdf has been generated)\n    for invoice in Invoice.objects.filter(order__isnull=False, sent_to_customer=False).exclude(pdf=''):\n        logger.info(\"found unmailed Invoice object: %s\" % invoice)\n        # add email to the outgoing email queue\n        if add_invoice_email(invoice=invoice):\n            invoice.sent_to_customer = True\n            invoice.save()\n            logger.info('OK: Invoice email to {} added to queue.'.format(\n                invoice.order.user.email)\n            )\n        else:\n            logger.error('Unable to add email for invoice {} to {}'.format(\n                    invoice.pk,\n                    invoice.order.user.email\n                )\n            )\n\n    # check if we need to generate any pdf creditnotes?\n    for creditnote in CreditNote.objects.filter(pdf=''):\n        # generate the pdf\n        try:\n            pdffile = generate_pdf_letter(\n                filename=creditnote.filename,\n                template='pdf/creditnote.html',\n                formatdict={\n                    'creditnote': creditnote,\n                },\n            )\n            logger.info('Generated pdf for creditnote %s' % creditnote)\n        except Exception as E:\n            logger.exception('Unable to generate PDF file for creditnote #%s. Error: %s' % (creditnote.pk, E))\n            continue\n\n        # update creditnote object with the file\n        creditnote.pdf.save(creditnote.filename, File(pdffile))\n        creditnote.save()\n\n    # check if we need to send out any creditnotes (only where pdf has been generated and only for creditnotes linked to a user)\n    for creditnote in CreditNote.objects.filter(sent_to_customer=False).exclude(pdf='').exclude(user=None):\n        # send the email\n        if add_creditnote_email(creditnote=creditnote):\n            logger.info('OK: Creditnote email to %s added' % creditnote.user.email)\n            creditnote.sent_to_customer = True\n            creditnote.save()\n        else:\n            logger.error('Unable to add creditnote email for creditnote %s to %s' % (creditnote.pk, creditnote.user.email))\n\n", "path": "src/shop/invoiceworker.py"}], "after_files": [{"content": "from django.conf import settings\nfrom django.core.files import File\nfrom utils.pdf import generate_pdf_letter\nfrom shop.email import add_invoice_email, add_creditnote_email\nfrom shop.models import Order, CustomOrder, Invoice, CreditNote\nimport logging\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger('bornhack.%s' % __name__)\n\n\ndef do_work():\n    \"\"\"\n        The invoice worker creates Invoice objects for shop orders and\n        for custom orders. It also generates PDF files for Invoice objects\n        that have no PDF. It also emails invoices for shop orders.\n    \"\"\"\n\n    # check if we need to generate any invoices for shop orders\n    for order in Order.objects.filter(paid=True, invoice__isnull=True):\n        # generate invoice for this Order\n        Invoice.objects.create(order=order)\n        logger.info('Generated Invoice object for %s' % order)\n\n    # check if we need to generate any invoices for custom orders\n    for customorder in CustomOrder.objects.filter(invoice__isnull=True):\n        # generate invoice for this CustomOrder\n        Invoice.objects.create(customorder=customorder)\n        logger.info('Generated Invoice object for %s' % customorder)\n\n    # check if we need to generate any pdf invoices\n    for invoice in Invoice.objects.filter(pdf=''):\n        # generate the pdf\n        try:\n            if invoice.customorder:\n                template = 'pdf/custominvoice.html'\n            else:\n                template = 'pdf/invoice.html'\n            pdffile = generate_pdf_letter(\n                filename=invoice.filename,\n                template=template,\n                formatdict={\n                    'invoice': invoice,\n                    'bank': settings.BANKACCOUNT_BANK,\n                    'bank_iban': settings.BANKACCOUNT_IBAN,\n                    'bank_bic': settings.BANKACCOUNT_SWIFTBIC,\n                    'bank_dk_reg': settings.BANKACCOUNT_REG,\n                    'bank_dk_accno': settings.BANKACCOUNT_ACCOUNT,\n                },\n            )\n            logger.info('Generated pdf for invoice %s' % invoice)\n        except Exception as E:\n            logger.exception('Unable to generate PDF file for invoice #%s. Error: %s' % (invoice.pk, E))\n            continue\n\n        # update invoice object with the file\n        invoice.pdf.save(invoice.filename, File(pdffile))\n        invoice.save()\n\n    # check if we need to send out any invoices (only for shop orders, and only where pdf has been generated)\n    for invoice in Invoice.objects.filter(order__isnull=False, sent_to_customer=False).exclude(pdf=''):\n        logger.info(\"found unmailed Invoice object: %s\" % invoice)\n        # add email to the outgoing email queue\n        if add_invoice_email(invoice=invoice):\n            invoice.sent_to_customer = True\n            invoice.save()\n            logger.info('OK: Invoice email to {} added to queue.'.format(\n                invoice.order.user.email)\n            )\n        else:\n            logger.error('Unable to add email for invoice {} to {}'.format(\n                    invoice.pk,\n                    invoice.order.user.email\n                )\n            )\n\n    # check if we need to generate any pdf creditnotes?\n    for creditnote in CreditNote.objects.filter(pdf=''):\n        # generate the pdf\n        try:\n            pdffile = generate_pdf_letter(\n                filename=creditnote.filename,\n                template='pdf/creditnote.html',\n                formatdict={\n                    'creditnote': creditnote,\n                },\n            )\n            logger.info('Generated pdf for creditnote %s' % creditnote)\n        except Exception as E:\n            logger.exception('Unable to generate PDF file for creditnote #%s. Error: %s' % (creditnote.pk, E))\n            continue\n\n        # update creditnote object with the file\n        creditnote.pdf.save(creditnote.filename, File(pdffile))\n        creditnote.save()\n\n    # check if we need to send out any creditnotes (only where pdf has been generated and only for creditnotes linked to a user)\n    for creditnote in CreditNote.objects.filter(sent_to_customer=False).exclude(pdf='').exclude(user=None):\n        # send the email\n        if add_creditnote_email(creditnote=creditnote):\n            logger.info('OK: Creditnote email to %s added' % creditnote.user.email)\n            creditnote.sent_to_customer = True\n            creditnote.save()\n        else:\n            logger.error('Unable to add creditnote email for creditnote %s to %s' % (creditnote.pk, creditnote.user.email))\n\n", "path": "src/shop/invoiceworker.py"}]}