Доработка отчета + рефактор

This commit is contained in:
zakhy 2025-03-16 10:37:46 +07:00
parent d1803db65a
commit c730af39f2
2 changed files with 12 additions and 11 deletions

View File

@ -78,18 +78,17 @@ class ReportService:
for cheque in cheques:
month_key = cheque.uploaded_at.strftime('%Y-%m')
if month_key not in cheques_by_month or \
cheque.uploaded_at > cheques_by_month[
month_key].uploaded_at:
cheque.uploaded_at > cheques_by_month[month_key].uploaded_at:
cheques_by_month[month_key] = cheque
latest_contract = Contract.objects.filter(user=user).latest(
'uploaded_at')
latest_contract = Contract.objects.filter(user=user).order_by(
'uploaded_at').last()
user_dict = {
"id": user.id,
"name": user.get_name(),
"visits_count": user_circles_count,
"contract": f'{host_url}{latest_contract.file.url}',
"contract": f'{host_url}{latest_contract.file.url}' if user_has_contract else None,
"cheques": [
{
"month": f"{months_names[cheque.uploaded_at.strftime('%m')]} "

View File

@ -100,18 +100,20 @@
<b>Количество посещений: </b>
<a href="{% url 'report:circle_history' not_accessed.id %}?date_start={{ date_start }}&date_end={{ date_end }}">{{ not_accessed.visits_count }}/{{ required_count }}</a>
</p>
<a href="{{ not_accessed.contract }}" class="btn btn-outline-primary">Договор</a>
{% if not_accessed.contract %}
<a href="{{ not_accessed.contract }}" class="btn btn-outline-primary">Договор</a>
{% endif %}
{% for cheque in not_accessed.cheques %}
<a href="{{ cheque.url }}" class="btn btn-outline-primary">Чек
за {{ cheque.month }}</a>
{% endfor %}
<h6 class="mt-3">Причины отказа:</h6>
<ul>
{% for reason in not_accessed.reasons %}
<li>
{{ reason }}
</li>
{% endfor %}
{% for reason in not_accessed.reasons %}
<li>
{{ reason }}
</li>
{% endfor %}
</ul>
<hr>