Skip to content

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 JSON format.
  • Each event contains an eventType field 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
ParameterValue
Event TypeCONTRACT_SAVE
Routing Keycore.entity.contract.save
API MethodPOST /main/contracts
Formation ConditionsContract created, status — "New", creationDate field is filled

Event body example:

json
{
  "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
ParameterValue
Event TypeCONTRACT_SAVE
Routing Keycore.entity.contract.save
API MethodPUT /main/contracts/{id}
Formation ConditionsContract data changed before issuance, status remains "New", creationDate is not null

Event body example:

json
{
  "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
ParameterValue
Event TypeMAKE_CONTRACT_ISSUE
Routing Keycore.entity.contract.make_contract_issue
SourcesUI ("For Issuance" checkbox), API Method - PUT /main/contracts/{id}
Formation ConditionsField "forIssue": true, and forIssueSetupDate is automatically set

Event body example:

json
{
  "eventType": "MAKE_CONTRACT_ISSUE",
  "id": 4596
}

Important! When setting the "For Issuance" flag, two events are generated simultaneously:

  1. MAKE_CONTRACT_ISSUE
  2. CONTRACT_SAVE with modificationType: 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
ParameterValue
Event TypeFUNDTRANSACTION_SAVE
API MethodsCreate cash flow POST /fund-transactions?autoaccept=false, then process acceptance POST /fund-transactions/{id}/autoaccept

Event body example:

json
{
  "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
ParameterValue
Event TypeCONTRACT_NEW_SCHEDULE
ConditionAfter creation, cash flow acceptance, and at the moment of initial schedule calculation

Event body example:

json
{
  "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:

json
{
  "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 issueDate is set

Event body example:

json
{
  "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:

json
{
  "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:

json
{
  "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:

json
{
  "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:

  1. FUNDTRANSACTION_SAVE (creating income cash flow)
  2. 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:

  1. FUNDTRANSACTION_SAVE (creating income cash flow)
  2. CONTRACT_STATUS_CHANGED (possible status change)
  3. CONTRACT_BALANCE_CHANGED (write-off)
  4. CONTRACT_REPAYMENT (repayment recording)
  5. CONTRACT_BALANCE_CHANGED (additional change)
  6. 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:

json
{
  "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:

  1. CONTRACT_STATUS_CHANGED
  2. CONTRACT_BALANCE_CHANGE_ROLLBACK
  3. CONTRACT_REPAYMENT_ROLLBACK

Event body example:

json
{
  "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:

  1. CONTRACT_STATUS_CHANGED
  2. CONTRACT_BALANCE_CHANGED (interest)
  3. CONTRACT_BALANCE_CHANGED (other amounts)
  4. CONTRACT_REPAYMENT (if adjustment was made)
  5. CONTRACT_NEW_SCHEDULE
  6. CONTRACT_BALANCE_CHANGED (final update)

Event body example:

json
{
  "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:

  1. CONTRACT_BALANCE_CHANGED
  2. CONTRACT_STATUS_CHANGED
  3. CONTRACT_SCHEDULE_DELETED
  4. CONTRACT_BALANCE_CHANGE_ROLLBACK

Event body example:

json
{
  "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:

  1. CONTRACT_SAVE (UPDATED)
  2. CONTRACT_NEW_SCHEDULE (firstSchedule: false)
  3. CONTRACT_PROLONGATION
  4. CONTRACT_STATUS_CHANGED
  5. CONTRACT_BALANCE_CHANGED

Event body example:

json
{
  "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:

  • 101481 Repaid
  • 101482 Restructured
  • 101483 Written off
  • 101484 Adjusted
  • 101485 Written off by cession
  • 101486 Cancelled
  • 101487 For realization

Up to 2 interrelated events are generated:

  1. CONTRACT_CLOSE
  2. CONTRACT_BALANCE_CHANGED

Event body example:

json
{
  "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:

json
{
  "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:

  1. CONTRACT_BALANCE_CHANGE_ROLLBACK
  2. CONTRACT_SCHEDULE_DELETED
  3. CONTRACT_DELETE

Event body example:

json
{
  "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:

json
{
  "eventType": "CONTRACT_INCOMING_CESSION_TRANSFER",
  "id": 4596
}