def total_amount(qs) -> Total:
    """Sums the amounts of the objects in the queryset, keeping each currency separate.
    :param qs: A querystring containing objects that have an amount field of type Money.
    :return: A Total object.
    """
    aggregate = qs.values('amount_currency').annotate(sum=Sum('amount'))
    return Total(Money(amount=r['sum'], currency=r['amount_currency']) for r in aggregate)
def total_amount ( qs ) -> Total : aggregate = qs . values ( 'amount_currency' ) . annotate ( sum = Sum ( 'amount' ) ) return Total ( Money ( amount = r [ 'sum' ] , currency = r [ 'amount_currency' ] ) for r in aggregate )
Sums the amounts of the objects in the queryset, keeping each currency separate.
    :param qs: A querystring containing objects that have an amount field of type Money.
    :return: A Total object.