It has been awhile since I had a template update, but when I catch a logical error, I try to fix it as soon as possible and do a video about exactly what happened so that is what you are getting here.
Original Problem: In the scenario where the asset was being sold at less than the original cost basis, the model was taking the difference in the original cost basis and the sales proceeds and counting that as a loss that offsets depreciation recapture taxable amount. In reality, the depreciation recapture is simply any amount you sell an asset for that is greater than the adjusted cost basis but less than the original cost basis.
Fix: Now, in that same scenario, the correct calculation is happening which is taking the difference between the sales proceeds and the adjusted cost basis (book value or value after accounting for accumulated depreciation) and using that as the only thing to figure out the depreciation recapture amount.
The original model worked perfectly for calculating recapture if you sold the asset for more than the original cost basis or less than the adjusted cost basis. It was that scenario where it is in between where the problem happened.
If you sell for more than the original basis, you just have to pay taxes on the amount of depreciation that was taken. Anything over the original basis still gets taxed at the capital gains tax rate and selling for less than the adjusted cost basis gives you a capital loss.
The main reason I came across this error is because I was looking at what happens if you have a net operating loss carryforward (NOL carry) and if it could be used to offset depreciation recapture due. The answer to that was yes, but now I have also improved the original depreciation recapture template.
Note, there are many caveats to taxes so please consult a tax attorney or CPA for your specific situation.
I've built many templates over the years, check out more accounting tools here and real estate models here.