This is why you have to include a margin in your pricing.
If the sales proceeds equal book value, there is no gain or loss, because the exchange of one asset for another of equal recorded value is not a net inflow of resources.