frm.toggle_display("set_exchange_gain_loss",
(frm.doc.paid_amount && frm.doc.received_amount && frm.doc.difference_amount &&
((frm.doc.paid_from_account_currency != company_currency ||
frm.doc.paid_to_account_currency != company_currency) &&
frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency)));
I feel this is a lack of understanding of business logic.
In reality whenever any currency is different from Company Currency there can be a exchange gain/loss and button should appear.
With payments of non-company currency Z invoices to/from non-company currency Z accounts we have to manually enter the difference amount to the exchange gain/loss account to accomplish same purpose.
Much easier if button appeared.