Skip to content

Commit

Permalink
renamed methods to dr and cr
Browse files Browse the repository at this point in the history
  • Loading branch information
epogrebnyak committed Aug 20, 2024
1 parent 659d381 commit 0a873c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions playground/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ class MultipleEntry(IterableEntry):
def __iter__(self):
return iter(self.debits + self.credits)

def debit(self, account_name, amount):
def dr(self, account_name, amount):
self.debits.append(DebitEntry(account_name, amount))
return self

def credit(self, account_name, amount):
def cr(self, account_name, amount):
self.credits.append(CreditEntry(account_name, amount))
return self

Expand All @@ -239,7 +239,7 @@ class DoubleEntry(IterableEntry):
@property
def multiple_entry(self) -> MultipleEntry:
a = self.amount
return MultipleEntry().debit(self.debit, a).credit(self.credit, a)
return MultipleEntry().dr(self.debit, a).cr(self.credit, a)

def __iter__(self):
return iter(self.multiple_entry)
Expand Down
4 changes: 2 additions & 2 deletions playground/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_balance_sheet_on_contra_account():

def test_ledger_post_method():
book = Ledger({"a": DebitAccount(), "b": CreditAccount()})
e = MultipleEntry().debit("a", 100).credit("b", 100)
e = MultipleEntry().dr("a", 100).cr("b", 100)
book.post(e)
assert book == {
"a": DebitAccount(Amount(100), Amount(0)),
Expand All @@ -76,7 +76,7 @@ def test_end_to_end():
DoubleEntry("cash", "equity", 100),
DoubleEntry("inventory", "cash", 90),
DoubleEntry("cogs", "inventory", 60),
MultipleEntry().debit("cash", 75).debit("refunds", 2).credit("sales", 77),
MultipleEntry().dr("cash", 75).dr("refunds", 2).cr("sales", 77),
]

chart = Chart(
Expand Down
6 changes: 3 additions & 3 deletions playground/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from .core import (
from core import (
T5,
AbacusError,
Account,
Expand Down Expand Up @@ -47,15 +47,15 @@ def debit(
):
"""Add debit entry or debit account name."""
amount = Amount(amount or self._amount)
self._entry.debit(account_name, amount)
self._entry.dr(account_name, amount)
return self

def credit(
self, account_name: AccountName, amount: Amount | int | float | None = None
):
"""Add credit entry or credit account name."""
amount = Amount(amount or self._amount)
self._entry.credit(account_name, amount)
self._entry.cr(account_name, amount)
return self

def __iter__(self):
Expand Down

0 comments on commit 0a873c4

Please sign in to comment.