DELETE
  FROM SYS_CENARIO
/

COMMIT 
/

ALTER TABLE SYS_CENARIO MODIFY DIAS_FUT FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY ORIGEM FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY DESTINACAO FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY COD_NATOP FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY MUN_ORIG FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY MUN_DEST FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY CNAE_DEST FLOAT
/

ALTER TABLE SYS_CENARIO MODIFY ENT_SAI FLOAT
/

ALTER TABLE SYS_CENARIO ADD ID_CENARIO_PRIN VARCHAR2(20)
/

ALTER TABLE SYS_CENARIO ADD GRUPOS_PRODUTOS VARCHAR2(50)
/

ALTER TABLE SYS_CENARIO ADD FINALIDADE FLOAT
/

ALTER TABLE SYS_CENARIO ADD CONSTRAINT PK_SYS_CENARIO PRIMARY KEY (ID_CENARIO)
/

DELETE
  FROM SYS_MATERIAL
/

COMMIT
/

ALTER TABLE SYS_MATERIAL ADD CFOP_ENTRADA FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY COD_PROD VARCHAR2(50)
/

ALTER TABLE SYS_MATERIAL MODIFY DESCRICAO VARCHAR2(120)
/

ALTER TABLE SYS_MATERIAL MODIFY EAN FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY NCM FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY EX_TIPI FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY ORI_PROD FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY CFOP FLOAT
/

ALTER TABLE SYS_MATERIAL MODIFY CEST FLOAT
/

ALTER TABLE SYS_MATERIAL ADD CONSTRAINT PK_SYS_MATERIAL PRIMARY KEY (ID_CENARIO, COD_PROD)
/

DELETE
  FROM SYS_ICMS
/

COMMIT
/

ALTER TABLE SYS_ICMS ADD PERCENT_DIFER FLOAT
/

ALTER TABLE SYS_ICMS ADD FCP FLOAT
/

ALTER TABLE SYS_ICMS ADD NRSEQIMP VARCHAR2(4) DEFAULT 1 NOT NULL
/

ALTER TABLE SYS_ICMS ADD BC_COMPOS_SN_ESP FLOAT
/

ALTER TABLE SYS_ICMS ADD BC_CONPOS_FCP FLOAT
/

ALTER TABLE SYS_ICMS ADD ALIQ_DESONERA FLOAT
/

ALTER TABLE SYS_ICMS ADD ALIQ_CF FLOAT
/

ALTER TABLE SYS_ICMS ADD ALIQ_SN_ESP FLOAT
/

ALTER TABLE SYS_ICMS ADD VALOR_PAUTA FLOAT
/

ALTER TABLE SYS_ICMS ADD UNIDADE_PAUTA VARCHAR2(3)
/

ALTER TABLE SYS_ICMS ADD DIF_ALIQ_N_CONTR FLOAT
/

ALTER TABLE SYS_ICMS ADD GENERICO VARCHAR2(50)
/

ALTER TABLE SYS_ICMS ADD INF_ADICIONAIS VARCHAR2(200)
/

ALTER TABLE SYS_ICMS ADD ESTATISTICA VARCHAR2(100)
/

ALTER TABLE SYS_ICMS ADD SEVERIDADE FLOAT
/

ALTER TABLE SYS_ICMS ADD CONSTRAINT PK_SYS_ICMS PRIMARY KEY (ID_CENARIO, COD_PROD, NRSEQIMP)
/

ALTER TABLE SYS_ICMS MODIFY BC_COMPOS FLOAT
/

ALTER TABLE SYS_ICMS MODIFY P_RED_BC FLOAT
/

ALTER TABLE SYS_ICMS MODIFY DISPOSITIVO VARCHAR2(200)
/

ALTER TABLE SYS_ICMS MODIFY OBSERVACAO VARCHAR2(200)
/

ALTER TABLE SYS_ICMS ADD ERRO VARCHAR2(4000)
/

ALTER TABLE SYS_ICMS ADD IDIMPORTA VARCHAR2(01)
/

CREATE TABLE SYS_ICMSST(
   ID_CENARIO        VARCHAR2(20) NOT NULL,
   COD_PROD          VARCHAR2(120) NOT NULL,
   NRSEQIMP          VARCHAR2(4) NOT NULL,
   BC_COMPOSICAO     FLOAT,
   BC_COMPOSICAO_FCP FLOAT,
   P_RED_BC_ST       FLOAT,
   ALIQUOTA_ST       FLOAT,
   FCP               FLOAT,
   CARGA_MEDIA       FLOAT,
   MVA               FLOAT,
   MVA_AJUSTADO      FLOAT,
   MVA_LIS_POS_AJUST FLOAT,
   MVA_LIS_NEG_AJUST FLOAT,
   MVA_LIS_NEU_AJUST FLOAT,
   VALOR_PAUTA       FLOAT,
   UNIDADE_PAUTA     VARCHAR2(3),
   GENERICO          VARCHAR2(50),
   VIG_DE            DATE,
   VIG_ATE           DATE,
   DISPOSITIVO       VARCHAR2(200),
   OBSERVACOES       VARCHAR2(200),
   ESTATISTICA       VARCHAR2(100),
   SEVERIDADE        FLOAT,
   ERRO              VARCHAR2(4000),
   IDIMPORTA         VARCHAR2(01),
   NRORG             NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO           VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_SYS_ICMSST CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO        DATE NULL,
   DTULTATU          DATE NULL,
   NRORGINCLUSAO     NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO    VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU       NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU      VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_SYS_ICMSST PRIMARY KEY (ID_CENARIO, COD_PROD, NRSEQIMP)
)
/

CREATE TABLE SYS_IPI(
   ID_CENARIO          VARCHAR2(20) NOT NULL,
   COD_PROD            VARCHAR2(120) NOT NULL,
   NRSEQIMP            VARCHAR2(04) NOT NULL,
   CST                 VARCHAR2(03),
   CENQ                VARCHAR2(03),
   BC_COMPOS           INTEGER,
   P_RED_BC            FLOAT,
   P_RED_ALIQ          FLOAT,
   ALIQUOTA            FLOAT,
   VALOR_POR_UNID_TRIB FLOAT,
   P_RED_VAL_IMP       FLOAT,
   GENERICO            VARCHAR2(50),
   VIG_DE              DATE,
   VIG_ATE             DATE,
   DISPOSITIVO         VARCHAR2(200),
   OBSERVACAO          VARCHAR2(200),
   INF_ADICIONAIS      VARCHAR2(200),
   ESTATISTICA         VARCHAR2(100),
   SEVERIDADE          FLOAT,
   ERRO                VARCHAR2(4000),
   IDIMPORTA           VARCHAR2(01),
   NRORG               NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO             VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_SYS_IPI CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO          DATE NULL,
   DTULTATU            DATE NULL,
   NRORGINCLUSAO       NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO      VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU         NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU        VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_SYS_IPI PRIMARY KEY (ID_CENARIO, COD_PROD, NRSEQIMP)
)
/

DELETE
  FROM SYS_PIS
/

COMMIT
/

ALTER TABLE SYS_PIS MODIFY BC_COMPOS FLOAT
/

ALTER TABLE SYS_PIS MODIFY P_RED_BC FLOAT
/

ALTER TABLE SYS_PIS MODIFY DISPOSITIVO VARCHAR2(200)
/

ALTER TABLE SYS_PIS MODIFY OBSERVACAO VARCHAR2(200)
/

ALTER TABLE SYS_PIS ADD ALIQ_ESP FLOAT
/

ALTER TABLE SYS_PIS ADD GENERICO VARCHAR2(50)
/

ALTER TABLE SYS_PIS ADD INF_ADICIONAIS VARCHAR2(200)
/

ALTER TABLE SYS_PIS ADD COD_NATU_RECEITA VARCHAR2(03)
/

ALTER TABLE SYS_PIS ADD ESTATISTICA VARCHAR2(100)
/

ALTER TABLE SYS_PIS ADD SEVERIDADE FLOAT
/

ALTER TABLE SYS_PIS ADD NRSEQIMP VARCHAR2(04) DEFAULT 1 NOT NULL
/

ALTER TABLE SYS_PIS ADD ERRO VARCHAR2(4000)
/

ALTER TABLE SYS_PIS ADD IDIMPORTA VARCHAR2(01)
/

ALTER TABLE SYS_PIS ADD CONSTRAINT PK_SYS_PIS PRIMARY KEY (ID_CENARIO, COD_PROD, NRSEQIMP)
/

DELETE
  FROM SYS_COFINS
/

COMMIT
/

ALTER TABLE SYS_COFINS MODIFY BC_COMPOS FLOAT
/

ALTER TABLE SYS_COFINS MODIFY P_RED_BC FLOAT
/

ALTER TABLE SYS_COFINS MODIFY DISPOSITIVO VARCHAR2(200)
/

ALTER TABLE SYS_COFINS MODIFY OBSERVACAO VARCHAR2(200)
/

ALTER TABLE SYS_COFINS ADD ALIQ_ESP FLOAT
/

ALTER TABLE SYS_COFINS ADD GENERICO VARCHAR2(50)
/

ALTER TABLE SYS_COFINS ADD INF_ADICIONAIS VARCHAR2(200)
/

ALTER TABLE SYS_COFINS ADD COD_NATU_RECEITA VARCHAR2(03)
/

ALTER TABLE SYS_COFINS ADD ESTATISTICA VARCHAR2(100)
/

ALTER TABLE SYS_COFINS ADD SEVERIDADE FLOAT
/

ALTER TABLE SYS_COFINS ADD NRSEQIMP VARCHAR2(04) DEFAULT 1 NOT NULL
/

ALTER TABLE SYS_COFINS ADD ERRO VARCHAR2(4000)
/

ALTER TABLE SYS_COFINS ADD IDIMPORTA VARCHAR2(01)
/

ALTER TABLE SYS_COFINS ADD CONSTRAINT PK_SYS_COFINS PRIMARY KEY (ID_CENARIO, COD_PROD, NRSEQIMP)
/

CREATE TABLE SYS_DADOSACESSO
(
   NRSEQDADOAC          INTEGER NOT NULL,
   USUARIO              VARCHAR2(100) NOT NULL,
   SENHA                VARCHAR2(100) NOT NULL,
   URL_CADASTRO         VARCHAR2(200) NOT NULL,
   URL_ERP              VARCHAR2(200) NOT NULL,
   ULTPROD              VARCHAR2(20),
   ULTCENARIO           VARCHAR2(20),
   PONTEIRO_ATUALIZACAO INTEGER,
   NRORG                NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO              VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_SYS_DADOSACESSO CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO           DATE NULL,
   DTULTATU             DATE NULL,
   NRORGINCLUSAO        NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO       VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU         VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_SYS_DADOSACESSO PRIMARY KEY (NRSEQDADOAC)
)
/

CREATE TABLE GRUPPRODCON
(
   CDGRUPPRODCON  VARCHAR2(4) NOT NULL,
   DSGRUPPRODCON  VARCHAR2(50) NOT NULL,
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_GRUPPRODCON CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE NULL,
   NRORGINCLUSAO  NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU    NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU   VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_GRUPPRODCON PRIMARY KEY (CDGRUPPRODCON)
)
/

CREATE TABLE ITGRUPPRODCON
(
   CDGRUPPRODCON  VARCHAR2(4) NOT NULL,
   CDPRODUTO      VARCHAR2(10) NOT NULL,
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ITGRUPPRODCON CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE NULL,
   NRORGINCLUSAO  NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU    NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU   VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_ITGRUPPRODCON PRIMARY KEY (CDGRUPPRODCON, CDPRODUTO)
)
/

CREATE TABLE CENARIOGRUP
(
   CDGRUPPRODCON  VARCHAR2(4) NOT NULL,
   ID_CENARIO     VARCHAR2(100),
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_CENARIOGRUP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE NULL,
   NRORGINCLUSAO  NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU    NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU   VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_CENARIOGRUP PRIMARY KEY (CDGRUPPRODCON, ID_CENARIO)
)
/

CREATE TABLE SYS_REGRAGRUP
(
   CDGRUPPRODCON  VARCHAR2(4) NOT NULL,
   CDREGRA        VARCHAR2(10),
   NRORG          NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1) DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_SYS_REGRAGRUP CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE NULL,
   DTULTATU       DATE NULL,
   NRORGINCLUSAO  NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')  NULL,
   CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL,
   NRORGULTATU    NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU   VARCHAR2(12) DEFAULT '1',
   CONSTRAINT PK_SYS_REGRAGRUP PRIMARY KEY (CDGRUPPRODCON, CDREGRA)
)
/

CREATE INDEX FIS00788_FK ON SYS_REGRAGRUP (CDREGRA ASC) 
/

ALTER TABLE SYS_REGRAGRUP
    ADD CONSTRAINT FKFIS00788SYS_REGGRUP_REGFIS FOREIGN KEY (CDREGRA)
       REFERENCES REGRAFISCAL (CDREGRAFISC)
/