mahlzeit


Namemahlzeit JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://gitlab.com/meschenbacher/mahlzeit
SummaryMahlzeit Plaintextaccounting für Essen und Anderes
upload_time2022-12-23 16:14:40
maintainer
docs_urlNone
authorMaximilian Eschenbacher
requires_python>=3
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Mahlzeit food accounting

You're buying groceries and cooking food for and share them with friends or colleagues.
Next time, a different colleague buys and cooks food. In between, a bank note changes hands.
Who owes how much money after a week's (or more) worth of buying, cooking and eating?

In order to track the balances of all participants, all transactions (purchases as well as cash
exchanging hands or bank accounts) need to be accounted using the `Mahlzeit` class and
`Mahlzeit.einkauf()` and `Mahlzeit.bezahlung()` methods.

For viewing the balances (and transaction), the following methods exist:

- As python dict via `Mahlzeit.calc()` with a simple mapping of the overall account balance:
  `[account]balance`
- Sorted and formatted directly on the console via `Mahlzeit.pretty(file=sys.stdout)`
- In a  [`ledger`-compatible format](https://hledger.org/hledger.html#journal-format) (which
  requires dates and descriptions to be set for each transaction) via
  `Mahlzeit.ledger(file=sys.stdout, prec=3)`

# API and usage

Transactions are grouped within a `Mahlzeit` object:

    from Mahlzeit import Mahlzeit
    m = Mahlzeit()

Each purchase is recorded as call to `Mahlzeit.einkauf(amount, eaters, payer, datum=None, description=None, comment=None)`:

    m.einkauf(10, ('Alice', 'Bob'), 'Alice')

`eaters` and `payer` may be a single string, tuple or list or strings or `Esser` objects.

Change in cash can be recorded with a call to `Mahlzeit.bezahlung(payer, payee, amount, datum=None, description=None, comment=None)`:

    m.bezahlung('Bob', 'Alice', 5)

If `ledger`-compatible output is desired, each transaction (`einkauf` and `bezahlung`) must be
annotated with a date and description:

    m.einkauf(10, ('Alice', 'Bob'), 'Alice', datum='2022/03/16', description='Kebap')
    m.bezahlung('Bob', 'Alice', 5, datum='2022/03/17', description='Payback')

Which can be used in a context to group several transactions within the same annotation:

    with m(datum='2022/03/16', description='Kebap'):
        m.einkauf(10, ('Alice', 'Bob'), 'Alice')
        m.bezahlung('Bob', 'Alice', 5)

Quick console output:

    m.pretty()

Or `ledger` output:

    m.journal()

to be interactively used as

    hledger -f <(python3 main.py) balance

We feature a convenience wrapper for "weighing" eaters. In some cases you need to weigh eaters
in case the is a couple at the weight of `2` or `0.5`. Instantiate a object of class
`Esser(name: str, weight: float)`:

    from mahlzeit import Mahlzeit, Esser as E
    m = Mahlzeit()
    m.einkauf(15, ('Laura', 'Nils', E('Katja_Martin', 2), 'Max'), 'Katja_Martin')
    m.pprint()

# Example integration into a personal ledger (ref. plaintextaccounting)

This example explains how to integrate the `--ledger` output of the Mahlzeit module into your
personal journal. It assumes that you're translating the Mahlzeit account for eating
`$you:einkauf:esser` to your personal expense account e.g. `expenses:food:work`. Account money
you spend for you and your colleagues as `liabilities:kollegen`.

```Makefile
.PHONY: auto-mahlzeit.journal

auto-mahlzeit.journal:
	hledger -f <(echo -e "= expenses:food:work\n    unused    *1\n    liabilities:kollegen  *-1\n"; MAHLZEIT_PLACES=2 venv/bin/python main.py --ledger) \
	--alias=meschenbacher:einkauf:esser=expenses:food:work \
	--alias=/meschenbacher:bezahlung:bezahlt*er/=unused \
	--alias=/meschenbacher:einkauf:bezahler/=unused \
	--alias=/.*:\(einkauf\|bezahlung\):.*/=unused \
	--begin 2022-04-09 \
	print --auto > $@
```

and include it into your journal via `include`.


# Installation

Via pip

    pip install mahlzeit

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/meschenbacher/mahlzeit",
    "name": "mahlzeit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "",
    "author": "Maximilian Eschenbacher",
    "author_email": "qbzioxli@m.t.kajt.de",
    "download_url": "https://files.pythonhosted.org/packages/15/9b/0e53e4aa9279df1e9af618a28c2d6088249857f60314f46f8848fa0d87e8/mahlzeit-1.0.0.tar.gz",
    "platform": null,
    "description": "# Mahlzeit food accounting\n\nYou're buying groceries and cooking food for and share them with friends or colleagues.\nNext time, a different colleague buys and cooks food. In between, a bank note changes hands.\nWho owes how much money after a week's (or more) worth of buying, cooking and eating?\n\nIn order to track the balances of all participants, all transactions (purchases as well as cash\nexchanging hands or bank accounts) need to be accounted using the `Mahlzeit` class and\n`Mahlzeit.einkauf()` and `Mahlzeit.bezahlung()` methods.\n\nFor viewing the balances (and transaction), the following methods exist:\n\n- As python dict via `Mahlzeit.calc()` with a simple mapping of the overall account balance:\n  `[account]balance`\n- Sorted and formatted directly on the console via `Mahlzeit.pretty(file=sys.stdout)`\n- In a  [`ledger`-compatible format](https://hledger.org/hledger.html#journal-format) (which\n  requires dates and descriptions to be set for each transaction) via\n  `Mahlzeit.ledger(file=sys.stdout, prec=3)`\n\n# API and usage\n\nTransactions are grouped within a `Mahlzeit` object:\n\n    from Mahlzeit import Mahlzeit\n    m = Mahlzeit()\n\nEach purchase is recorded as call to `Mahlzeit.einkauf(amount, eaters, payer, datum=None, description=None, comment=None)`:\n\n    m.einkauf(10, ('Alice', 'Bob'), 'Alice')\n\n`eaters` and `payer` may be a single string, tuple or list or strings or `Esser` objects.\n\nChange in cash can be recorded with a call to `Mahlzeit.bezahlung(payer, payee, amount, datum=None, description=None, comment=None)`:\n\n    m.bezahlung('Bob', 'Alice', 5)\n\nIf `ledger`-compatible output is desired, each transaction (`einkauf` and `bezahlung`) must be\nannotated with a date and description:\n\n    m.einkauf(10, ('Alice', 'Bob'), 'Alice', datum='2022/03/16', description='Kebap')\n    m.bezahlung('Bob', 'Alice', 5, datum='2022/03/17', description='Payback')\n\nWhich can be used in a context to group several transactions within the same annotation:\n\n    with m(datum='2022/03/16', description='Kebap'):\n        m.einkauf(10, ('Alice', 'Bob'), 'Alice')\n        m.bezahlung('Bob', 'Alice', 5)\n\nQuick console output:\n\n    m.pretty()\n\nOr `ledger` output:\n\n    m.journal()\n\nto be interactively used as\n\n    hledger -f <(python3 main.py) balance\n\nWe feature a convenience wrapper for \"weighing\" eaters. In some cases you need to weigh eaters\nin case the is a couple at the weight of `2` or `0.5`. Instantiate a object of class\n`Esser(name: str, weight: float)`:\n\n    from mahlzeit import Mahlzeit, Esser as E\n    m = Mahlzeit()\n    m.einkauf(15, ('Laura', 'Nils', E('Katja_Martin', 2), 'Max'), 'Katja_Martin')\n    m.pprint()\n\n# Example integration into a personal ledger (ref. plaintextaccounting)\n\nThis example explains how to integrate the `--ledger` output of the Mahlzeit module into your\npersonal journal. It assumes that you're translating the Mahlzeit account for eating\n`$you:einkauf:esser` to your personal expense account e.g. `expenses:food:work`. Account money\nyou spend for you and your colleagues as `liabilities:kollegen`.\n\n```Makefile\n.PHONY: auto-mahlzeit.journal\n\nauto-mahlzeit.journal:\n\thledger -f <(echo -e \"= expenses:food:work\\n    unused    *1\\n    liabilities:kollegen  *-1\\n\"; MAHLZEIT_PLACES=2 venv/bin/python main.py --ledger) \\\n\t--alias=meschenbacher:einkauf:esser=expenses:food:work \\\n\t--alias=/meschenbacher:bezahlung:bezahlt*er/=unused \\\n\t--alias=/meschenbacher:einkauf:bezahler/=unused \\\n\t--alias=/.*:\\(einkauf\\|bezahlung\\):.*/=unused \\\n\t--begin 2022-04-09 \\\n\tprint --auto > $@\n```\n\nand include it into your journal via `include`.\n\n\n# Installation\n\nVia pip\n\n    pip install mahlzeit\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Mahlzeit Plaintextaccounting f\u00fcr Essen und Anderes",
    "version": "1.0.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "19c2b6bafd0682f216328148453ed6a3",
                "sha256": "55bbcc05a729b432b91b9eb98da5d02a5d381dd0c6ea2586a337bf5b550e1259"
            },
            "downloads": -1,
            "filename": "mahlzeit-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "19c2b6bafd0682f216328148453ed6a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 17314,
            "upload_time": "2022-12-23T16:14:40",
            "upload_time_iso_8601": "2022-12-23T16:14:40.426234Z",
            "url": "https://files.pythonhosted.org/packages/15/9b/0e53e4aa9279df1e9af618a28c2d6088249857f60314f46f8848fa0d87e8/mahlzeit-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-23 16:14:40",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "gitlab_user": "meschenbacher",
    "gitlab_project": "mahlzeit",
    "lcname": "mahlzeit"
}
        
Elapsed time: 0.03291s