CREATE TABLE BOLETRECASSINA (
    CDFILIAL       VARCHAR2(04) NOT NULL,
    NRLANBOLREC    VARCHAR2(10) NOT NULL,
    CDCLIENTE      VARCHAR(21),     
    NRPARCELABOLREC      NUMBER,
    DTVENBOLREC    DATE,
    VRJUROS        FLOAT,
    VRMULTA        FLOAT,
    VRFINALBREC    FLOAT,
    IDSTATUS       VARCHAR2(01),
    CDBARRA        VARCHAR2(44),
    DSLINHADIGI    VARCHAR2(48),
    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_BOLETRECASSINA CHECK (IDATIVO IN ('S','N')),
    CONSTRAINT CKC_IDSTATUS_BOLETASSINA CHECK (IDSTATUS IS NULL OR (IDSTATUS IN ('A','B','E','C','P','D'))),
    CONSTRAINT PK_BOLETRECASSINA PRIMARY KEY (CDFILIAL, NRLANBOLREC)
)
/

ALTER TABLE BOLETRECASSINA ADD CDCONSUMIDOR VARCHAR2(21) NULL 
/

ALTER TABLE BOLETRECASSINA ADD NRAUTORIZAPIX VARCHAR2(400) NULL 
/

ALTER TABLE BOLETRECASSINA ADD CDNSUTEF VARCHAR2(400) NULL 
/

CREATE INDEX FIN00406_FK ON BOLETRECASSINA (CDFILIAL ASC, NRLANBOLREC ASC)
/

ALTER TABLE BOLETRECASSINA
    ADD CONSTRAINT FKFIN00406BOLETREC FOREIGN KEY  (CDFILIAL, NRLANBOLREC)
       REFERENCES BOLETRECEBER (CDFILIAL, NRLANBOLREC) ON DELETE CASCADE
/

ALTER TABLE NCSERVASSCLI ADD IDSTATUSBOLREC VARCHAR2(01) NULL 
/

ALTER TABLE NOTAFISCAL ADD NRSERVASS VARCHAR2(10) NULL 
/

ALTER TABLE CONTARECEBER ADD NRSERVASS VARCHAR2(10) NULL 
/

ALTER TABLE CONTARECEBER ADD CDCONSUMIDOR VARCHAR2(21) NULL 
/