Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified set of types and rules for core #80

Open
epogrebnyak opened this issue Jul 21, 2024 · 1 comment
Open

Simplified set of types and rules for core #80

epogrebnyak opened this issue Jul 21, 2024 · 1 comment

Comments

@epogrebnyak
Copy link
Owner

epogrebnyak commented Jul 21, 2024

Work flow:

  • A chart of accounts defines a ledger: Chart -> Ledger
  • One can post entries to ledger, invalid entries are not posted Ledger -> List[Entry] -> (Ledger, List[Entry])
  • On ledger closing we close income and expense accounts, create income statement, and transfer current profit to retained earnings: Ledger -> (ClosedLedger, IncomeStatement)
  • Postclose entries may distribute dividend: ClosedLedger -> List[Entry] -> ClosedLedger
  • End of period account balances are saved for next period: ClosedLedger -> Balances
  • End of period balances create an opening entry for start of next period Balances -> Entry
  • We condense contra accounts and show balance sheet report ClosedLedger -> BalanceSheet

Obtain information about ledger:

  • Trial balance reflects state of ledger Ledger -> TrialBalance
  • We can calculate current profit based on state of income and expense accounts

Other:

  • Chart, [Entry], IncomeStatement, BalanceSheet and Balances are serialisable

Assumptions:

  • No contra accounts
  • Simplistic or no cash flow statement
  • One level of accounts
  • One currency
  • No negativity or overspending checks
  • Entry can touch any accounts
  • Must supply entries, not transactions

Chart:

  • required accounts are retained earnings account and income summary account
  • Asset, Expense, Capital, Liability, Income, IncomeSummaryAccount, RetainedEarnings
epogrebnyak added a commit that referenced this issue Jul 22, 2024
epogrebnyak added a commit that referenced this issue Jul 22, 2024
epogrebnyak added a commit that referenced this issue Jul 26, 2024
epogrebnyak added a commit that referenced this issue Jul 27, 2024
epogrebnyak added a commit that referenced this issue Aug 20, 2024
epogrebnyak added a commit that referenced this issue Aug 20, 2024
@epogrebnyak
Copy link
Owner Author

from playground.ui import Book

# Start company
book = Book(company_name="Pied Piper")

# Create chart of accounts
book.add_assets("cash", "inventory", "ar")
book.add_capital("equity")
book.add_income("sales", offsets=["refunds"])
book.add_expense("cogs")
book.add_liability("dividend")
book.set_retained_earnings("re")

# Open ledger and post entries
book.open()
book.entry("Shareholder investment").amount(300).debit("cash").credit("equity").commit()
book.entry("Bought inventory").amount(200).debit("inventory").credit("cash").commit()
book.entry("Invoiced sales").debit("ar", 380).debit("refunds", 20).credit("sales", 400).commit()
book.entry("Shippled goods").amount(200).debit("cogs").credit("inventory").commit()

# Close ledger at period end and make post-close entries
book.close()
book.entry("Accrue dividend").amount(90).debit("re").credit("dividend").commit()

# Show reports
print(book.balance_sheet.json())
print(book.income_statement.json())

Result:

{"assets": {"cash": 100, "inventory": 0, "ar": 380}, "capital": {"equity": 300, "re": 90}, "liabilities": {"dividend": 90}}
{"income": {"sales": 380}, "expenses": {"cogs": 200}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant