Skip to content

Commit

Permalink
#79 sample API call
Browse files Browse the repository at this point in the history
  • Loading branch information
epogrebnyak committed Jan 24, 2024
1 parent 3e9102d commit 9698e90
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions core/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def short(accounts: list[str], re: str, t: list[str]):
"""Short names of arguments for nicer API query string."""
return reports(accounts, re, t)


def reports(
accounts: list[str], retained_earnings_account: str, transactions: list[str]
):
"""Return trial balance, balance sheet, and income statement."""
return dict(
accounts=accounts.split("+"),
retained_earnings_account=retained_earnings_account,
transactions=[t.split("+") for t in transactions],
)


accounts = "asset:cash,ar+asset:ppe^depreciation+capital:equity+contra:equity:ts+liabilities:vat+income:sales"
re = "retained_earnings"
ts = ["cash,equity,500", "cr:vat,20+cr:sales,100+dr:cash,120"]
accepted = short(accounts, re, ts)
print(accepted)
assert accepted == {
"accounts": [
"asset:cash,ar",
"asset:ppe",
"capital:equity",
"contra:equity:ts",
"contra:ppe:depreciation",
"liabilities:vat",
"income:sales",
],
"retained_earnings_account": "retained_earnings",
"transactions": [["cash,equity,500"], ["cr:vat,20", "cr:sales,100", "dr:cash,120"]],
}

0 comments on commit 9698e90

Please sign in to comment.