Add getDecimalFieldSum method to domain
This will summarise the Decimal field value Signed-off-by: WimVelzeboer <wimvelzeboer@protonmail.com>
This commit is contained in:
@@ -249,6 +249,22 @@ public virtual class fflib_SObjects2
|
||||
.getDateTimeFieldValues(sObjectField);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sObjectField The Schema.SObjectField to get the SUM of
|
||||
*
|
||||
* @return The total SUM of the given field
|
||||
*/
|
||||
@TestVisible
|
||||
protected virtual Decimal getDecimalFieldSum(Schema.SObjectField sObjectField)
|
||||
{
|
||||
Decimal result = 0;
|
||||
for (SObject record : getRecords())
|
||||
{
|
||||
result += record.get(sObjectField) == null ? 0 : (Decimal) record.get(sObjectField);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sObjectField The Schema.SObjectField to get their Id values
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user