CREATE TABLE cmf_fiscal_doc_headers (
    DOCUMENT_HEADER_ID            NUMBER(18, 0) ,
    INTERFACED_FLAG               VARCHAR2(4)   ,
    DOCUMENT_NUMBER               VARCHAR2(120)     NOT NULL,
    ACCESS_KEY_NUMBER             VARCHAR2(256) ,
    DOCUMENT_STATUS               VARCHAR2(120)     NOT NULL,
    BILL_TO_BUSINESS_UNIT_ID      NUMBER(18, 0)     NOT NULL,
    SOLD_TO_LEGAL_ENTITY_ID       NUMBER(18, 0)     NOT NULL,
    FISCAL_DOC_ASSOCTNS_ID        NUMBER(18, 0)     NOT NULL,
    FISCAL_PROC_OPTIONS_ID        NUMBER(18, 0)     NOT NULL,
    INVOICE_ID                    NUMBER(18, 0) ,
    INVOICE_NUM                   VARCHAR2(200) ,
    ISSUER_TAX_ID                 NUMBER(18, 0)     NOT NULL,
    ISSUER_PARTY_ID               NUMBER(18, 0)     NOT NULL,
    ISSUER_PARTY_SITE_ID          NUMBER(18, 0)     NOT NULL,
    ISSUER_LOCATION_ID            NUMBER(18, 0)     NOT NULL,
    COUNTRY_CODE                  VARCHAR2(8)   ,
    RECEIVER_TAX_ID               NUMBER(18, 0) ,
    RECEIVER_PARTY_ID             NUMBER(18, 0)     NOT NULL,
    RECEIVER_PARTY_SITE_ID        NUMBER(18, 0)     NOT NULL,
    RECEIVER_LOCATION_ID          NUMBER(18, 0)     NOT NULL,
    SHIPTO_TAX_ID                 NUMBER(18, 0)     NOT NULL,
    SHIPTO_PARTY_ID               NUMBER(18, 0)     NOT NULL,
    SHIPTO_PARTY_SITE_ID          NUMBER(18, 0)     NOT NULL,
    SHIPTO_LOCATION_ID            NUMBER(18, 0)     NOT NULL,
    SHIPFROM_TAX_ID               NUMBER(18, 0) ,
    SHIPFROM_PARTY_ID             NUMBER(18, 0)     NOT NULL,
    SHIPFROM_PARTY_SITE_ID        NUMBER(18, 0)     NOT NULL,
    SHIPFROM_LOCATION_ID          NUMBER(18, 0)     NOT NULL,
    SHIPFROM_IBGE_CITY_CODE       VARCHAR2(1440),
    SHIPFROM_IBGE_CITY_ID         NUMBER(18, 0) ,
    SHIPTO_IBGE_CITY_CODE         VARCHAR2(1440),
    SHIPTO_IBGE_CITY_ID           NUMBER(18, 0) ,
    SOURCE_REF_DOC_HEADER_ID      NUMBER(18, 0) ,
    PARENT_DOCUMENT_HEADER_ID     NUMBER(18, 0) ,
    DOCUMENT_UNIQUE_IDENTIFIER    VARCHAR2(480) ,
    INTEREST_INDICATOR            VARCHAR2(4)   ,
    OBJECT_VERSION_NUMBER         NUMBER(9, 0)      NOT NULL,
    ISSUE_DATE                    DATE              NOT NULL,
    ACKNOWLEDGED_DATE             DATE          ,
    MODEL                         VARCHAR2(120)     NOT NULL,
    SERIES                        VARCHAR2(40)      NOT NULL,
    SUBSERIES                     VARCHAR2(40)  ,
    SOURCE_DOCUMENT_TYPE          VARCHAR2(120)     NOT NULL,
    DOCUMENT_TYPE                 VARCHAR2(120)     NOT NULL,
    CURRENCY                      VARCHAR2(120)     NOT NULL,
    CONVERSTION_TYPE              VARCHAR2(120)     NOT NULL,
    CONVERSION_RATE               NUMBER        ,
    TOTAL_AMOUNT                  NUMBER            NOT NULL,
    ITEM_LINE_AMOUNT              NUMBER            NOT NULL,
    OPERATION_TYPE                VARCHAR2(120)     NOT NULL,
    VALIDATION_STATUS             VARCHAR2(120) ,
    REFERENCED_STATUS             VARCHAR2(120) ,
    CHARGE_ALLOCATION_STATUS      VARCHAR2(120)     NOT NULL,
    TAX_CALCULATION_STATUS        VARCHAR2(120) ,
    REASON                        VARCHAR2(120) ,
    SCHEDULES_ALLOCATED_FLAG      VARCHAR2(4)       NOT NULL,
    CMR_INTERFACED_FLAG           VARCHAR2(4)   ,
    INVOICE_INTERFACED_FLAG       VARCHAR2(4)   ,
    EXTERNAL_SYSTEM_REFERENCE     VARCHAR2(960) ,
    EXTERNAL_SYSTEM_REF_ID        VARCHAR2(120) ,
    ISSUING_PURPOSE               VARCHAR2(120) ,
    TYPE_OF_DEBIT                 VARCHAR2(40)  ,
    TYPE_OF_CREDIT                VARCHAR2(40)  ,
    REQUEST_ID                    NUMBER(18, 0) ,
    JOB_DEFINITION_NAME           VARCHAR2(400) ,
    JOB_DEFINITION_PACKAGE        VARCHAR2(3600),
    CREATED_BY                    VARCHAR2(256)     NOT NULL,
    CREATION_DATE                 TIMESTAMP(6)      NOT NULL,
    LAST_UPDATED_BY               VARCHAR2(256)     NOT NULL,
    LAST_UPDATE_DATE              TIMESTAMP(6)      NOT NULL,
    LAST_UPDATE_LOGIN             VARCHAR2(128) ,
    ATTRIBUTE_CATEGORY            VARCHAR2(120) ,
    ATTRIBUTE_CHAR1               VARCHAR2(600) ,
    ATTRIBUTE_CHAR2               VARCHAR2(600) ,
    ATTRIBUTE_CHAR3               VARCHAR2(600) ,
    ATTRIBUTE_CHAR4               VARCHAR2(600) ,
    ATTRIBUTE_CHAR5               VARCHAR2(600) ,
    ATTRIBUTE_CHAR6               VARCHAR2(600) ,
    ATTRIBUTE_CHAR7               VARCHAR2(600) ,
    ATTRIBUTE_CHAR8               VARCHAR2(600) ,
    ATTRIBUTE_CHAR9               VARCHAR2(600) ,
    ATTRIBUTE_CHAR10              VARCHAR2(600) ,
    ATTRIBUTE_CHAR11              VARCHAR2(600) ,
    ATTRIBUTE_CHAR12              VARCHAR2(600) ,
    ATTRIBUTE_CHAR13              VARCHAR2(600) ,
    ATTRIBUTE_CHAR14              VARCHAR2(600) ,
    ATTRIBUTE_CHAR15              VARCHAR2(600) ,
    ATTRIBUTE_CHAR16              VARCHAR2(600) ,
    ATTRIBUTE_CHAR17              VARCHAR2(600) ,
    ATTRIBUTE_CHAR18              VARCHAR2(600) ,
    ATTRIBUTE_CHAR19              VARCHAR2(600) ,
    ATTRIBUTE_CHAR20              VARCHAR2(600) ,
    ATTRIBUTE_NUMBER1             NUMBER        ,
    ATTRIBUTE_NUMBER2             NUMBER        ,
    ATTRIBUTE_NUMBER3             NUMBER        ,
    ATTRIBUTE_NUMBER4             NUMBER        ,
    ATTRIBUTE_NUMBER5             NUMBER        ,
    ATTRIBUTE_NUMBER6             NUMBER        ,
    ATTRIBUTE_NUMBER7             NUMBER        ,
    ATTRIBUTE_NUMBER8             NUMBER        ,
    ATTRIBUTE_NUMBER9             NUMBER        ,
    ATTRIBUTE_NUMBER10            NUMBER        ,
    ATTRIBUTE_DATE1               DATE          ,
    ATTRIBUTE_DATE2               DATE          ,
    ATTRIBUTE_DATE3               DATE          ,
    ATTRIBUTE_DATE4               DATE          ,
    ATTRIBUTE_DATE5               DATE          ,
    ATTRIBUTE_TIMESTAMP1          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP2          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP3          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP4          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP5          TIMESTAMP(6)  ,
    DOCUMENT_HEADER_ID            NUMBER(18, 0) ,
    INTERFACED_FLAG               VARCHAR2(4)   ,
    PARENT_DOCUMENT_HEADER_ID     NUMBER(18, 0) ,
    OBJECT_VERSION_NUMBER         NUMBER(9, 0)      NOT NULL,
    DOCUMENT_NUMBER               VARCHAR2(120)     NOT NULL,
    ACCESS_KEY_NUMBER             VARCHAR2(256) ,
    ISSUE_DATE                    DATE              NOT NULL,
    ACKNOWLEDGED_DATE             DATE          ,
    MODEL                         VARCHAR2(120)     NOT NULL,
    SERIES                        VARCHAR2(40)      NOT NULL,
    SUBSERIES                     VARCHAR2(40)  ,
    SOURCE_DOCUMENT_TYPE          VARCHAR2(120)     NOT NULL,
    DOCUMENT_TYPE                 VARCHAR2(120)     NOT NULL,
    ISSUER_TAX_ID                 NUMBER(18, 0)     NOT NULL,
    ISSUER_PARTY_ID               NUMBER(18, 0)     NOT NULL,
    ISSUER_PARTY_SITE_ID          NUMBER(18, 0)     NOT NULL,
    ISSUER_LOCATION_ID            NUMBER(18, 0)     NOT NULL,
    COUNTRY_CODE                  VARCHAR2(8)   ,
    RECEIVER_TAX_ID               NUMBER(18, 0) ,
    RECEIVER_PARTY_ID             NUMBER(18, 0)     NOT NULL,
    RECEIVER_PARTY_SITE_ID        NUMBER(18, 0)     NOT NULL,
    RECEIVER_LOCATION_ID          NUMBER(18, 0)     NOT NULL,
    SHIPTO_TAX_ID                 NUMBER(18, 0)     NOT NULL,
    SHIPTO_PARTY_ID               NUMBER(18, 0)     NOT NULL,
    SHIPTO_PARTY_SITE_ID          NUMBER(18, 0)     NOT NULL,
    SHIPTO_LOCATION_ID            NUMBER(18, 0)     NOT NULL,
    SHIPFROM_TAX_ID               NUMBER(18, 0) ,
    SHIPFROM_PARTY_ID             NUMBER(18, 0)     NOT NULL,
    SHIPFROM_PARTY_SITE_ID        NUMBER(18, 0)     NOT NULL,
    SHIPFROM_LOCATION_ID          NUMBER(18, 0)     NOT NULL,
    CURRENCY                      VARCHAR2(120)     NOT NULL,
    CONVERSTION_TYPE              VARCHAR2(120)     NOT NULL,
    CONVERSION_RATE               NUMBER        ,
    TOTAL_AMOUNT                  NUMBER            NOT NULL,
    ITEM_LINE_AMOUNT              NUMBER            NOT NULL,
    OPERATION_TYPE                VARCHAR2(120)     NOT NULL,
    DOCUMENT_STATUS               VARCHAR2(120)     NOT NULL,
    VALIDATION_STATUS             VARCHAR2(120) ,
    REFERENCED_STATUS             VARCHAR2(120) ,
    CHARGE_ALLOCATION_STATUS      VARCHAR2(120)     NOT NULL,
    REASON                        VARCHAR2(120) ,
    TAX_CALCULATION_STATUS        VARCHAR2(120) ,
    SCHEDULES_ALLOCATED_FLAG      VARCHAR2(4)       NOT NULL,
    CMR_INTERFACED_FLAG           VARCHAR2(4)   ,
    INVOICE_INTERFACED_FLAG       VARCHAR2(4)   ,
    BILL_TO_BUSINESS_UNIT_ID      NUMBER(18, 0)     NOT NULL,
    SOLD_TO_LEGAL_ENTITY_ID       NUMBER(18, 0)     NOT NULL,
    FISCAL_DOC_ASSOCTNS_ID        NUMBER(18, 0)     NOT NULL,
    FISCAL_PROC_OPTIONS_ID        NUMBER(18, 0)     NOT NULL,
    EXTERNAL_SYSTEM_REFERENCE     VARCHAR2(960) ,
    EXTERNAL_SYSTEM_REF_ID        VARCHAR2(120) ,
    REQUEST_ID                    NUMBER(18, 0) ,
    JOB_DEFINITION_NAME           VARCHAR2(400) ,
    JOB_DEFINITION_PACKAGE        VARCHAR2(3600),
    CREATED_BY                    VARCHAR2(256)     NOT NULL,
    CREATION_DATE                 TIMESTAMP(6)      NOT NULL,
    LAST_UPDATED_BY               VARCHAR2(256)     NOT NULL,
    LAST_UPDATE_DATE              TIMESTAMP(6)      NOT NULL,
    LAST_UPDATE_LOGIN             VARCHAR2(128) ,
    ATTRIBUTE_CATEGORY            VARCHAR2(120) ,
    ATTRIBUTE_CHAR1               VARCHAR2(600) ,
    ATTRIBUTE_CHAR2               VARCHAR2(600) ,
    ATTRIBUTE_CHAR3               VARCHAR2(600) ,
    ATTRIBUTE_CHAR4               VARCHAR2(600) ,
    ATTRIBUTE_CHAR5               VARCHAR2(600) ,
    ATTRIBUTE_CHAR6               VARCHAR2(600) ,
    ATTRIBUTE_CHAR7               VARCHAR2(600) ,
    ATTRIBUTE_CHAR8               VARCHAR2(600) ,
    ATTRIBUTE_CHAR9               VARCHAR2(600) ,
    ATTRIBUTE_CHAR10              VARCHAR2(600) ,
    ATTRIBUTE_CHAR11              VARCHAR2(600) ,
    ATTRIBUTE_CHAR12              VARCHAR2(600) ,
    ATTRIBUTE_CHAR13              VARCHAR2(600) ,
    ATTRIBUTE_CHAR14              VARCHAR2(600) ,
    ATTRIBUTE_CHAR15              VARCHAR2(600) ,
    ATTRIBUTE_CHAR16              VARCHAR2(600) ,
    ATTRIBUTE_CHAR17              VARCHAR2(600) ,
    ATTRIBUTE_CHAR18              VARCHAR2(600) ,
    ATTRIBUTE_CHAR19              VARCHAR2(600) ,
    ATTRIBUTE_CHAR20              VARCHAR2(600) ,
    ATTRIBUTE_NUMBER1             NUMBER        ,
    ATTRIBUTE_NUMBER2             NUMBER        ,
    ATTRIBUTE_NUMBER3             NUMBER        ,
    ATTRIBUTE_NUMBER4             NUMBER        ,
    ATTRIBUTE_NUMBER5             NUMBER        ,
    ATTRIBUTE_NUMBER6             NUMBER        ,
    ATTRIBUTE_NUMBER7             NUMBER        ,
    ATTRIBUTE_NUMBER8             NUMBER        ,
    ATTRIBUTE_NUMBER9             NUMBER        ,
    ATTRIBUTE_NUMBER10            NUMBER        ,
    ATTRIBUTE_DATE1               DATE          ,
    ATTRIBUTE_DATE2               DATE          ,
    ATTRIBUTE_DATE3               DATE          ,
    ATTRIBUTE_DATE4               DATE          ,
    ATTRIBUTE_DATE5               DATE          ,
    ATTRIBUTE_TIMESTAMP1          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP2          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP3          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP4          TIMESTAMP(6)  ,
    ATTRIBUTE_TIMESTAMP5          TIMESTAMP(6)  ,
    SOURCE_REF_DOC_HEADER_ID      NUMBER(18, 0) ,
    SHIPFROM_IBGE_CITY_CODE       VARCHAR2(1440),
    SHIPFROM_IBGE_CITY_ID         NUMBER(18, 0) ,
    SHIPTO_IBGE_CITY_CODE         VARCHAR2(1440),
    SHIPTO_IBGE_CITY_ID           NUMBER(18, 0) ,
    INVOICE_ID                    NUMBER(18, 0) ,
    INVOICE_NUM                   VARCHAR2(200) ,
    DOCUMENT_UNIQUE_IDENTIFIER    VARCHAR2(480) ,
    INTEREST_INDICATOR            VARCHAR2(4)   ,
    ISSUING_PURPOSE               VARCHAR2(120) ,
    TYPE_OF_DEBIT                 VARCHAR2(40)  ,
    TYPE_OF_CREDIT                VARCHAR2(40)  ,
    CONSTRAINT pk_cmf_fiscal_doc_headers PRIMARY KEY (DOCUMENT_HEADER_ID, DOCUMENT_HEADER_ID)
);
