So, does that mean you have not stored “compare_at_price” on your system?
It will be hard to get the discount value if you are not recording/storing the compare_at_price of products/variants on your own system. Since “Compare at price” field can get changed a lot of times, to have the history of discount, it is better to record them on your own system.
Customer bought 4, the data in the order file is prefect - total price 10.50x4, 2.10x4 and net paid 8.4x4
Line_Item.Price = 10.50
Line_Item.quantity = 4
Discount_Allocations = 8.40
Customer returns 1 unit,
quantity = 1
subtotal field for the return is correct at 8.40
price is correct at 10.50
but the discount_allocation section under returns repeats the entire discount 2.10x4=8.40 instead of 2.10x1=2.10 and this creates an issue when posting the sales into the ERP as no where in the files is per unit discount mentioned and discount appears as 8.40