CREATE TABLE VNDCARDS
(
	CDFILIAL			VARCHAR2(10) 	NOT NULL,
	DTVNDCARDS			DATE 			NOT NULL,
	HORAVNDCARDS	    VARCHAR(5),
	QTTICKETCARD		FLOAT 			DEFAULT 0,
	TOTVENDCARD			FLOAT 			DEFAULT 0,
	AVGTICKETCARD		FLOAT 			DEFAULT 0,
	CANCVENDCARD		FLOAT 			DEFAULT 0,
	FECHCAIXPENDCARD	FLOAT 			DEFAULT 0,
	APROVMOVCARD		FLOAT 			DEFAULT 0,
	DIFAPURACARD		FLOAT 			DEFAULT 0,
	QTDIFAPURACARD		FLOAT 			DEFAULT 0,
	CUPOMPENDCARD		FLOAT 			DEFAULT 0,
	ITESTPENDCARD		FLOAT 			DEFAULT 0,
    NRORG               NUMBER 	        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO             VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO          DATE            DEFAULT SYSDATE,
    DTULTATU            DATE            DEFAULT SYSDATE,
    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 CKC_IDATIVO_VNDCARDS CHECK (IDATIVO IN ('S','N')),	
		CONSTRAINT PK_VNDCARDS PRIMARY KEY (CDFILIAL, DTVNDCARDS)
)
 /


CREATE INDEX VND00836_FK ON VNDCARDS (CDFILIAL ASC)
 /

CREATE INDEX VNDCARDS_001 ON VNDCARDS (DTVNDCARDS ASC, CDFILIAL ASC)
 /

ALTER TABLE VNDCARDS ADD CMVDASHIDEAL FLOAT DEFAULT 0
/

ALTER TABLE VNDCARDS ADD CMVDASHREDE FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD CMVDASHREAL FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD TOTMESVENDDIA FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD VRCMVREDE FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD VRSALDOESTAN FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD CTGMESANT FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD CTGMES FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD VRCOMPRAS FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD VRDEV FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD CONSFUNC FLOAT DEFAULT 0
 /
 
ALTER TABLE VNDCARDS ADD PRODIRREG FLOAT DEFAULT 0
 /


CREATE TABLE LOGALTERADASH
(
	CDFILIAL		VARCHAR2(10) 	NOT NULL,
	DTLOGDASH		DATE 			NOT NULL,
	NRORG           NUMBER          DEFAULT   SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO         VARCHAR2(1)     DEFAULT 'S'   NOT NULL,
      CONSTRAINT CKC_IDATIVO_LOGALTERADASH 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' NULL,
        CONSTRAINT PK_LOGALTERADASH PRIMARY KEY (CDFILIAL, DTLOGDASH)
)
 /


CREATE INDEX VND00838_FK ON LOGALTERADASH (CDFILIAL ASC)
 /

CREATE INDEX VND00839_FK ON LOGALTERADASH (DTLOGDASH ASC)
 /


CREATE TABLE JOB_FINAN 
(	NRSEQJOB 		  NUMBER 		 NOT NULL, 
	CDEMPRESA 		  VARCHAR2(2) 	 NOT NULL, 
	CDFILIAL 		  VARCHAR2(4), 
	VRVENCDIA 		  NUMBER, 
	VRVENC7DIAS 	  NUMBER, 
	VRVENC15DIAS 	  NUMBER, 
	VRVENC30DIAS      NUMBER, 
	VRTOTALVENCIDO    NUMBER, 
	VRSALDOCCOR 	  NUMBER, 
	IDINFJOB 		  VARCHAR2(1)	  NOT NULL, 
	DTINICIO 	      DATE, 
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    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',
	DSBANCO 		  VARCHAR2(40), 
		CONSTRAINT CKC_IDATIVO_JOB_FINAN CHECK (IDATIVO IN ('S','N'))
)
 /


ALTER TABLE PARAMGERAL ADD IDDASHBOARD VARCHAR2(1) DEFAULT 'P' NOT NULL
 /

ALTER TABLE PARAMGERAL ADD CONSTRAINT CKC_IDDASHBOARD_PARAMGERAL CHECK (IDDASHBOARD IN ('P','C'))
 /