I'd also put the device id into the record, because generating unique IDs is not that trivial - but generating incrementing IDs for each device would yield unique ids when combined with the device id.
(logical clock, device, operation)
...and also adding the UTC timestamp to that: (logical clock, device, utc timestamp, operation)
The operation is the serialized form of an object of type Command. Each operation (set budget, add transaction etc.) has a it's own Command (i.e. SetBudgetCommand inherits from Command; AddTransactionCommand inherits from command).
These commands can be executed on a command bus, which then performs the corresponding actions (after checking the precondition that must be met for each command). They also contain properties/fields for all the required data (essentially they wrap both the arguments of a method call, as well as describing the method call).
The following is mostly my thought process when looking at the example:
In your third step, D2 would pull the entire history from D1 (i.e. IDs 1, 3 and 5). It then sees that it has ID1 already, but not ID 3 and 5.
So first D2 would have to determine when 3 and 5 happened. They must have happened after 1, because otherwise D2 would have seen them already.
If we can rely on the timestamps, we might see that ts(2) < ts(3) < ts(5). Therefore the order must be: 1, 2, 3, 4, 5.
In that order, we check the preconditions.
1: Still valid
2: still valid
3: not valid, conflict
5: not valid, conflict
If we resolve the conflict on 3 by letting 3 win, then we somehow have to note that (mark 2 invalid or add a compensating operation before 3 to tell 3 "hey, your precondition should be X" or some other way?)
If we resolve the conflict on 3 by letting 2 win, then we have to mark 3 as invalid... but what about 5? That would yield yet another conflict...
When resolving conflicts, we would have to look at the last resulting state (i.e. total budget in that category) for each device and possibly present those to the user. Then we have to figure out how to reach that state.