Split the report parameters from the report class so that it works better with both CSV export and HTML templates.
This commit is contained in:
		| @@ -146,8 +146,10 @@ First written: 2023/3/5 | ||||
|   {% include "accounting/report/include/period-chooser.html" %} | ||||
| {% endwith %} | ||||
|  | ||||
| {% if list %} | ||||
|   {% include "accounting/include/pagination.html" %} | ||||
| {% if report.has_data %} | ||||
|   {% with pagination = report.pagination %} | ||||
|     {% include "accounting/include/pagination.html" %} | ||||
|   {% endwith %} | ||||
|  | ||||
|   <div class="d-none d-md-block accounting-report-table accounting-income-expenses-table"> | ||||
|     <div class="accounting-report-table-header"> | ||||
| @@ -161,17 +163,8 @@ First written: 2023/3/5 | ||||
|       </div> | ||||
|     </div> | ||||
|     <div class="accounting-report-table-body"> | ||||
|       {% for item in list %} | ||||
|         {% if item.transaction %} | ||||
|           <a class="accounting-report-table-row" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|             <div>{{ item.date|accounting_format_date }}</div> | ||||
|             <div>{{ item.account.title|title }}</div> | ||||
|             <div>{{ item.summary|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.income|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.expense|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </a> | ||||
|         {% else %} | ||||
|       {% if report.brought_forward %} | ||||
|         {% with item = report.brought_forward %} | ||||
|           <div class="accounting-report-table-row"> | ||||
|             <div>{{ item.date|accounting_format_date }}</div> | ||||
|             <div>{{ item.account.title|title }}</div> | ||||
| @@ -180,35 +173,48 @@ First written: 2023/3/5 | ||||
|             <div class="accounting-amount">{{ item.expense|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </div> | ||||
|         {% endif %} | ||||
|         {% endwith %} | ||||
|       {% endif %} | ||||
|       {% for item in report.data_rows %} | ||||
|         <a class="accounting-report-table-row" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|           <div>{{ item.date|accounting_format_date }}</div> | ||||
|           <div>{{ item.account.title|title }}</div> | ||||
|           <div>{{ item.summary|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.income|accounting_format_amount|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.expense|accounting_format_amount|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|         </a> | ||||
|       {% endfor %} | ||||
|     </div> | ||||
|     {% if report.total_row %} | ||||
|       <div class="accounting-report-table-footer"> | ||||
|         <div class="accounting-report-table-row"> | ||||
|           <div>{{ A_("Total") }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.income|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.expense|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.balance|accounting_format_amount }}</div> | ||||
|     {% if report.total %} | ||||
|       {% with item = report.total %} | ||||
|         <div class="accounting-report-table-footer"> | ||||
|           <div class="accounting-report-table-row"> | ||||
|             <div>{{ A_("Total") }}</div> | ||||
|             <div class="accounting-amount">{{ item.income|accounting_format_amount }}</div> | ||||
|             <div class="accounting-amount">{{ item.expense|accounting_format_amount }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </div> | ||||
|         </div> | ||||
|       </div> | ||||
|       {% endwith %} | ||||
|     {% endif %} | ||||
|   </div> | ||||
|  | ||||
|   <div class="list-group d-md-none"> | ||||
|   {% for item in list %} | ||||
|     {% if item.transaction is not none %} | ||||
|       <a class="list-group-item list-group-item-action d-flex justify-content-between" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|         {% include "accounting/report/include/income-expenses-mobile-row.html" %} | ||||
|       </a> | ||||
|     {% else %} | ||||
|   {% if report.brought_forward %} | ||||
|     {% with item = report.brought_forward %} | ||||
|       <div class="list-group-item list-group-item-action d-flex justify-content-between"> | ||||
|         {% include "accounting/report/include/income-expenses-mobile-row.html" %} | ||||
|       </div> | ||||
|     {% endif %} | ||||
|     {% endwith %} | ||||
|   {% endif %} | ||||
|   {% for item in report.data_rows %} | ||||
|     <a class="list-group-item list-group-item-action d-flex justify-content-between" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|       {% include "accounting/report/include/income-expenses-mobile-row.html" %} | ||||
|     </a> | ||||
|   {% endfor %} | ||||
|   {% if report.total_row is not none %} | ||||
|     {% with item = report.total_row %} | ||||
|   {% if report.total is not none %} | ||||
|     {% with item = report.total %} | ||||
|       <div class="list-group-item list-group-item-action d-flex justify-content-between"> | ||||
|         {% include "accounting/report/include/income-expenses-mobile-row.html" %} | ||||
|       </div> | ||||
|   | ||||
| @@ -88,8 +88,10 @@ First written: 2023/3/4 | ||||
|   {% include "accounting/report/include/period-chooser.html" %} | ||||
| {% endwith %} | ||||
|  | ||||
| {% if list %} | ||||
|   {% include "accounting/include/pagination.html" %} | ||||
| {% if report.has_data %} | ||||
|   {% with pagination = report.pagination %} | ||||
|     {% include "accounting/include/pagination.html" %} | ||||
|   {% endwith %} | ||||
|  | ||||
|   <div class="d-none d-md-block accounting-report-table accounting-journal-table"> | ||||
|     <div class="accounting-report-table-header"> | ||||
| @@ -103,7 +105,7 @@ First written: 2023/3/4 | ||||
|       </div> | ||||
|     </div> | ||||
|     <div class="accounting-report-table-body"> | ||||
|       {% for item in list %} | ||||
|       {% for item in report.data_rows %} | ||||
|         <a class="accounting-report-table-row" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|           <div>{{ item.transaction.date|accounting_format_date }}</div> | ||||
|           <div>{{ item.currency.name }}</div> | ||||
| @@ -117,7 +119,7 @@ First written: 2023/3/4 | ||||
|   </div> | ||||
|  | ||||
|   <div class="list-group d-md-none"> | ||||
|   {% for item in list %} | ||||
|   {% for item in report.data_rows %} | ||||
|     <a class="list-group-item list-group-item-action" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|       <div class="d-flex justify-content-between"> | ||||
|         <div {% if not item.is_debit %} class="accounting-mobile-journal-credit" {% endif %}> | ||||
|   | ||||
| @@ -146,8 +146,10 @@ First written: 2023/3/5 | ||||
|   {% include "accounting/report/include/period-chooser.html" %} | ||||
| {% endwith %} | ||||
|  | ||||
| {% if list %} | ||||
|   {% include "accounting/include/pagination.html" %} | ||||
| {% if report.has_data %} | ||||
|   {% with pagination = report.pagination %} | ||||
|     {% include "accounting/include/pagination.html" %} | ||||
|   {% endwith %} | ||||
|  | ||||
|   <div class="d-none d-md-block accounting-report-table accounting-ledger-table"> | ||||
|     <div class="accounting-report-table-header"> | ||||
| @@ -160,16 +162,8 @@ First written: 2023/3/5 | ||||
|       </div> | ||||
|     </div> | ||||
|     <div class="accounting-report-table-body"> | ||||
|       {% for item in list %} | ||||
|         {% if item.transaction %} | ||||
|           <a class="accounting-report-table-row" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|             <div>{{ item.date|accounting_format_date }}</div> | ||||
|             <div>{{ item.summary|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.debit|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.credit|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </a> | ||||
|         {% else %} | ||||
|       {% if report.brought_forward %} | ||||
|         {% with item = report.brought_forward %} | ||||
|           <div class="accounting-report-table-row"> | ||||
|             <div>{{ item.date|accounting_format_date }}</div> | ||||
|             <div>{{ item.summary|accounting_default }}</div> | ||||
| @@ -177,35 +171,47 @@ First written: 2023/3/5 | ||||
|             <div class="accounting-amount">{{ item.credit|accounting_format_amount|accounting_default }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </div> | ||||
|         {% endif %} | ||||
|         {% endwith %} | ||||
|       {% endif %} | ||||
|       {% for item in report.data_rows %} | ||||
|         <a class="accounting-report-table-row" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|           <div>{{ item.date|accounting_format_date }}</div> | ||||
|           <div>{{ item.summary|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.debit|accounting_format_amount|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.credit|accounting_format_amount|accounting_default }}</div> | ||||
|           <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|         </a> | ||||
|       {% endfor %} | ||||
|     </div> | ||||
|     {% if report.total_row %} | ||||
|       <div class="accounting-report-table-footer"> | ||||
|         <div class="accounting-report-table-row"> | ||||
|           <div>{{ A_("Total") }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.debit|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.credit|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.balance|accounting_format_amount }}</div> | ||||
|     {% if report.total %} | ||||
|       {% with item = report.total %} | ||||
|         <div class="accounting-report-table-footer"> | ||||
|           <div class="accounting-report-table-row"> | ||||
|             <div>{{ A_("Total") }}</div> | ||||
|             <div class="accounting-amount">{{ item.debit|accounting_format_amount }}</div> | ||||
|             <div class="accounting-amount">{{ item.credit|accounting_format_amount }}</div> | ||||
|             <div class="accounting-amount">{{ item.balance|accounting_format_amount }}</div> | ||||
|           </div> | ||||
|         </div> | ||||
|       </div> | ||||
|       {% endwith %} | ||||
|     {% endif %} | ||||
|   </div> | ||||
|  | ||||
|   <div class="list-group d-md-none"> | ||||
|   {% for item in list %} | ||||
|     {% if item.transaction is not none %} | ||||
|       <a class="list-group-item list-group-item-action d-flex justify-content-between" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|         {% include "accounting/report/include/ledger-mobile-row.html" %} | ||||
|       </a> | ||||
|     {% else %} | ||||
|   {% if report.brought_forward %} | ||||
|     {% with item = report.brought_forward %} | ||||
|       <div class="list-group-item list-group-item-action d-flex justify-content-between"> | ||||
|         {% include "accounting/report/include/ledger-mobile-row.html" %} | ||||
|       </div> | ||||
|     {% endif %} | ||||
|     {% endwith %} | ||||
|   {% endif %} | ||||
|   {% for item in report.data_rows %} | ||||
|     <a class="list-group-item list-group-item-action d-flex justify-content-between" href="{{ url_for("accounting.transaction.detail", txn=item.transaction)|accounting_append_next }}"> | ||||
|       {% include "accounting/report/include/ledger-mobile-row.html" %} | ||||
|     </a> | ||||
|   {% endfor %} | ||||
|   {% if report.total_row is not none %} | ||||
|     {% with item = report.total_row %} | ||||
|   {% if report.total is not none %} | ||||
|     {% with item = report.total %} | ||||
|       <div class="list-group-item list-group-item-action d-flex justify-content-between"> | ||||
|         {% include "accounting/report/include/ledger-mobile-row.html" %} | ||||
|       </div> | ||||
|   | ||||
| @@ -116,7 +116,7 @@ First written: 2023/3/5 | ||||
|   {% include "accounting/report/include/period-chooser.html" %} | ||||
| {% endwith %} | ||||
|  | ||||
| {% if list %} | ||||
| {% if report.has_data %} | ||||
|   <div class="accounting-sheet"> | ||||
|     <div class="d-none d-sm-flex justify-content-center mb-3"> | ||||
|       <h2 class="text-center">{{ _("Trial Balance of %(currency)s %(period)s", currency=report.currency.name|title, period=report.period.desc|title) }}</h2> | ||||
| @@ -131,7 +131,7 @@ First written: 2023/3/5 | ||||
|         </div> | ||||
|       </div> | ||||
|       <div class="accounting-report-table-body"> | ||||
|         {% for item in list %} | ||||
|         {% for item in report.data_rows %} | ||||
|           <a class="accounting-report-table-row" href="{{ item.url }}"> | ||||
|             <div> | ||||
|               <span class="d-none d-md-inline">{{ item.account.code }}</span> | ||||
| @@ -145,8 +145,8 @@ First written: 2023/3/5 | ||||
|       <div class="accounting-report-table-footer"> | ||||
|         <div class="accounting-report-table-row"> | ||||
|           <div>{{ A_("Total") }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.debit|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total_row.credit|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total.debit|accounting_format_amount }}</div> | ||||
|           <div class="accounting-amount">{{ report.total.credit|accounting_format_amount }}</div> | ||||
|       </div> | ||||
|       </div> | ||||
|     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user