Item and stock valuation Error

Description of the issue

I am using Erpnext version 13.5.1, and facing an issue with calculating the items valuation rate, I am using FIFO on the stock valuation method setting, it seems that it calculates the valuation as average, as an example, the image below shows an item which has only two purchase prices (117, 143) but it gives a faulty stock balance value and makes a weird drop on the incoming rate, as shown in the following image:

Context information (for bug reports)

Screenshot (8)

On the third row, the stock qty is 5 but it gives stock valuation as if it is 1 piece (5 pcs * 117 rate, should be 585, but it shows 117).
On the 4th and 5th rows, the valuation rate has become 23 and 70 which is faulty and does not exist in reality.

Output of bench version

erpnext 13.5.1
frappe 13.5.1

OS 20.04/ubuntu, ERPNext install method, etc.