Package: mahlzeit
Mahlzeit food accountingYou'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 theMahlzeitclass andMahlzeit.einkauf()andMahlzeit.bezahlung()methods.For viewing the balances (and transaction), the following methods exist:As python dict viaMahlzeit.calc()with a simple mapping of the overall account balance:[account]balanceSorted and formatted directly on the console viaMahlzeit.pretty(file=sys.stdout)In aledger-compatible format(which
requires dates and descriptions to be set for each transaction) viaMahlzeit.ledger(file=sys.stdout, prec=3)API and usageTransactions are grouped within aMahlzeitobject:from Mahlzeit import Mahlzeit
m = Mahlzeit()Each purchase is recorded as call toMahlzeit.einkauf(amount, eaters, payer, datum=None, description=None, comment=None):m.einkauf(10, ('Alice', 'Bob'), 'Alice')eatersandpayermay be a single string, tuple or list or strings orEsserobjects.Change in cash can be recorded with a call toMahlzeit.bezahlung(payer, payee, amount, datum=None, description=None, comment=None):m.bezahlung('Bob', 'Alice', 5)Ifledger-compatible output is desired, each transaction (einkaufandbezahlung) 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()Orledgeroutput:m.journal()to be interactively used ashledger -f <(python3 main.py) balanceWe feature a convenience wrapper for "weighing" eaters. In some cases you need to weigh eaters
in case the is a couple at the weight of2or0.5. Instantiate a object of classEsser(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--ledgeroutput of the Mahlzeit module into your
personal journal. It assumes that you're translating the Mahlzeit account for eating$you:einkauf:esserto your personal expense account e.g.expenses:food:work. Account money
you spend for you and your colleagues asliabilities:kollegen..PHONY:auto-mahlzeit.journalauto-mahlzeit.journal:hledger-f<(echo-e"= expenses:food:work\n    unused    *1\n    liabilities:kollegen  *-1\n";MAHLZEIT_PLACES=2venv/bin/pythonmain.py--ledger)\--alias=meschenbacher:einkauf:esser=expenses:food:work\--alias=/meschenbacher:bezahlung:bezahlt*er/=unused\--alias=/meschenbacher:einkauf:bezahler/=unused\--alias=/.*:\(einkauf\|bezahlung\):.*/=unused\--begin2022-04-09\print--auto>$@and include it into your journal viainclude.InstallationVia pippip install mahlzeit