This flow is a suggested interpretation of the Dataprev manuals for Crédito do Trabalhador. The manuals prevail over this page. Your institution validates the flow and implements it on the Lerian APIs. See how to read the diagrams.
Participants
- Your institution. The financial institution that holds the loans and makes the new one.
- Lerian. Lerian Consignado. It exchanges the requests with Dataprev, and exposes the API your institution uses.
- Dataprev. Runs the Crédito do Trabalhador system: the loan auctions and the registry of payroll loans.
Diagram
Steps
Each contract to settle must be a contract that Lerian holds for your institution: registered through Lerian, or imported with
POST /v1/consignado/contracts/{numero_contrato}/import. Any other contract answers 404, and Lerian does not call Dataprev. The same holds for a contract that the follow-up read of Lerian shows at Dataprev as excluded, ended or closed by renegotiation. With FGTS collateral, a refinancing settles one contract. When temGarantias is false, leave out the three FGTS collateral values, and never send 0. Lerian refuses them with 422 before it calls Dataprev.
Add the optional booking block to book the new contract at Lender. Lerian never sends it to Dataprev. The block has loan_product_version, expected_disbursement_date, formalization_deadline and margin_snapshot, and an optional origination_fee_amount. Send all the members, and leave out origination_fee_amount when there is no fee. With the block, competenciaInicioDesconto is required. valorEmprestimo less valorIOF and less the fee must equal valorPago plus valorTroco, or the request answers 422 DECLARED_TERMS_INCONSISTENT. Lerian answers 422 with the booking codes of the averbação to any other booking that Lender would refuse. Without the block, the new contract exists only at Dataprev, and Lender books nothing.
Lerian reports the outstanding balance of the new contract to Dataprev. For each settled contract, it sends a final balance of 0.00.
You can reverse only a refinancing that Lerian registered.
Lerian publishes three facts for a refinancing that goes through it. consignado.refinanciamento.efetivado carries the new contract, the settled contracts and the accepted terms. With booking, it also carries novo_contrato, in the shape of consignado.contract.registered. consignado.refinanciamento.revertido says that a reversal excluded the new contract, also one made on the Dataprev portal that the follow-up read of Lerian finds. consignado.refinanciamento.recusado says that the refinancing was refused or executed nothing, and names the contracts that stay active. A refinancing made outside Lerian publishes nothing.
With booking, Lerian publishes novo_contrato only on terms that Dataprev confirmed. If Dataprev confirms another competenciaInicioDesconto, the request answers 503 OUTCOME_UNKNOWN and Lerian parks the command. Recovery publishes efetivado only when its read of the new contract shows the booked terms.
If the answer does not settle the command, Lerian parks it in outcome_unknown and answers 503 OUTCOME_UNKNOWN. Do not send the command again under a new key. The same key meets RAIL_COMMAND_OUTCOME_UNRESOLVED, which means that Lerian does not know the outcome yet. Read the command with GET /v1/consignado/rail-commands.
If recovery cannot decide, your back office closes the parked command with POST /v1/consignado/rail-commands/{id}/close. Send outcome (accepted or refused) and portal_evidence, which states what the Dataprev portal shows. The call answers 204. A close as accepted makes Lerian read the new contract at Dataprev once. A close as refused reads nothing, frees the new contract number, and publishes consignado.refinanciamento.recusado with reason_code GW-BANCO-RECUSADO. A command parked for less than 5 minutes answers 409 RAIL_COMMAND_NOT_CLOSEABLE.
When nothing ran at Dataprev, Lerian closes the command refused. A 503 DATAPREV_UNAVAILABLE whose detail says so means that the call never left Lerian, or that Dataprev answered only OZ, its competência-turnover code. A 422 with the Dataprev codes in upstream means that the codes prove nothing ran. Send a corrected request under a new key. The code RAIL_COMMAND_ALREADY_REFUSED means that the command under the old key closed refused, by Dataprev or before it reached Dataprev.
How you know it finished
Row 4 returns the new contract number and the settled contracts, and Lerian publishes
consignado.refinanciamento.efetivado.

