Skip to content

Commit a49b7ad

Browse files
authored
Merge pull request #400 from jdebacker/dp_rule_update
Update structure of tax depreciation rules
2 parents 9cf614a + cc518ec commit a49b7ad

29 files changed

+3687
-3170
lines changed

.github/workflows/build_and_test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ jobs:
1717
persist-credentials: false
1818

1919
- name: Setup Miniconda using Python ${{ matrix.python-version }}
20-
uses: conda-incubator/setup-miniconda@v2
20+
uses: conda-incubator/setup-miniconda@v3
2121
with:
22+
miniconda-version: "latest"
23+
auto-update-conda: true
2224
activate-environment: ccc-dev
2325
environment-file: environment.yml
2426
python-version: ${{ matrix.python-version }}

.github/workflows/check_jupyterbook.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Checkout
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010
with:
1111
persist-credentials: false
1212

1313
- name: Setup Miniconda
1414
uses: conda-incubator/setup-miniconda@v2
1515
with:
16-
miniforge-variant: Mambaforge
16+
miniconda-version: "latest"
17+
auto-update-conda: true
1718
activate-environment: ccc-dev
1819
environment-file: environment.yml
1920
python-version: 3.12

.github/workflows/deploy_jupyterbook.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313
with:
1414
persist-credentials: false
1515

1616
- name: Setup Miniconda
17-
uses: conda-incubator/setup-miniconda@v2
17+
uses: conda-incubator/setup-miniconda@v3
1818
with:
19-
miniforge-variant: Mambaforge
19+
miniconda-version: "latest"
20+
auto-update-conda: true
2021
activate-environment: ccc-dev
2122
environment-file: environment.yml
2223
python-version: 3.12

ccc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from ccc.data import *
77
from ccc.calculator import *
88

9-
__version__ = "1.5.2"
9+
__version__ = "2.0.0"

ccc/calcfunctions.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,18 @@ def update_depr_methods(df, p, dp):
2020
2121
"""
2222
# update tax_deprec_rates based on user defined parameters
23-
# create dataframe with depreciation policy parameters
24-
deprec_df = pd.DataFrame(dp.asset)
25-
# split out value into two columns
26-
deprec_df = deprec_df.join(
27-
pd.DataFrame(deprec_df.pop("value").values.tolist())
28-
)
29-
# drop information duplicated in asset dataframe
30-
deprec_df.drop(
31-
columns=["asset_name", "minor_asset_group", "major_asset_group"],
32-
inplace=True,
33-
)
23+
# create dataframe with depreciation policy parameters for all
24+
# known years
25+
deprec_df = dp.expanded_df()
26+
# keep just the current year in the CCC parameters object
27+
deprec_df = deprec_df[deprec_df.year == p.year]
3428
# merge depreciation policy parameters to asset dataframe
3529
df.drop(columns=deprec_df.keys(), inplace=True, errors="ignore")
3630
df = df.merge(
3731
deprec_df, how="left", left_on="bea_asset_code", right_on="BEA_code"
3832
)
3933
# add bonus depreciation to tax deprec parameters dataframe
40-
df["bonus"] = df["GDS_life"]
34+
df["bonus"] = df["life"]
4135
# update tax_deprec_rates based on user defined parameters
4236
df.replace({"bonus": p.bonus_deprec}, inplace=True)
4337
# Compute b
@@ -49,13 +43,9 @@ def update_depr_methods(df, p, dp):
4943
df.loc[df["b"] == "Income Forecast", "b"] = 1.0
5044
# cast b as float
5145
df["b"] = df["b"].astype(float)
46+
# Set Y to length of depreciable life
47+
df["Y"] = df["life"]
5248

53-
df.loc[df["system"] == "ADS", "Y"] = df.loc[
54-
df["system"] == "ADS", "ADS_life"
55-
]
56-
df.loc[df["system"] == "GDS", "Y"] = df.loc[
57-
df["system"] == "GDS", "GDS_life"
58-
]
5949
return df
6050

6151

0 commit comments

Comments
 (0)