
/*------ ATD 309754 ------*/
IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='RESSARCIMENTO_SINTEGRA')
BEGIN
	CREATE TABLE RESSARCIMENTO_SINTEGRA
	(
	ID INT IDENTITY PRIMARY KEY NOT NULL,
	FILIAL CHAR(2),
	MES NUMERIC(2,0),
	ANO NUMERIC(4,0),
	TIPO CHAR(2),
	SUBTIPO CHAR(6),
	CGC CHAR(14),
	INSCRICAO CHAR(20),
	DTEMIS DATETIME,
	ESTADO CHAR(2),
	NUMNOTA CHAR(13),
	SERIE CHAR(3),
	CFOP CHAR(4),
	VALCONTAB NUMERIC(15,2),
	BASE NUMERIC(15,2),
	ALIQUOTA NUMERIC(8,2),
	ISENTO NUMERIC(15,2),
	OUTRAS NUMERIC(15,2),
	GERAL VARCHAR(100),
	DESPESAS NUMERIC(15,2),
	QTDE NUMERIC(13,3),
	ICMS NUMERIC(6,2),
	IPI NUMERIC(15,2),
	PRODUTO CHAR(17),
	MODELONF CHAR(2),
	SERIENF CHAR(3),
	SUBSERIENF CHAR(3),
	NFNOTA CHAR(6),
	VALORMERC NUMERIC(15,2),
	CT CHAR(3),
	NUMORD INT,
	ITEM CHAR(5),
	DESCONTO NUMERIC(15,2),
	VALSEGURO NUMERIC(15,2),
	FRETE NUMERIC(15,2),
	BASEIPI NUMERIC(15,2),
	ISENTOIPI NUMERIC(15,2),
	OUTRASIPI NUMERIC(15,2),
	TOTALBASEICMS NUMERIC(15,2),
	TOTALVALICMS NUMERIC(15,2),
	TOTALSTMEDIA NUMERIC(15,2),
	TOTALICMSMEDIO NUMERIC(15,2),
	VALORST NUMERIC(15,2),
	UNIDADE CHAR(6),
	DTCHEG DATETIME,
	CODFOR INT,
	)
END
GO


DELETE OPCSISTCAD WHERE CODSIS = 'LIF' AND CODOPC = '3.06'
GO
INSERT INTO OPCSISTCAD (CODSIS, CODOPC, NOMEOPC, ATIVADO, RAZDESATIV, MENSAGEM, NUMEROATIV, MEDIAUSO, NUMDEMESES, USOULTMES, AUDITATIVO, ATIVPOROPC) 
VALUES ('LIF', '3.06', 'RESSARCIMENTO - SINTEGRA', 'S', '', '', 0, 0, 0, 0, '', '')
GO

IF NOT EXISTS (SELECT 1 FROM SYSCOLUMNS WHERE name = 'CODFOR' and syscolumns.id IN (SELECT ID FROM SYSOBJECTS WHERE TYPE='U' AND name='RESSARCIMENTO_SINTEGRA'))
	ALTER TABLE RESSARCIMENTO_SINTEGRA ADD CODFOR INT
GO
