Skip to content

Commit

Permalink
Merge pull request #400 from jdebacker/dp_rule_update
Browse files Browse the repository at this point in the history
Update structure of tax depreciation rules
  • Loading branch information
jdebacker authored Jan 7, 2025
2 parents 9cf614a + cc518ec commit a49b7ad
Show file tree
Hide file tree
Showing 29 changed files with 3,687 additions and 3,170 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
persist-credentials: false

- name: Setup Miniconda using Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: ccc-dev
environment-file: environment.yml
python-version: ${{ matrix.python-version }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/check_jupyterbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniconda-version: "latest"
auto-update-conda: true
activate-environment: ccc-dev
environment-file: environment.yml
python-version: 3.12
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/deploy_jupyterbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniconda-version: "latest"
auto-update-conda: true
activate-environment: ccc-dev
environment-file: environment.yml
python-version: 3.12
Expand Down
2 changes: 1 addition & 1 deletion ccc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from ccc.data import *
from ccc.calculator import *

__version__ = "1.5.2"
__version__ = "2.0.0"
26 changes: 8 additions & 18 deletions ccc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,18 @@ def update_depr_methods(df, p, dp):
"""
# update tax_deprec_rates based on user defined parameters
# create dataframe with depreciation policy parameters
deprec_df = pd.DataFrame(dp.asset)
# split out value into two columns
deprec_df = deprec_df.join(
pd.DataFrame(deprec_df.pop("value").values.tolist())
)
# drop information duplicated in asset dataframe
deprec_df.drop(
columns=["asset_name", "minor_asset_group", "major_asset_group"],
inplace=True,
)
# create dataframe with depreciation policy parameters for all
# known years
deprec_df = dp.expanded_df()
# keep just the current year in the CCC parameters object
deprec_df = deprec_df[deprec_df.year == p.year]
# merge depreciation policy parameters to asset dataframe
df.drop(columns=deprec_df.keys(), inplace=True, errors="ignore")
df = df.merge(
deprec_df, how="left", left_on="bea_asset_code", right_on="BEA_code"
)
# add bonus depreciation to tax deprec parameters dataframe
df["bonus"] = df["GDS_life"]
df["bonus"] = df["life"]
# update tax_deprec_rates based on user defined parameters
df.replace({"bonus": p.bonus_deprec}, inplace=True)
# Compute b
Expand All @@ -49,13 +43,9 @@ def update_depr_methods(df, p, dp):
df.loc[df["b"] == "Income Forecast", "b"] = 1.0
# cast b as float
df["b"] = df["b"].astype(float)
# Set Y to length of depreciable life
df["Y"] = df["life"]

df.loc[df["system"] == "ADS", "Y"] = df.loc[
df["system"] == "ADS", "ADS_life"
]
df.loc[df["system"] == "GDS", "Y"] = df.loc[
df["system"] == "GDS", "GDS_life"
]
return df


Expand Down
Loading

0 comments on commit a49b7ad

Please sign in to comment.