Credit Contract Lifecycle Events
This document describes the key events occurring during the credit contract lifecycle. Each event is recorded as a separate object in the system and sent via the message bus with the specified routingKey and eventType. Special attention is given to the sequence and interrelation of events, as well as their sources.
General Principles:
- All events are generated in
JSONformat. - Each event contains an
eventTypefield that defines the event type. - Events are published to the message broker (RabbitMQ) with the corresponding
routingKey. - Despite the logical sequence, each event is independent and processed separately.
1. Contract Creation
- Event:
CONTRACT_SAVE(CREATED) - Contract saved - routingKey:
core.entity.contract.save - eventType:
CONTRACT_SAVE(in header and message body) - long id: contract id
- Modification type:
CREATED
| Parameter | Value |
|---|---|
| Event Type | CONTRACT_SAVE |
| Routing Key | core.entity.contract.save |
| API Method | POST /main/contracts |
| Formation Conditions | Contract created, status — "New", creationDate field is filled |
Event body example:
{
"eventType": "CONTRACT_SAVE",
"id": 4596,
"modificationType": "CREATED"
}Note:
id— contract identifier.modificationType: CREATED— indicates creation of a new contract.
2. Contract Editing
- Event:
CONTRACT_SAVE(UPDATED) - Contract saved - routingKey:
core.entity.contract.save - eventType:
CONTRACT_SAVE(in header and message body) - long id: contract id
- Modification type:
UPDATED
| Parameter | Value |
|---|---|
| Event Type | CONTRACT_SAVE |
| Routing Key | core.entity.contract.save |
| API Method | PUT /main/contracts/{id} |
| Formation Conditions | Contract data changed before issuance, status remains "New", creationDate is not null |
Event body example:
{
"eventType": "CONTRACT_SAVE",
"id": 4596,
"modificationType": "UPDATED"
}Note: This event is generated for any contract change before its issuance.
3. Setting "For Issuance" Status
- Event:
MAKE_CONTRACT_ISSUE- Contract for issuance (core) - routingKey:
core.entity.contract.make_contract_issue - eventType:
MAKE_CONTRACT_ISSUE(in header and message body) - long id: contract id
| Parameter | Value |
|---|---|
| Event Type | MAKE_CONTRACT_ISSUE |
| Routing Key | core.entity.contract.make_contract_issue |
| Sources | UI ("For Issuance" checkbox), API Method - PUT /main/contracts/{id} |
| Formation Conditions | Field "forIssue": true, and forIssueSetupDate is automatically set |
Event body example:
{
"eventType": "MAKE_CONTRACT_ISSUE",
"id": 4596
}Important! When setting the "For Issuance" flag, two events are generated simultaneously:
MAKE_CONTRACT_ISSUECONTRACT_SAVEwithmodificationType: UPDATED
3.1. Setting "For Issuance" Status During Auto-Issuance via Personal Account
Similar to the previous one, but the event is initiated from the payer's personal account gateway.
- Event:
MAKE_CONTRACT_ISSUE - routingKey:
core.entity.contract.make_contract_issue - Logic: Identical, only the source is an external service.
4. Contract Issuance
The contract issuance process includes several interrelated but independent events.
4.1. Creating Expense Cash Flow
- Event:
FUNDTRANSACTION_SAVE- FundTransaction saved - routingKey:
core.entity.fundtransaction.save
| Parameter | Value |
|---|---|
| Event Type | FUNDTRANSACTION_SAVE |
| API Methods | Create cash flow POST /fund-transactions?autoaccept=false, then process acceptance POST /fund-transactions/{id}/autoaccept |
Event body example:
{
"eventType": "FUNDTRANSACTION_SAVE",
"id": 3762,
"contractId": 4596
}Note: This event indicates the creation and acceptance (approval) of an expense cash flow transaction.
4.2. Creating the First Payment Schedule
- Event:
CONTRACT_NEW_SCHEDULE- New schedule created for contract - routingKey:
core.entity.contract.new_schedule
| Parameter | Value |
|---|---|
| Event Type | CONTRACT_NEW_SCHEDULE |
| Condition | After creation, cash flow acceptance, and at the moment of initial schedule calculation |
Event body example:
{
"eventType": "CONTRACT_NEW_SCHEDULE",
"id": 4596,
"firstSchedule": true
}Note:
firstSchedule: true— this is the first schedule;false— subsequent.
4.3. Contract Status Change
- Event:
CONTRACT_STATUS_CHANGED - routingKey:
core.entity.contract.status_changed - Status change: from "New" to "Normal" (
contractStatusId: 101281)
Event body example:
{
"eventType": "CONTRACT_STATUS_CHANGED",
"id": 4596,
"contractStatusId": 101281,
"statusDate": 1757451600000
}Note:
statusDate— status change date in Unix timestamp (ms).
4.4. The Issuance Event Itself
- Event:
CONTRACT_ISSUE- Contract issued - routingKey:
core.entity.contract.contract_issue - Condition: Issue date
issueDateis set
Event body example:
{
"eventType": "CONTRACT_ISSUE",
"id": 4596
}4.5. Lead Status Change
- Event:
LEAD_STATUS_CHANGE- Lead status changed - routingKey:
core.entity.lead.status_change - New status:
CONTRACT(contract issued)
Event body example:
{
"eventType": "LEAD_STATUS_CHANGE",
"id": 7566,
"status": "CONTRACT"
}Note: Generated simultaneously with contract issuance.
4.6. Contract Balance Change
- Event:
CONTRACT_BALANCE_CHANGED- Contract balance changed - routingKey:
core.entity.contract.balance_changed
Event body example:
{
"eventType": "CONTRACT_BALANCE_CHANGED",
"contractId": 4596,
"amountTypeIds": [101291],
"operations": [{ "id": 38543, "operDate": 1757505192000 }]
}Note:
amountTypeIds— IDs of amount types (e.g., 101291 — Principal). Reflects balance change after issuance.
5. Balance Changes: Main Cases
5.1. Nightly Processing (Interest Accrual)
- Event:
CONTRACT_BALANCE_CHANGED - Description: Daily processing, interest, penalties, etc. are accrued. Balance increases.
Event body example:
{
"eventType": "CONTRACT_BALANCE_CHANGED",
"contractId": 4596,
"amountTypeIds": [101292],
"operations": [{ "id": 38544, "operDate": 1757538061000 }]
}Note:
amountTypeIds: [101292]– amount type "Interest".
5.2. Payment Receipt (Not on Payment Date)
Up to 2 sequential events are generated:
FUNDTRANSACTION_SAVE(creating income cash flow)CONTRACT_BALANCE_CHANGED(balance change)
Note: Process "Repayment with prepayment" -> Operation "Prepayment" -> amount type "Interest prepayment".
5.3. Payment on Payment Date (Repayment)
- Event:
CONTRACT_REPAYMENT- Contract repayments - routingKey:
core.entity.contract.repayment
Up to 6 interrelated events are generated:
FUNDTRANSACTION_SAVE(creating income cash flow)CONTRACT_STATUS_CHANGED(possible status change)CONTRACT_BALANCE_CHANGED(write-off)CONTRACT_REPAYMENT(repayment recording)CONTRACT_BALANCE_CHANGED(additional change)CONTRACT_REPAYMENT(principal and interest repayment)
5.4. Operation Rollback (Deletion)
- Event:
CONTRACT_BALANCE_CHANGE_ROLLBACK- Balance change rollback - routingKey:
core.entity.contract.balance_change_rollback
Event body example:
{
"eventType": "CONTRACT_BALANCE_CHANGE_ROLLBACK",
"contractId": 4596,
"amountTypeIds": [101292],
"operations": [{ "id": 38557, "operDate": 1760205991281 }]
}5.5. Income Cash Flow Repayment Rollback
- Event:
CONTRACT_REPAYMENT_ROLLBACK- Repayment operations rollback - routingKey:
core.entity.contract.repayment_rollback
Up to 3 interrelated events are generated:
CONTRACT_STATUS_CHANGEDCONTRACT_BALANCE_CHANGE_ROLLBACKCONTRACT_REPAYMENT_ROLLBACK
Event body example:
{
"eventType": "CONTRACT_REPAYMENT_ROLLBACK",
"contractId": 4596,
"amountTypeIds": [101291, 101292],
"operations": [
{ "id": 38554, "operDate": 1760086800000 },
{ "id": 38555, "operDate": 1760086800000 }
]
}6. Schedule Recalculation (Additional Services)
- Event:
CONTRACT_NEW_SCHEDULE- New schedule created - routingKey:
core.entity.contract.new_schedule
Supported operations: Deferral, credit holidays, partial early repayment/full early repayment, payment skip, schedule extension.
Up to 6 interrelated events are generated:
CONTRACT_STATUS_CHANGEDCONTRACT_BALANCE_CHANGED(interest)CONTRACT_BALANCE_CHANGED(other amounts)CONTRACT_REPAYMENT(if adjustment was made)CONTRACT_NEW_SCHEDULECONTRACT_BALANCE_CHANGED(final update)
Event body example:
{
"eventType": "CONTRACT_NEW_SCHEDULE",
"id": 4596,
"firstSchedule": false
}7. Deletion (Rollback) of Schedule Recalculation Operation
- Event:
CONTRACT_SCHEDULE_DELETED- Schedule deleted - routingKey:
core.entity.contract.schedule_deleted
Up to 4 interrelated events are generated:
CONTRACT_BALANCE_CHANGEDCONTRACT_STATUS_CHANGEDCONTRACT_SCHEDULE_DELETEDCONTRACT_BALANCE_CHANGE_ROLLBACK
Event body example:
{
"eventType": "CONTRACT_SCHEDULE_DELETED",
"id": 4596,
"scheduleId": 2689,
"scheduleCreationDate": "2025-10-10"
}8. Contract Prolongation
- Event:
CONTRACT_PROLONGATION - routingKey:
core.entity.contract.prolongation
Up to 5 interrelated events are generated:
CONTRACT_SAVE(UPDATED)CONTRACT_NEW_SCHEDULE(firstSchedule: false)CONTRACT_PROLONGATIONCONTRACT_STATUS_CHANGEDCONTRACT_BALANCE_CHANGED
Event body example:
{
"eventType": "CONTRACT_PROLONGATION",
"id": 4596,
"newScheduleCreationDate": "2025-09-11"
}9. Closure (Contract Repayment)
- Event:
CONTRACT_CLOSE- Contract closed - routingKey:
core.entity.contract.close - Conditions: Contract balance equals zero, close date (
closeDate) is set.
Closure statuses:
101481Repaid101482Restructured101483Written off101484Adjusted101485Written off by cession101486Cancelled101487For realization
Up to 2 interrelated events are generated:
CONTRACT_CLOSECONTRACT_BALANCE_CHANGED
Event body example:
{
"eventType": "CONTRACT_CLOSE",
"id": 4596,
"closedStatusId": 101485,
"closeDate": 1757609557000
}10. Contract Restructuring
- Event:
CONTRACT_RESTRUCTURING - routingKey:
core.entity.contract.restructuring
A complex chain of up to 22 interrelated events is generated, including closing the old contract, creating a new lead, application, contract, etc.
Event body example:
{
"eventType": "CONTRACT_RESTRUCTURING",
"id": 4597,
"restructuredId": 4521
}Note:
id: 4597— new contract,restructuredId: 4521— closed contract.
11. Contract Deletion
- Event:
CONTRACT_DELETE- Contract deleted - routingKey:
core.entity.contract.delete - API Method:
DELETE /main/contracts
Up to 3 events are generated if the contract had operations:
CONTRACT_BALANCE_CHANGE_ROLLBACKCONTRACT_SCHEDULE_DELETEDCONTRACT_DELETE
Event body example:
{
"eventType": "CONTRACT_DELETE",
"id": 4597
}12. Contract Purchased by Cession
- Event:
CONTRACT_INCOMING_CESSION_TRANSFER- Cession transfer - routingKey:
core.entity.contract.incoming_cession_transfer - API Method:
/main/contracts/{id}/cession-transfers
Event body example:
{
"eventType": "CONTRACT_INCOMING_CESSION_TRANSFER",
"id": 4596
}