INSERT INTO `itensnfs` VALUES ('1',199189,'V',0.0000,'T ','00','FAT',277,'011609',200,0.0791,15.8200,0.0378,0.0378,0.0520,0.0520,'5102','VENDA NORMAL NO ESTADO',0.2600,1.2000,0.0000,12.0000,1.8984,1.8984,0.0000,0.0000,0.0000,0.0000,0.0000,'0201004','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','TOUCA DESC BRANCA SANFONADA C/100',1),('1',199189,'V',0.0000,'XP','60','FAT',282,'15128993',4000,0.1882,752.8000,0.1419,0.1170,0.1339,0.1339,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,90.3360,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','BIPERIDENO 2MG CX.C/200 COMP CINETOL(*C-1',1),('1',199189,'V',0.0000,'XP','60','FAT',288,'16010314',50,1.3800,69.0000,1.1353,1.1353,1.0710,1.0710,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,8.2800,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','FENOBARBITAL 200MG 2ML IM/IV CX/50 AMP',1),('1',199189,'V',0.0000,'XP','60','FAT',298,'16032085',600,0.7000,420.0000,0.5203,0.5131,0.4909,0.4909,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,50.4000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','LEVOMEPROMAZINA 100MG (*C-1) C/200 COMP',1),('1',199189,'V',0.0000,'ZP','60','FAT',311,'16020927',150,1.0400,156.0000,0.8609,0.8609,0.8122,0.8122,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,28.0800,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0204','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','HALOPERIDOL 5MG CX/50 AMP. 1ML.*(C-1)',1),('1',199189,'V',0.0000,'XP','60','FAT',325,'15096860',1600,0.1820,291.2000,0.1372,0.1372,0.1294,0.1294,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,34.9440,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','CLORPROMAZINA 100 MG CX/200 COMP *(C1)',1),('1',199189,'V',0.0000,'XP','60','FAT',325,'15096861',3400,0.1820,618.8000,0.1372,0.1372,0.1294,0.1294,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,74.2560,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','CLORPROMAZINA 100 MG CX/200 COMP *(C1)',1),('1',199189,'V',0.0000,'XP','60','FAT',327,'15129271',600,0.2600,156.0000,0.1703,0.1703,0.1607,0.1607,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,18.7200,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','IMIPRAMINA 25 MG CX/200 CPRS. *(C-1)',1),('1',199189,'V',0.0000,'XP','60','FAT',392,'1603462',10000,0.0985,985.0000,0.0742,0.0743,0.0700,0.0700,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,118.2000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0204','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','HALOPERIDOL 5MG CX/200 COMP. *(C-1)UNI HA',1),('1',199189,'V',0.0000,'XP','60','FAT',506,'30401416',2000,0.0424,84.8000,0.0272,0.0265,0.0250,0.0250,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,10.1760,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','DIAZEPAM 10 MG CX/1000 COMP *(B-1)',1),('1',199189,'V',0.0000,'XP','60','FAT',669,'16021002',50,3.9300,196.5000,3.2639,3.2525,3.0791,3.1238,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,23.5800,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','FLUFENAN DEPOT 25MG/ML C/50 AM P.1ML *(C1)',1),('1',199189,'V',0.0000,'D ','60','FAT',712,'144341541',72,0.6500,46.8000,0.2784,0.2784,0.3001,0.3001,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.7700,3.5500,0.0000,18.0000,8.4240,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201002','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','ATAD.CREP.10CM X 4,5M 13 FIOS AMERICA',1),('1',199189,'V',0.0000,'D ','60','FAT',713,'947J',200,0.1401,28.0200,0.1166,0.1113,0.1050,0.1050,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,5.0436,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201001','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','SERINGA DESC. 3ML C/AG 25 X 7 L.S C/500',1),('1',199189,'V',0.0000,'XP','60','FAT',734,'AT942',500,0.1014,50.7000,0.0650,0.0636,0.0600,0.0600,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,6.0840,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202001','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','SULFA+TRIM 400MG+80MG CX.C/500 BACTRISAN',1),('1',199189,'V',0.0000,'XN','60','FAT',895,'160477',500,0.1323,66.1500,0.0848,0.0712,0.0672,0.0672,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,7.9380,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','DIPIRONA 500MG CX/500 COMP.',1),('1',199189,'V',0.0000,'YP','60','FAT',1965,'3122810',3000,0.0796,238.8000,0.0600,0.0530,0.0500,0.0500,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,42.9840,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0203','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','CARBAMAZEPINA 200 MG CX/500 G COMP *(C-1)',1),('1',199189,'V',0.0000,'YP','60','FAT',2038,'2245022',500,0.1097,54.8500,0.0703,0.0712,0.0650,0.0650,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,9.8730,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0203','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','FENOBARBITAL 100 MG CX.C/100 (GEN)*(B-1)',1),('1',199189,'V',0.0000,'D ','60','FAT',2526,'102010',200,0.3700,74.0000,0.2648,0.2339,0.2495,0.2495,'5403','VENDA SUBS. TRIBT. NO ESTADO',1.2200,5.6200,0.0000,18.0000,13.3200,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201002','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','ABSOR. HOSPIT. TAM. UNICO PCT/ 20 UND',1),('1',199189,'V',0.0000,'PH','00','FAT',3770,'SDLTCG017M',1000,0.1700,170.0000,0.1225,0.1116,0.1162,0.1162,'5102','VENDA NORMAL NO ESTADO',0.0000,0.0000,0.0000,18.0000,30.6000,30.6000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201003','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','LUVA PROC.N/EST.TAM \"M\" CX/100 UND',1),('1',199189,'V',0.0000,'YP','60','FAT',4427,'0274/16',3000,0.1687,506.1000,0.1272,0.1238,0.1200,0.1200,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,91.0980,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0203','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','CARBONATO LITIO 300 MG *(C1) G CX/500 COMP',1),('1',199189,'V',0.0000,'XN','60','FAT',6577,'1430263',300,0.1654,49.6200,0.1060,0.1060,0.1000,0.1000,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,12.0000,5.9544,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','BISACODIL 5MG CX/150 CPRS BISALAX',1),('1',199189,'V',0.0000,'D ','60','FAT',6621,'1677',4,8.1400,32.5600,5.7953,5.7953,5.9900,5.9900,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.5300,2.4700,0.0000,18.0000,5.8608,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201002','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','ALGODÃO HIDROFILO 500 GR',1),('1',199189,'V',0.0000,'D ','60','FAT',6865,'1094J',200,0.1592,31.8400,0.1325,0.1278,0.1250,0.1250,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,5.7312,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0201001','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','SERINGA DESC. 5ML C/AG 25 X 7 L.SLIP C/500',1),('1',199189,'V',0.0000,'PI','60','FAT',6936,'106351C',600,0.4230,253.8000,0.3000,0.2264,0.2135,0.2135,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,4.0000,10.1520,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202001','2016-06-08',12781,'SANATÓRIO PSIQUIÁTRICO DE RECUPERAÇÃO LTDA',2852,'VALERYA CABRAL',2850,'VALERYA.CABRAL','PE','CEFALEXINA 500 MG C/200 CAP KEFORAL',1),('1',199190,'V',0.0000,'XN','60','FAT',380,'15C982',1,8.5500,8.5500,5.4802,5.4802,5.1700,5.1700,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,1.5390,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',17393,'MARCIO MACHADO DE FARIAS',999,'DROGAFONTE',2798,'CLEYBSON.JUNIO','PE','NITROFURAZONA 2MG/G POM PT 500G',1),('1',199190,'V',0.0000,'XN','60','FAT',895,'151131',20,0.1325,2.6500,0.0848,0.0712,0.0672,0.0672,'5403','VENDA SUBS. TRIBT. NO ESTADO',0.0000,0.0000,0.0000,18.0000,0.4770,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',17393,'MARCIO MACHADO DE FARIAS',999,'DROGAFONTE',2798,'CLEYBSON.JUNIO','PE','DIPIRONA 500MG CX/500 COMP.',1),('1',199191,'O',0.0000,'XP','60','SBN',3482,'1002006',15,0.2600,3.9000,0.1908,0.1211,0.1143,0.1143,'6910','REMESSA EM BONIFIC DOAÇAO OU BRINDE',0.0000,0.0000,0.0000,18.0000,0.7020,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0202','2016-06-08',19682,'FUNDO MUNICIPAL DE SAÚDE DE MOGEIRO',999,'DROGAFONTE',2829,'MARIA.CECILIA','PB','NORETISTERONA 0,35MG CX.C/35 NORESTIN',1),('1',199191,'O',0.0000,'PI','60','SBN',5517,'16D60H',10,0.0600,0.6000,0.0329,0.0318,0.0300,0.0300,'6910','REMESSA EM BONIFIC DOAÇAO OU BRINDE',0.0000,0.0000,0.0000,4.0000,0.0240,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0203','2016-06-08',19682,'FUNDO MUNICIPAL DE SAÚDE DE MOGEIRO',999,'DROGAFONTE',2829,'MARIA.CECILIA','PB','OMEPRAZOL 20MG GEN CX.C/560 CAP',1),('1',199191,'O',0.0000,'YP','60','SBN',6130,'1604314',5,0.0600,0.3000,0.0318,0.0318,0.0300,0.0300,'6910','REMESSA EM BONIFIC DOAÇAO OU BRINDE',0.0000,0.0000,0.0000,18.0000,0.0540,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0109','2016-06-08',19682,'FUNDO MUNICIPAL DE SAÚDE DE MOGEIRO',999,'DROGAFONTE',2829,'MARIA.CECILIA','PB','LOSARTANA POTASSICO 50MG C/450 GEN',1),('1',199193,'V',0.0000,'ZP','60','PP',5780,'772592',600,0.3400,204.0000,0.3023,0.3023,0.2963,0.2963,'6403','VENDA SUBS. TRIBT. FORA DO ESTADO',0.0000,0.0000,0.0000,18.0000,36.7200,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0204','2016-06-08',18097,'FUNDO M. DE SAÚDE DE SANTO ANTÔNIO DE JESUS',1346,'DANI CAL COMERC',2736,'EUGENIA.CABRAL','BA','ISOSSORBIDA 5MG SL CX/30 CPRS ISORDIL',1),('1',199193,'V',0.0000,'XP','60','PP',6014,'1002666',1200,0.5100,612.0000,0.3604,0.3074,0.2900,0.2900,'6403','VENDA SUBS. TRIBT. FORA DO ESTADO',0.0000,0.0000,0.0000,18.0000,110.1600,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0109','2016-06-08',18097,'FUNDO M. DE SAÚDE DE SANTO ANTÔNIO DE JESUS',1346,'DANI CAL COMERC',2736,'EUGENIA.CABRAL','BA','CIPROFIBRATO 100MG C/60 CPR LIPLESS',1),('1',199194,'V',0.0000,'GP','60','FAT',882,'106217C',168,8.9800,1508.6400,7.4770,7.4770,7.0538,7.0538,'6108','VENDA CONSUMIDOR FINAL FORA ESTADO',0.0000,0.0000,0.0000,18.0000,271.5552,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,'0203','2016-06-08',12877,'SOCIEDADE ANÔNIMA HOSPITAL ALIANÇA',2899,'ADRIANA.DOMINGO',2898,'ADRIANA.DOMINGO','BA','CEFEPIMA 2 GR F/A S/DIL. GENER C/1 F/A',1);

--
-- Table structure for table `motivoprocedimento`
--

CREATE TABLE `motivoprocedimento` (
  `idmotivoProcedimento` int(11) NOT NULL AUTO_INCREMENT,
  `descMotivo` varchar(45) NOT NULL,
  `tipoDeProdecimento` varchar(4) NOT NULL COMMENT 'PCTD= PROCEDIMENTO DE DEVOLUÇÃO DE MERCADORIA\nPCTS= PROCEDIMENTO DE SUBSTITUIÇÃO DE NF-E',
  `status` varchar(45) NOT NULL DEFAULT 'A',
  `dataCadastro` datetime NOT NULL,
  PRIMARY KEY (`idmotivoProcedimento`),
  KEY `tipoDeProdecimento_idx` (`tipoDeProdecimento`),
  CONSTRAINT `tipoDeProdecimento` FOREIGN KEY (`tipoDeProdecimento`) REFERENCES `tipoprocedimento` (`idtipoProcedimento`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `motivoprocedimento`
--

INSERT INTO `motivoprocedimento` VALUES (1,'Devolução por Avaria','PCTD','A','2016-06-07 00:00:00'),(2,'Devolução por Validade','PCTD','A','2016-06-07 00:00:00'),(3,'(Dev.)  Por Produto diferente do solicitado','PCTD','A','2016-06-07 00:00:00'),(4,'Devolução por Duplicidade','PCTD','A','2016-06-07 00:00:00'),(5,'(Dev.) Por Quantidade divergente do pedido','PCTD','A','2016-06-07 00:00:00'),(6,'Desmembramento de NF','PCTS','A','2016-06-07 00:00:00'),(7,'Empenhar','PCTS','A','2016-06-07 00:00:00'),(8,'Correção de Enderço','PCTS','A','2016-06-07 00:00:00'),(9,'Correção de Razão Social/CNPJ','PCTS','A','2016-06-07 00:00:00'),(10,'Correção de Informações complementares','PCTS','A','2016-06-07 00:00:00'),(11,'(Dev.)  Desvio de Qualidade','PCTD','A','2016-06-07 00:00:00'),(12,'(Dev.)  Empenho não Solicitado','PCTD','A','2016-06-07 00:00:00'),(13,'Correção de Desc/Valor Produto','PCTS','A','2016-06-07 00:00:00'),(14,'Correção de Descrição de Produto','PCTS','A','2016-06-07 00:00:00'),(15,'Correção do Valor Produto','PCTS','A','2016-06-07 00:00:00'),(16,'Feriado Local','PCTS','A','2016-06-07 00:00:00'),(17,'(Dev.)  Por Falta de Documentação Exigida','PCTD','A','2016-06-07 00:00:00'),(18,'(Dev.)  Por Quantidade sem Saldo','PCTD','A','2016-06-07 00:00:00'),(19,'(Dev.) Produto Licitado Errado','PCTD','A','2016-06-07 00:00:00'),(20,'Produto Diponibilizado para Outro Cliente','PCTD','A','2016-06-07 00:00:00'),(21,'Produto Faltante','PCTC','A','2016-06-07 00:00:00'),(22,'Permuta','PCTO','A','2016-06-07 00:00:00'),(23,'Valor da NF Menor que o Valor do Frete','PCTD','A','2016-06-07 00:00:00'),(24,'Término de vigência de Contrato','PCTD','A','2016-06-07 00:00:00'),(25,'Local de Entrega Errado','PCTD','A','2016-06-07 00:00:00'),(26,'Empenho Cancelado','PCTD','A','2016-06-07 00:00:00'),(27,'Extravio de Mercadoria','PCTO','A','2016-06-07 00:00:00'),(28,'Reenvio da Mercadoria','PCTS','A','2016-06-07 00:00:00'),(29,'(Dev.) Mercadoria para o Cliente Errado','PCTD','A','2016-06-07 00:00:00'),(30,'(Dev.) Atraso na Entrega','PCTD','A','2016-06-07 00:00:00'),(31,'(Dev.) Emprestimo','PCTD','A','2016-06-07 00:00:00'),(32,'(Dev.) Cliente desistiu da Compra','PCTD','A','2016-06-07 00:00:00'),(33,'(Dev.) Lote do produto divergente da NF','PCTD','A','2016-06-07 00:00:00'),(34,'Erro no CST','PCTS','A','2016-06-07 00:00:00'),(35,'(Dev.) Pedido em desacordo','PCTD','A','2016-06-07 00:00:00'),(36,'Cliente não aceita NF-e para entrega futura','PCTS','A','2016-06-07 00:00:00'),(37,'Unificar Nota Fiscais','PCTS','A','2016-06-07 00:00:00'),(38,'Emprestimo','PCTO','A','2016-06-07 00:00:00'),(39,'SOLIC. DESCONTO','PCTO','A','2016-06-07 00:00:00');

--
-- Table structure for table `procedimento`
--

CREATE TABLE `procedimento` (
  `idprocedimento` int(11) NOT NULL AUTO_INCREMENT,
  `tipoProcedimento` varchar(4) NOT NULL,
  `usuario` varchar(45) NOT NULL,
  `dataImpressao` datetime DEFAULT NULL,
  `cod_cliente` int(11) NOT NULL,
  `razao_social` varchar(100) NOT NULL,
  `uf` varchar(2) NOT NULL,
  `ser_nfOrigem` varchar(5) NOT NULL,
  `nf_origem` int(11) NOT NULL,
  `dat_emissao` datetime DEFAULT NULL,
  `vlrTotalNota` decimal(18,4) NOT NULL,
  `digitador` varchar(60) DEFAULT NULL,
  `digEmpenho` varchar(60) DEFAULT NULL,
  `numTicketSac` int(11) DEFAULT NULL,
  `motivoDev` varchar(100) DEFAULT NULL,
  `descMotivoDev` varchar(500) DEFAULT NULL,
  `dataBaixa` datetime DEFAULT NULL,
  `parecerBaixa` varchar(500) DEFAULT NULL,
  `status` varchar(3) NOT NULL DEFAULT 'A',
  PRIMARY KEY (`idprocedimento`),
  KEY `tipoProced_idx` (`tipoProcedimento`),
  CONSTRAINT `tipoProced` FOREIGN KEY (`tipoProcedimento`) REFERENCES `tipoprocedimento` (`idtipoProcedimento`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `procedimento`
--


--
-- Table structure for table `tipoprocedimento`
--

CREATE TABLE `tipoprocedimento` (
  `idtipoProcedimento` varchar(4) NOT NULL,
  `descProcedimento` varchar(100) NOT NULL,
  `status` varchar(3) DEFAULT 'A',
  PRIMARY KEY (`idtipoProcedimento`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tipoprocedimento`
--

INSERT INTO `tipoprocedimento` VALUES ('PCTC','PROCEDIMENTO DE NF-E COMPLEMENTAR DE MARCADORIA FALTANTE','A'),('PCTD','PROCEDIMENTO DE DEVOLUÇÃO DE MERCADORIA','A'),('PCTO','PROCEDIMENTO DE NF-E OUTROS','A'),('PCTS','PROCEDIMENTO DE SUBSTITUIÇÃO DE NF-E','A'),('PCTT','PROCEDIMENTO DE OCORRENCIA DE TRANSPORTE','A');

--
-- Temporary view structure for view `view_compramensal`
--

/*!50001 DROP VIEW IF EXISTS `view_compramensal`*/;
/*!50001 CREATE VIEW `view_compramensal` AS SELECT 
 1 AS `ano`,
 1 AS `devJan`,
 1 AS `devFev`,
 1 AS `devMar`,
 1 AS `devAbr`,
 1 AS `devMai`,
 1 AS `devJun`,
 1 AS `devJul`,
 1 AS `devAgo`,
 1 AS `devSet`,
 1 AS `devOut`,
 1 AS `devNov`,
 1 AS `devDez`*/;

--
-- Temporary view structure for view `view_compramensalano`
--

/*!50001 DROP VIEW IF EXISTS `view_compramensalano`*/;
/*!50001 CREATE VIEW `view_compramensalano` AS SELECT 
 1 AS `ano`,
 1 AS `compJan`,
 1 AS `compFev`,
 1 AS `compMar`,
 1 AS `compAbr`,
 1 AS `compMai`,
 1 AS `compJun`,
 1 AS `compJul`,
 1 AS `compAgo`,
 1 AS `compSet`,
 1 AS `compOut`,
 1 AS `compNov`,
 1 AS `compDez`*/;

--
-- Temporary view structure for view `view_compraporlabano`
--

/*!50001 DROP VIEW IF EXISTS `view_compraporlabano`*/;
/*!50001 CREATE VIEW `view_compraporlabano` AS SELECT 
 1 AS `idLabAno`,
 1 AS `Cod_Emitente`,
 1 AS `Razao_Social`,
 1 AS `qtdNotas`,
 1 AS `qtdUnidades`,
 1 AS `vlrTotalCompras`,
 1 AS `ano`*/;

--
-- Temporary view structure for view `view_comprasxdevporstentrada`
--

/*!50001 DROP VIEW IF EXISTS `view_comprasxdevporstentrada`*/;
/*!50001 CREATE VIEW `view_comprasxdevporstentrada` AS SELECT 
 1 AS `idCompraMesAnoProdu`,
 1 AS `ano`,
 1 AS `mes`,
 1 AS `Alq_IcmDeb`,
 1 AS `qtdNotas`,
 1 AS `qtd_NotaDev`,
 1 AS `Qtd_Pedido`,
 1 AS `Qtd_ProdutoDev`,
 1 AS `Vlr_TotItemCompras`,
 1 AS `Vlr_TotItemComprasDev`,
 1 AS `Cus_LiqUni`,
 1 AS `Prc_CustoMedio`,
 1 AS `Vlr_CusMedioGerencDev`,
 1 AS `Vlr_IcmsNor`,
 1 AS `Vlr_IcmsDev`,
 1 AS `Vlr_IcmsTrib`,
 1 AS `Vlr_IcmsTriDev`,
 1 AS `Vlr_DifTri`,
 1 AS `vlr_RessarST`*/;

--
-- Temporary view structure for view `view_devcompramesanoprodu`
--

/*!50001 DROP VIEW IF EXISTS `view_devcompramesanoprodu`*/;
/*!50001 CREATE VIEW `view_devcompramesanoprodu` AS SELECT 
 1 AS `idDevCompraMesAnoProdu`,
 1 AS `mes`,
 1 AS `ano`,
 1 AS `Alq_DebSbtEnt`,
 1 AS `qtd_Nota`,
 1 AS `Qtd_Produto`,
 1 AS `Vlr_LiqItem`,
 1 AS `Vlr_CusIte_NF`,
 1 AS `Vlr_CusMedioGerenc`,
 1 AS `Vlr_Icms`,
 1 AS `Vlr_IcmsTri`,
 1 AS `vlr_RessarST`*/;

--
-- Temporary view structure for view `view_devfatmensal`
--

/*!50001 DROP VIEW IF EXISTS `view_devfatmensal`*/;
/*!50001 CREATE VIEW `view_devfatmensal` AS SELECT 
 1 AS `ano`,
 1 AS `DevJan`,
 1 AS `DevFev`,
 1 AS `DevMar`,
 1 AS `DevAbr`,
 1 AS `DevMai`,
 1 AS `DevJun`,
 1 AS `DevJul`,
 1 AS `DevAgo`,
 1 AS `DevSet`,
 1 AS `DevOut`,
 1 AS `DevNov`,
 1 AS `DevDez`*/;

--
-- Temporary view structure for view `view_itenssaida`
--

/*!50001 DROP VIEW IF EXISTS `view_itenssaida`*/;
/*!50001 CREATE VIEW `view_itenssaida` AS SELECT 
 1 AS `idLinhaItem`,
 1 AS `ser_Nota`,
 1 AS `Num_Nota`,
 1 AS `tip_saida`,
 1 AS `Cod_Produto`,
 1 AS `Cod_Lote`,
 1 AS `Qtd_Produto`,
 1 AS `Prc_Unitario`,
 1 AS `Vlr_LiqItem`,
 1 AS `Vlr_CusIte_NF`,
 1 AS `Vlr_CusMedioGerenc`,
 1 AS `Prc_UltEnt`,
 1 AS `PrcUltimaEntrada`,
 1 AS `Cod_Cfop`,
 1 AS `DescCfop`,
 1 AS `Vlr_Pis`,
 1 AS `Vlr_Cofins`,
 1 AS `Vlr_IPI`,
 1 AS `Alq_Icms`,
 1 AS `Vlr_Icms`,
 1 AS `Vlr_IcmsTri`,
 1 AS `Vlr_SubsTrib`,
 1 AS `Vlr_RepIcms`,
 1 AS `Vlr_IcmFcpUfDes`,
 1 AS `Vlr_IcmIntUfDes`,
 1 AS `Vlr_IcmIntUfRem`,
 1 AS `Cod_Classif`,
 1 AS `Dat_Emissao`,
 1 AS `Cod_Clien`,
 1 AS `Razao_Social`,
 1 AS `Cod_Vendedor`,
 1 AS `Nome_Guerra`,
 1 AS `UF`,
 1 AS `Desc_Prod`,
 1 AS `Flg_MovEst`*/;

--
-- Temporary view structure for view `view_stcompraspormesano`
--

/*!50001 DROP VIEW IF EXISTS `view_stcompraspormesano`*/;
/*!50001 CREATE VIEW `view_stcompraspormesano` AS SELECT 
 1 AS `idCompraMesAnoProdu`,
 1 AS `mes`,
 1 AS `ano`,
 1 AS `Alq_IcmDeb`,
 1 AS `qtdNotas`,
 1 AS `Qtd_Pedido`,
 1 AS `Vlr_LiqIte`,
 1 AS `Cus_LiqUni`,
 1 AS `Prc_CustoMedio`,
 1 AS `Vlr_IcmsNor`,
 1 AS `Vlr_IcmsTrib`,
 1 AS `Vlr_DifTri`,
 1 AS `Vlr_TotItem`*/;

--
-- Temporary view structure for view `view_vendalinhamedicamentoporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendalinhamedicamentoporano`*/;
/*!50001 CREATE VIEW `view_vendalinhamedicamentoporano` AS SELECT 
 1 AS `idVendLinhaMaterial`,
 1 AS `Cod_Produto`,
 1 AS `Desc_Prod`,
 1 AS `Unidades`,
 1 AS `Vlr_total`,
 1 AS `PrcUltimaEntrada`,
 1 AS `ano`*/;

--
-- Temporary view structure for view `view_vendamaterialxdevporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamaterialxdevporano`*/;
/*!50001 CREATE VIEW `view_vendamaterialxdevporano` AS SELECT 
 1 AS `idVendLinhaMaterial`,
 1 AS `Cod_Produto`,
 1 AS `Desc_Prod`,
 1 AS `Unidades`,
 1 AS `qtdTotalDev`,
 1 AS `qtdUndComDev`,
 1 AS `Vlr_total`,
 1 AS `vlrTotalDev`,
 1 AS `vlrVendaComDev`,
 1 AS `PrcUltimaEntrada`,
 1 AS `rentabilidade`,
 1 AS `ano`*/;

--
-- Temporary view structure for view `view_vendamedicamentosxdevporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamedicamentosxdevporano`*/;
/*!50001 CREATE VIEW `view_vendamedicamentosxdevporano` AS SELECT 
 1 AS `idVendLinhaMaterial`,
 1 AS `Cod_Produto`,
 1 AS `Desc_Prod`,
 1 AS `Unidades`,
 1 AS `qtdTotalDev`,
 1 AS `qtdUndComDev`,
 1 AS `Vlr_total`,
 1 AS `vlrTotalDev`,
 1 AS `vlrVendaComDev`,
 1 AS `PrcUltimaEntrada`,
 1 AS `rentabilidade`,
 1 AS `ano`*/;

--
-- Temporary view structure for view `view_vendamensal`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamensal`*/;
/*!50001 CREATE VIEW `view_vendamensal` AS SELECT 
 1 AS `ano`,
 1 AS `fatJan`,
 1 AS `fatFev`,
 1 AS `fatMar`,
 1 AS `fatAbr`,
 1 AS `fatMai`,
 1 AS `fatJun`,
 1 AS `fatJul`,
 1 AS `fatAgo`,
 1 AS `fatSet`,
 1 AS `fatOut`,
 1 AS `fatNov`,
 1 AS `fatDez`*/;

--
-- Temporary view structure for view `view_vendprincprodulinhadescartporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendprincprodulinhadescartporano`*/;
/*!50001 CREATE VIEW `view_vendprincprodulinhadescartporano` AS SELECT 
 1 AS `idVendLinhaMaterial`,
 1 AS `Cod_Produto`,
 1 AS `Desc_Prod`,
 1 AS `Unidades`,
 1 AS `Vlr_total`,
 1 AS `PrcUltimaEntrada`,
 1 AS `rentabilidade`,
 1 AS `ano`*/;

--
-- Temporary view structure for view `view_vendprincprodulinhadescartpormesano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendprincprodulinhadescartpormesano`*/;
/*!50001 CREATE VIEW `view_vendprincprodulinhadescartpormesano` AS SELECT 
 1 AS `idVendLinhaMaterial`,
 1 AS `Cod_Produto`,
 1 AS `Desc_Prod`,
 1 AS `Unidades`,
 1 AS `Vlr_total`,
 1 AS `PrcUltimaEntrada`,
 1 AS `rentabilidade`,
 1 AS `mesAno`*/;

--
-- Final view structure for view `devporano`
--

/*!50001 DROP VIEW IF EXISTS `devporano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `devporano` AS select `itensnfe`.`Cod_Produto` AS `Cod_Produto`,sum(`itensnfe`.`Qtd_Pedido`) AS `Qtd_Pedido`,sum(`itensnfe`.`Vlr_TotItem`) AS `vlrTotalDev`,date_format(`itensnfe`.`Dat_Movimento`,'%Y') AS `ano` from `itensnfe` where (`itensnfe`.`Tip_NF` = 'D') group by `itensnfe`.`Cod_Produto`,date_format(`itensnfe`.`Dat_Movimento`,'%Y') */;

--
-- Final view structure for view `view_compramensal`
--

/*!50001 DROP VIEW IF EXISTS `view_compramensal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_compramensal` AS select year(`itensnfs`.`Dat_Emissao`) AS `ano`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 1) then `itensnfs`.`Vlr_LiqItem` end)) AS `devJan`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 2) then `itensnfs`.`Vlr_LiqItem` end)) AS `devFev`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 3) then `itensnfs`.`Vlr_LiqItem` end)) AS `devMar`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 4) then `itensnfs`.`Vlr_LiqItem` end)) AS `devAbr`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 5) then `itensnfs`.`Vlr_LiqItem` end)) AS `devMai`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 6) then `itensnfs`.`Vlr_LiqItem` end)) AS `devJun`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 7) then `itensnfs`.`Vlr_LiqItem` end)) AS `devJul`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 8) then `itensnfs`.`Vlr_LiqItem` end)) AS `devAgo`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 9) then `itensnfs`.`Vlr_LiqItem` end)) AS `devSet`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 10) then `itensnfs`.`Vlr_LiqItem` end)) AS `devOut`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 11) then `itensnfs`.`Vlr_LiqItem` end)) AS `devNov`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 12) then `itensnfs`.`Vlr_LiqItem` end)) AS `devDez` from `itensnfs` where ((`itensnfs`.`Cod_Cfop` in (5202,5411,6202,6411)) and (`itensnfs`.`Cod_ClaTri` <> 'AI')) group by year(`itensnfs`.`Dat_Emissao`) */;

--
-- Final view structure for view `view_compramensalano`
--

/*!50001 DROP VIEW IF EXISTS `view_compramensalano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_compramensalano` AS select year(`itensnfe`.`Dat_Movimento`) AS `ano`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 1) then `itensnfe`.`Vlr_TotItem` end)) AS `compJan`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 2) then `itensnfe`.`Vlr_TotItem` end)) AS `compFev`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 3) then `itensnfe`.`Vlr_TotItem` end)) AS `compMar`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 4) then `itensnfe`.`Vlr_TotItem` end)) AS `compAbr`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 5) then `itensnfe`.`Vlr_TotItem` end)) AS `compMai`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 6) then `itensnfe`.`Vlr_TotItem` end)) AS `compJun`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 7) then `itensnfe`.`Vlr_TotItem` end)) AS `compJul`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 8) then `itensnfe`.`Vlr_TotItem` end)) AS `compAgo`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 9) then `itensnfe`.`Vlr_TotItem` end)) AS `compSet`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 10) then `itensnfe`.`Vlr_TotItem` end)) AS `compOut`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 11) then `itensnfe`.`Vlr_TotItem` end)) AS `compNov`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 12) then `itensnfe`.`Vlr_TotItem` end)) AS `compDez` from `itensnfe` where (`itensnfe`.`Cod_Cfo` in (1102,1403,2102,2403)) group by year(`itensnfe`.`Dat_Movimento`) */;

--
-- Final view structure for view `view_compraporlabano`
--

/*!50001 DROP VIEW IF EXISTS `view_compraporlabano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_compraporlabano` AS select concat(`itensnfe`.`Cod_Emitente`,'|',date_format(`itensnfe`.`Dat_Movimento`,'%Y')) AS `idLabAno`,`itensnfe`.`Cod_Emitente` AS `Cod_Emitente`,`itensnfe`.`Razao_Social` AS `Razao_Social`,count(distinct `itensnfe`.`protocolo`) AS `qtdNotas`,sum(`itensnfe`.`Qtd_Pedido`) AS `qtdUnidades`,sum(`itensnfe`.`Vlr_TotItem`) AS `vlrTotalCompras`,date_format(`itensnfe`.`Dat_Movimento`,'%Y') AS `ano` from `itensnfe` where (`itensnfe`.`Tip_NF` = 'c') group by concat(`itensnfe`.`Cod_Emitente`,'|',date_format(`itensnfe`.`Dat_Movimento`,'%Y')),`itensnfe`.`Cod_Emitente`,`itensnfe`.`Razao_Social`,date_format(`itensnfe`.`Dat_Movimento`,'%Y') order by count(distinct `itensnfe`.`protocolo`) desc */;

--
-- Final view structure for view `view_comprasxdevporstentrada`
--

/*!50001 DROP VIEW IF EXISTS `view_comprasxdevporstentrada`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_comprasxdevporstentrada` AS select `view_stcompraspormesano`.`idCompraMesAnoProdu` AS `idCompraMesAnoProdu`,`view_stcompraspormesano`.`ano` AS `ano`,`view_stcompraspormesano`.`mes` AS `mes`,`view_stcompraspormesano`.`Alq_IcmDeb` AS `Alq_IcmDeb`,`view_stcompraspormesano`.`qtdNotas` AS `qtdNotas`,(select (case when (count(`view_devcompramesanoprodu`.`qtd_Nota`) = 0) then 0 else `view_devcompramesanoprodu`.`qtd_Nota` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `qtd_NotaDev`,`view_stcompraspormesano`.`Qtd_Pedido` AS `Qtd_Pedido`,(select (case when (count(`view_devcompramesanoprodu`.`Qtd_Produto`) = 0) then 0 else `view_devcompramesanoprodu`.`Qtd_Produto` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `Qtd_ProdutoDev`,`view_stcompraspormesano`.`Vlr_TotItem` AS `Vlr_TotItemCompras`,(select (case when (count(`view_devcompramesanoprodu`.`Vlr_LiqItem`) = 0) then 0 else `view_devcompramesanoprodu`.`Vlr_LiqItem` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `Vlr_TotItemComprasDev`,`view_stcompraspormesano`.`Cus_LiqUni` AS `Cus_LiqUni`,`view_stcompraspormesano`.`Prc_CustoMedio` AS `Prc_CustoMedio`,(select (case when (count(`view_devcompramesanoprodu`.`Vlr_CusMedioGerenc`) = 0) then 0 else `view_devcompramesanoprodu`.`Vlr_CusMedioGerenc` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `Vlr_CusMedioGerencDev`,`view_stcompraspormesano`.`Vlr_IcmsNor` AS `Vlr_IcmsNor`,(select (case when (count(`view_devcompramesanoprodu`.`Vlr_Icms`) = 0) then 0 else `view_devcompramesanoprodu`.`Vlr_Icms` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `Vlr_IcmsDev`,`view_stcompraspormesano`.`Vlr_IcmsTrib` AS `Vlr_IcmsTrib`,(select (case when (count(`view_devcompramesanoprodu`.`Vlr_IcmsTri`) = 0) then 0 else `view_devcompramesanoprodu`.`Vlr_IcmsTri` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `Vlr_IcmsTriDev`,`view_stcompraspormesano`.`Vlr_DifTri` AS `Vlr_DifTri`,(select (case when (count(`view_devcompramesanoprodu`.`vlr_RessarST`) = 0) then 0 else `view_devcompramesanoprodu`.`vlr_RessarST` end) from `view_devcompramesanoprodu` where ((`view_devcompramesanoprodu`.`mes` = `view_stcompraspormesano`.`mes`) and (`view_devcompramesanoprodu`.`ano` = `view_stcompraspormesano`.`ano`) and (`view_devcompramesanoprodu`.`Alq_DebSbtEnt` = `view_stcompraspormesano`.`Alq_IcmDeb`))) AS `vlr_RessarST` from `view_stcompraspormesano` */;

--
-- Final view structure for view `view_devcompramesanoprodu`
--

/*!50001 DROP VIEW IF EXISTS `view_devcompramesanoprodu`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_devcompramesanoprodu` AS select concat(date_format(`itensnfs`.`Dat_Emissao`,'%m'),'|',date_format(`itensnfs`.`Dat_Emissao`,'%Y')) AS `idDevCompraMesAnoProdu`,date_format(`itensnfs`.`Dat_Emissao`,'%m') AS `mes`,date_format(`itensnfs`.`Dat_Emissao`,'%Y') AS `ano`,`itensnfs`.`Alq_DebSbtEnt` AS `Alq_DebSbtEnt`,count(distinct `itensnfs`.`Num_Nota`) AS `qtd_Nota`,sum(`itensnfs`.`Qtd_Produto`) AS `Qtd_Produto`,sum(`itensnfs`.`Vlr_LiqItem`) AS `Vlr_LiqItem`,sum((`itensnfs`.`Qtd_Produto` * `itensnfs`.`Vlr_CusIte_NF`)) AS `Vlr_CusIte_NF`,sum((`itensnfs`.`Qtd_Produto` * `itensnfs`.`Vlr_CusMedioGerenc`)) AS `Vlr_CusMedioGerenc`,sum(`itensnfs`.`Vlr_Icms`) AS `Vlr_Icms`,sum(`itensnfs`.`Vlr_IcmsTri`) AS `Vlr_IcmsTri`,sum((`itensnfs`.`Vlr_LiqItem` * (`itensnfs`.`Alq_DebSbtEnt` / 100))) AS `vlr_RessarST` from `itensnfs` where ((`itensnfs`.`Cod_Cfop` in (5202,5411,6202)) and (`itensnfs`.`Cod_ClaTri` <> 'AI')) group by `itensnfs`.`Alq_DebSbtEnt`,date_format(`itensnfs`.`Dat_Emissao`,'%m'),date_format(`itensnfs`.`Dat_Emissao`,'%Y'),concat(date_format(`itensnfs`.`Dat_Emissao`,'%m'),'|',date_format(`itensnfs`.`Dat_Emissao`,'%Y')) */;

--
-- Final view structure for view `view_devfatmensal`
--

/*!50001 DROP VIEW IF EXISTS `view_devfatmensal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_devfatmensal` AS select year(`itensnfe`.`Dat_Movimento`) AS `ano`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 1) then `itensnfe`.`Vlr_TotItem` end)) AS `DevJan`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 2) then `itensnfe`.`Vlr_TotItem` end)) AS `DevFev`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 3) then `itensnfe`.`Vlr_TotItem` end)) AS `DevMar`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 4) then `itensnfe`.`Vlr_TotItem` end)) AS `DevAbr`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 5) then `itensnfe`.`Vlr_TotItem` end)) AS `DevMai`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 6) then `itensnfe`.`Vlr_TotItem` end)) AS `DevJun`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 7) then `itensnfe`.`Vlr_TotItem` end)) AS `DevJul`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 8) then `itensnfe`.`Vlr_TotItem` end)) AS `DevAgo`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 9) then `itensnfe`.`Vlr_TotItem` end)) AS `DevSet`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 10) then `itensnfe`.`Vlr_TotItem` end)) AS `DevOut`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 11) then `itensnfe`.`Vlr_TotItem` end)) AS `DevNov`,sum((case when (month(`itensnfe`.`Dat_Movimento`) = 12) then `itensnfe`.`Vlr_TotItem` end)) AS `DevDez` from `itensnfe` where (`itensnfe`.`Cod_Cfo` in (1202,1411,2202,2411)) group by year(`itensnfe`.`Dat_Movimento`) */;

--
-- Final view structure for view `view_itenssaida`
--

/*!50001 DROP VIEW IF EXISTS `view_itenssaida`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_itenssaida` AS select concat(`itensnfs`.`ser_Nota`,'|',`itensnfs`.`Num_Nota`,'|',`itensnfs`.`Cod_Produto`,'|',`itensnfs`.`Cod_Lote`) AS `idLinhaItem`,`itensnfs`.`ser_Nota` AS `ser_Nota`,`itensnfs`.`Num_Nota` AS `Num_Nota`,`itensnfs`.`tip_saida` AS `tip_saida`,`itensnfs`.`Cod_Produto` AS `Cod_Produto`,`itensnfs`.`Cod_Lote` AS `Cod_Lote`,`itensnfs`.`Qtd_Produto` AS `Qtd_Produto`,`itensnfs`.`Prc_Unitario` AS `Prc_Unitario`,`itensnfs`.`Vlr_LiqItem` AS `Vlr_LiqItem`,`itensnfs`.`Vlr_CusIte_NF` AS `Vlr_CusIte_NF`,`itensnfs`.`Vlr_CusMedioGerenc` AS `Vlr_CusMedioGerenc`,`itensnfs`.`Prc_UltEnt` AS `Prc_UltEnt`,`itensnfs`.`PrcUltimaEntrada` AS `PrcUltimaEntrada`,`itensnfs`.`Cod_Cfop` AS `Cod_Cfop`,`itensnfs`.`DescCfop` AS `DescCfop`,`itensnfs`.`Vlr_Pis` AS `Vlr_Pis`,`itensnfs`.`Vlr_Cofins` AS `Vlr_Cofins`,`itensnfs`.`Vlr_IPI` AS `Vlr_IPI`,`itensnfs`.`Alq_Icms` AS `Alq_Icms`,`itensnfs`.`Vlr_Icms` AS `Vlr_Icms`,`itensnfs`.`Vlr_IcmsTri` AS `Vlr_IcmsTri`,`itensnfs`.`Vlr_SubsTrib` AS `Vlr_SubsTrib`,`itensnfs`.`Vlr_RepIcms` AS `Vlr_RepIcms`,`itensnfs`.`Vlr_IcmFcpUfDes` AS `Vlr_IcmFcpUfDes`,`itensnfs`.`Vlr_IcmIntUfDes` AS `Vlr_IcmIntUfDes`,`itensnfs`.`Vlr_IcmIntUfRem` AS `Vlr_IcmIntUfRem`,`itensnfs`.`Cod_Classif` AS `Cod_Classif`,`itensnfs`.`Dat_Emissao` AS `Dat_Emissao`,`itensnfs`.`Cod_Clien` AS `Cod_Clien`,`itensnfs`.`Razao_Social` AS `Razao_Social`,`itensnfs`.`Cod_Vendedor` AS `Cod_Vendedor`,`itensnfs`.`Nome_Guerra` AS `Nome_Guerra`,`itensnfs`.`UF` AS `UF`,`itensnfs`.`Desc_Prod` AS `Desc_Prod`,`itensnfs`.`Flg_MovEst` AS `Flg_MovEst` from `itensnfs` */;

--
-- Final view structure for view `view_stcompraspormesano`
--

/*!50001 DROP VIEW IF EXISTS `view_stcompraspormesano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_stcompraspormesano` AS select concat(ceiling(`itensnfe`.`Alq_IcmDeb`),'|',date_format(`itensnfe`.`Dat_Movimento`,'%m'),'|',date_format(`itensnfe`.`Dat_Movimento`,'%Y')) AS `idCompraMesAnoProdu`,date_format(`itensnfe`.`Dat_Movimento`,'%m') AS `mes`,date_format(`itensnfe`.`Dat_Movimento`,'%Y') AS `ano`,ceiling(`itensnfe`.`Alq_IcmDeb`) AS `Alq_IcmDeb`,count(distinct `itensnfe`.`protocolo`) AS `qtdNotas`,sum(`itensnfe`.`Qtd_Pedido`) AS `Qtd_Pedido`,sum(`itensnfe`.`Vlr_LiqIte`) AS `Vlr_LiqIte`,sum((`itensnfe`.`Qtd_Pedido` * `itensnfe`.`Cus_LiqUni`)) AS `Cus_LiqUni`,sum((`itensnfe`.`Qtd_Pedido` * `itensnfe`.`Prc_CustoMedio`)) AS `Prc_CustoMedio`,sum(`itensnfe`.`Vlr_IcmsNor`) AS `Vlr_IcmsNor`,sum(`itensnfe`.`Vlr_IcmsTrib`) AS `Vlr_IcmsTrib`,sum(`itensnfe`.`Vlr_DifTri`) AS `Vlr_DifTri`,sum(`itensnfe`.`Vlr_TotItem`) AS `Vlr_TotItem` from `itensnfe` where (`itensnfe`.`Cod_Cfo` in (1102,1403,2102,2403)) group by date_format(`itensnfe`.`Dat_Movimento`,'%M'),date_format(`itensnfe`.`Dat_Movimento`,'%Y'),`itensnfe`.`Alq_IcmDeb` */;

--
-- Final view structure for view `view_vendalinhamedicamentoporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendalinhamedicamentoporano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendalinhamedicamentoporano` AS select concat(date_format(`itensnfs`.`Dat_Emissao`,'%Y'),'|',`itensnfs`.`Cod_Produto`) AS `idVendLinhaMaterial`,`itensnfs`.`Cod_Produto` AS `Cod_Produto`,`itensnfs`.`Desc_Prod` AS `Desc_Prod`,sum(`itensnfs`.`Qtd_Produto`) AS `Unidades`,sum(`itensnfs`.`Vlr_LiqItem`) AS `Vlr_total`,sum((`itensnfs`.`PrcUltimaEntrada` * `itensnfs`.`Qtd_Produto`)) AS `PrcUltimaEntrada`,date_format(`itensnfs`.`Dat_Emissao`,'%Y') AS `ano` from `itensnfs` where ((`itensnfs`.`tip_saida` = 'v') and (`itensnfs`.`Cod_Classif` not in (201,201001,201002,201003,201004,201005,201006))) group by `itensnfs`.`Cod_Produto`,`itensnfs`.`Desc_Prod`,date_format(`itensnfs`.`Dat_Emissao`,'%Y'),concat(date_format(`itensnfs`.`Dat_Emissao`,'%Y'),'|',`itensnfs`.`Cod_Produto`) order by sum(`itensnfs`.`Qtd_Produto`) desc */;

--
-- Final view structure for view `view_vendamaterialxdevporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamaterialxdevporano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendamaterialxdevporano` AS select `vw`.`idVendLinhaMaterial` AS `idVendLinhaMaterial`,`vw`.`Cod_Produto` AS `Cod_Produto`,`vw`.`Desc_Prod` AS `Desc_Prod`,`vw`.`Unidades` AS `Unidades`,(select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`Qtd_Pedido` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`))) AS `qtdTotalDev`,(`vw`.`Unidades` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`Qtd_Pedido` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) AS `qtdUndComDev`,`vw`.`Vlr_total` AS `Vlr_total`,(select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`))) AS `vlrTotalDev`,(`vw`.`Vlr_total` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) AS `vlrVendaComDev`,`vw`.`PrcUltimaEntrada` AS `PrcUltimaEntrada`,((`vw`.`Vlr_total` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) - `vw`.`PrcUltimaEntrada`) AS `rentabilidade`,`vw`.`ano` AS `ano` from `view_vendprincprodulinhadescartporano` `vw` */;

--
-- Final view structure for view `view_vendamedicamentosxdevporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamedicamentosxdevporano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendamedicamentosxdevporano` AS select `vw`.`idVendLinhaMaterial` AS `idVendLinhaMaterial`,`vw`.`Cod_Produto` AS `Cod_Produto`,`vw`.`Desc_Prod` AS `Desc_Prod`,`vw`.`Unidades` AS `Unidades`,(select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`Qtd_Pedido` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`))) AS `qtdTotalDev`,(`vw`.`Unidades` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`Qtd_Pedido` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) AS `qtdUndComDev`,`vw`.`Vlr_total` AS `Vlr_total`,(select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`))) AS `vlrTotalDev`,(`vw`.`Vlr_total` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) AS `vlrVendaComDev`,`vw`.`PrcUltimaEntrada` AS `PrcUltimaEntrada`,((`vw`.`Vlr_total` - (select (case when (count(`devporano`.`Cod_Produto`) = 0) then 0 else `devporano`.`vlrTotalDev` end) from `devporano` where ((`devporano`.`Cod_Produto` = `vw`.`Cod_Produto`) and (`devporano`.`ano` = `vw`.`ano`)))) - `vw`.`PrcUltimaEntrada`) AS `rentabilidade`,`vw`.`ano` AS `ano` from `view_vendalinhamedicamentoporano` `vw` */;

--
-- Final view structure for view `view_vendamensal`
--

/*!50001 DROP VIEW IF EXISTS `view_vendamensal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendamensal` AS select year(`itensnfs`.`Dat_Emissao`) AS `ano`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 1) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatJan`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 2) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatFev`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 3) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatMar`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 4) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatAbr`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 5) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatMai`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 6) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatJun`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 7) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatJul`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 8) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatAgo`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 9) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatSet`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 10) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatOut`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 11) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatNov`,sum((case when (month(`itensnfs`.`Dat_Emissao`) = 12) then `itensnfs`.`Vlr_LiqItem` end)) AS `fatDez` from `itensnfs` where (`itensnfs`.`Cod_Cfop` in (5102,5403,5922,6102,6108,6403,6922)) group by year(`itensnfs`.`Dat_Emissao`) */;

--
-- Final view structure for view `view_vendprincprodulinhadescartporano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendprincprodulinhadescartporano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendprincprodulinhadescartporano` AS select concat(date_format(`itensnfs`.`Dat_Emissao`,'%Y'),'|',`itensnfs`.`Cod_Produto`) AS `idVendLinhaMaterial`,`itensnfs`.`Cod_Produto` AS `Cod_Produto`,`itensnfs`.`Desc_Prod` AS `Desc_Prod`,sum(`itensnfs`.`Qtd_Produto`) AS `Unidades`,sum(`itensnfs`.`Vlr_LiqItem`) AS `Vlr_total`,sum((`itensnfs`.`PrcUltimaEntrada` * `itensnfs`.`Qtd_Produto`)) AS `PrcUltimaEntrada`,(sum(`itensnfs`.`Vlr_LiqItem`) - sum((`itensnfs`.`PrcUltimaEntrada` * `itensnfs`.`Qtd_Produto`))) AS `rentabilidade`,date_format(`itensnfs`.`Dat_Emissao`,'%Y') AS `ano` from `itensnfs` where ((`itensnfs`.`tip_saida` = 'v') and (`itensnfs`.`Cod_Classif` in (201,201001,201002,201003,201004,201005,201006))) group by `itensnfs`.`Cod_Produto`,`itensnfs`.`Desc_Prod`,date_format(`itensnfs`.`Dat_Emissao`,'%Y'),concat(date_format(`itensnfs`.`Dat_Emissao`,'%Y'),'|',`itensnfs`.`Cod_Produto`) order by sum(`itensnfs`.`Qtd_Produto`) desc */;

--
-- Final view structure for view `view_vendprincprodulinhadescartpormesano`
--

/*!50001 DROP VIEW IF EXISTS `view_vendprincprodulinhadescartpormesano`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `view_vendprincprodulinhadescartpormesano` AS select concat(date_format(`itensnfs`.`Dat_Emissao`,'%m-%Y'),'|',`itensnfs`.`Cod_Produto`) AS `idVendLinhaMaterial`,`itensnfs`.`Cod_Produto` AS `Cod_Produto`,`itensnfs`.`Desc_Prod` AS `Desc_Prod`,sum(`itensnfs`.`Qtd_Produto`) AS `Unidades`,sum(`itensnfs`.`Vlr_LiqItem`) AS `Vlr_total`,sum((`itensnfs`.`PrcUltimaEntrada` * `itensnfs`.`Qtd_Produto`)) AS `PrcUltimaEntrada`,(sum(`itensnfs`.`Vlr_LiqItem`) - sum((`itensnfs`.`PrcUltimaEntrada` * `itensnfs`.`Qtd_Produto`))) AS `rentabilidade`,date_format(`itensnfs`.`Dat_Emissao`,'%m-%Y') AS `mesAno` from `itensnfs` where ((`itensnfs`.`tip_saida` = 'v') and (`itensnfs`.`Cod_Classif` in (201,201001,201002,201003,201004,201005,201006))) group by `itensnfs`.`Cod_Produto`,`itensnfs`.`Desc_Prod`,date_format(`itensnfs`.`Dat_Emissao`,'%m-%Y'),concat(date_format(`itensnfs`.`Dat_Emissao`,'%m-%Y'),'|',`itensnfs`.`Cod_Produto`) order by sum(`itensnfs`.`Qtd_Produto`) desc */;


