feat: add KS-3/payments, tech debt fixes, UI polish, and KS-2 Excel/Word export

Tasks 008-016: KS-6a journal, KS-3 documents, payments with allocations,
tech debt cleanup, financial privacy, document tree, storno mechanism,
row-click UI, BOQ collapse/sticky header, and KS-2 export to Excel/Word
via shared DTO architecture.
This commit is contained in:
Арсентьев Александр
2026-09-27 13:38:45 +03:00
parent 6c608a8779
commit 9cfb341774
57 changed files with 7163 additions and 50 deletions
+98
View File
@@ -0,0 +1,98 @@
{% extends "base.html" %}
{% block title %}{{ 'Редактирование' if document else 'Создание' }} КС-3{% endblock %}
{% block content %}
<div class="container mt-4">
<nav class="mb-3">
<a href="/projects/{{ project.id }}" class="btn btn-outline-secondary btn-sm">&larr; К проекту</a>
</nav>
<div class="row">
<div class="col-12">
<h2>{{ 'Редактирование КС-3' if document else 'Создание КС-3' }}</h2>
{% if error %}
<div class="alert alert-danger" role="alert">{{ error }}</div>
{% endif %}
<form method="post" action="/projects/{{ project.id }}/ks3{% if document %}/{{ document.id }}/edit{% endif %}">
<div class="row mb-3">
<div class="col-md-3">
<label for="number" class="form-label">Номер КС-3</label>
<input type="text" class="form-control" id="number" name="number" required
value="{{ document.number if document else '' }}">
</div>
<div class="col-md-3">
<label for="document_date" class="form-label">Дата</label>
<input type="date" class="form-control" id="document_date" name="document_date" required
value="{{ document.date.isoformat() if document else '' }}">
</div>
<div class="col-md-3">
<label for="reporting_period_from" class="form-label">Период с</label>
<input type="date" class="form-control" id="reporting_period_from" name="reporting_period_from" required
value="{{ document.reporting_period_from.isoformat() if document and document.reporting_period_from else '' }}">
</div>
<div class="col-md-3">
<label for="reporting_period_to" class="form-label">Период по</label>
<input type="date" class="form-control" id="reporting_period_to" name="reporting_period_to" required
value="{{ document.reporting_period_to.isoformat() if document and document.reporting_period_to else '' }}">
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
<label for="comment" class="form-label">Комментарий</label>
<input type="text" class="form-control" id="comment" name="comment"
value="{{ document.comment if document and document.comment else '' }}">
</div>
</div>
<h4>Выберите проведённые КС-2</h4>
{% if available_ks2 %}
<div class="table-responsive">
<table class="table table-striped table-sm" style="table-layout: fixed;">
<colgroup>
<col style="width: 40px">
<col style="width: 100px">
<col style="width: 90px">
<col>
<col style="width: 120px">
</colgroup>
<thead>
<tr>
<th></th>
<th>№ КС-2</th>
<th>Дата</th>
<th>Период</th>
<th class="text-end text-nowrap">Сумма</th>
</tr>
</thead>
<tbody>
{% for item in available_ks2 %}
<tr>
<td>
<input type="checkbox" class="form-check-input" name="ks2_ids"
value="{{ item.id }}"
{% if item.id in selected_ids %}checked{% endif %}>
</td>
<td>{{ item.number }}</td>
<td>{{ item.date.strftime('%d.%m.%Y') }}</td>
<td>{% if item.period_from and item.period_to %}{{ item.period_from.strftime('%d.%m.%Y') }} — {{ item.period_to.strftime('%d.%m.%Y') }}{% endif %}</td>
<td class="text-end text-nowrap">{{ item.total | money }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info">Нет проведённых КС-2 для выбора.</div>
{% endif %}
<button type="submit" class="btn btn-primary">{{ 'Сохранить' if document else 'Создать' }}</button>
<a href="/projects/{{ project.id }}/ks3{% if document %}/{{ document.id }}{% endif %}" class="btn btn-secondary">Отмена</a>
</form>
</div>
</div>
</div>
{% endblock %}
+55
View File
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% block title %}КС-3 проекта {{ project.name }}{% endblock %}
{% block content %}
<div class="container mt-4">
<nav class="mb-3">
<a href="/projects/{{ project.id }}" class="btn btn-outline-secondary btn-sm">&larr; К проекту</a>
</nav>
<div class="row">
<div class="col-12">
<h2>КС-3 проекта {{ project.name }}</h2>
<a href="/projects/{{ project.id }}/ks3/new" class="btn btn-primary mb-3">Создать КС-3</a>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Номер</th>
<th>Дата</th>
<th>Период</th>
<th>Статус</th>
<th>КС-2</th>
<th class="text-end text-nowrap">Сумма</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr class="clickable-row" data-url="/projects/{{ project.id }}/ks3/{{ row.document.id }}">
<td>{{ row.document.number }}</td>
<td>{{ row.document.date.strftime('%d.%m.%Y') }}</td>
<td>{% if row.document.reporting_period_from and row.document.reporting_period_to %}{{ row.document.reporting_period_from.strftime('%d.%m.%Y') }} — {{ row.document.reporting_period_to.strftime('%d.%m.%Y') }}{% endif %}</td>
<td>
<span class="badge bg-{{ 'success' if row.document.status == 'issued' else 'secondary' }}">
{{ 'Проведён' if row.document.status == 'issued' else 'Черновик' }}
</span>
</td>
<td>{{ row.ks2_count }}</td>
<td class="text-end text-nowrap money-value">{{ row.amount | money }}</td>
<td>
<a href="/projects/{{ project.id }}/ks3/{{ row.document.id }}" class="btn btn-sm btn-outline-primary">Просмотр</a>
</td>
</tr>
{% else %}
<tr><td colspan="7" class="text-center text-muted py-4">КС-3 пока нет.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
+100
View File
@@ -0,0 +1,100 @@
{% extends "base.html" %}
{% block title %}КС-3 №{{ document.number }} от {{ document.date.strftime('%d.%m.%Y') }}{% endblock %}
{% block content %}
<div class="container mt-4">
<nav class="mb-3">
<a href="/projects/{{ project.id }}" class="btn btn-outline-secondary btn-sm">&larr; К проекту</a>
</nav>
<div class="row">
<div class="col-12">
<h2>КС-3 №{{ document.number }} от {{ document.date.strftime('%d.%m.%Y') }}</h2>
<div class="card mb-3">
<div class="card-body">
<p><strong>Статус:</strong>
{% if document.status == 'cancelled' %}
<span class="badge bg-danger">Сторнирован</span>
{% elif document.status == 'issued' %}
<span class="badge bg-success">Проведён</span>
{% else %}
<span class="badge bg-secondary">Черновик</span>
{% endif %}
</p>
{% if document.reporting_period_from and document.reporting_period_to %}
<p><strong>Период:</strong> {{ document.reporting_period_from.strftime('%d.%m.%Y') }} — {{ document.reporting_period_to.strftime('%d.%m.%Y') }}</p>
{% endif %}
{% if document.comment %}
<p><strong>Комментарий:</strong> {{ document.comment }}</p>
{% endif %}
</div>
</div>
{% if document.status == 'cancelled' %}
<div class="alert alert-danger" role="alert">
КС-3 сторнировано. Документ неизменяем, исключён из финансовых агрегатов. Связанные КС-2 сохранены.
</div>
<a href="/projects/{{ project.id }}/ks3" class="btn btn-secondary">Назад к списку</a>
{% else %}
<h4>Включённые КС-2</h4>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>№ КС-2</th>
<th>Дата</th>
<th>Период</th>
<th class="text-end text-nowrap">Сумма</th>
</tr>
</thead>
<tbody>
{% for row in ks2_rows %}
<tr>
<td>{{ row.ks2.number }}</td>
<td>{{ row.ks2.date.strftime('%d.%m.%Y') }}</td>
<td>{% if row.ks2.reporting_period_from and row.ks2.reporting_period_to %}{{ row.ks2.reporting_period_from.strftime('%d.%m.%Y') }} — {{ row.ks2.reporting_period_to.strftime('%d.%m.%Y') }}{% endif %}</td>
<td class="text-end text-nowrap money-value">{{ row.total | money }}</td>
</tr>
{% else %}
<tr><td colspan="4" class="text-center text-muted">Нет включённых КС-2.</td></tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th colspan="3" class="text-end">Итого</th>
<th class="text-end text-nowrap money-value">{{ total | money }}</th>
</tr>
</tfoot>
</table>
</div>
{% if document.status == 'draft' %}
<div class="d-flex gap-2 align-items-center">
<a href="/projects/{{ project.id }}/ks3/{{ document.id }}/edit" class="btn btn-primary">Редактировать</a>
<form method="post" action="/projects/{{ project.id }}/ks3/{{ document.id }}/issue" class="d-inline">
<button type="submit" class="btn btn-success"
onclick="return confirm('После проведения КС-3 изменить его будет нельзя. Продолжить?')">Провести КС-3</button>
</form>
<a href="/projects/{{ project.id }}/ks3" class="btn btn-secondary">Назад к списку</a>
</div>
{% else %}
<div class="alert alert-success" role="alert">
КС-3 проведено. Документ не может быть изменён.
</div>
<div class="mb-3">
<form method="post" action="/projects/{{ project.id }}/ks3/{{ document.id }}/cancel" class="d-inline">
<button type="submit" class="btn btn-outline-danger"
onclick="return confirm('ВНИМАНИЕ: Сторнировать КС-3? Документ будет исключён из финансовых агрегатов. Действие необратимо.')">Сторнировать</button>
</form>
</div>
<a href="/projects/{{ project.id }}/ks3" class="btn btn-secondary">Назад к списку</a>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endblock %}