feat(contratos): gestión de códigos de pago + asignación por contrato
- Nueva tabla SQLite codigos_pago (codigo, nombre) con seed CIAC/CR/MU - Columna cod_forma_pago en contratos (override por contrato) - Página contratos: tarjeta para agregar/eliminar códigos, select inline por fila - generar_factura_venta acepta forma_pago_override; si asignado lo usa, sino auto CIAC/CR - Rutas: /codigos-pago/create, /codigos-pago/delete, /set-forma-pago Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
551dec9c11
commit
91dbcc8135
@@ -50,6 +50,45 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Códigos de pago -->
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-200">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h3 class="font-semibold text-gray-800"><i class="fas fa-tags mr-2 text-indigo-500"></i>Códigos de Pago</h3>
|
||||
</div>
|
||||
<div class="p-6 space-y-4">
|
||||
<div class="flex flex-wrap gap-3">
|
||||
{% for cp in codigos_pago %}
|
||||
<div class="flex items-center gap-2 px-3 py-2 bg-indigo-50 border border-indigo-200 rounded-lg text-sm">
|
||||
<span class="font-mono font-semibold text-indigo-700">{{ cp.codigo }}</span>
|
||||
<span class="text-gray-600">{{ cp.nombre }}</span>
|
||||
<form method="POST" action="/contratos/codigos-pago/delete/{{ cp.id }}" class="inline"
|
||||
onsubmit="return confirm('¿Eliminar código {{ cp.codigo }}?')">
|
||||
<button type="submit" class="text-red-400 hover:text-red-600 ml-1">
|
||||
<i class="fas fa-times text-xs"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<form method="POST" action="/contratos/codigos-pago/create" class="flex items-end gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Código</label>
|
||||
<input type="text" name="codigo" required placeholder="Ej: CIAC" maxlength="10"
|
||||
class="w-28 px-3 py-2 border border-gray-300 rounded-lg text-sm uppercase focus:ring-2 focus:ring-indigo-500">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Nombre</label>
|
||||
<input type="text" name="nombre" placeholder="Ej: Contado inmediato"
|
||||
class="w-56 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-indigo-500">
|
||||
</div>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-lg transition-colors">
|
||||
<i class="fas fa-plus mr-1"></i> Agregar
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabla de contratos -->
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-200">
|
||||
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
|
||||
@@ -70,6 +109,7 @@
|
||||
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Excluir RDA</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Excluir Ventas</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Sin Contrato</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Forma Pago</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -133,7 +173,18 @@
|
||||
</form>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<button onclick="openEdit({{ c.id }}, '{{ c.numero_contrato }}', '{{ c.nit_empresa }}', '{{ c.tipo_usuario }}', '{{ c.descripcion }}', {{ c.excluir }}, {{ c.sin_contrato }}, {{ c.excluir_ventas }})"
|
||||
<form method="POST" action="/contratos/set-forma-pago/{{ c.id }}" class="inline">
|
||||
<select name="cod_forma_pago" onchange="this.form.submit()"
|
||||
class="text-xs border border-gray-200 rounded-lg px-2 py-1 focus:ring-2 focus:ring-indigo-400 bg-white {% if c.cod_forma_pago %}text-indigo-700 font-semibold{% else %}text-gray-400{% endif %}">
|
||||
<option value="" {% if not c.cod_forma_pago %}selected{% endif %}>— auto —</option>
|
||||
{% for cp in codigos_pago %}
|
||||
<option value="{{ cp.codigo }}" {% if c.cod_forma_pago == cp.codigo %}selected{% endif %}>{{ cp.codigo }} — {{ cp.nombre }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<button onclick="openEdit({{ c.id }}, '{{ c.numero_contrato }}', '{{ c.nit_empresa }}', '{{ c.tipo_usuario }}', '{{ c.descripcion }}', {{ c.excluir }}, {{ c.sin_contrato }}, {{ c.excluir_ventas }}, '{{ c.cod_forma_pago }}')"
|
||||
class="text-blue-600 hover:text-blue-800 mr-3 text-xs">
|
||||
<i class="fas fa-edit"></i> Editar
|
||||
</button>
|
||||
@@ -189,6 +240,16 @@
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-600 mb-1">Forma de Pago (Ventas)</label>
|
||||
<select name="cod_forma_pago" id="edit-forma-pago"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-indigo-500">
|
||||
<option value="">— automático (CIAC si total=0, CR si total>0) —</option>
|
||||
{% for cp in codigos_pago %}
|
||||
<option value="{{ cp.codigo }}">{{ cp.codigo }} — {{ cp.nombre }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" name="excluir" id="edit-excluir" value="1" class="rounded">
|
||||
@@ -218,12 +279,13 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function openEdit(id, nc, nit, tu, desc, excluir, sinContrato, excluirVentas) {
|
||||
function openEdit(id, nc, nit, tu, desc, excluir, sinContrato, excluirVentas, formaPago) {
|
||||
document.getElementById('edit-form').action = '/contratos/update/' + id;
|
||||
document.getElementById('edit-nc').value = nc;
|
||||
document.getElementById('edit-nit').value = nit;
|
||||
document.getElementById('edit-tu').value = tu;
|
||||
document.getElementById('edit-desc').value = desc;
|
||||
document.getElementById('edit-forma-pago').value = formaPago || '';
|
||||
document.getElementById('edit-excluir').checked = excluir === 1;
|
||||
document.getElementById('edit-sin-contrato').checked = sinContrato === 1;
|
||||
document.getElementById('edit-excluir-ventas').checked = excluirVentas === 1;
|
||||
|
||||
Reference in New Issue
Block a user