Skip to content

Commit

Permalink
Mistake was fixed for portuguese tax report - inflation coefficient s…
Browse files Browse the repository at this point in the history
…houldn't be used in calculation (correction is done by AT).
  • Loading branch information
titov-vv committed Jun 8, 2024
1 parent ddf4d64 commit 9870555
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
53 changes: 2 additions & 51 deletions jal/data_export/tax_reports/portugal.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,8 @@
{
"2022": {
"tax_treaty": ["ad", "ae","ao","at","bb", "be", "bg","bh", "br", "ca", "ch", "ci", "cl", "co", "cn", "cv", "cu", "cy", "cz", "de", "dk", "dz", "ee", "es", "et", "fr", "gb", "ge", "gr", "gw", "hk", "hr", "hu", "id", "ie", "il", "in", "is", "it", "jp", "ke", "kr", "kw", "lv", "lt", "lu", "ma", "md", "me", "mo", "mt", "mx", "mz", "nl", "no", "om", "pa", "pe", "pk", "pl", "qa", "ro", "ru", "sa", "se", "sg", "si", "sk", "sm", "sn", "st", "tl", "tn", "tr", "ua", "us", "uy", "ve", "vn", "za"],
"currency_devaluation": {
"2000": 1.44,
"2001": 1.35,
"2002": 1.30,
"2003": 1.26,
"2004": 1.24,
"2005": 1.21,
"2006": 1.17,
"2007": 1.15,
"2008": 1.11,
"2009": 1.13,
"2010": 1.11,
"2011": 1.07,
"2012": 1.04,
"2013": 1.04,
"2014": 1.04,
"2015": 1.04,
"2016": 1.03,
"2017": 1.02,
"2018": 1.01,
"2019": 1.01,
"2020": 1.01,
"2021": 1.00
}
"tax_treaty": ["ad", "ae","ao","at","bb", "be", "bg","bh", "br", "ca", "ch", "ci", "cl", "co", "cn", "cv", "cu", "cy", "cz", "de", "dk", "dz", "ee", "es", "et", "fr", "gb", "ge", "gr", "gw", "hk", "hr", "hu", "id", "ie", "il", "in", "is", "it", "jp", "ke", "kr", "kw", "lv", "lt", "lu", "ma", "md", "me", "mo", "mt", "mx", "mz", "nl", "no", "om", "pa", "pe", "pk", "pl", "qa", "ro", "ru", "sa", "se", "sg", "si", "sk", "sm", "sn", "st", "tl", "tn", "tr", "ua", "us", "uy", "ve", "vn", "za"]
},
"2023": {
"tax_treaty": ["ad", "ae","ao","at","bb", "be", "bg","bh", "br", "ca", "ch", "ci", "cl", "co", "cn", "cv", "cu", "cy", "cz", "de", "dk", "dz", "ee", "es", "et", "fr", "gb", "ge", "gr", "gw", "hk", "hr", "hu", "id", "ie", "il", "in", "is", "it", "jp", "ke", "kr", "kw", "lv", "lt", "lu", "ma", "md", "me", "mo", "mt", "mx", "mz", "nl", "no", "om", "pa", "pe", "pk", "pl", "qa", "ro", "ru", "sa", "se", "sg", "si", "sk", "sm", "sn", "st", "tl", "tn", "tr", "ua", "us", "uy", "ve", "vn", "za"],
"currency_devaluation": {
"2000": 1.56,
"2001": 1.46,
"2002": 1.40,
"2003": 1.36,
"2004": 1.34,
"2005": 1.31,
"2006": 1.26,
"2007": 1.24,
"2008": 1.20,
"2009": 1.22,
"2010": 1.20,
"2011": 1.16,
"2012": 1.12,
"2013": 1.12,
"2014": 1.12,
"2015": 1.12,
"2016": 1.11,
"2017": 1.10,
"2018": 1.09,
"2019": 1.09,
"2020": 1.09,
"2021": 1.08,
"2022": 1.00
}
"tax_treaty": ["ad", "ae","ao","at","bb", "be", "bg","bh", "br", "ca", "ch", "ci", "cl", "co", "cn", "cv", "cu", "cy", "cz", "de", "dk", "dz", "ee", "es", "et", "fr", "gb", "ge", "gr", "gw", "hk", "hr", "hu", "id", "ie", "il", "in", "is", "it", "jp", "ke", "kr", "kw", "lv", "lt", "lu", "ma", "md", "me", "mo", "mt", "mx", "mz", "nl", "no", "om", "pa", "pe", "pk", "pl", "qa", "ro", "ru", "sa", "se", "sg", "si", "sk", "sm", "sn", "st", "tl", "tn", "tr", "ua", "us", "uy", "ve", "vn", "za"]
}
}
14 changes: 0 additions & 14 deletions jal/data_export/tax_reports/portugal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from decimal import Decimal
from datetime import datetime, timezone
from jal.constants import PredefinedAsset, PredefinedCategory
from jal.db.operations import AssetPayment, CorporateAction
from jal.data_export.taxes import TaxReport
Expand Down Expand Up @@ -49,15 +48,6 @@ def prepare_dividends(self):
self.insert_totals(dividends_report, ["amount", "amount_eur", "tax", "tax_eur"])
return dividends_report

def inflation(self, timestamp: int) -> Decimal:
year = datetime.fromtimestamp(timestamp, tz=timezone.utc).strftime('%Y')
inflation_coefficients = self._parameters['currency_devaluation']
try:
coefficient = Decimal(inflation_coefficients[year])
except KeyError:
coefficient = Decimal('1')
return coefficient

# ----------------------------------------------------------------------------------------------------------------------
def prepare_stocks_and_etf(self):
deals_report = []
Expand All @@ -72,10 +62,6 @@ def prepare_stocks_and_etf(self):
if trade.qty() >= Decimal('0'): # Long trade
value_realization = round(trade.close_amount(no_settlement=ns), 2)
value_acquisition = round(trade.open_amount(no_settlement=ns), 2)
inflation = self.inflation(trade.open_operation().settlement())
if inflation != Decimal('1'):
value_acquisition = value_acquisition * inflation
note = f"Acquisition inflation coefficient {inflation:.2f} for year {datetime.fromtimestamp(trade.open_operation().settlement(), tz=timezone.utc).strftime('%Y')}\n"
else: # Short trade
value_realization = round(trade.open_amount(no_settlement=ns), 2)
value_acquisition = round(trade.close_amount(no_settlement=ns), 2)
Expand Down

0 comments on commit 9870555

Please sign in to comment.