| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- "use client"
- import { FacturaHeader } from "@/components/factura/FacturaHeader"
- import { InfoTributariaForm } from "@/components/factura/InfoTributariaForm"
- import { InfoFacturaForm } from "@/components/factura/InfoFacturaForm"
- import { DetallesList } from "@/components/factura/DetallesList"
- import { ResumenTotales } from "@/components/factura/ResumenTotales"
- import { FacturaActions } from "@/components/factura/FacturaActions"
- import { XmlViewer } from "@/components/factura/XmlViewer"
- import { useFacturaState } from "@/hooks/factura/useFacturaState"
- import { useFacturaCalculations } from "@/hooks/factura/useFacturaCalculations"
- import { useXmlGeneration } from "@/hooks/factura/useXmlGeneration"
- export default function FacturaPage() {
- const {
- infoTributaria,
- infoFactura,
- detalles,
- xmlGenerado,
- setXmlGenerado,
- handleInfoTributariaChange,
- handleInfoFacturaChange,
- agregarDetalle,
- actualizarDetalle,
- eliminarDetalle,
- updateInfoFactura
- } = useFacturaState()
- const { calcularTotalesImpuestos } = useFacturaCalculations(detalles, updateInfoFactura)
-
- const { generarXml, descargarXml } = useXmlGeneration()
- const handleGenerarXml = () => {
- const totalesImpuestos = calcularTotalesImpuestos()
- generarXml(
- infoTributaria,
- infoFactura,
- detalles,
- totalesImpuestos,
- setXmlGenerado
- )
- }
- const handleDescargarXml = () => {
- descargarXml(xmlGenerado, infoTributaria.ruc)
- }
- return (
- <div className="space-y-6">
- {/* Header */}
- <FacturaHeader />
- {/* Info Tributaria */}
- <InfoTributariaForm
- infoTributaria={infoTributaria}
- onChange={handleInfoTributariaChange}
- />
- {/* Info Factura */}
- <InfoFacturaForm
- infoFactura={infoFactura}
- onChange={handleInfoFacturaChange}
- />
- {/* Detalles */}
- <DetallesList
- detalles={detalles}
- onAgregarDetalle={agregarDetalle}
- onActualizarDetalle={actualizarDetalle}
- onEliminarDetalle={eliminarDetalle}
- />
- {/* Totales */}
- <ResumenTotales
- detalles={detalles}
- importeTotal={infoFactura.importeTotal}
- />
- {/* Acciones */}
- <FacturaActions
- onGenerarXml={handleGenerarXml}
- onDescargarXml={handleDescargarXml}
- xmlGenerado={xmlGenerado}
- />
- {/* XML Generado */}
- <XmlViewer xmlGenerado={xmlGenerado} />
- </div>
- )
- }
|