-- Adminer 4.1.0 MySQL dump

SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `cab_ctacte_pvee`;
CREATE TABLE `cab_ctacte_pvee` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `pvee_id` int(10) NOT NULL,
  `fecha_apertura` date NOT NULL,
  `fecha_baja` date DEFAULT NULL,
  `total_deuda` decimal(14,2) DEFAULT '0.00',
  `observacion` longtext,
  PRIMARY KEY (`id`,`pvee_id`),
  KEY `ctacte_pvee_id_ind` (`pvee_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `cab_documentos`;
CREATE TABLE `cab_documentos` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `tdm_id` int(3) NOT NULL,
  `com_id` int(10) NOT NULL,
  `dep_id` int(10) NOT NULL DEFAULT '1',
  `suc_id` int(10) NOT NULL,
  `cli_id` int(10) DEFAULT NULL,
  `pvee_id` int(10) DEFAULT NULL,
  `fecha_emision` date DEFAULT NULL,
  `fecha_recepcion` date DEFAULT NULL,
  `tp_doc_recep` varchar(3) DEFAULT NULL,
  `nro_doc_recep` int(10) DEFAULT NULL,
  `mpago_id` int(5) DEFAULT NULL,
  `observacion` longtext,
  `id_padre` int(10) NOT NULL,
  `subtotal` decimal(14,2) DEFAULT NULL,
  `Total` decimal(14,2) DEFAULT '0.00',
  `descuento` decimal(14,2) DEFAULT NULL,
  `total_neto` decimal(14,2) DEFAULT NULL,
  `iva` decimal(8,2) DEFAULT NULL,
  `iibb` decimal(8,2) DEFAULT NULL,
  `fecha_act_stock` date DEFAULT NULL,
  `fecha_ctacte` date DEFAULT NULL,
  PRIMARY KEY (`id`,`tdm_id`,`id_padre`,`com_id`,`dep_id`,`suc_id`),
  KEY `cab_doc_tdm_ind` (`tdm_id`),
  KEY `cab_doc_comer_ind` (`com_id`,`dep_id`,`suc_id`),
  KEY `cab_documentos_fk_depos` (`dep_id`),
  KEY `cab_documentos_fk_sucur` (`suc_id`),
  CONSTRAINT `cab_documentos_fk_comer` FOREIGN KEY (`com_id`) REFERENCES `sucursales` (`com_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `cab_documentos_fk_depos` FOREIGN KEY (`dep_id`) REFERENCES `sucursales` (`dep_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `cab_documentos_fk_suc` FOREIGN KEY (`suc_id`) REFERENCES `sucursales` (`id`),
  CONSTRAINT `cab_documentos_fk_tdm` FOREIGN KEY (`tdm_id`) REFERENCES `tipos_doc_mov` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `det_cta_cte_pvee`;
CREATE TABLE `det_cta_cte_pvee` (
  `cctepv_id` int(10) NOT NULL,
  `cdoc_id` int(10) NOT NULL,
  `fecha_vto` date NOT NULL,
  `debe` decimal(14,2) DEFAULT '0.00',
  `haber` decimal(14,2) DEFAULT '0.00',
  `saldo` decimal(14,2) DEFAULT '0.00',
  `fec_pago` date DEFAULT NULL,
  PRIMARY KEY (`cctepv_id`,`cdoc_id`),
  KEY `doc_cab_idx` (`cdoc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `det_documentos`;
CREATE TABLE `det_documentos` (
  `cdoc_id` int(10) NOT NULL,
  `tmd_id` int(3) NOT NULL DEFAULT '0',
  `n_item` int(10) NOT NULL AUTO_INCREMENT,
  `art_id` varchar(15) NOT NULL,
  `talle_id` int(5) NOT NULL,
  `codigo_material` int(10) NOT NULL DEFAULT '0',
  `mar_id` int(5) NOT NULL,
  `rbro_id` int(5) NOT NULL,
  `id_tp` int(5) NOT NULL,
  `cantidad` int(5) DEFAULT NULL,
  `precio` decimal(14,2) DEFAULT NULL,
  `subtotal` decimal(14,2) DEFAULT NULL,
  `iva` decimal(14,2) DEFAULT NULL,
  `porc_iva` decimal(14,2) DEFAULT NULL,
  `iibb` decimal(14,2) DEFAULT NULL,
  `porc_iibb` decimal(5,3) DEFAULT NULL,
  `total` decimal(14,2) DEFAULT NULL,
  PRIMARY KEY (`cdoc_id`,`tmd_id`,`n_item`),
  KEY `n_item` (`n_item`),
  KEY `art_id` (`art_id`),
  KEY `det_documentos_ibfk_1` (`talle_id`),
  KEY `fk_detart_doc` (`art_id`,`mar_id`,`rbro_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


DROP TABLE IF EXISTS `stock`;
CREATE TABLE `stock` (
  `art_id` varchar(15) NOT NULL,
  `estk_id` int(3) NOT NULL,
  `dep_id` int(5) NOT NULL,
  `suc_id` int(5) NOT NULL,
  `com_id` int(10) NOT NULL,
  `pvee_id` int(10) NOT NULL,
  `talle_id` int(5) NOT NULL,
  `cantidad` int(10) NOT NULL,
  `mar_id` int(5) NOT NULL,
  `rbro_id` int(5) NOT NULL,
  `codigo_material` int(10) NOT NULL,
  `id_tp` int(5) NOT NULL,
  PRIMARY KEY (`mar_id`,`rbro_id`,`art_id`,`estk_id`,`dep_id`,`suc_id`,`com_id`,`pvee_id`,`talle_id`),
  KEY `stock_comer_ind` (`com_id`),
  KEY `estk_id` (`estk_id`),
  KEY `stock_ibfk_4` (`dep_id`),
  KEY `stock_ibfk_5` (`suc_id`),
  KEY `pvee_id` (`pvee_id`),
  KEY `stock_talle_id` (`talle_id`),
  KEY `fk_det_art_stk` (`art_id`,`mar_id`,`rbro_id`),
  KEY `codigo_material` (`codigo_material`),
  CONSTRAINT `stock_ibfk_1` FOREIGN KEY (`codigo_material`) REFERENCES `materiales` (`codigo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


-- 2018-04-27 21:30:36
