Add getDecimalById to fflib_SObjects2

Signed-off-by: WimVelzeboer <william@velzeboer.nl>
This commit is contained in:
WimVelzeboer
2023-04-13 11:10:45 +01:00
parent d32d33ba28
commit 3d9e8fae8a
2 changed files with 31 additions and 0 deletions
@@ -246,6 +246,27 @@ public virtual class fflib_SObjects2
.getDateTimeFieldValues(sObjectField);
}
/**
* @param decimalField The field to use as the Value of the returned Map
* @param idField The field to use as the Key of the returned map
*
* @return Returns a map with the values of two fields
*/
@TestVisible
protected virtual Map<Id, Decimal> getDecimalById(Schema.SObjectField decimalField, Schema.SObjectField idField) {
Map<Id, Decimal> result = new Map<Id, Decimal>();
for (SObject record : getRecords())
{
if (record.get(idField) == null) continue;
result.put(
(Id) record.get(idField),
(Decimal) record.get(decimalField)
);
}
return result;
}
/**
* @param sObjectField The Schema.SObjectField to get the SUM of
*