Once the real costs can be charged, the deposit paid by the guest on forehand should be settled with the costs to be paid.
01. Book deposit/advance payment reverse
To settle the deposit/advanced payment the guest already paid for, an extra has to be added to the reservation having the value in negative of the deposit/advanced payment that's already in the reservation.
This easily could be done in CICO as well on Check-out by adding the same extra for number = -1.