運搬計画PDF: 袋数を整数 or 小数1桁で表示(4桁表示を修正)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
{% load fertilizer_tags %}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ja">
|
<html lang="ja">
|
||||||
<head>
|
<head>
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
<tr class="group-row">
|
<tr class="group-row">
|
||||||
<td class="col-name"><span class="group-star">★</span>{{ group.name }}</td>
|
<td class="col-name"><span class="group-star">★</span>{{ group.name }}</td>
|
||||||
{% for total in group.totals %}
|
{% for total in group.totals %}
|
||||||
<td>{% if total %}{{ total }}{% else %}<span class="zero">-</span>{% endif %}</td>
|
<td>{% if total %}{{ total|bags_fmt }}{% else %}<span class="zero">-</span>{% endif %}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{# 圃場サブ行 #}
|
{# 圃場サブ行 #}
|
||||||
@@ -55,7 +56,7 @@
|
|||||||
<tr class="field-row">
|
<tr class="field-row">
|
||||||
<td class="col-name field-indent">{{ row.field.name }}({{ row.field.area_tan }}反)</td>
|
<td class="col-name field-indent">{{ row.field.name }}({{ row.field.area_tan }}反)</td>
|
||||||
{% for cell in row.cells %}
|
{% for cell in row.cells %}
|
||||||
<td>{% if cell %}{{ cell }}{% else %}<span class="zero">-</span>{% endif %}</td>
|
<td>{% if cell %}{{ cell|bags_fmt }}{% else %}<span class="zero">-</span>{% endif %}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
<tr class="total-row">
|
<tr class="total-row">
|
||||||
<td class="col-name">合計</td>
|
<td class="col-name">合計</td>
|
||||||
{% for total in page.fert_totals %}
|
{% for total in page.fert_totals %}
|
||||||
<td>{{ total }}</td>
|
<td>{{ total|bags_fmt }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|||||||
0
backend/apps/fertilizer/templatetags/__init__.py
Normal file
0
backend/apps/fertilizer/templatetags/__init__.py
Normal file
15
backend/apps/fertilizer/templatetags/fertilizer_tags.py
Normal file
15
backend/apps/fertilizer/templatetags/fertilizer_tags.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def bags_fmt(value):
|
||||||
|
"""袋数を整数 or 小数点以下1桁で表示する。"""
|
||||||
|
if value is None or value == '':
|
||||||
|
return value
|
||||||
|
d = Decimal(str(value))
|
||||||
|
if d == d.to_integral_value():
|
||||||
|
return str(int(d))
|
||||||
|
return str(d.quantize(Decimal('0.1')))
|
||||||
Reference in New Issue
Block a user