Exemplo n.º 1
0
def test_get_active_years(load_doc) -> None:
    """
    2010-11-12 * "test"
        Assets:T   4.00 USD
        Expenses:T
    2011-11-12 * "test"
        Assets:T   4.00 USD
        Expenses:T
    2012-12-12 * "test"
        Assets:T   4.00 USD
        Expenses:T
    """

    entries, _, __ = load_doc
    assert get_active_years(entries, FiscalYearEnd(12, 31)) == [
        "2012",
        "2011",
        "2010",
    ]
    assert get_active_years(entries, FiscalYearEnd(12, 1)) == [
        "FY2013",
        "FY2011",
        "FY2010",
    ]
    assert get_active_years(entries, FiscalYearEnd(11, 1)) == [
        "FY2013",
        "FY2012",
        "FY2011",
    ]
Exemplo n.º 2
0
def test_parse_date_relative(expect_start: str, expect_end: str,
                             text: str) -> None:
    start, end = _to_date(expect_start), _to_date(expect_end)
    with mock.patch("fava.util.date.datetime.date") as mock_date:
        mock_date.today.return_value = _to_date("2016-06-24")
        mock_date.side_effect = date
        assert parse_date(text, FiscalYearEnd(6, 30)) == (start, end)
Exemplo n.º 3
0
class FavaOptions:
    """Options for Fava that can be set in the Beancount file."""

    # pylint: disable=too-many-instance-attributes

    account_journal_include_children: bool = True
    auto_reload: bool = False
    collapse_pattern: list[Pattern[str]] = field(default_factory=list)
    currency_column: int = 61
    default_file: str | None = None
    default_page: str = "income_statement/"
    fiscal_year_end: FiscalYearEnd = FiscalYearEnd(12, 31)
    import_config: str | None = None
    import_dirs: tuple[str, ...] = ()
    indent: int = 2
    insert_entry: list[InsertEntryOption] = field(default_factory=list)
    invert_income_liabilities_equity: bool = False
    language: str | None = None
    locale: str | None = None
    show_accounts_with_zero_balance: bool = True
    show_accounts_with_zero_transactions: bool = True
    show_closed_accounts: bool = False
    sidebar_show_queries: int = 5
    unrealized: str = "Unrealized"
    upcoming_events: int = 7
    uptodate_indicator_grey_lookback_days: int = 60
    use_external_editor: bool = False

    asdict = asdict
Exemplo n.º 4
0
def test_fava_options(load_doc: LoaderResult) -> None:
    """
    2016-06-14 custom "fava-option" "default-file"
    2016-04-14 custom "fava-option" "show-closed-accounts" "true"
    2016-04-14 custom "fava-option" "currency-column" "10"
    2016-04-14 custom "fava-option" "indent" "4"
    2016-04-14 custom "fava-option" "insert-entry" "Ausgaben:Test"
    2016-04-14 custom "fava-option" "invalid"
    2016-04-14 custom "fava-option" "locale" "en"
    2016-04-14 custom "fava-option" "locale" "invalid"
    2016-04-14 custom "fava-option" "collapse-pattern" "Account:Name"
    2016-04-14 custom "fava-option" "collapse_pattern" "(invalid"
    2016-04-14 custom "fava-option" "fiscal-year-end" "01-11"
    2016-04-14 custom "fava-option" "conversion-currencies" "USD EUR HOOLI"
    """

    entries, _, _ = load_doc
    options, errors = parse_options(entries)  # type: ignore

    assert len(errors) == 3

    assert options.indent == 4
    assert options.insert_entry == [
        InsertEntryOption(
            datetime.date(2016, 4, 14),
            re.compile("Ausgaben:Test"),
            "<string>",
            6,
        )
    ]
    assert options.show_closed_accounts
    assert options.currency_column == 10
    assert options.collapse_pattern == [re.compile("Account:Name")]
    assert options.fiscal_year_end == FiscalYearEnd(1, 11)
    assert options.conversion_currencies == ("USD", "EUR", "HOOLI")
def test_fava_options(load_doc):
    """
    2016-06-14 custom "fava-option" "default-file"
    2016-04-14 custom "fava-option" "show-closed-accounts" "true"
    2016-04-14 custom "fava-option" "journal-show" "transaction open"
    2016-04-14 custom "fava-option" "currency-column" "10"
    2016-04-14 custom "fava-option" "indent" "4"
    2016-04-14 custom "fava-option" "insert-entry" "Ausgaben:Test"
    2016-04-14 custom "fava-option" "invalid"
    2016-04-14 custom "fava-option" "locale" "en"
    2016-04-14 custom "fava-option" "locale" "invalid"
    2016-04-14 custom "fava-option" "collapse-pattern" "Account:Name"
    2016-04-14 custom "fava-option" "collapse-pattern" "(invalid"
    2016-04-14 custom "fava-option" "fiscal-year-end" "01-11"
    """

    entries, _, _ = load_doc
    options, errors = parse_options(entries)

    assert len(errors) == 3

    assert options["indent"] == 4
    assert options["insert-entry"] == [
        InsertEntryOption(
            datetime.date(2016, 4, 14),
            re.compile("Ausgaben:Test"),
            "<string>",
            7,
        )
    ]
    assert options["show-closed-accounts"]
    assert options["journal-show"] == ["transaction", "open"]
    assert options["currency-column"] == 10
    assert options["collapse-pattern"] == [re.compile("Account:Name")]
    assert options["fiscal-year-end"] == FiscalYearEnd(1, 11)
Exemplo n.º 6
0
    """

    date: datetime.date
    re: Pattern[str]
    filename: str
    lineno: int


DEFAULTS = {
    "account-journal-include-children": True,
    "currency-column": 61,
    "collapse-pattern": [],
    "auto-reload": False,
    "conversion": "at_cost",
    "default-file": None,
    "fiscal-year-end": FiscalYearEnd(12, 31),
    "import-config": None,
    "import-dirs": [],
    "indent": 2,
    "insert-entry": [],
    "interval": "month",
    "journal-show": [
        "transaction",
        "balance",
        "note",
        "document",
        "custom",
        "budget",
        "query",
    ],
    "journal-show-document": ["discovered", "statement"],
Exemplo n.º 7
0

DEFAULTS = {
    "account-journal-include-children":
    True,
    "currency-column":
    61,
    "collapse-pattern": [],
    "auto-reload":
    False,
    "default-file":
    None,
    "default-page":
    "income_statement/",
    "fiscal-year-end":
    FiscalYearEnd(12, 31),
    "import-config":
    None,
    "import-dirs": [],
    "indent":
    2,
    "insert-entry": [],
    "invert-income-liabilities-equity":
    False,
    "journal-show": [
        "transaction",
        "balance",
        "note",
        "document",
        "custom",
        "budget",
Exemplo n.º 8
0
def test_parse_date_empty() -> None:
    assert parse_date("     ", FiscalYearEnd(6, 30)) == (None, None)
    assert parse_date("     ", None) == (None, None)
Exemplo n.º 9
0
def test_parse_date(expect_start: str, expect_end: str, text: str) -> None:
    expected = (_to_date(expect_start), _to_date(expect_end))
    assert parse_date(text, FiscalYearEnd(6, 30)) == expected
    if "FY" not in text:
        assert parse_date(text, None) == expected