I have a managed travel expense app with an AggregateResult SOQL
that sums up Expenses per Day. All expenses can have different currencies and don't have to match the corporate nor the current users currency.
public with sharing class CtrlExt {
...
Map<Date, Decimal> expensesPerDay = new Map<Date, Decimal>();
for(AggregateResult ar : [SELECT dat_DatField__c day, SUM(cur_Amount__c) sum FROM Expense__c GROUP BY dat_DatField__c]) {
Date day = (Date) ar.get('day');
Decimal daySum = (Decimal) ar.get('sum');
expensesPerDay.put(day, daySum);
}
...
}
My questions are:
- Does
daySum
take all the different currencies into account? - The resulting Decimal
daySum
implicitly uses which Currency? Org, User? - If I write the value of
daySum
into a Currency field would the Currency Iso Code be automaticall set correctly ? Correctly means that if I display it with on a VF page would the Currency and the value be what the user expects?