Skip to content

Commit

Permalink
Merge pull request #203 from SuffolkLITLab/year-make-model
Browse files Browse the repository at this point in the history
allow use of arbitrary separator in year_make_model method, slight refactor
  • Loading branch information
nonprofittechy authored Nov 8, 2023
2 parents 0dc8eb9 + 2cc7f0f commit 0f59f76
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions docassemble/ALToolbox/al_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,35 +678,42 @@ def owners(


class ALVehicle(ALAsset):
"""
An ALAsset with special attributes that help representing a vehicle.
"""Represents a vehicle as a specialized type of ALAsset.
Vehicles have a .year_make_model() method which facilitates
listing vehicles on many financial statement forms.
This subclass of ALAsset adds specific attributes relevant to vehicles,
such as year, make, and model, and includes methods for representing
these attributes in a standardized format, as often required on financial
statement forms.
Attributes:
.year {str} The model year of the vehicle, like 2022
.make {str} The make of the vehicle, like "Honda"
.model {str} The model of the vehicle, like "Accord"
.market_value {float | Decimal} Market value of an asset.
.balance {float | Decimal} Balance of an asset.
.value {float | Decimal} (Optional) Income earned by the vehicle (typically 0)
.times_per_year {float} Time frequency over which the `value` is earned
.owner {str} Full name of the asset owner as a single string.
.source {str} (Optional) The "source" of the asset. Defaults to "vehicle".
year (str): The model year of the vehicle, e.g., '2022'.
make (str): The make of the vehicle, e.g., 'Honda'.
model (str): The model of the vehicle, e.g., 'Accord'.
market_value (float or Decimal): Market value of the vehicle.
balance (float or Decimal): Balance of the loan on the vehicle.
value (float or Decimal, optional): Income earned by the vehicle, typically 0.
times_per_year (int): The frequency over which the `value` is earned annually.
owner (str): Full name of the vehicle owner.
source (str, optional): The source of the asset, defaults to 'vehicle'.
"""

def init(self, *pargs, **kwargs):
super().init(*pargs, **kwargs)
if not hasattr(self, "source"):
self.source = "vehicle"

def year_make_model(self) -> str:
def year_make_model(self, separator: str = " / ") -> str:
"""
Returns a string of the format year/make/model of the vehicle. Triggers
gathering those attributes.
Args:
separator {str} (Optional) The separator between the year, make and model.
Returns:
A string of the format year/make/model of the vehicle.
"""
return f"{ self.year } / { self.make } / { self.model }"
return separator.join(map(str, [self.year, self.make, self.model]))


class ALVehicleList(ALAssetList):
Expand Down

0 comments on commit 0f59f76

Please sign in to comment.