-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+21.4 KB
input/golden/generic/test_data3_generic_2019-12-01_2020-04-01_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+21.1 KB
input/golden/generic/test_data3_generic_2019-12-01_2020-04-01_hifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+21 KB
input/golden/generic/test_data3_generic_2019-12-01_2020-04-01_lifo_rp2_full_report.ods
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+34.4 KB
input/golden/generic/test_data_multi_method_generic_mixed_rp2_full_report.ods
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+19.6 KB
input/golden/generic/test_many_year_data_generic_0_2016-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+21.8 KB
input/golden/generic/test_many_year_data_generic_0_2017-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+22.9 KB
input/golden/generic/test_many_year_data_generic_0_2018-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+24.6 KB
input/golden/generic/test_many_year_data_generic_0_2019-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+25.7 KB
input/golden/generic/test_many_year_data_generic_0_2020-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+23.3 KB
...golden/generic/test_many_year_data_generic_2017-01-01_2019-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+25.8 KB
...t/golden/generic/test_many_year_data_generic_2017-01-01_infinity_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+21.3 KB
...golden/generic/test_many_year_data_generic_2018-01-01_2019-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+23.9 KB
...t/golden/generic/test_many_year_data_generic_2018-01-01_infinity_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+20 KB
...golden/generic/test_many_year_data_generic_2019-01-01_2019-12-31_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+23 KB
...t/golden/generic/test_many_year_data_generic_2019-01-01_infinity_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+20.9 KB
...t/golden/generic/test_many_year_data_generic_2020-01-01_infinity_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+19.8 KB
...t/golden/generic/test_many_year_data_generic_2021-01-01_infinity_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+27 KB
input/golden/generic/test_many_year_data_generic_fifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+26.9 KB
input/golden/generic/test_many_year_data_generic_hifo_rp2_full_report.ods
Binary file not shown.
Binary file added
BIN
+26.9 KB
input/golden/generic/test_many_year_data_generic_lifo_rp2_full_report.ods
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2021 eprbell | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
from typing import Set | ||
|
||
from rp2.abstract_country import AbstractCountry | ||
from rp2.rp2_error import RP2ValueError | ||
from rp2.rp2_main import rp2_main | ||
|
||
|
||
# Generic country class | ||
class Generic(AbstractCountry): | ||
def __init__(self) -> None: | ||
currency_iso_code = os.environ.get("CURRENCY_CODE") | ||
if not currency_iso_code: | ||
raise RP2ValueError("CURRENCY_CODE environment variable not found: it is required to use the generic country plugin") | ||
long_term_capital_gain_period = os.environ.get("LONG_TERM_CAPITAL_GAINS") | ||
if not long_term_capital_gain_period: | ||
raise RP2ValueError("LONG_TERM_CAPITAL_GAINS environment variable not found: it is required to use the generic country plugin") | ||
try: | ||
self.__long_term_capital_gain_period = int(long_term_capital_gain_period) | ||
except (ValueError, TypeError) as exc: | ||
raise RP2ValueError( | ||
f"LONG_TERM_CAPITAL_GAINS environment variable has value " f"'{long_term_capital_gain_period}', which is not convertible to integer" | ||
) from exc | ||
if self.__long_term_capital_gain_period < 0: | ||
raise RP2ValueError( | ||
f"LONG_TERM_CAPITAL_GAINS environment variable has negative value " f"'{long_term_capital_gain_period}': it should be >= 0 instead" | ||
) | ||
super().__init__("generic", currency_iso_code) | ||
|
||
# Measured in days | ||
def get_long_term_capital_gain_period(self) -> int: | ||
return self.__long_term_capital_gain_period | ||
|
||
# Default accounting method to use if the user doesn't specify one on the command line | ||
def get_default_accounting_method(self) -> str: | ||
return "fifo" | ||
|
||
# Set of accounting methods accepted in the country | ||
def get_accounting_methods(self) -> Set[str]: | ||
return {"fifo", "lifo", "hifo"} | ||
|
||
# Default set of generators to use if the user doesn't specify them on the command line | ||
def get_report_generators(self) -> Set[str]: | ||
return { | ||
"open_positions", | ||
"rp2_full_report", | ||
} | ||
|
||
# Default language to use at report generation if the user doesn't specify it on the command line (in ISO 639-1 format) | ||
def get_default_generation_language(self) -> str: | ||
return "en" | ||
|
||
|
||
# US-specific entry point | ||
def rp2_entry() -> None: | ||
rp2_main(Generic()) |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.