Sales return stock valuation on perpetual inventory - possible bug?

I’ve been checking the erpnext docs on sales return and regarding stock valuation it says " To maintain correct stock valuation, stock balance will go up according to the original purchase rate of the returned items."
I understood this to be the purchase rate of the customer.
But this doesn’t seem to be the case.
I checked one of the returns in my system and incoming rate is not the same as the outgoing rate of original delivery note.
Any idea what’s happening here?

EDIT

OK, I know what’s happening now. The problem comes from backdating stock receipt.

Suppose you sell an item with certain valuation of say $100 at day 1 and make sales return at day 2. The return will correctly pick up original valuation of $100 and create correct stock and general ledger entries.
But then when you create a backdated purchase receipt BEFORE DAY 1 that made the stock valuation at day 1 to change from $100 to $110. The valuation will change correctly for sales invoice but the return invoice’s incoming rate will remain at $100 until cancelled and resubmitted.
Is this intentional or should be considered a bug.

1 Like