Skip to main content

ALToolbox.Addup

DAValidationError

word

__all__

Addup Objects

class Addup()

Utility class for calculating sums of numeric fields across DAList objects.

This class provides functionality to sum specific numeric fields from all items in a Docassemble DAList, which is useful for financial calculations and data aggregation in legal document automation.

__init__

def __init__(listName, varName)

Initialize the Addup calculator and compute the sum immediately.

Arguments

  • self - The instance being initialized.
  • listName - A DAList object containing items with numeric fields.
  • varName str - The name of the field to sum across all list items.

g

def g(listName, varName) -> float

Calculate the sum of a specific numeric field across all items in a DAList.

Iterates through each item in the provided DAList, extracts the specified field value, and adds all values together. Raises an error if the sum is 0, which indicates the field was not found or contained no numeric values.

Arguments

  • listName - A DAList object containing items with numeric fields.
  • varName str - The name of the field to sum across all list items.

Returns

  • float - The sum of all values for the specified field.

Raises

  • DAValidationError - If the sum is 0, indicating the field was not found or contained no numeric values.

Example

>>> addup = Addup(income_list, "monthly_amount")
>>> # Returns sum of monthly_amount fields from all items in income_list