Skip to content

Commit

Permalink
Tutorial changes (#145)
Browse files Browse the repository at this point in the history
Bump to 0.7.1, with lots of non-breaking changes for used classes, and
lots of polish and removing inconsistencies in unused classes, so they will
be used.

## Polish in al_income.py
* Sets insertion value, and keep object type for ALExpense
* update docstrings to reflect what's used and what function
  output actually looks like
* Extend `recent_years` default to 25, to go back to 2001 and
  cover more cars

## Polish in al_income.yml

* Added default tables and revisit screens for every type in documentation
  * show "income"/"deduction" in ALItemizedJob review screen
* Deleted duplicate blocks that had been added earlier
* Moved blocks around to make sense categorically
* Align similar classes of blocks, like ALJob and ALItemizedJob, so
   they ask questions in the same way by default ("Zip or postal code", etc)
* Added blocks from Affidavit to be default ones here, including
  * `.moved` and `.gathered` for ALIncomeList
  * `.market_value` only by default for ALVehicleList
  * Can set the name of an ALIncome if not set by the "select" screen
* Show `.display_name` if ALIncome has one, instead of `.source`
* don't require "how often is the income earned" if the value
  of an asset isn't required
* ALVehicleList uses market_value by default, not value (not likely
  for vehicles).

##  Reorg and fix-up income demo

* added intermediate screens between each feature
* removed all demo specific code blocks, to get the default experience
   with most classes
* added the ability to directly start one particular feature with url_args
* removed "all of the above" feature. Is in upstream docassemble now, but
   trying to avoid newer features, and the original feature broke with url_args,
   and url_args take priority for a useful feature.
* show classes in the same order that the user gets to select them
* Add ALExpenseList to demo

---------

Co-authored-by: plocket <52798256+plocket@users.noreply.github.com>
  • Loading branch information
BryceStevenWilley and plocket authored Feb 3, 2023
1 parent 092ac9f commit 3ef0ff6
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 219 deletions.
2 changes: 1 addition & 1 deletion docassemble/ALToolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.0'
__version__ = '0.7.1'
27 changes: 18 additions & 9 deletions docassemble/ALToolbox/al_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def times_per_year(


def recent_years(
past: int = 15, order: str = "descending", future: int = 1
past: int = 25, order: str = "descending", future: int = 1
) -> List[int]:
"""
Returns a list of the most recent past years, continuing into the future.
Expand Down Expand Up @@ -130,7 +130,6 @@ class ALPeriodicAmount(DAObject):
.times_per_year {float | Decimal} Represents a number of the annual frequency of
the income. E.g. 12 for a monthly income.
.source {str} (Optional) The "source" of the income, like a "job" or a "house".
.owner {str} (Optional) Full name of the income's owner as a single string.
.display_name {str} (Optional) If present, will have a translated string to show the
user, as opposed to a raw english string from the program
"""
Expand Down Expand Up @@ -267,7 +266,8 @@ def matches(
satifies_sources = _source_to_callable(source, exclude_source)
# Construct the filtered list
return ALIncomeList(
elements=[item for item in self.elements if satifies_sources(item.source)]
elements=[item for item in self.elements if satifies_sources(item.source)],
object_type=self.object_type,
)

def total(
Expand Down Expand Up @@ -325,7 +325,7 @@ def move_checks_to_list(
if not selected_terms:
selected_terms = {}
self.elements.clear()
for source in selected_types.true_values():
for source in selected_types.true_values(insertion_order=True):
if source == "other":
self.appendObject()
else:
Expand Down Expand Up @@ -416,7 +416,15 @@ def employer_name_address_phone(self) -> str:
gathering the `.employer`, `.employer_address`, and `.employer_phone`
attributes.
"""
return f"{self.employer.name}: {self.employer.address}, {self.employer.phone}"
if self.employer.address.address and self.employer.phone:
return (
f"{self.employer.name}: {self.employer.address}, {self.employer.phone}"
)
if self.employer.address.address:
return f"{self.employer.name}: {self.employer.address}"
if self.employer.phone:
return f"{self.employer.name}: {self.employer.phone}"
return f"{self.employer.name}"

def normalized_hours(self, times_per_year: float = 1) -> float:
"""
Expand Down Expand Up @@ -545,8 +553,8 @@ class ALExpenseList(ALIncomeList):
A list of expenses
* each element has a:
* value
* source
* owner
* display name
"""

Expand Down Expand Up @@ -910,8 +918,8 @@ def total(self) -> Decimal:

def __str__(self) -> str:
"""
Returns a string of the dictionary's key/value pairs in a list. E.g.
"['federal_taxes': '2500.00', 'wages': '15.50']"
Returns a string of the dictionary's key/value pairs as two-element lists in a list.
E.g. '[["federal_taxes", "2500.00"], ["wages", "15.50"]]'
"""
to_stringify = []
for key in self:
Expand Down Expand Up @@ -1185,7 +1193,8 @@ def init(self, *pargs, **kwargs):

def sources(self, which_side: Optional[str] = None) -> Set[str]:
"""Returns a set of the unique sources in all of the jobs.
By default gets from both sides, if which_side is "deductions", only gets from deductions."""
By default gets from both sides, if which_side is "deductions", only gets from deductions.
"""
sources = set()
if not which_side:
which_side = "all"
Expand Down
1 change: 1 addition & 0 deletions docassemble/ALToolbox/copy_button.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from docassemble.base.functions import word


# See GitHub issue https://github.com/SuffolkLITLab/docassemble-ALToolbox/issues/16
def copy_button_html(
text_to_copy: str,
Expand Down
Loading

0 comments on commit 3ef0ff6

Please sign in to comment.