When you change the item in the sales doctype, the system considers the old sales amounts from the previous item, and puts the difference in the amount in the discount.
WARRING
If u inser a item with $8 of sales price and trade for a item with $10, the item of $10 will get $2 for sales price…
Example
Item A = $ 10
Item B = $2
How to reproduce