diff --git a/budgets/Budget-Vorlage-2021.xlsx b/budgets/Budget-Vorlage-2021.xlsx new file mode 100644 index 0000000..d5c3c34 Binary files /dev/null and b/budgets/Budget-Vorlage-2021.xlsx differ diff --git a/budgets/Budget-Vorlage-2022.xlsx b/budgets/Budget-Vorlage-2022.xlsx new file mode 100644 index 0000000..0322c27 Binary files /dev/null and b/budgets/Budget-Vorlage-2022.xlsx differ diff --git a/budgets/Budget-Vorlage-2023.xlsx b/budgets/Budget-Vorlage-2023.xlsx new file mode 100644 index 0000000..68c29f3 Binary files /dev/null and b/budgets/Budget-Vorlage-2023.xlsx differ diff --git a/superx_budget/helpers.py b/superx_budget/helpers.py index 07d5c24..0200e21 100644 --- a/superx_budget/helpers.py +++ b/superx_budget/helpers.py @@ -19,7 +19,7 @@ def excel_value_as_number(value): def get_sheet_of_file(excel_file, sheet=None): - """ returns a sheet from an excel FileCache + """returns a sheet from an excel FileCache if name is set to None, the function returns the first sheet """ diff --git a/superx_budget/pyramid/overview.py b/superx_budget/pyramid/overview.py index b77a6ed..347340a 100644 --- a/superx_budget/pyramid/overview.py +++ b/superx_budget/pyramid/overview.py @@ -142,7 +142,7 @@ def send_overview(context, request): or not budget_file.is_file() ): request.session.flash( - f"There was an error with your submisssion, please try again.", + "There was an error with your submisssion, please try again.", "error", ) return HTTPFound("/") diff --git a/superx_budget/superx.py b/superx_budget/superx.py index dc7da87..e3ee9d1 100644 --- a/superx_budget/superx.py +++ b/superx_budget/superx.py @@ -51,9 +51,10 @@ def _get_export_metadata(row): raise SuperXParserError( f"unexpected grouping: {metadata['Gruppierung']}" ) + date_part, *rest = metadata["Stand"].split(",") return SuperXResult( metadata["Haushaltsjahr"], - datetime.strptime(metadata["Stand"], "%d.%m.%Y"), + datetime.strptime(date_part.strip(), "%d.%m.%Y"), None, ) diff --git a/tests/test_budget_parser.py b/tests/test_budget_parser.py index 892e07d..1fb1800 100644 --- a/tests/test_budget_parser.py +++ b/tests/test_budget_parser.py @@ -2,7 +2,7 @@ import pytest def test_check_table_header_raises_error(): - from superx_budget.budget import _check_table_header, ExcelRow + from superx_budget.budget import ExcelRow, _check_table_header from superx_budget.exceptions import BudgetParserError row = ExcelRow(None, ["not", "the", "expected", "row", None, 0]) @@ -12,7 +12,7 @@ def test_check_table_header_raises_error(): def test_skip_empty_lines(): - from superx_budget.budget import _skip_empty_lines, ExcelRow + from superx_budget.budget import ExcelRow, _skip_empty_lines rows = [ ExcelRow(0, [""]), @@ -29,7 +29,7 @@ def test_skip_empty_lines(): def test_parse_data_table(): - from superx_budget.budget import _parse_data_table, ExcelRow + from superx_budget.budget import ExcelRow, _parse_data_table rows = [ ExcelRow(2, list("ABCDEFG")), diff --git a/tests/test_overview.py b/tests/test_overview.py index b95be30..dd93374 100644 --- a/tests/test_overview.py +++ b/tests/test_overview.py @@ -79,8 +79,8 @@ def test_project_overview_available_property(example_budget_data): def test_create_overview_map(budget_example_file): - from superx_budget.overview import _create_overview_map from superx_budget.budget import parse_budget_file + from superx_budget.overview import _create_overview_map budget_data = parse_budget_file(budget_example_file) result = _create_overview_map(budget_data) @@ -92,12 +92,12 @@ def test_create_overview_map(budget_example_file): def test_create_entries_from_export(budget_example_file, superx_example_file): + from superx_budget.budget import parse_budget_file + from superx_budget.superx import parse_exported_file from superx_budget.overview import ( - _create_entries_from_superx, _create_overview_map, + _create_entries_from_superx, ) - from superx_budget.budget import parse_budget_file - from superx_budget.superx import parse_exported_file superx_data = parse_exported_file(superx_example_file) budget_data = parse_budget_file(budget_example_file) @@ -109,11 +109,11 @@ def test_create_entries_from_export(budget_example_file, superx_example_file): def test_filter_superx_material_expenses(superx_example_file): + from superx_budget.superx import parse_exported_file from superx_budget.overview import ( - _filter_superx_material_expenses, VALID_MATERIAL_IDS, + _filter_superx_material_expenses, ) - from superx_budget.superx import parse_exported_file superx_data = parse_exported_file(superx_example_file) result = list(_filter_superx_material_expenses(superx_data)) @@ -124,9 +124,9 @@ def test_filter_superx_material_expenses(superx_example_file): def test_create_overview(budget_example_file, superx_example_file): - from superx_budget.overview import create_overview from superx_budget.budget import parse_budget_file from superx_budget.superx import parse_exported_file + from superx_budget.overview import create_overview superx_data = parse_exported_file(superx_example_file) budget_data = parse_budget_file(budget_example_file) diff --git a/tests/test_superx_parser.py b/tests/test_superx_parser.py index 55cafbe..1a757b0 100644 --- a/tests/test_superx_parser.py +++ b/tests/test_superx_parser.py @@ -15,9 +15,10 @@ def test_check_export_headline(): def test_get_export_metadata_ok(): - from superx_budget.superx import _get_export_metadata from datetime import datetime + from superx_budget.superx import _get_export_metadata + value = "Haushaltsjahr: XXX;Stand:31.12.2020;Gruppierung:automatisch" row = [value] metadata = _get_export_metadata(row) @@ -88,9 +89,10 @@ def test_parse_data_table(): def test_parse_export_data(superx_example_workbook): - from superx_budget.superx import parse_export_data from datetime import datetime + from superx_budget.superx import parse_export_data + result = parse_export_data(superx_example_workbook.active) assert result.account_year == "2020"