Purchase Invoice converted from Purchase Order / Purchase Receipt currency

Might be a bug but not sure. When creating a Purchase Invoice from Purchase Order or Purchase Receipt, if the Currency is NOT a functional currency, the output Purchase Invoice does not copy the correct Currency and instead uses the functional currency.

Then after running Create>>Purchase Invoice

For a split second, after conversion, when the Currency section is expanded, it can be seen that the Currency is correctly set to USD, but then it suddenly becomes PHP. Note that PHP is the functional currency.

Frappe and ERPNext version is v13.18.0. Has anyone run into the same issue and has a solution?

When converting PO into PR, the correct currency is carried over. When converting PR to PI, same issue. I’ve done a bit of browser debugging and it seems to change to the incorrect currency when this line of code is ran during the conversion process:

However, I could not pin down the exact line of code when the Currency is replaced.