prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Budget without value makes IATI export crash
  ## Test plan
  
  GIVEN the IATI export (bottom right on project page)
  WHEN a budget of the project has no value, but does have a value date / currency / label
  THEN the `value` tag of the budget item should not be generated
  AND no internal server error should be shown
  ## Issue description
  
  See http://sentry.support.akvo-ops.org/rsr/live/group/832/
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `akvo/iati/exports/elements/budget.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 # Akvo RSR is covered by the GNU Affero General Public License.
  4 # See more details in the license.txt file located at the root folder of the Akvo RSR module.
  5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
  6 
  7 from lxml import etree
  8 
  9 
  10 def budget(project):
  11     """
  12     Generate the budget elements.
  13 
  14     :param project: Project object
  15     :return: A list of Etree elements
  16     """
  17     budget_elements = []
  18 
  19     for budget_item in project.budget_items.all():
  20         if budget_item.amount or budget_item.period_start or budget_item.period_end or \
  21                 budget_item.type or budget_item.status or budget_item.value_date or \
  22                 budget_item.currency or budget_item.other_extra or budget_item.label:
  23             element = etree.Element("budget")
  24 
  25             if budget_item.type:
  26                 element.attrib['type'] = budget_item.type
  27 
  28             if budget_item.status:
  29                 element.attrib['status'] = budget_item.status
  30 
  31             if budget_item.period_start:
  32                 period_start_element = etree.SubElement(element, "period-start")
  33                 period_start_element.attrib['iso-date'] = str(budget_item.period_start)
  34 
  35             if budget_item.period_end:
  36                 period_end_element = etree.SubElement(element, "period-end")
  37                 period_end_element.attrib['iso-date'] = str(budget_item.period_end)
  38 
  39             if budget_item.amount == 0 or budget_item.amount:
  40                 value_element = etree.SubElement(element, "value")
  41                 value_element.text = str(budget_item.amount)
  42 
  43             if budget_item.value_date:
  44                 value_element.attrib['value-date'] = str(budget_item.value_date)
  45 
  46             if budget_item.currency:
  47                 value_element.attrib['currency'] = budget_item.currency
  48 
  49             if budget_item.other_extra:
  50                 value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\
  51                     other_extra
  52             elif budget_item.label and budget_item.label.label:
  53                 value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\
  54                     label
  55 
  56             budget_elements.append(element)
  57 
  58     return budget_elements
  59
  ```
  --- 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/akvo/iati/exports/elements/budget.py b/akvo/iati/exports/elements/budget.py
  --- a/akvo/iati/exports/elements/budget.py
  +++ b/akvo/iati/exports/elements/budget.py
  @@ -40,18 +40,17 @@
                   value_element = etree.SubElement(element, "value")
                   value_element.text = str(budget_item.amount)
   
  -            if budget_item.value_date:
  -                value_element.attrib['value-date'] = str(budget_item.value_date)
  -
  -            if budget_item.currency:
  -                value_element.attrib['currency'] = budget_item.currency
  -
  -            if budget_item.other_extra:
  -                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\
  -                    other_extra
  -            elif budget_item.label and budget_item.label.label:
  -                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\
  -                    label
  +                if budget_item.value_date:
  +                    value_element.attrib['value-date'] = str(budget_item.value_date)
  +
  +                if budget_item.currency:
  +                    value_element.attrib['currency'] = budget_item.currency
  +
  +                akvo_label = '{http://akvo.org/iati-activities}label'
  +                if budget_item.other_extra:
  +                    value_element.attrib[akvo_label] = budget_item.other_extra
  +                elif budget_item.label and budget_item.label.label:
  +                    value_element.attrib[akvo_label] = budget_item.label.label
   
               budget_elements.append(element)
  
verification_info: {"golden_diff": "diff --git a/akvo/iati/exports/elements/budget.py b/akvo/iati/exports/elements/budget.py\n--- a/akvo/iati/exports/elements/budget.py\n+++ b/akvo/iati/exports/elements/budget.py\n@@ -40,18 +40,17 @@\n                 value_element = etree.SubElement(element, \"value\")\n                 value_element.text = str(budget_item.amount)\n \n-            if budget_item.value_date:\n-                value_element.attrib['value-date'] = str(budget_item.value_date)\n-\n-            if budget_item.currency:\n-                value_element.attrib['currency'] = budget_item.currency\n-\n-            if budget_item.other_extra:\n-                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\\\n-                    other_extra\n-            elif budget_item.label and budget_item.label.label:\n-                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\\\n-                    label\n+                if budget_item.value_date:\n+                    value_element.attrib['value-date'] = str(budget_item.value_date)\n+\n+                if budget_item.currency:\n+                    value_element.attrib['currency'] = budget_item.currency\n+\n+                akvo_label = '{http://akvo.org/iati-activities}label'\n+                if budget_item.other_extra:\n+                    value_element.attrib[akvo_label] = budget_item.other_extra\n+                elif budget_item.label and budget_item.label.label:\n+                    value_element.attrib[akvo_label] = budget_item.label.label\n \n             budget_elements.append(element)\n", "issue": "Budget without value makes IATI export crash\n## Test plan\n\nGIVEN the IATI export (bottom right on project page)\nWHEN a budget of the project has no value, but does have a value date / currency / label\nTHEN the `value` tag of the budget item should not be generated\nAND no internal server error should be shown\n## Issue description\n\nSee http://sentry.support.akvo-ops.org/rsr/live/group/832/\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom lxml import etree\n\n\ndef budget(project):\n    \"\"\"\n    Generate the budget elements.\n\n    :param project: Project object\n    :return: A list of Etree elements\n    \"\"\"\n    budget_elements = []\n\n    for budget_item in project.budget_items.all():\n        if budget_item.amount or budget_item.period_start or budget_item.period_end or \\\n                budget_item.type or budget_item.status or budget_item.value_date or \\\n                budget_item.currency or budget_item.other_extra or budget_item.label:\n            element = etree.Element(\"budget\")\n\n            if budget_item.type:\n                element.attrib['type'] = budget_item.type\n\n            if budget_item.status:\n                element.attrib['status'] = budget_item.status\n\n            if budget_item.period_start:\n                period_start_element = etree.SubElement(element, \"period-start\")\n                period_start_element.attrib['iso-date'] = str(budget_item.period_start)\n\n            if budget_item.period_end:\n                period_end_element = etree.SubElement(element, \"period-end\")\n                period_end_element.attrib['iso-date'] = str(budget_item.period_end)\n\n            if budget_item.amount == 0 or budget_item.amount:\n                value_element = etree.SubElement(element, \"value\")\n                value_element.text = str(budget_item.amount)\n\n            if budget_item.value_date:\n                value_element.attrib['value-date'] = str(budget_item.value_date)\n\n            if budget_item.currency:\n                value_element.attrib['currency'] = budget_item.currency\n\n            if budget_item.other_extra:\n                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.\\\n                    other_extra\n            elif budget_item.label and budget_item.label.label:\n                value_element.attrib['{http://akvo.org/iati-activities}label'] = budget_item.label.\\\n                    label\n\n            budget_elements.append(element)\n\n    return budget_elements\n", "path": "akvo/iati/exports/elements/budget.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom lxml import etree\n\n\ndef budget(project):\n    \"\"\"\n    Generate the budget elements.\n\n    :param project: Project object\n    :return: A list of Etree elements\n    \"\"\"\n    budget_elements = []\n\n    for budget_item in project.budget_items.all():\n        if budget_item.amount or budget_item.period_start or budget_item.period_end or \\\n                budget_item.type or budget_item.status or budget_item.value_date or \\\n                budget_item.currency or budget_item.other_extra or budget_item.label:\n            element = etree.Element(\"budget\")\n\n            if budget_item.type:\n                element.attrib['type'] = budget_item.type\n\n            if budget_item.status:\n                element.attrib['status'] = budget_item.status\n\n            if budget_item.period_start:\n                period_start_element = etree.SubElement(element, \"period-start\")\n                period_start_element.attrib['iso-date'] = str(budget_item.period_start)\n\n            if budget_item.period_end:\n                period_end_element = etree.SubElement(element, \"period-end\")\n                period_end_element.attrib['iso-date'] = str(budget_item.period_end)\n\n            if budget_item.amount == 0 or budget_item.amount:\n                value_element = etree.SubElement(element, \"value\")\n                value_element.text = str(budget_item.amount)\n\n                if budget_item.value_date:\n                    value_element.attrib['value-date'] = str(budget_item.value_date)\n\n                if budget_item.currency:\n                    value_element.attrib['currency'] = budget_item.currency\n\n                akvo_label = '{http://akvo.org/iati-activities}label'\n                if budget_item.other_extra:\n                    value_element.attrib[akvo_label] = budget_item.other_extra\n                elif budget_item.label and budget_item.label.label:\n                    value_element.attrib[akvo_label] = budget_item.label.label\n\n            budget_elements.append(element)\n\n    return budget_elements\n", "path": "akvo/iati/exports/elements/budget.py"}]}