Thanks for the patch.
We've been thinking about this whole issue - here's where we've gotten to.
There may be an issue with your patch approach. That is that FA holds a single rate for each day/date - what happens if there is more than one foreign exchange transaction on that date. I know it works out the amount on the fly for each transaction but the amount may not match the rate stored for that day. No biggie of a problem - but it may confuse the story of what's happening. Also, it may make the Foreign Exchange gain/loss amounts incorrect.
So - this is our current plan.
We run our accounts in GBP. We get an invoice in a foreign currency amount (EUR 200.00) - we add an exchange rate (from exchange rate historical records online) for that invoice date (say 0.75) - enter the invoice - expenses get increased by the equivalent amount in our local currency (GPB 150.00).
So far so good.
Several days later we then pay the invoice using online payment.
Now - we look at the bank statement/online banking and see the exact amount deducted in our local currency - say it comes out as a payment of GBP 161.00.
So, this is how we enter it on FA.
We look up the exchange rate for the payment date - say 0.8.
We enter that rate in the exchange rate table for the payment date.
We create a payment to that supplier for GBP 161.00.
OK so far - the payment of GBP 161.00 will match perfectly on the reconciliation screen.
Now we go to allocate the payment to the original EUR 200.00 invoice.
FA uses the payment date rate of 0.8 to figure out that is needs GBP 160.00 to fully pay the invoice. This leaves GBP 1.00 of the payment as unallocated.
NB - it could be the other way depending on the rates - i.e. it may result in an invoice which is not fully paid.
(It's important to note that the exchange rate we enter for the payment date will hardly ever match the exact rate which was used when the bank made the payment. Rates fluctuate during the day so an exact match is highly unlikely).
The important point to note is that at this point we have an overpayment or an underpayment.
We are going to treat this like any other overpayment or underpayment. We may have a customer who pays us slightly too much - or one who pays slightly too little. If they are a private customer they may not be interested in correcting the payment - and it's not worth our time to chase a small underpayment. I've put up another post at https://frontaccounting.com/punbb/viewtopic.php?id=3982 to work out how to deal with over/under payments.
Please note - if the invoice date and the payment date are the same day then there is no foreign exchange loss or gain as the exchange rate is the same. Any difference between the amount FA calculates for the invoice/payment and the actual payment made will be treated as an over/under payment.
The main point is this. Foreign exchange losses/gains occur due to exchange rate differences between the invoice date and the payment date. Differences in the actual amounts on the allocation screen should be treated as under/over payments.