Create material Issue with old date cause to wrong bin values

We want to create material issues with an old date but the system after running the repost item valuation
to correct the valuation rate and stock in the bin, the code changes the bin to the wrong values and decreases the stock in the bin

So after the code finishes the bin does not equal the stock ledgers report.

An example:
this is in the items


and here in the stock ledger report:

ERPNext: v13.36.2 (version-13)
Frappe Framework: v13.36.3 (version-13)
i put some print in update_bin functuin to check what is going on i see this:

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0007532 
{'actual_qty': 384.0, 'stock_value': 9774.9} 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0006556
{'actual_qty': 3.0, 'stock_value': 87.87}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0001587
{'actual_qty': 30.0, 'stock_value': 797.4}

this is when it checks the correct warehouse (BIN/0007532) is the affected bin
then

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0006556
{'actual_qty': 25.0, 'stock_value': 636.48}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0007532
{'actual_qty': 35.0, 'stock_value': 1025.15}

then

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0001587
{'actual_qty': 0.0, 'stock_value': 0.0}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0005686
{'actual_qty': 1.0, 'stock_value': 26.58}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ in update_bin
BIN/0007532
{'actual_qty': 0.0, 'stock_value': 0.0}```