How to use fava - 10 common examples

To help you get started, we’ve selected a few fava examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beancount / fava / fava / template_filters.py View on Github external
def format_date(date):
    """Format a date according to the current interval."""
    if g.interval is Interval.YEAR:
        return date.strftime("%Y")
    if g.interval is Interval.QUARTER:
        return "{}Q{}".format(date.year, (date.month - 1) // 3 + 1)
    if g.interval is Interval.MONTH:
        return date.strftime("%b %Y")
    if g.interval is Interval.WEEK:
        return date.strftime("%YW%W")
    if g.interval is Interval.DAY:
        return date.strftime("%Y-%m-%d")
    return ""
github beancount / fava / fava / template_filters.py View on Github external
def format_date(date):
    """Format a date according to the current interval."""
    if g.interval is Interval.YEAR:
        return date.strftime("%Y")
    if g.interval is Interval.QUARTER:
        return "{}Q{}".format(date.year, (date.month - 1) // 3 + 1)
    if g.interval is Interval.MONTH:
        return date.strftime("%b %Y")
    if g.interval is Interval.WEEK:
        return date.strftime("%YW%W")
    if g.interval is Interval.DAY:
        return date.strftime("%Y-%m-%d")
    return ""
github beancount / fava / tests / test_core_inventory.py View on Github external
def test_add_inventory():
    inv = CounterInventory()
    inv2 = CounterInventory()
    inv3 = CounterInventory()
    inv.add_amount(A("10 USD"))
    inv2.add_amount(A("30 USD"))
    inv3.add_amount(A("-40 USD"))
    inv.add_inventory(inv2)
    assert len(inv) == 1
    inv.add_inventory(inv3)
    assert inv.is_empty()
    inv = CounterInventory()
    inv.add_inventory(inv2)
    assert len(inv) == 1
github beancount / fava / tests / test_core_inventory.py View on Github external
def test_add_inventory():
    inv = CounterInventory()
    inv2 = CounterInventory()
    inv3 = CounterInventory()
    inv.add_amount(A("10 USD"))
    inv2.add_amount(A("30 USD"))
    inv3.add_amount(A("-40 USD"))
    inv.add_inventory(inv2)
    assert len(inv) == 1
    inv.add_inventory(inv3)
    assert inv.is_empty()
    inv = CounterInventory()
    inv.add_inventory(inv2)
    assert len(inv) == 1
github beancount / fava / tests / test_core_inventory.py View on Github external
def test_add_amount():
    inv = CounterInventory()
    inv.add_amount(A("10 USD"))
    inv.add_amount(A("30 USD"))
    assert len(inv) == 1
    inv.add_amount(A("-40 USD"))
    assert inv.is_empty()

    inv.add_amount(A("10 USD"))
    inv.add_amount(A("20 CAD"))
    inv.add_amount(A("10 USD"))
    assert len(inv) == 2
    inv.add_amount(A("-20 CAD"))
    assert len(inv) == 1
github beancount / fava / tests / test_template_filters.py View on Github external
def test_should_show(app):
    with app.test_request_context("/"):
        app.preprocess_request()
        assert should_show(g.ledger.root_tree.get("")) is True
        assert should_show(g.ledger.root_tree.get("Expenses")) is True

        account = TreeNode("name")
        assert should_show(account) is False
        account.balance_children = CounterInventory({("USD", None): 9})
        assert should_show(account) is True
    with app.test_request_context("/?time=2100"):
        app.preprocess_request()
        assert not g.ledger.fava_options["show-accounts-with-zero-balance"]
        assert should_show(g.ledger.root_tree.get("")) is True
        assert should_show(g.ledger.root_tree.get("Expenses")) is False
github beancount / fava / tests / test_util_date.py View on Github external
def test_interval():
    assert Interval.get("month") is Interval.MONTH
    assert Interval.get("year") is Interval.YEAR
    assert Interval.get("YEAR") is Interval.YEAR
    assert Interval.get("asdfasdf") is Interval.MONTH
github beancount / fava / tests / test_core_charts.py View on Github external
def test_net_worth(app, example_ledger, snapshot):
    with app.test_request_context():
        app.preprocess_request()
        g.conversion = "USD"
        data = example_ledger.charts.net_worth(Interval.MONTH)
        snapshot(data)
github beancount / fava / tests / test_core_charts.py View on Github external
def test_interval_totals(app, small_example_ledger, snapshot):
    with app.test_request_context(""):
        g.conversion = None
        data = small_example_ledger.charts.interval_totals(
            Interval.MONTH, "Expenses"
        )
        snapshot(data)
github beancount / fava / tests / test_util.py View on Github external
def test_slugify():
    assert slugify("Example Beancount File") == "example-beancount-file"
    assert slugify("    Example Beancount File  ") == "example-beancount-file"
    assert slugify("test") == "test"
    assert slugify("烫烫烫") == "烫烫烫"
    assert slugify("nonun烫icode 烫烫") == "nonun烫icode-烫烫"
    assert slugify("%✓") == ""
    assert slugify("söße") == "söße"
    assert slugify("ASDF") == "asdf"
    assert slugify("ASDF test test") == "asdf-test-test"