From 0a873c4b458465c547dbe39e5f7f41856bbd1f1c Mon Sep 17 00:00:00 2001 From: Evgeny Pogrebnyak Date: Tue, 20 Aug 2024 06:51:19 +0000 Subject: [PATCH] renamed methods to dr and cr --- playground/core.py | 6 +++--- playground/test_core.py | 4 ++-- playground/ui.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/playground/core.py b/playground/core.py index 10f057f..ea532d2 100644 --- a/playground/core.py +++ b/playground/core.py @@ -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 @@ -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) diff --git a/playground/test_core.py b/playground/test_core.py index b287151..bf4f6fb 100644 --- a/playground/test_core.py +++ b/playground/test_core.py @@ -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)), @@ -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( diff --git a/playground/ui.py b/playground/ui.py index ee7585e..11e6aa0 100644 --- a/playground/ui.py +++ b/playground/ui.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from .core import ( +from core import ( T5, AbacusError, Account, @@ -47,7 +47,7 @@ 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( @@ -55,7 +55,7 @@ def credit( ): """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):