Sistema de Facturación SRI

Comprobante en creación
Ver Comprobantes

Datos del Comprobante

La retención se ligará a una factura existente.

Documento Sustento para Retención

Solo se muestran facturas activas como sustento.
Factura relacionada: No seleccionada
Fecha sustento: -
Subtotal gravado: 0.00
IVA factura: 0.00
Total factura: 0.00

Datos del Cliente

Puedes escribir o escoger un cliente ya usado.
Puedes verificar por cédula o RUC.

Referencia / Observación

Cálculo de Retenciones

Detalle del Comprobante

Código Descripción Cantidad Precio sin IVA Tarifa IVA Subtotal IVA línea Total línea Acción
const clientes = [{"cliente_nombre":"ALLISSON NAOMY DELGADO GARCIA","cliente_identificacion":"1313360909"},{"cliente_nombre":"ANDY RIVADENEYRA NEIDA SONIA","cliente_identificacion":"1500982499"},{"cliente_nombre":"ANGULO GUADAMUD JONATHAN ALEJANDRO","cliente_identificacion":"1315258564"},{"cliente_nombre":"Antonio Marquez Firmiño","cliente_identificacion":"0903984243"},{"cliente_nombre":"ARRIAGA ALVARADO JOSE RICARDO","cliente_identificacion":"0940002207"},{"cliente_nombre":"AVEGNO TARABO KENT ANTHONY","cliente_identificacion":"1313444653"},{"cliente_nombre":"AYALA ERAZO HENRY FRANCISCO","cliente_identificacion":"0918696485"},{"cliente_nombre":"BELEN ASTUDILLO DUQUE","cliente_identificacion":"0915671127"},{"cliente_nombre":"BRIONES VELIZ CARLOS HUMBERTO","cliente_identificacion":"1311838617"},{"cliente_nombre":"CARGOFREIGHT LOGISTICS S.A.","cliente_identificacion":"0993247790001"},{"cliente_nombre":"CEDEÑO CEVALLOS STALIN JAVIER","cliente_identificacion":"1309989125"},{"cliente_nombre":"CHAVEZ PAZMIÑO DORA DIOCNADA","cliente_identificacion":"1304864455001"},{"cliente_nombre":"CONSUMIDOR FINAL","cliente_identificacion":"9999999999999"},{"cliente_nombre":"CONSUMINDOR FINAL","cliente_identificacion":"9999999999999"},{"cliente_nombre":"DAFARCA S.A.S.","cliente_identificacion":"0993370879001"},{"cliente_nombre":"DEL HIERRO AVILES MARIA BEATRIZ","cliente_identificacion":"0908948409001"},{"cliente_nombre":"DENISE LOPEZ","cliente_identificacion":"0914012760"},{"cliente_nombre":"EDUARDO RAAD SERRANO","cliente_identificacion":"0914617584"},{"cliente_nombre":"ESCOBAR CADENA RODRIGO VITERVO","cliente_identificacion":"0914021258"},{"cliente_nombre":"ESCOBAR CADENA RODRIGO VITERVO","cliente_identificacion":"0914021258001"},{"cliente_nombre":"ESTEFANIA KATHERINE RIVERA DELGADO","cliente_identificacion":"1312205048"},{"cliente_nombre":"FIGUEROA TUMBACO ALEJANDRO NEMECIO","cliente_identificacion":"0912445269001"},{"cliente_nombre":"GARITZMO SA","cliente_identificacion":"0992271744001"},{"cliente_nombre":"GUERRERO VINCES NEGDA SONIA","cliente_identificacion":"1307740579"},{"cliente_nombre":"HOLGUIN MUÑOZ OSCAR YOVANNY","cliente_identificacion":"0918048653001"},{"cliente_nombre":"INMOBILIARIA TODUBRI SA","cliente_identificacion":"0991058044001"},{"cliente_nombre":"LEGATORIE SA","cliente_identificacion":"0992171863001"},{"cliente_nombre":"MACIAS MUENTES MARITZA MIRELLA","cliente_identificacion":"1304024548"},{"cliente_nombre":"MANTUANO VELEZ ANGEL VICENTE","cliente_identificacion":"0918129537001"},{"cliente_nombre":"MARIA ELENA ELIZALDE DELGADO","cliente_identificacion":"0903821080"},{"cliente_nombre":"MARIA JOSE NAVARRETE","cliente_identificacion":"0921179180001"},{"cliente_nombre":"MUÑOZ SOLORZANO JOHANA ISABEL","cliente_identificacion":"1312941840"},{"cliente_nombre":"PINARGOTE PARRAGA ARELIS ANYELINE","cliente_identificacion":"0803552215"},{"cliente_nombre":"PROCORPORATION SA","cliente_identificacion":"0992361751001"},{"cliente_nombre":"PRODUCIR Y EXPORTAR PREXPORT SA","cliente_identificacion":"0992802707001"},{"cliente_nombre":"PRODUCSOL S.A.","cliente_identificacion":"0992701692001"},{"cliente_nombre":"PRODUCSOL S.A.","cliente_identificacion":"0992791692001"},{"cliente_nombre":"PRODUCSOL SA","cliente_identificacion":"0992701692001"},{"cliente_nombre":"PUBLIBRATA S.A.","cliente_identificacion":"0990953252001"},{"cliente_nombre":"RODRIGUEZ RIOS KERLY YESSTER","cliente_identificacion":"1310561798"},{"cliente_nombre":"RODRIGUEZ RODAS MARCELO BOLIVAR","cliente_identificacion":"0904327400001"},{"cliente_nombre":"ROSA MARGARITA SUCOZ DURAZNO","cliente_identificacion":"0905282836"},{"cliente_nombre":"ROSA MARGARTIA SUCOZ DURAZNO","cliente_identificacion":"0905282836"},{"cliente_nombre":"SEAMAR S.A.","cliente_identificacion":"0990713111001"},{"cliente_nombre":"SEAMAR S.A.","cliente_identificacion":"0990937818001"},{"cliente_nombre":"SICCO BELLINI NATALIA","cliente_identificacion":"0917130049001"},{"cliente_nombre":"SLEM S.A.","cliente_identificacion":"0992328029001"},{"cliente_nombre":"SOLORZANO BRUGOS MARIALENA ALEJANDRINA","cliente_identificacion":"1308285418"},{"cliente_nombre":"SOLORZANO MUÑOZ JOHANA ISABEL","cliente_identificacion":"1312941840"},{"cliente_nombre":"SONNIA ARACELY GUTIERREZ CASSAGNE","cliente_identificacion":"0901544882001"},{"cliente_nombre":"SUSANA AGUIRRE DE KONFLE","cliente_identificacion":"0914321682"},{"cliente_nombre":"TARABO VASQUEZ LESLIE ALEXANDRA","cliente_identificacion":"1307135523001"},{"cliente_nombre":"TECNOLOGICO EUROAMERICANO","cliente_identificacion":"0992410140001"},{"cliente_nombre":"VARGAS MERA YOLANDA FILOMENA","cliente_identificacion":"1310129158"},{"cliente_nombre":"VILLA TORRES KEVIN BRYAN","cliente_identificacion":"0950492843"}]; const facturasBase = []; const inputNombre = document.getElementById('cliente_nombre'); const inputIdentificacion = document.getElementById('cliente_identificacion'); const tipoComprobante = document.getElementById('tipo_comprobante'); const facturaBaseSelect = document.getElementById('factura_base_select'); function normalizarTexto(valor) { return (valor || '').toString().trim().toLowerCase(); } function buscarClientePorNombre(nombre) { const valor = normalizarTexto(nombre); return clientes.find(c => normalizarTexto(c.cliente_nombre) === valor); } function buscarClientePorIdentificacion(identificacion) { const valor = normalizarTexto(identificacion); return clientes.find(c => normalizarTexto(c.cliente_identificacion) === valor); } inputNombre.addEventListener('input', function () { const cliente = buscarClientePorNombre(this.value); if (cliente) { inputIdentificacion.value = cliente.cliente_identificacion; } }); inputIdentificacion.addEventListener('input', function () { const cliente = buscarClientePorIdentificacion(this.value); if (cliente) { inputNombre.value = cliente.cliente_nombre; } }); function verificarCliente() { let nombre = inputNombre.value.trim(); let identificacion = inputIdentificacion.value.trim(); let encontrado = false; if (nombre !== '') { const clientePorNombre = buscarClientePorNombre(nombre); if (clientePorNombre) { inputNombre.value = clientePorNombre.cliente_nombre; inputIdentificacion.value = clientePorNombre.cliente_identificacion; encontrado = true; } } if (!encontrado && identificacion !== '') { const clientePorId = buscarClientePorIdentificacion(identificacion); if (clientePorId) { inputNombre.value = clientePorId.cliente_nombre; inputIdentificacion.value = clientePorId.cliente_identificacion; encontrado = true; } } if (encontrado) { alert('Cliente encontrado correctamente.'); } else { alert('Cliente no encontrado. Puedes registrarlo con este comprobante.'); } } function limpiarCliente() { if (tipoComprobante.value === 'retencion') { return; } inputNombre.value = ''; inputIdentificacion.value = ''; } function agregarFila() { if (tipoComprobante.value === 'retencion') { return; } const tbody = document.querySelector("#tablaProductos tbody"); const fila = document.createElement("tr"); fila.innerHTML = ` `; tbody.appendChild(fila); calcularTotales(); } function calcularFila(input) { const fila = input.closest("tr"); const cantidad = parseFloat(fila.querySelector('input[name="cantidad[]"]').value) || 0; const precio = parseFloat(fila.querySelector('input[name="precio[]"]').value) || 0; const tarifa = parseFloat(fila.querySelector('select[name="tarifa_iva[]"]').value) || 0; const subtotalLinea = cantidad * precio; const valorIva = subtotalLinea * (tarifa / 100); const totalLinea = subtotalLinea + valorIva; fila.querySelector('input[name="subtotal_linea[]"]').value = subtotalLinea.toFixed(2); fila.querySelector('input[name="iva_linea[]"]').value = valorIva.toFixed(2); fila.querySelector('input[name="total_producto[]"]').value = totalLinea.toFixed(2); calcularTotales(); } function eliminarFila(boton) { const fila = boton.closest("tr"); fila.remove(); calcularTotales(); } function calcularTotales() { if (tipoComprobante.value === 'retencion') { return; } const filas = document.querySelectorAll("#tablaProductos tbody tr"); let subtotalBrutoGravado = 0; let subtotalBruto0 = 0; let subtotalBrutoGeneral = 0; filas.forEach(function(fila) { const cantidad = parseFloat(fila.querySelector('input[name="cantidad[]"]').value) || 0; const precio = parseFloat(fila.querySelector('input[name="precio[]"]').value) || 0; const tarifa = parseFloat(fila.querySelector('select[name="tarifa_iva[]"]').value) || 0; const subtotalLinea = cantidad * precio; if (tarifa === 0) { subtotalBruto0 += subtotalLinea; } else { subtotalBrutoGravado += subtotalLinea; } subtotalBrutoGeneral += subtotalLinea; }); let descuento = parseFloat(document.getElementById('descuento').value) || 0; if (descuento < 0) descuento = 0; if (descuento > subtotalBrutoGeneral) descuento = subtotalBrutoGeneral; document.getElementById('descuento').value = descuento.toFixed(2); let subtotalGravadoNeto = 0; let subtotal0Neto = 0; let totalIva = 0; let totalFinal = 0; let descuentoAsignado = 0; const totalFilas = filas.length; filas.forEach(function(fila, index) { const cantidad = parseFloat(fila.querySelector('input[name="cantidad[]"]').value) || 0; const precio = parseFloat(fila.querySelector('input[name="precio[]"]').value) || 0; const tarifa = parseFloat(fila.querySelector('select[name="tarifa_iva[]"]').value) || 0; const subtotalLineaBruto = cantidad * precio; let descuentoLinea = 0; if (subtotalBrutoGeneral > 0 && descuento > 0) { if (index < totalFilas - 1) { descuentoLinea = ((subtotalLineaBruto / subtotalBrutoGeneral) * descuento); descuentoLinea = parseFloat(descuentoLinea.toFixed(2)); descuentoAsignado += descuentoLinea; } else { descuentoLinea = parseFloat((descuento - descuentoAsignado).toFixed(2)); } } if (descuentoLinea < 0) descuentoLinea = 0; if (descuentoLinea > subtotalLineaBruto) descuentoLinea = subtotalLineaBruto; const baseLinea = subtotalLineaBruto - descuentoLinea; const valorIva = baseLinea * (tarifa / 100); const totalLinea = baseLinea + valorIva; fila.querySelector('input[name="subtotal_linea[]"]').value = baseLinea.toFixed(2); fila.querySelector('input[name="iva_linea[]"]').value = valorIva.toFixed(2); fila.querySelector('input[name="total_producto[]"]').value = totalLinea.toFixed(2); if (tarifa === 0) { subtotal0Neto += baseLinea; } else { subtotalGravadoNeto += baseLinea; } totalIva += valorIva; totalFinal += totalLinea; }); document.getElementById('subtotal_gravado').value = subtotalGravadoNeto.toFixed(2); document.getElementById('subtotal_0').value = subtotal0Neto.toFixed(2); document.getElementById('iva').value = totalIva.toFixed(2); document.getElementById('total').value = totalFinal.toFixed(2); }