from decimal import Decimal


def total(cart):
    return sum(
        (
            Decimal(str(item.product_special_price or item.product_regular_price))
            * item.quantity
        )
        for item in cart
        if (item.product_special_price or item.product_regular_price) is not None
    )
