-- https://www.phpmyadmin.net/
--
-- Servidor: localhost:3306
-- Tiempo de generación: 25-09-2024 a las 17:11:16
-- Versión del servidor: 8.0.39
-- Versión de PHP: 8.3.11

START TRANSACTION;



-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `documents`
--

CREATE TABLE `documents` (
  `id` bigint NOT NULL,
  `customerid` bigint NOT NULL,
  `docdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `docnumber` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `doccontrol` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `doctype` int NOT NULL DEFAULT '1' COMMENT '1=FACTURA',
  `base` double NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT '0',
  `pagado` double NOT NULL DEFAULT '0',
  `errlvl` int DEFAULT NULL,
  `errdsc` varchar(4096) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Volcado de datos para la tabla `documents`
--

INSERT INTO `documents` (`id`, `customerid`, `docdate`, `docnumber`, `doccontrol`, `doctype`, `base`, `total`, `pagado`, `errlvl`, `errdsc`) VALUES
(169, 1097, '2019-07-24 00:00:00', '07-0012', '01-00000003', 1, 9542135, 11068876.6, 10591769.85, 0, ''),
(170, 1097, '2019-08-21 00:00:00', '07-0013', '00-00000045', 1, 7000, 8120, 6930, 0, ''),
(171, 1097, '2019-08-26 00:00:00', '23422', '08-00000012', 1, 7000, 8120, 6930, 0, ''),
(172, 1096, '2019-10-16 04:00:00', '98989898', '00-98989898', 1, 1763120.62, 2045219.92, 211574.48, 1, ' No se seleccionó ningún archivo como comprobante de retención del IVA.| Monto pagado menos lo retenido, no concuerda con el total de la factura. 1622070.96|'),
(173, 410, '2019-11-16 04:00:00', '14882459', '00-15941446', 1, 36086288.47, 41860094.63, 36808014.24, 0, '');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `retislr`
--

CREATE TABLE `retislr` (
  `id` bigint NOT NULL,
  `documentid` bigint NOT NULL,
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `islrdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `islrnumber` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `pdf` varchar(2048) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `repdate` timestamp NULL DEFAULT NULL,
  `status` int NOT NULL COMMENT '0=Nuevo,1=Revisado,2=Rechazado',
  `obs` varchar(2048) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Volcado de datos para la tabla `retislr`
--

INSERT INTO `retislr` (`id`, `documentid`, `amount`, `islrdate`, `islrnumber`, `pdf`, `repdate`, `status`, `obs`) VALUES
(3, 169, 477106.75, '2019-08-26 12:40:46', '07-00000231', '/data/customer/islr/169.pdf', '2019-08-30 08:40:00', 1, ''),
(6, 170, 350.00, '2019-08-26 12:40:46', '20190000012', '/data/customer/islr/170.pdf', '2019-08-30 08:40:00', 1, ''),
(10, 171, 350.00, '2019-08-26 12:40:46', '201907000012', '/data/customer/islr/171.pdf', '2019-08-30 08:40:00', 1, ''),
(14, 173, 721725.77, '2019-11-16 04:00:00', '000000001', '/data/customer/islr/173.pdf', NULL, 0, '');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `retiva`
--

CREATE TABLE `retiva` (
  `id` bigint NOT NULL,
  `documentid` bigint NOT NULL,
  `ivadate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `ivanumber` varchar(40) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `pdf` varchar(2048) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `status` int NOT NULL DEFAULT '0' COMMENT '0=Nuevo,1=Revisado,2=Rechazado',
  `obs` varchar(2048) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL,
  `repdate` timestamp NULL DEFAULT NULL,
  `amount` double NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

--
-- Volcado de datos para la tabla `retiva`
--

INSERT INTO `retiva` (`id`, `documentid`, `ivadate`, `ivanumber`, `pdf`, `status`, `obs`, `repdate`, `amount`) VALUES
(3, 170, '2019-08-26 12:40:46', '201908000012', '/data/customer/iva/170.pdf', 1, '', '2019-08-30 08:40:00', 840),
(7, 171, '2019-08-26 12:40:46', '201908000013', '/data/customer/iva/171.pdf', 1, '', '2019-08-30 08:40:00', 840),
(12, 172, '2019-10-16 04:00:00', '20191000000001', '', 0, '', NULL, 211574.48),
(16, 173, '2019-11-16 04:00:00', '20191100000001', '/data/customer/iva/173.pdf', 0, '', NULL, 4330354.62);

--
-- Indices de la tabla `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customerid` (`customerid`),
  ADD KEY `doccontrol` (`doccontrol`),
  ADD KEY `doccontrol_2` (`doccontrol`),
  ADD KEY `doccontrol_3` (`doccontrol`);

--
-- Indices de la tabla `retislr`
--
ALTER TABLE `retislr`
  ADD PRIMARY KEY (`id`),
  ADD KEY `documentid` (`documentid`);

--
-- Indices de la tabla `retiva`
--
ALTER TABLE `retiva`
  ADD PRIMARY KEY (`id`),
  ADD KEY `documentid` (`documentid`),
  ADD KEY `documentid_2` (`documentid`);

--
-- AUTO_INCREMENT de la tabla `documents`
--
ALTER TABLE `documents`
  MODIFY `id` bigint NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=174;

--
-- AUTO_INCREMENT de la tabla `retislr`
--
ALTER TABLE `retislr`
  MODIFY `id` bigint NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT de la tabla `retiva`
--
ALTER TABLE `retiva`
  MODIFY `id` bigint NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `doc_cust` FOREIGN KEY (`customerid`) REFERENCES `customers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Filtros para la tabla `retislr`
--
ALTER TABLE `retislr`
  ADD CONSTRAINT `islr_doc` FOREIGN KEY (`documentid`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Filtros para la tabla `retiva`
--
ALTER TABLE `retiva`
  ADD CONSTRAINT `iva_doc` FOREIGN KEY (`documentid`) REFERENCES `documents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

