Skip to content

Commit fed21ee

Browse files
Merge pull request #545 from SuffolkLITLab/copilot/fix-329
Add comprehensive SMS notification style guidelines
2 parents ba8076c + 3960fe9 commit fed21ee

32 files changed

+3178
-2257
lines changed

docs/components/ALToolbox/Addup.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Table of Contents
2+
3+
* [ALToolbox.Addup](#ALToolbox.Addup)
4+
* [Addup](#ALToolbox.Addup.Addup)
5+
* [\_\_init\_\_](#ALToolbox.Addup.Addup.__init__)
6+
* [g](#ALToolbox.Addup.Addup.g)
7+
8+
---
9+
sidebar_label: Addup
10+
title: ALToolbox.Addup
11+
---
12+
13+
<a id="ALToolbox.Addup.Addup"></a>
14+
15+
## Addup Objects
16+
17+
```python
18+
class Addup()
19+
```
20+
21+
Utility class for calculating sums of numeric fields across DAList objects.
22+
23+
This class provides functionality to sum specific numeric fields from all
24+
items in a Docassemble DAList, which is useful for financial calculations
25+
and data aggregation in legal document automation.
26+
27+
<a id="ALToolbox.Addup.Addup.__init__"></a>
28+
29+
#### \_\_init\_\_(listName, varName)
30+
31+
```python
32+
def __init__(listName, varName)
33+
```
34+
35+
Initialize the Addup calculator and compute the sum immediately.
36+
37+
**Arguments**:
38+
39+
- `self` - The instance being initialized.
40+
- `listName` - A DAList object containing items with numeric fields.
41+
- `varName` _str_ - The name of the field to sum across all list items.
42+
43+
<a id="ALToolbox.Addup.Addup.g"></a>
44+
45+
#### g(listName, varName)
46+
47+
```python
48+
def g(listName, varName) -> float
49+
```
50+
51+
Calculate the sum of a specific numeric field across all items in a DAList.
52+
53+
Iterates through each item in the provided DAList, extracts the specified
54+
field value, and adds all values together. Raises an error if the sum is 0,
55+
which indicates the field was not found or contained no numeric values.
56+
57+
**Arguments**:
58+
59+
- `listName` - A DAList object containing items with numeric fields.
60+
- `varName` _str_ - The name of the field to sum across all list items.
61+
62+
63+
**Returns**:
64+
65+
- `float` - The sum of all values for the specified field.
66+
67+
68+
**Raises**:
69+
70+
- `DAValidationError` - If the sum is 0, indicating the field was not found
71+
or contained no numeric values.
72+
73+
74+
**Example**:
75+
76+
&gt;&gt;&gt; addup = Addup(income_list, &quot;monthly_amount&quot;)
77+
&gt;&gt;&gt; # Returns sum of monthly_amount fields from all items in income_list
78+
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Table of Contents
2+
3+
* [ALToolbox.ThreePartsDate](#ALToolbox.ThreePartsDate)
4+
* [check\_empty\_parts](#ALToolbox.ThreePartsDate.check_empty_parts)
5+
* [ThreePartsDate](#ALToolbox.ThreePartsDate.ThreePartsDate)
6+
* [validate](#ALToolbox.ThreePartsDate.ThreePartsDate.validate)
7+
* [transform](#ALToolbox.ThreePartsDate.ThreePartsDate.transform)
8+
* [default\_for](#ALToolbox.ThreePartsDate.ThreePartsDate.default_for)
9+
* [BirthDate](#ALToolbox.ThreePartsDate.BirthDate)
10+
* [validate](#ALToolbox.ThreePartsDate.BirthDate.validate)
11+
12+
---
13+
sidebar_label: ThreePartsDate
14+
title: ALToolbox.ThreePartsDate
15+
---
16+
17+
<a id="ALToolbox.ThreePartsDate.check_empty_parts"></a>
18+
19+
#### check\_empty\_parts(item: str, default\_msg="{} is not a valid date")
20+
21+
```python
22+
def check_empty_parts(item: str,
23+
default_msg="{} is not a valid date") -> Optional[str]
24+
```
25+
26+
Validate a date string in MM/DD/YYYY format and return specific error messages for missing parts.
27+
28+
Analyzes a date string separated by forward slashes to determine which parts
29+
(month, day, year) are missing and returns a helpful error message indicating
30+
what needs to be entered. Currently only handles US date format.
31+
32+
**Arguments**:
33+
34+
- `item` _str_ - The date string to validate, expected in MM/DD/YYYY format.
35+
- `default_msg` _str, optional_ - Default error message template for invalid dates.
36+
Defaults to &quot;\{\} is not a valid date&quot;.
37+
38+
39+
**Returns**:
40+
41+
Error message if validation fails, None if date is valid.
42+
Returns None when the date is complete and valid, otherwise returns
43+
a localized error message indicating which parts need to be entered.
44+
45+
46+
**Example**:
47+
48+
&gt;&gt;&gt; check_empty_parts(&quot;12//2023&quot;)
49+
&quot;Enter a day&quot;
50+
&gt;&gt;&gt; check_empty_parts(&quot;//&quot;)
51+
&quot;Enter a month, a day, and a year&quot;
52+
&gt;&gt;&gt; check_empty_parts(&quot;12/25/2023&quot;)
53+
None
54+
55+
<a id="ALToolbox.ThreePartsDate.ThreePartsDate"></a>
56+
57+
## ThreePartsDate Objects
58+
59+
```python
60+
class ThreePartsDate(CustomDataType)
61+
```
62+
63+
<a id="ALToolbox.ThreePartsDate.ThreePartsDate.validate"></a>
64+
65+
#### validate(cls, item: str)
66+
67+
```python
68+
@classmethod
69+
def validate(cls, item: str) -> bool
70+
```
71+
72+
Validate a date string in MM/DD/YYYY format.
73+
74+
**Arguments**:
75+
76+
- `item` _str_ - The date string to validate.
77+
78+
79+
**Returns**:
80+
81+
- `bool` - True if valid or empty, raises DAValidationError if invalid.
82+
83+
84+
**Raises**:
85+
86+
- `DAValidationError` - If the date string is invalid or cannot be parsed.
87+
88+
<a id="ALToolbox.ThreePartsDate.ThreePartsDate.transform"></a>
89+
90+
#### transform(cls, item)
91+
92+
```python
93+
@classmethod
94+
def transform(cls, item) -> Optional[datetime]
95+
```
96+
97+
Transform a date string into a datetime object.
98+
99+
**Arguments**:
100+
101+
- `item` - The date string to transform.
102+
103+
104+
**Returns**:
105+
106+
datetime or None: The parsed datetime object, or None if empty.
107+
108+
<a id="ALToolbox.ThreePartsDate.ThreePartsDate.default_for"></a>
109+
110+
#### default\_for(cls, item)
111+
112+
```python
113+
@classmethod
114+
def default_for(cls, item) -> Optional[str]
115+
```
116+
117+
Convert a datetime object to MM/dd/yyyy format string.
118+
119+
**Arguments**:
120+
121+
- `item` - The datetime object to format.
122+
123+
124+
**Returns**:
125+
126+
str or None: The formatted date string, or None if empty.
127+
128+
<a id="ALToolbox.ThreePartsDate.BirthDate"></a>
129+
130+
## BirthDate Objects
131+
132+
```python
133+
class BirthDate(ThreePartsDate)
134+
```
135+
136+
<a id="ALToolbox.ThreePartsDate.BirthDate.validate"></a>
137+
138+
#### validate(cls, item: str)
139+
140+
```python
141+
@classmethod
142+
def validate(cls, item: str) -> bool
143+
```
144+
145+
Validate a birth date string ensuring it&#x27;s a valid past date.
146+
147+
Validates that the input is a properly formatted date string in MM/DD/YYYY
148+
format that represents a date on or before today and after the year 1000.
149+
Empty or None values are considered valid.
150+
151+
**Arguments**:
152+
153+
- `item` _str_ - The birth date string to validate in MM/DD/YYYY format.
154+
155+
156+
**Returns**:
157+
158+
True if the date is valid, otherwise raises DAValidationError.
159+
160+
161+
**Raises**:
162+
163+
- `DAValidationError` - If the date is invalid, improperly formatted,
164+
or in the future.
165+

0 commit comments

Comments
 (0)