Skip to content

Commit 45bfd57

Browse files
authored
[Fix] number of share handling (#33)
1 parent 0b2fa94 commit 45bfd57

5 files changed

Lines changed: 13 additions & 26 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ${VENV}/bin/activate:
66

77
venv: ${VENV}/bin/activate
88

9-
install: requirements.txt requirements-dev.txt venv
9+
install: pyproject.toml venv
1010
${VENV}/bin/pip3 install -e .
1111

1212
test:

pyproject.toml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "moneywiz-api"
8-
version = "1.0.6"
9-
authors = [
10-
{ name="iLeoDo", email="iLeoDo@gmail.com" },
11-
]
8+
version = "1.0.7"
9+
authors = [{ name = "iLeoDo", email = "iLeoDo@gmail.com" }]
1210
description = "A Python api to access moneywiz sqlite database"
1311
readme = "README.md"
1412
requires-python = ">=3.10"
@@ -17,19 +15,10 @@ classifiers = [
1715
"License :: OSI Approved :: MIT License",
1816
"Operating System :: OS Independent",
1917
]
20-
dependencies = [
21-
"pandas"
22-
]
18+
dependencies = ["pandas"]
2319

2420
[project.optional-dependencies]
25-
dev = [
26-
"pytest",
27-
"pytest-cov",
28-
"ruff",
29-
"mypy",
30-
"build",
31-
"twine"
32-
]
21+
dev = ["pytest", "pytest-cov", "ruff", "mypy", "build", "twine"]
3322

3423
[project.scripts]
3524
moneywiz-cli = "moneywiz_api.cli.cli:main"
@@ -40,9 +29,7 @@ moneywiz-cli = "moneywiz_api.cli.cli:main"
4029

4130

4231
[tool.pytest.ini_options]
43-
pythonpath = [
44-
".", "src",
45-
]
32+
pythonpath = [".", "src"]
4633

4734

4835
[tool.ruff]

src/moneywiz_api/model/investment_holding.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass, field
2-
from typing import Dict, Any, Optional
32
from decimal import Decimal
3+
from typing import Any, Dict, Optional
44

55
from moneywiz_api.model.raw_data_handler import RawDataHandler as RDH
66
from moneywiz_api.model.record import Record
@@ -47,7 +47,7 @@ def __init__(self, row):
4747
self.opening_number_of_shares = RDH.get_nullable_decimal(
4848
row, "ZOPENNINGNUMBEROFSHARES"
4949
)
50-
self.number_of_shares = RDH.get_decimal(row, "ZNUMBEROFSHARES")
50+
self.number_of_shares = RDH.get_nullable_decimal(row, "ZNUMBEROFSHARES")
5151
# self.price_per_share = row["ZPRICEPERSHARE"]
5252
self.symbol = row["ZSYMBOL"]
5353
self.holding_type = row["ZHOLDINGTYPE"]
@@ -62,6 +62,7 @@ def __init__(self, row):
6262
)
6363

6464
# Fixes
65+
self.number_of_shares = self.number_of_shares or Decimal(0)
6566

6667
# Validate
6768
self.validate()

src/moneywiz_api/model/transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def __init__(self, row):
177177
self.fee = RDH.get_decimal(row, "ZFEE2")
178178

179179
self.investment_holding = row["ZINVESTMENTHOLDING"]
180-
self.number_of_shares = RDH.get_decimal(row, "ZNUMBEROFSHARES1")
180+
self.number_of_shares = RDH.get_decimal(row, "ZNUMBEROFSHARES")
181181
self.price_per_share = RDH.get_decimal(row, "ZPRICEPERSHARE1")
182182

183183
# Fixes
@@ -230,7 +230,7 @@ def __init__(self, row):
230230
self.fee = RDH.get_decimal(row, "ZFEE2")
231231

232232
self.investment_holding = row["ZINVESTMENTHOLDING"]
233-
self.number_of_shares = RDH.get_decimal(row, "ZNUMBEROFSHARES1")
233+
self.number_of_shares = RDH.get_decimal(row, "ZNUMBEROFSHARES")
234234
self.price_per_share = RDH.get_decimal(row, "ZPRICEPERSHARE1")
235235

236236
# Fixes

tests/integration/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from pathlib import Path
22

33
from moneywiz_api import MoneywizApi
4-
54
from tests.integration.test_config import (
6-
TEST_DB_PATH,
5+
# BALANCE_AS_OF_DATE,
76
# CASH_BALANCES,
87
# HOLDINGS_BALANCES,
9-
# BALANCE_AS_OF_DATE,
8+
TEST_DB_PATH,
109
)
1110

1211
moneywizApi = MoneywizApi(Path(TEST_DB_PATH))

0 commit comments

Comments
 (0)