--
-- Host: localhost    Database: nomina_app
-- ------------------------------------------------------


--
-- Table structure for table `auditoria`
--

CREATE TABLE `auditoria` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `usuario` varchar(60) NOT NULL,
  `accion` varchar(60) NOT NULL,
  `antes` text,
  `despues` text,
  `ts` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `auditoria`
--


--
-- Table structure for table `empleados`
--

CREATE TABLE `empleados` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombres` varchar(80) NOT NULL,
  `apellidos` varchar(80) NOT NULL,
  `doc_id` varchar(40) NOT NULL,
  `banco` varchar(60) DEFAULT '',
  `cuenta` varchar(60) DEFAULT '',
  `salario_usd` decimal(18,2) NOT NULL DEFAULT '0.00',
  `activo` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `empleados`
--

INSERT INTO `empleados` VALUES (1,'Peter','Abboud','19077705','bsnrsvo','4616161616',100.00,1),(2,'Romio','Abboud','561616','Baneco','65166161616165',50.00,1);

--
-- Table structure for table `nomina_detalles`
--

CREATE TABLE `nomina_detalles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nomina_id` int(11) NOT NULL,
  `empleado_id` int(11) NOT NULL,
  `bruto_usd` decimal(18,2) NOT NULL,
  `deducciones_usd` decimal(18,2) NOT NULL,
  `neto_usd` decimal(18,2) NOT NULL,
  `neto_bs` decimal(18,2) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `nomina_id` (`nomina_id`),
  KEY `empleado_id` (`empleado_id`),
  CONSTRAINT `nomina_detalles_ibfk_1` FOREIGN KEY (`nomina_id`) REFERENCES `nominas` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nomina_detalles_ibfk_2` FOREIGN KEY (`empleado_id`) REFERENCES `empleados` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `nomina_detalles`
--

INSERT INTO `nomina_detalles` VALUES (1,1,1,100.00,0.00,100.00,25000.00,'2025-10-16 17:02:09'),(2,1,2,50.00,0.00,50.00,12500.00,'2025-10-16 17:02:09');

--
-- Table structure for table `nominas`
--

CREATE TABLE `nominas` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `periodo` varchar(60) NOT NULL,
  `fx_bcv` decimal(18,6) NOT NULL,
  `estado` enum('abierta','cerrada') NOT NULL DEFAULT 'abierta',
  `creado_en` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `nominas`
--

INSERT INTO `nominas` VALUES (1,'2025-10',250.000000,'abierta','2025-10-16 17:02:09');

--
-- Table structure for table `pagos`
--

CREATE TABLE `pagos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `detalle_id` int(11) NOT NULL,
  `metodo` varchar(30) NOT NULL,
  `monto` decimal(18,2) NOT NULL,
  `moneda` enum('USD','Bs') NOT NULL,
  `referencia` varchar(120) DEFAULT '',
  `creado_en` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `detalle_id` (`detalle_id`),
  KEY `moneda` (`moneda`),
  CONSTRAINT `pagos_ibfk_1` FOREIGN KEY (`detalle_id`) REFERENCES `nomina_detalles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `pagos`
--


--
-- Table structure for table `tasas_cambio`
--

CREATE TABLE `tasas_cambio` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fuente` varchar(20) NOT NULL,
  `valor` decimal(18,6) NOT NULL,
  `fecha` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_fuente_fecha` (`fuente`,`fecha`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tasas_cambio`
--

INSERT INTO `tasas_cambio` VALUES (1,'BCV',250.000000,'2025-10-16 17:01:57');

--
-- Dumping events for database 'nomina_app'
--

--
-- Dumping routines for database 'nomina_app'
--


