月次レポート機能の改善として、開始日・終了日によるフィルタリング機能を追加し、店舗区分および経費区分の選択肢を実装。経費区分と店舗マスタの管理画面を新規作成し、関連するマイグレーションを追加。CSV取込画面における経費区分の表示を改善。作業ログをdiary.mdに追記。
This commit is contained in:
@@ -8,14 +8,87 @@
|
||||
<h2>月次レポート</h2>
|
||||
<form method="get">
|
||||
<label>
|
||||
年月
|
||||
<input type="month" name="target_month" value="{{ target_month }}">
|
||||
開始日
|
||||
<input type="date" name="start_date" value="{{ start_date }}">
|
||||
</label>
|
||||
<label>
|
||||
終了日
|
||||
<input type="date" name="end_date" value="{{ end_date }}">
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" name="all_time" value="1" {% if all_time %}checked{% endif %}>
|
||||
全期間
|
||||
</label>
|
||||
<label>
|
||||
店舗区分
|
||||
<select name="store_id">
|
||||
<option value="" {% if not selected_store %}selected{% endif %}>全て</option>
|
||||
<option value="unassigned" {% if selected_store == "unassigned" %}selected{% endif %}>
|
||||
未設定
|
||||
</option>
|
||||
{% for store in stores %}
|
||||
<option value="{{ store.id }}" {% if selected_store == store.id|stringformat:"s" %}selected{% endif %}>
|
||||
{{ store.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
経費区分
|
||||
<select name="expense_category_id">
|
||||
<option value="" {% if not selected_category %}selected{% endif %}>全て</option>
|
||||
<option value="unassigned" {% if selected_category == "unassigned" %}selected{% endif %}>
|
||||
未設定
|
||||
</option>
|
||||
{% for category in categories %}
|
||||
<option value="{{ category.id }}" {% if selected_category == category.id|stringformat:"s" %}selected{% endif %}>
|
||||
{{ category.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
利用先
|
||||
<input type="search" name="description" value="{{ description_query }}">
|
||||
</label>
|
||||
<input type="hidden" name="show" value="1">
|
||||
<button type="submit">表示</button>
|
||||
{% if show_report %}
|
||||
<a
|
||||
href="{% url 'monthly_report_pdf' %}?start_date={{ start_date }}&end_date={{ end_date }}&store_id={{ selected_store }}&expense_category_id={{ selected_category }}&description={{ description_query|urlencode }}&all_time={% if all_time %}1{% endif %}"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
PDF出力
|
||||
</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
<script>
|
||||
const startInput = document.querySelector('input[name="start_date"]');
|
||||
const endInput = document.querySelector('input[name="end_date"]');
|
||||
const allTimeInput = document.querySelector('input[name="all_time"]');
|
||||
if (startInput && endInput && allTimeInput) {
|
||||
const syncAllTime = () => {
|
||||
if (startInput.value || endInput.value) {
|
||||
allTimeInput.checked = false;
|
||||
}
|
||||
};
|
||||
startInput.addEventListener('change', syncAllTime);
|
||||
endInput.addEventListener('change', syncAllTime);
|
||||
allTimeInput.addEventListener('change', () => {
|
||||
if (allTimeInput.checked) {
|
||||
startInput.value = '';
|
||||
endInput.value = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% if error_message %}
|
||||
<p style="color: #b00020;">{{ error_message }}</p>
|
||||
{% endif %}
|
||||
{% if not show_report %}
|
||||
<p>条件を指定して表示ボタンを押してください。</p>
|
||||
{% else %}
|
||||
<div>
|
||||
<h3>合計</h3>
|
||||
<p class="amount">{{ report.total_amount|intcomma }} 円</p>
|
||||
@@ -50,6 +123,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日付</th>
|
||||
<th>経費区分</th>
|
||||
<th>利用先</th>
|
||||
<th class="amount">金額</th>
|
||||
<th>備考</th>
|
||||
@@ -59,13 +133,14 @@
|
||||
{% for detail in row.details %}
|
||||
<tr>
|
||||
<td>{{ detail.use_date }}</td>
|
||||
<td>{{ detail.expense_category_name|default:"未設定" }}</td>
|
||||
<td>{{ detail.description }}</td>
|
||||
<td class="amount">{{ detail.amount|intcomma }}</td>
|
||||
<td>{{ detail.note }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="4">対象データがありません。</td>
|
||||
<td colspan="5">対象データがありません。</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -102,6 +177,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日付</th>
|
||||
<th>経費区分</th>
|
||||
<th>利用先</th>
|
||||
<th class="amount">金額</th>
|
||||
<th>備考</th>
|
||||
@@ -111,13 +187,14 @@
|
||||
{% for detail in row.details %}
|
||||
<tr>
|
||||
<td>{{ detail.use_date }}</td>
|
||||
<td>{{ detail.expense_category_name|default:"未設定" }}</td>
|
||||
<td>{{ detail.description }}</td>
|
||||
<td class="amount">{{ detail.amount|intcomma }}</td>
|
||||
<td>{{ detail.note }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="4">対象データがありません。</td>
|
||||
<td colspan="5">対象データがありません。</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -154,6 +231,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日付</th>
|
||||
<th>経費区分</th>
|
||||
<th>利用先</th>
|
||||
<th class="amount">金額</th>
|
||||
<th>備考</th>
|
||||
@@ -163,13 +241,14 @@
|
||||
{% for detail in row.details %}
|
||||
<tr>
|
||||
<td>{{ detail.use_date }}</td>
|
||||
<td>{{ detail.expense_category_name|default:"未設定" }}</td>
|
||||
<td>{{ detail.description }}</td>
|
||||
<td class="amount">{{ detail.amount|intcomma }}</td>
|
||||
<td>{{ detail.note }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="4">対象データがありません。</td>
|
||||
<td colspan="5">対象データがありません。</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -185,5 +264,6 @@
|
||||
<li>対象総件数: {{ report.unclassified_counts.total }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user