139 lines
10 KiB
HTML
139 lines
10 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
{% load humanize %}
|
|
|
|
{% block content %}
|
|
<section class="page-view active">
|
|
<div class="view-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;">
|
|
<div class="view-title">
|
|
<h2 style="margin:0; color:var(--efintel-petroleum); display:flex; align-items:center; gap:0.5rem;"><i data-lucide="truck" style="color:var(--efintel-blue);"></i> Control de Erogaciones (Flujo Operativo)</h2>
|
|
<p style="margin-top:0.25rem; font-size:0.9rem; color:var(--efintel-gray);">Bandeja de gestión y aprobación de costos y gastos registrados.</p>
|
|
</div>
|
|
<div>
|
|
<a href="{% url 'expense_create' %}" class="btn-primary" style="text-decoration: none;">
|
|
<i data-lucide="plus-circle" style="width:16px;"></i> Registrar Nuevo
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="data-card" style="margin-bottom: 2rem;">
|
|
<form method="get" id="filter-form" style="display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap;">
|
|
<div class="form-group" style="margin-bottom: 0; flex: 1; min-width: 200px;">
|
|
<label for="project" style="font-size: 0.8rem; font-weight: 600;">Centro de Costo</label>
|
|
<select name="project" id="project" style="width: 100%; padding: 0.65rem; border: 1px solid var(--efintel-border); border-radius: 4px; outline: none; font-family: 'Inter';" onchange="document.getElementById('filter-form').submit();">
|
|
<option value="">Todos los Centros</option>
|
|
{% for p in projects %}
|
|
<option value="{{ p.id }}" {% if request.GET.project == p.id|stringformat:"s" %}selected{% endif %}>{{ p.code }} - {{ p.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="form-group" style="margin-bottom: 0; flex: 1; min-width: 200px;">
|
|
<label for="category" style="font-size: 0.8rem; font-weight: 600;">Categoría</label>
|
|
<select name="category" id="category" style="width: 100%; padding: 0.65rem; border: 1px solid var(--efintel-border); border-radius: 4px; outline: none; font-family: 'Inter';" onchange="document.getElementById('filter-form').submit();">
|
|
<option value="">Todas las Categorías</option>
|
|
{% for c in categories %}
|
|
<option value="{{ c.id }}" {% if request.GET.category == c.id|stringformat:"s" %}selected{% endif %}>{{ c.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn-outline" style="height: 42px;"><i data-lucide="filter" style="width:16px;"></i> Filtrar</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="data-card">
|
|
<div class="data-table-wrapper">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>ID Transacción</th>
|
|
<th>Fecha</th>
|
|
<th>Centro / Proyecto</th>
|
|
<th>Detalle Imputación</th>
|
|
<th>Monto Neto ($ CLP / USD)</th>
|
|
<th>Estado de Aprobación</th>
|
|
<th>Acciones</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for expense in expenses %}
|
|
<tr>
|
|
<td style="font-family: var(--font-mono); font-size: 0.75rem; color: var(--efintel-gray);">{{ expense.expense_code|truncatechars:12 }}</td>
|
|
<td style="font-size:0.8rem; font-weight: 600;">{{ expense.date|date:"d/m/Y" }}</td>
|
|
<td>
|
|
<span class="project-tag" {% if expense.project.type == 'GASTO_OPERACIONAL_OVERHEAD' %}style="background:#e2e8f0; color:#475569;"{% endif %}>
|
|
{{ expense.project.code }}
|
|
</span>
|
|
</td>
|
|
<td style="font-weight:600; color:var(--efintel-dark); font-size: 0.85rem;">
|
|
{{ expense.description|truncatechars:40 }}<br>
|
|
<span style="font-size:0.65rem; color:var(--efintel-gray);">{{ expense.responsible_person.username|default:expense.user.username }}</span>
|
|
{% if expense.documents.all %}
|
|
<div style="margin-top: 0.25rem; display: flex; flex-direction: column; gap: 0.2rem;">
|
|
{% for doc in expense.documents.all %}
|
|
<div style="display:inline-flex; align-items:center; gap:0.3rem;">
|
|
<a href="{{ doc.file.url }}" target="_blank" style="font-size:0.65rem; color:var(--efintel-blue); text-decoration:none;" title="{{ doc.title|default:doc.file.name }}">
|
|
<i data-lucide="paperclip" style="width:10px;"></i> {{ doc.title|default:doc.file.name|truncatechars:20 }}
|
|
</a>
|
|
<button type="button" onclick="previewDocument('{{ doc.file.url }}', '{{ doc.title|escapejs }}', {% if doc.is_pdf %}true{% else %}false{% endif %})" style="background:none; border:none; color:#0284c7; cursor:pointer; padding:0; font-size:0.65rem;" title="Vista Previa Modal">
|
|
<i data-lucide="eye" style="width:12px;"></i> Ver
|
|
</button>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="amount-cell">
|
|
<div>${{ expense.amount_clp|floatformat:"0"|intcomma }} CLP</div>
|
|
<div style="font-size:0.68rem; color:var(--efintel-gray); font-family:var(--font-mono);">${{ expense.amount_usd|floatformat:"2"|intcomma }} USD</div>
|
|
</td>
|
|
<td>
|
|
{% if expense.approval_status == 'EN_REVISION_DOCUMENTAL' %}
|
|
<span class="badge badge-amber"><i data-lucide="clock" style="width:12px;"></i> En Revisión</span>
|
|
{% elif expense.approval_status == 'SOLICITADO_FINANZAS' %}
|
|
<span class="badge badge-blue"><i data-lucide="send" style="width:12px;"></i> Solicitado Finanzas</span>
|
|
{% elif expense.approval_status == 'LIBERADO_PAGADO' %}
|
|
<span class="badge badge-emerald"><i data-lucide="check-check" style="width:12px;"></i> Pagado</span>
|
|
{% else %}
|
|
<span class="badge badge-red"><i data-lucide="x-circle" style="width:12px;"></i> Rechazado</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div style="display: flex; gap: 0.3rem;">
|
|
{% if expense.approval_status == 'EN_REVISION_DOCUMENTAL' %}
|
|
<a href="{% url 'approve_expense' expense.id 'solicitar' %}" class="btn-primary" style="padding:0.3rem; font-size:0.65rem; background: var(--efintel-blue);" title="Elevar a Finanzas"><i data-lucide="arrow-right"></i></a>
|
|
{% endif %}
|
|
|
|
{% if expense.approval_status == 'SOLICITADO_FINANZAS' and 'Administrador Finanzas' in request.user.groups.all.0.name or request.user.is_superuser %}
|
|
<a href="{% url 'approve_expense' expense.id 'pagar' %}" class="btn-primary" style="padding:0.3rem; font-size:0.65rem; background: var(--efintel-success);" title="Liberar Pago"><i data-lucide="check"></i></a>
|
|
<a href="{% url 'approve_expense' expense.id 'rechazar' %}" class="btn-danger" style="padding:0.3rem; font-size:0.65rem;" title="Rechazar"><i data-lucide="x"></i></a>
|
|
{% endif %}
|
|
|
|
{% if expense.approval_status != 'SOLICITADO_FINANZAS' and expense.approval_status != 'LIBERADO_PAGADO' %}
|
|
{% if request.user.groups.all.0.name == 'Administrador' or request.user.is_superuser or expense.user == request.user %}
|
|
<a href="/gastos/{{ expense.id }}/editar/" class="btn-secondary" style="padding: 0.3rem; background: var(--efintel-light); color: var(--efintel-petroleum);" title="Editar"><i data-lucide="pencil" style="width:14px;"></i></a>
|
|
{% endif %}
|
|
|
|
{% if request.user.groups.all.0.name == 'Administrador' or request.user.is_superuser %}
|
|
<form method="post" action="/gastos/{{ expense.id }}/eliminar/" style="display:inline;">
|
|
{% csrf_token %}
|
|
<button type="submit" class="btn-danger" style="padding: 0.3rem;" onclick="return confirm('¿Seguro que desea eliminar esta erogación? Esta acción quedará en el Log de Auditoría.');" title="Eliminar"><i data-lucide="trash-2" style="width:14px;"></i></button>
|
|
</form>
|
|
{% endif %}
|
|
{% else %}
|
|
<span style="font-size:0.75rem; color:var(--efintel-gray); padding: 0.3rem;" title="Comprobante Bloqueado"><i data-lucide="lock" style="width:14px;"></i></span>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" style="text-align: center; padding: 2rem; color: var(--efintel-gray);">No hay gastos registrados para este filtro.</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{% endblock %}
|