From 9c0d7122f6ba1c70ca5abf9d280ab0e767031e0f Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Sun, 30 Apr 2023 21:17:07 +1000 Subject: [PATCH] Add budget graphs On the budget page, add a pie chart of expenses, and a bar chart comparing expenses to revenue. --- sstreasury/jinja2/sstreasury/base.html | 13 +- sstreasury/jinja2/sstreasury/budget_view.html | 548 +++++++++--------- sstreasury/static/sstreasury/budget.js | 85 ++- 3 files changed, 365 insertions(+), 281 deletions(-) diff --git a/sstreasury/jinja2/sstreasury/base.html b/sstreasury/jinja2/sstreasury/base.html index d4102f1..4069528 100644 --- a/sstreasury/jinja2/sstreasury/base.html +++ b/sstreasury/jinja2/sstreasury/base.html @@ -2,7 +2,8 @@ {# Society Self-Service - Copyright © 2018–2020 Yingtong Li (RunasSudo) + Copyright © 2018–2023 Yingtong Li (RunasSudo) + Copyright © 2023 MUMUS Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -21,7 +22,7 @@ {% block content %}
{# side menu #} -
+ {% endblock %} diff --git a/sstreasury/jinja2/sstreasury/budget_view.html b/sstreasury/jinja2/sstreasury/budget_view.html index 2708a30..774abc5 100644 --- a/sstreasury/jinja2/sstreasury/budget_view.html +++ b/sstreasury/jinja2/sstreasury/budget_view.html @@ -2,7 +2,8 @@ {# Society Self-Service - Copyright © 2018–2020 Yingtong Li (RunasSudo) + Copyright © 2018–2023 Yingtong Li (RunasSudo) + Copyright © 2023 MUMUS Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -20,286 +21,296 @@ {% block title %}{{ revision.name }}{% endblock %} -{% block maincontent %} -

{{ revision.name }}

- -
- Status: {{ revision.get_state_display() }} +{% block aftersidebar %} +
+

{{ revision.name }}

- {% if is_latest %} - {% if revision.can_submit(request.user) %} - - {% endif %} - {% if revision.can_endorse(request.user) %} - - - - {% endif %} - {% if revision.can_approve(request.user) %} - - - - {% endif %} - {% if revision.can_withdraw(request.user) %} - - {% endif %} - {% if revision.can_cancel(request.user) %} - - {% endif %} - - {% if revision.can_edit(request.user) %} - Edit - {% endif %} - - Print - - {% if not revision.can_edit(request.user) and revision.can_withdraw(request.user) %} -
-

This budget has been submitted and is now awaiting approval. If you wish to edit this budget, you must first withdraw it. This will revert the budget to a draft.

-
- {% endif %} - - - - {% else %} - Print - -
-

You are viewing an older version of this budget. To make any changes, click here to return to the current version.

-
- {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDBU-{{ revision.budget.id }}
Title{{ revision.name }}
Due date{{ revision.date or '' }}
Event details - {% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %} - {% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %} - {% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %} -
Contributors - -
Comments{{ revision.comments|markdown }}
Revenue -
- {% if revision.revenue_comments %} -
-
- - Revenue comments -
-
- {{ revision.revenue_comments|markdown }} -
-
- {% endif %} -
Expenses - {% if revision.expense_no_emergency_fund %} -

No emergency fund required (please add a comment explaining why)

- {% endif %} -
- {% if revision.expense_comments %} -
-
- - Expense comments -
-
- {{ revision.expense_comments|markdown }} -
-
- {% endif %} -
Total Profit (Loss){{ '${:.2f}'.format(revision.get_revenue_total() - revision.get_expense_total()) if revision.get_revenue_total() >= revision.get_expense_total() else '(${:.2f})'.format(revision.get_expense_total() - revision.get_revenue_total()) }}
- - {% if is_latest %}
-
- -
- - - + Status: {{ revision.get_state_display() }} - {% if revision.state == import('sstreasury.models').BudgetState.AWAIT_REVIEW.value and request.user.groups.filter(name='Treasury').exists() %} - + {% if is_latest %} + {% if revision.can_submit(request.user) %} + + {% endif %} + {% if revision.can_endorse(request.user) %} + + + + {% endif %} + {% if revision.can_approve(request.user) %} + + + + {% endif %} + {% if revision.can_withdraw(request.user) %} + + {% endif %} + {% if revision.can_cancel(request.user) %} + + {% endif %} - - {% elif revision.state != import('sstreasury.models').BudgetState.APPROVED.value and request.user.groups.filter(name='Secretary').exists() %} - + {% if revision.can_edit(request.user) %} + Edit + {% endif %} - + Print + + {% if not revision.can_edit(request.user) and revision.can_withdraw(request.user) %} +
+

This budget has been submitted and is now awaiting approval. If you wish to edit this budget, you must first withdraw it. This will revert the budget to a draft.

+
+ {% endif %} + + + + {% else %} + Print + +
+

You are viewing an older version of this budget. To make any changes, click here to return to the current version.

+
{% endif %}
-
- {% for item in history %} - {% if item.__class__.__name__ == 'BudgetComment' %} -
-
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDBU-{{ revision.budget.id }}
Title{{ revision.name }}
Due date{{ revision.date or '' }}
Event details + {% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %} + {% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %} + {% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %} +
Contributors + -
-
- - {{ item.author.first_name }} {{ item.author.last_name }} commented -
- {{ localtime(item.time) }} +
Comments{{ revision.comments|markdown }}
Revenue +
+ {% if revision.revenue_comments %} +
+
+ + Revenue comments +
+
+ {{ revision.revenue_comments|markdown }}
-
- {{ item.content|markdown }} -
- - - {% elif item.__class__.__name__ == 'BudgetRevision' %} -
-
- -
-
-
- - {% if item.action == import('sstreasury.models').BudgetAction.CREATE.value %} - {{ item.author.first_name }} {{ item.author.last_name }} created the budget (view) - {% elif item.action == import('sstreasury.models').BudgetAction.EDIT.value %} - {{ item.author.first_name }} {{ item.author.last_name }} edited the budget (view) - {% elif item.action == import('sstreasury.models').BudgetAction.UPDATE_STATE.value %} - {{ item.author.first_name }} {{ item.author.last_name }} changed the state to: {{ item.get_state_display() }} - {% else %} - {{ item.author.first_name }} {{ item.author.last_name }} modified the budget (view) - {% endif %} -
- {{ localtime(item.time) }} + {% endif %} +
Expenses + {% if revision.expense_no_emergency_fund %} +

No emergency fund required (please add a comment explaining why)

+ {% endif %} +
+ {% if revision.expense_comments %} +
+
+ + Expense comments +
+
+ {{ revision.expense_comments|markdown }}
- - - {% endif %} - {% endfor %} - + {% endif %} +
Total Profit (Loss){{ '${:.2f}'.format(revision.get_revenue_total() - revision.get_expense_total()) if revision.get_revenue_total() >= revision.get_expense_total() else '(${:.2f})'.format(revision.get_expense_total() - revision.get_revenue_total()) }}
- {% if claims is not none %} -

Reimbursement claims

- - {% if claims %} - - - - - - - - - - - {% for claim in claims %} - - - - - - - {% endfor %} - -
PurposeStatusTotalView
{{ claim.purpose }}{{ claim.get_state_display() }}{{ '${:.2f}'.format(claim.get_total()) }} - -
- -
-

This list will not include invoices, or other transactions tracked outside of Self Service.

+ {% if is_latest %} +
+
+
- {% else %} -

There are no claims to display.

+ + + + + {% if revision.state == import('sstreasury.models').BudgetState.AWAIT_REVIEW.value and request.user.groups.filter(name='Treasury').exists() %} + + + + {% elif revision.state != import('sstreasury.models').BudgetState.APPROVED.value and request.user.groups.filter(name='Secretary').exists() %} + + + + {% endif %} +
+ +
+ {% for item in history %} + {% if item.__class__.__name__ == 'BudgetComment' %} +
+
+ +
+
+
+ + {{ item.author.first_name }} {{ item.author.last_name }} commented +
+ {{ localtime(item.time) }} +
+
+
+ {{ item.content|markdown }} +
+
+
+ {% elif item.__class__.__name__ == 'BudgetRevision' %} +
+
+ +
+
+
+ + {% if item.action == import('sstreasury.models').BudgetAction.CREATE.value %} + {{ item.author.first_name }} {{ item.author.last_name }} created the budget (view) + {% elif item.action == import('sstreasury.models').BudgetAction.EDIT.value %} + {{ item.author.first_name }} {{ item.author.last_name }} edited the budget (view) + {% elif item.action == import('sstreasury.models').BudgetAction.UPDATE_STATE.value %} + {{ item.author.first_name }} {{ item.author.last_name }} changed the state to: {{ item.get_state_display() }} + {% else %} + {{ item.author.first_name }} {{ item.author.last_name }} modified the budget (view) + {% endif %} +
+ {{ localtime(item.time) }} +
+
+
+
+ {% endif %} + {% endfor %} +
+ + {% if claims is not none %} +

Reimbursement claims

+ + {% if claims %} + + + + + + + + + + + {% for claim in claims %} + + + + + + + {% endfor %} + +
PurposeStatusTotalView
{{ claim.purpose }}{{ claim.get_state_display() }}{{ '${:.2f}'.format(claim.get_total()) }} + +
+ +
+

This list will not include invoices, or other transactions tracked outside of Self Service.

+
+ {% else %} +

There are no claims to display.

+ {% endif %} {% endif %} {% endif %} - {% endif %} + + +
-