def calculate_spendings(queryResult):
    """
    calculate_spendings(queryResult): Takes 1 argument for processing - queryResult
    which is the query result from the display total function in the same file.
    It parses the query result and turns it into a form suitable for display on the UI by the user.
    """
    total_dict = {}

    for row in queryResult:
        # date,cat,money
        s = row.split(",")
        # cat
        cat = s[1]
        if cat in total_dict:
            # round up to 2 decimal
            total_dict[cat] = round(total_dict[cat] + float(s[2]), 2)
        else:
            total_dict[cat] = float(s[2])
    total_text = ""
    for key, value in total_dict.items():
        total_text += str(key) + " $" + str(value) + "\n"
    return total_text