'Returns a Decimal indicating the total sum of field_to_aggregate for all verified certificates with a particular status.
Sample usages:
- status \'refunded\' and field_to_aggregate \'unit_cost\' will give the total amount of money refunded for course_id
- status \'purchased\' and field_to_aggregate \'service_fees\' gives the sum of all service fees for purchased certificates
etc'

@classmethod
def verified_certificates_monetary_field_sum(cls, course_id, status, field_to_aggregate):

    query = use_read_replica_if_available(CertificateItem.objects.filter(course_id=course_id, mode='verified', status=status)).aggregate(Sum(field_to_aggregate))[(field_to_aggregate + '__sum')]
    if (query is None):
        return Decimal(0.0)
    else:
        return query
