Sobes.tech
Senior

Are there any adjustments to events? For example, 10 rubles were credited, but it should have been 9. What should be done?

sobes.tech AI

Answer from AI

In systems where financial or other important operations occur, event adjustments are a common practice. If 10 rubles were credited, but it should have been 9, you can't just rewrite the original event to preserve history and ensure auditability.

Typically, the process is as follows:

  1. Create a new event with a negative value to "rollback" the erroneous credit (e.g., -10 rubles).
  2. Create a new corrective event with the correct value (+9 rubles).

This way, the history of changes is preserved, and it is possible to track what was corrected and when.

An example in Java (simplified):

class Event {
    String id;
    int amount; // in kopecks or cents
    LocalDateTime timestamp;
    String description;
}

// Correction
Event original = new Event("evt123", 1000, LocalDateTime.now(), "Credit");
Event correctionNegative = new Event("evt124", -1000, LocalDateTime.now(), "Rollback erroneous credit");
Event correctionPositive = new Event("evt125", 900, LocalDateTime.now(), "Corrected credit");

This approach ensures transparency and auditability.