{#- The monthly budget panel on the Usage page. Built-in Jinja only. budget_panel(status, can_edit=False, notice='', error='') status usage_budget.budget_status(...), or None when no budget is set can_edit used only when status is None; otherwise status.can_edit notice, error from usage_budget.budget_messages(request.query_params); a notice code ('saved', 'cleared') is shown as its text. -#} {% macro _money(value) -%}{{ '${:,.2f}'.format(value) }}{%- endmacro %} {% macro _budget_form(monthly_usd='', alert_percent=80) -%}
{%- endmacro %} {% macro budget_panel(status, can_edit=False, notice='', error='') -%} {% set editable = status.can_edit if status else can_edit %} {% set notice = {'saved': 'Budget saved.', 'cleared': 'Budget removed.'}.get(notice, notice) %}{% if status %}Known spend since {{ status.month_start.strftime('%b') }} {{ status.month_start.day }}, UTC. The Overview flags it at {{ status.alert_percent }}% of the budget.{% elif editable %}Set a monthly budget to get an alert before spend runs over.{% else %}No monthly budget is set.{% endif %}
Spend can't be read right now, so the budget can't be checked. Try again in a few minutes.
{% elif status %} {% set shown = status.percent|round(0, 'floor')|int %}{{ _money(status.spend) }} of {{ _money(status.budget) }} {{ shown }}%{% if status.state == 'over' %} ยท over budget{% endif %}
{% if status.unpriced_calls %}{% if status.unpriced_calls == 1 %}1 call has no price and isn't counted.{% else %}{{ '{:,}'.format(status.unpriced_calls) }} calls have no price and aren't counted.{% endif %} Set prices
{% endif %} {% endif %} {% if status and editable %}