epogrebnyak / abacus

A small yet valid double-entry accounting system in Python and command line.
https://epogrebnyak.github.io/abacus/
GNU General Public License v3.0
59 stars 4 forks source link

add Pipeline class #11

Closed epogrebnyak closed 1 year ago

epogrebnyak commented 1 year ago
methods change pipeline.entries:

pipeline.add_entries()
pipeline.close_contra_accounts(related_to=Income)
pipeline.close_contra_accounts(related_to=Expense)
pipeline.close_temporary_contra_accounts() # equivalent to two above
# --- at this point income statement can be calcultaed
# income and expense will need calculation of ledger
pipeline.close_income()   # raise error if balance of contraccount for income not zero
pipeline.close_expense()  # raise error if balance of contraccount for expenses not zero
pipeline.close_income_and_expense() # raise error if isa balance not zero 
pipeline.close_income_summary_account()
pipeline.close_contra_accounts(related_to=Asset)
pipeline.close_contra_accounts(related_to=Liability)
pipeline.close_contra_accounts(related_to=Capital)
pipeline.close_permanent_contra_accounts()  # equivalent to three above
ledger.is_closed() # all permanent contra accounts are zero, income, expense and isa are zero
ledger.is_neeted() # is closed and permanent contraccounts are closed
# --- at this point balance sheet statement can be calcultaed

@dataclass
class Pipeline:
  """Construct a list of postings to a ledger using add_entries() method and methods for closing temporarily accounts or netting contraccounts."""
  start_ledger: Ledger
  entries: List[Entry] #= ...

  def run(self):
    return process_entries(self.start_ledger, self.entries)
epogrebnyak commented 1 year ago

Maybe instead of ledger one may accept a list of single entries that create a ledger.