I need to compare QuoteLineItems and Opportunity Products in a trigger, but the queried rows amounts are being automatically converted to user-profile's currency, failing my comparison. How can I force queries to not convert the amounts?
My opportunities are being registered in USD. Some users have another currency in their profile. I have in my trigger a comparison between QuoteLineItem and its corresponding OpportunityProduct that checks their UnitPrice. These are the queries:
String qliQuery = 'select Id, QuoteId, PricebookEntryId, UnitPrice, Quantity, Discount, ServiceDate, SortOrder, CurrencyIsoCode' + qliFields + ' from QuoteLineItem where Id in (' + qliIds + ') order by QuoteId, SortOrder ASC'; List<QuoteLineItem> qlis = Database.query(qliQuery);
String oliQuery = 'select Id, OpportunityId, PricebookEntryId, UnitPrice, Quantity, Discount, ServiceDate, SortOrder, CurrencyIsoCode' + oliFields + ' from OpportunityLineItem where OpportunityId in (' + oppIds + ') order by OpportunityId, SortOrder ASC'; List<OpportunityLineItem> olis = Database.query(oliQuery);
My comparison fails in their UnitPrice, with the difference being exactly the currency conversion rate between those two currencies. I checked both CurrencyIsoCode values but both are USD.
Another interesting fact: this is a trigger responsible for syncing custom fields between Opportunity Products and QuoteLineItems. The UnitPrice amounts are not converted when some of the synced fields are populated.
I don't know why it is doing this conversion, but is there some way to force queries not to convert it?