Yes. Money is fungible. If you have $100, and you owe $40, and your debt is remitted by $20, you have $80.
Which is the exact same thing as having $100, owing $40, paying $40, and having the person you paid give you $20 back. Again, you have $80.
Trust me, in both cases you have $80...