> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# SCR 3040

> Generate the SCR Documento 3040 from the Reporter regulatory catalog, with Lender data and Lerian's reference mapping.

The Reporter regulatory catalog has the document `br.bcb.scr-3040` (SCR Documento 3040, individual credit-risk data). The document is monthly and its file is XML. It is for an SCD or an SCFI that runs Lender. The catalog publishes its contract, a manual, and a reference mapping from Lerian.

> [!WARNING]
>
> Do not send to BACEN a file that Reporter generates from this document. The manual of the document in the regulatory catalog says that the file is not ready to send.

The reference mapping reads three data sources:

* **Lender**: the three views of the [SCR reporting dataset](https://docs.lerian.studio/en/products/lender/brazil-regulatory-pack.md#scr-reporting-dataset).
* **Midaz onboarding**: the organization, which gives the CNPJ of the institution.
* **Midaz CRM**: the holders. Lender publishes no CPF, CNPJ, or name of a holder, so Reporter reads the document and the type of each holder from the CRM and joins them to the Lender rows in memory.

The file has the header, the clients, the operations, the maturities, and the guarantees. It also has the additional information 1002 and 1701, and the exit information of an operation that left the institution in the month.

## Prepare the data

***

1. Turn on the publication job of Lender, and keep the daily provision measurement on. See [SCR reporting dataset](https://docs.lerian.studio/en/products/lender/brazil-regulatory-pack.md#scr-reporting-dataset).
2. Declare the SCR modality of each Brazilian product version in Lender, before the first reference month (BACEN: *data-base*). Reporter does not generate the file while a contract has no modality.
3. The reference mapping reads the data sources named `lender` (the Lender database of the tenant), `midaz_onboarding`, and `plugin_crm` (the Midaz CRM). Check that the three are on the [Data Sources](https://docs.lerian.studio/en/products/reporter/console/managing-data-sources.md) page.
4. In the [scope of the institution](https://docs.lerian.studio/en/products/reporter/console/managing-institutions.md#scope-rules), add the three views to the Lender data source, under the table names that the mapping uses. The reference mapping names them `scr_operation_current`, `scr_maturity_current`, and `scr_guarantee_current`, with no schema. For each view, add the condition `midaz_organization_id` **is** the organization of the institution. The proposal from Midaz does not cover these views, so write this scope by hand. The scope must also cover the `organization` table of `midaz_onboarding`, with the condition `id` **is** the organization of the institution. In `plugin_crm`, add the `holders` table with the condition `organization_id` **is** the organization of the institution. Reporter refuses the generation when the scope does not cover a table that the mapping reads.

Lerian operations grants the Reporter read on the three views.

## Activate the document

***

When you [activate the document](https://docs.lerian.studio/en/reference/products/reporter/create-subscription.md), Reporter pins its version and writes the starting mapping of the subscription. The starting mapping is the reference mapping. To activate the document in the Lerian Console, see [Regulatory Filing](https://docs.lerian.studio/en/products/reporter/console/regulatory-filing.md).

Reporter finds a table with no schema in its name when one schema of the data source holds it. Reporter looks for a table with a schema in its name only in that schema. When more than one schema of the data source holds a Lender view, [edit the mapping](https://docs.lerian.studio/en/reference/products/reporter/replace-subscription-mapping.md) and write each table with its schema (`<schema>__<view>`). When the mapping names a schema that does not hold a view, edit the mapping and write the view with no schema. Write the same names in the scope of the institution.

## Generate the file

***

The document has two parameters:

* `dataBase`: the reference month, as `YYYY-MM`. Reporter accepts a closed month only.
* `remessa`: the number of the remittance in the reference month, `1` by default. Two generations of one reference month are the same filing, and Reporter sets no original or replacement rule. For a new remittance of a reference month, enter the next number yourself.

## Fields that you fill

***

The reference mapping leaves ten required fields to the institution. Give each one a value in the mapping: write the `value` of the field, or connect a source to it. A `value` is the same in every row of the group. For a field that differs by client or by operation, connect a source to it, or [correct the draft](https://docs.lerian.studio/en/reference/products/reporter/correct-regulatory-report.md) of a filing. Until a field has a value, Reporter leaves it blank, and the filing cannot be approved.

| Group | Fields |
| - | - |
| `Doc3040`: the header | `NomeResp`, `EmailResp`, `TelResp`, `MetodApPE`, `MetodDifTJE` |
| `Cli`: the client | `Autorzc`, `PorteCli`, `FatAnual` |
| `Op`: the operation | `OrigemRec`, `CEP` |

## What you do

***

* Read the [manual](https://docs.lerian.studio/en/reference/products/reporter/read-the-manual-of-the-version-this-subscription-files.md) of the version that you generate. It states what the mapping reads and what the version does not cover.
* Run the official validator of BACEN on the file. Reporter does not check the file against the XSD of the document.
* Review each `Draft` before you approve it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.