From 226e2cb13dc70d728e0710f1c8fd49e5b59b3055 Mon Sep 17 00:00:00 2001 From: Pramod Kumar Date: Wed, 27 Apr 2022 16:16:08 +0530 Subject: [PATCH 1/7] Remove pandas --- pyluca/balances.py | 18 ------------------ pyluca/ledger.py | 13 ------------- pyluca/tests/test_accountant.py | 1 - pyluca/tests/test_ledger.py | 14 -------------- 4 files changed, 46 deletions(-) delete mode 100644 pyluca/balances.py diff --git a/pyluca/balances.py b/pyluca/balances.py deleted file mode 100644 index c68c9aa..0000000 --- a/pyluca/balances.py +++ /dev/null @@ -1,18 +0,0 @@ -import pandas as pd -from pyluca.account_config import BalanceType - - -def add_account_balance(config: dict, ledger: pd.DataFrame, account: str) -> pd.DataFrame: - account_type = config['accounts'][account]['type'] - positive_col, negative_col = 'cr_amount', 'dr_amount' - if config['account_types'][account_type]['balance_type'] == BalanceType.DEBIT.value: - positive_col, negative_col = 'dr_amount', 'cr_amount' - - balance, balances = 0, [] - for i, row in ledger.iterrows(): - if row['account'] == account: - balance += row[positive_col] - balance -= row[negative_col] - balances.append(balance) - ledger[account] = balances - return ledger diff --git a/pyluca/ledger.py b/pyluca/ledger.py index 46092d3..bdc2386 100644 --- a/pyluca/ledger.py +++ b/pyluca/ledger.py @@ -1,7 +1,5 @@ -import pandas as pd from pyluca.account_config import BalanceType from pyluca.aging import get_account_aging -from pyluca.balances import add_account_balance from pyluca.journal import Journal @@ -22,17 +20,6 @@ def get_account_balance(self, account: str): return self.get_account_dr(account) - self.get_account_cr(account) return self.get_account_cr(account) - self.get_account_dr(account) - def get_df(self) -> pd.DataFrame: - return pd.DataFrame([j.__dict__ for j in self.journal.entries]) - def get_aging(self, account: str): return get_account_aging(self.config, self.journal.entries, account, self.journal.entries[-1].date) - def add_account_balance(self, account: str, df: pd.DataFrame): - return add_account_balance(self.config, df, account) - - def get_balance_sheet(self): - df = self.get_df() - for acct_name in self.config['accounts'].keys(): - df = self.add_account_balance(acct_name, df) - return df diff --git a/pyluca/tests/test_accountant.py b/pyluca/tests/test_accountant.py index f1a16cc..d2ea7ad 100644 --- a/pyluca/tests/test_accountant.py +++ b/pyluca/tests/test_accountant.py @@ -16,7 +16,6 @@ def test_base(self): ledger = Ledger(accountant.journal, accountant.config) self.assertEqual(ledger.get_account_balance('SAVINGS_BANK'), 20000) self.assertEqual(ledger.get_account_balance('SALARY'), 20000) - self.assertEqual(len(ledger.get_df()), 2) accountant.enter_journal('MUTUAL_FUNDS', 'SAVINGS_BANK', 10000, datetime(2022, 5, 1), 'ELSS') ledger = Ledger(accountant.journal, accountant.config) diff --git a/pyluca/tests/test_ledger.py b/pyluca/tests/test_ledger.py index c942590..ac36622 100644 --- a/pyluca/tests/test_ledger.py +++ b/pyluca/tests/test_ledger.py @@ -18,17 +18,3 @@ def test_ledger_aging(self): ]) ages = Ledger(journal, account_config).get_aging('SAVINGS_BANK') self.assertEqual(len(ages), 3) - - def test_ledger_balance_sheet(self): - accountant = Accountant(Journal(), account_config, '1') - accountant.enter_journal('SAVINGS_BANK', 'SALARY', 20000, datetime(2022, 4, 30), 'April salary') - accountant.enter_journal('MUTUAL_FUNDS', 'SAVINGS_BANK', 10000, datetime(2022, 5, 1), 'ELSS') - accountant.enter_journal('LOANS', 'SAVINGS_BANK', 5000, datetime(2022, 5, 2), 'Lend to Pramod') - accountant.enter_journal('CAR_EMI', 'SAVINGS_BANK', 3000, datetime(2022, 5, 2), 'EMI 3/48') - ledger = Ledger(accountant.journal, account_config) - last_row = ledger.get_balance_sheet().to_dict(orient='record')[-1] - self.assertEqual(last_row['SALARY'], 20000) - self.assertEqual(last_row['SAVINGS_BANK'], 2000) - self.assertEqual(last_row['MUTUAL_FUNDS'], 10000) - self.assertEqual(last_row['LOANS'], 5000) - self.assertEqual(last_row['CAR_EMI'], 3000) From 95283ba051256adfbab7763c5fd2f2b4e3cbfa1a Mon Sep 17 00:00:00 2001 From: Pramod Kumar Date: Wed, 27 Apr 2022 16:57:41 +0530 Subject: [PATCH 2/7] Remove pandas from req --- demo/personal_finance.py | 36 ------------------------------------ requirements.txt | 2 +- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/demo/personal_finance.py b/demo/personal_finance.py index cf333af..a437676 100644 --- a/demo/personal_finance.py +++ b/demo/personal_finance.py @@ -52,42 +52,6 @@ assert ledger.get_account_balance('LOANS') == 1000 assert ledger.get_account_balance('SAVINGS_BANK') == 4000 -# get pandas dataframe -ledger.get_df() -''' - sl_no account dr_amount ... date narration key -0 0 SAVINGS_BANK 20000 ... 2022-04-30 March salary person1 -1 1 SALARY 0 ... 2022-04-30 March salary person1 -2 2 MUTUAL_FUNDS 10000 ... 2022-05-01 Invest in NIFTY 50 Index person1 -3 3 SAVINGS_BANK 0 ... 2022-05-01 Invest in NIFTY 50 Index person1 -4 4 CAR_EMI 5000 ... 2022-05-05 5th EMI person1 -5 5 SAVINGS_BANK 0 ... 2022-05-05 5th EMI person1 -6 6 LOANS 3000 ... 2022-05-05 Lend to Kalyan person1 -7 7 SAVINGS_BANK 0 ... 2022-05-05 Lend to Kalyan person1 -8 8 SAVINGS_BANK 2000 ... 2022-05-15 Partial payback person1 -9 9 LOANS 0 ... 2022-05-15 Partial payback person1 - -[10 rows x 7 columns] -''' - -# get the balance sheet -ledger.get_balance_sheet() -''' - sl_no account dr_amount ... MUTUAL_FUNDS LOANS CAR_EMI -0 0 SAVINGS_BANK 20000 ... 0 0 0 -1 1 SALARY 0 ... 0 0 0 -2 2 MUTUAL_FUNDS 10000 ... 10000 0 0 -3 3 SAVINGS_BANK 0 ... 10000 0 0 -4 4 CAR_EMI 5000 ... 10000 0 5000 -5 5 SAVINGS_BANK 0 ... 10000 0 5000 -6 6 LOANS 3000 ... 10000 3000 5000 -7 7 SAVINGS_BANK 0 ... 10000 3000 5000 -8 8 SAVINGS_BANK 2000 ... 10000 3000 5000 -9 9 LOANS 0 ... 10000 1000 5000 - -[10 rows x 12 columns] -''' - ''' Events & Actions diff --git a/requirements.txt b/requirements.txt index fff319f..8b13789 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pandas==1.1.5 + From 3844bede4377255c27fab0697f26553e2c6e5731 Mon Sep 17 00:00:00 2001 From: Sattyam jain Date: Thu, 28 Apr 2022 12:53:41 +0530 Subject: [PATCH 3/7] Removed pandas support --- demo/personal_finance.py | 49 +++++++++++++++++---------------- pyluca/ledger.py | 33 ++++++++++++++++++++++ pyluca/tests/test_accountant.py | 1 + pyluca/tests/test_ledger.py | 14 ++++++++++ requirements.txt | 1 - 5 files changed, 73 insertions(+), 25 deletions(-) diff --git a/demo/personal_finance.py b/demo/personal_finance.py index cf333af..9d37ff0 100644 --- a/demo/personal_finance.py +++ b/demo/personal_finance.py @@ -52,20 +52,20 @@ assert ledger.get_account_balance('LOANS') == 1000 assert ledger.get_account_balance('SAVINGS_BANK') == 4000 -# get pandas dataframe -ledger.get_df() +ledger.get_ledger() ''' - sl_no account dr_amount ... date narration key -0 0 SAVINGS_BANK 20000 ... 2022-04-30 March salary person1 -1 1 SALARY 0 ... 2022-04-30 March salary person1 -2 2 MUTUAL_FUNDS 10000 ... 2022-05-01 Invest in NIFTY 50 Index person1 -3 3 SAVINGS_BANK 0 ... 2022-05-01 Invest in NIFTY 50 Index person1 -4 4 CAR_EMI 5000 ... 2022-05-05 5th EMI person1 -5 5 SAVINGS_BANK 0 ... 2022-05-05 5th EMI person1 -6 6 LOANS 3000 ... 2022-05-05 Lend to Kalyan person1 -7 7 SAVINGS_BANK 0 ... 2022-05-05 Lend to Kalyan person1 -8 8 SAVINGS_BANK 2000 ... 2022-05-15 Partial payback person1 -9 9 LOANS 0 ... 2022-05-15 Partial payback person1 +[ + {'sl_no': 0, 'account': 'SAVINGS_BANK', 'dr_amount': 20000, 'cr_amount': 0, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1'}, + {'sl_no': 1, 'account': 'SALARY', 'dr_amount': 0, 'cr_amount': 20000, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1'}, + {'sl_no': 2, 'account': 'MUTUAL_FUNDS', 'dr_amount': 10000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1'}, + {'sl_no': 3, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 10000, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1'}, + {'sl_no': 4, 'account': 'CAR_EMI', 'dr_amount': 5000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1'}, + {'sl_no': 5, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 5000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1'}, + {'sl_no': 6, 'account': 'LOANS', 'dr_amount': 3000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1'}, + {'sl_no': 7, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 3000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1'}, + {'sl_no': 8, 'account': 'SAVINGS_BANK', 'dr_amount': 2000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1'}, + {'sl_no': 9, 'account': 'LOANS', 'dr_amount': 0, 'cr_amount': 2000, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1'} +] [10 rows x 7 columns] ''' @@ -73,17 +73,18 @@ # get the balance sheet ledger.get_balance_sheet() ''' - sl_no account dr_amount ... MUTUAL_FUNDS LOANS CAR_EMI -0 0 SAVINGS_BANK 20000 ... 0 0 0 -1 1 SALARY 0 ... 0 0 0 -2 2 MUTUAL_FUNDS 10000 ... 10000 0 0 -3 3 SAVINGS_BANK 0 ... 10000 0 0 -4 4 CAR_EMI 5000 ... 10000 0 5000 -5 5 SAVINGS_BANK 0 ... 10000 0 5000 -6 6 LOANS 3000 ... 10000 3000 5000 -7 7 SAVINGS_BANK 0 ... 10000 3000 5000 -8 8 SAVINGS_BANK 2000 ... 10000 3000 5000 -9 9 LOANS 0 ... 10000 1000 5000 +[ + {'sl_no': 0, 'account': 'SAVINGS_BANK', 'dr_amount': 20000, 'cr_amount': 0, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1', 'SALARY': 0, 'SAVINGS_BANK': 20000, 'MUTUAL_FUNDS': 0, 'LOANS': 0, 'CAR_EMI': 0}, + {'sl_no': 1, 'account': 'SALARY', 'dr_amount': 0, 'cr_amount': 20000, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 20000, 'MUTUAL_FUNDS': 0, 'LOANS': 0, 'CAR_EMI': 0}, + {'sl_no': 2, 'account': 'MUTUAL_FUNDS', 'dr_amount': 10000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 20000, 'MUTUAL_FUNDS': 10000, 'LOANS': 0, 'CAR_EMI': 0}, + {'sl_no': 3, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 10000, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 10000, 'MUTUAL_FUNDS': 10000, 'LOANS': 0, 'CAR_EMI': 0}, + {'sl_no': 4, 'account': 'CAR_EMI', 'dr_amount': 5000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 10000, 'MUTUAL_FUNDS': 10000, 'LOANS': 0, 'CAR_EMI': 5000}, + {'sl_no': 5, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 5000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 5000, 'MUTUAL_FUNDS': 10000, 'LOANS': 0, 'CAR_EMI': 5000}, + {'sl_no': 6, 'account': 'LOANS', 'dr_amount': 3000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 5000, 'MUTUAL_FUNDS': 10000, 'LOANS': 3000, 'CAR_EMI': 5000}, + {'sl_no': 7, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 3000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 2000, 'MUTUAL_FUNDS': 10000, 'LOANS': 3000, 'CAR_EMI': 5000}, + {'sl_no': 8, 'account': 'SAVINGS_BANK', 'dr_amount': 2000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 4000, 'MUTUAL_FUNDS': 10000, 'LOANS': 3000, 'CAR_EMI': 5000}, + {'sl_no': 9, 'account': 'LOANS', 'dr_amount': 0, 'cr_amount': 2000, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1', 'SALARY': 20000, 'SAVINGS_BANK': 4000, 'MUTUAL_FUNDS': 10000, 'LOANS': 1000, 'CAR_EMI': 5000} +] [10 rows x 12 columns] ''' diff --git a/pyluca/ledger.py b/pyluca/ledger.py index bdc2386..4fb263e 100644 --- a/pyluca/ledger.py +++ b/pyluca/ledger.py @@ -1,8 +1,20 @@ +from datetime import datetime +from typing import List, TypedDict from pyluca.account_config import BalanceType from pyluca.aging import get_account_aging from pyluca.journal import Journal +class LedgerDict(TypedDict): + key: str + sl_no: int + account: str + dr_amount: float + cr_amount: float + date: datetime + narration: str + + class Ledger: def __init__(self, journal: Journal, config: dict): self.journal = journal @@ -20,6 +32,27 @@ def get_account_balance(self, account: str): return self.get_account_dr(account) - self.get_account_cr(account) return self.get_account_cr(account) - self.get_account_dr(account) + def get_ledger(self) -> List[LedgerDict]: + return [_entry.__dict__ for _entry in self.journal.entries] + def get_aging(self, account: str): return get_account_aging(self.config, self.journal.entries, account, self.journal.entries[-1].date) + def add_account_balance(self, account: str, ledger: List[LedgerDict]): + account_type = self.config['accounts'][account]['type'] + positive_col, negative_col = 'cr_amount', 'dr_amount' + if self.config['account_types'][account_type]['balance_type'] == BalanceType.DEBIT.value: + positive_col, negative_col = 'dr_amount', 'cr_amount' + balance = 0 + for row in ledger: + if row['account'] == account: + balance += row[positive_col] + balance -= row[negative_col] + row[account] = balance + return ledger + + def get_balance_sheet(self): + ledger = self.get_ledger() + for acct_name in self.config['accounts'].keys(): + ledger = self.add_account_balance(acct_name, ledger) + return ledger diff --git a/pyluca/tests/test_accountant.py b/pyluca/tests/test_accountant.py index d2ea7ad..26cdf4f 100644 --- a/pyluca/tests/test_accountant.py +++ b/pyluca/tests/test_accountant.py @@ -16,6 +16,7 @@ def test_base(self): ledger = Ledger(accountant.journal, accountant.config) self.assertEqual(ledger.get_account_balance('SAVINGS_BANK'), 20000) self.assertEqual(ledger.get_account_balance('SALARY'), 20000) + self.assertEqual(len(ledger.get_ledger()), 2) accountant.enter_journal('MUTUAL_FUNDS', 'SAVINGS_BANK', 10000, datetime(2022, 5, 1), 'ELSS') ledger = Ledger(accountant.journal, accountant.config) diff --git a/pyluca/tests/test_ledger.py b/pyluca/tests/test_ledger.py index ac36622..3a78f9b 100644 --- a/pyluca/tests/test_ledger.py +++ b/pyluca/tests/test_ledger.py @@ -18,3 +18,17 @@ def test_ledger_aging(self): ]) ages = Ledger(journal, account_config).get_aging('SAVINGS_BANK') self.assertEqual(len(ages), 3) + + def test_ledger_balance_sheet(self): + accountant = Accountant(Journal(), account_config, '1') + accountant.enter_journal('SAVINGS_BANK', 'SALARY', 20000, datetime(2022, 4, 30), 'April salary') + accountant.enter_journal('MUTUAL_FUNDS', 'SAVINGS_BANK', 10000, datetime(2022, 5, 1), 'ELSS') + accountant.enter_journal('LOANS', 'SAVINGS_BANK', 5000, datetime(2022, 5, 2), 'Lend to Pramod') + accountant.enter_journal('CAR_EMI', 'SAVINGS_BANK', 3000, datetime(2022, 5, 2), 'EMI 3/48') + ledger = Ledger(accountant.journal, account_config) + last_row = ledger.get_balance_sheet()[-1] + self.assertEqual(last_row['SALARY'], 20000) + self.assertEqual(last_row['SAVINGS_BANK'], 2000) + self.assertEqual(last_row['MUTUAL_FUNDS'], 10000) + self.assertEqual(last_row['LOANS'], 5000) + self.assertEqual(last_row['CAR_EMI'], 3000) diff --git a/requirements.txt b/requirements.txt index fff319f..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -pandas==1.1.5 From 32dec1508be27f2462f16bc904e84313324649b8 Mon Sep 17 00:00:00 2001 From: Sattyam jain Date: Thu, 28 Apr 2022 13:05:56 +0530 Subject: [PATCH 4/7] version update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 06b7f06..f21b305 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setuptools.setup( name='pyluca', - version='0.0.7', + version='0.0.8', author='datasignstech', author_email='tech+opensource@datasignstech.com', description='Double entry accounting system', From 986dd1232b2696ab11e8ebbdf18e942ce75ebb99 Mon Sep 17 00:00:00 2001 From: Sattyam jain Date: Thu, 28 Apr 2022 14:25:49 +0530 Subject: [PATCH 5/7] refactored --- pyluca/ledger.py | 29 +++++++++++------------------ pyluca/tests/test_accountant.py | 1 - 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/pyluca/ledger.py b/pyluca/ledger.py index 4fb263e..fe8a7e5 100644 --- a/pyluca/ledger.py +++ b/pyluca/ledger.py @@ -32,27 +32,20 @@ def get_account_balance(self, account: str): return self.get_account_dr(account) - self.get_account_cr(account) return self.get_account_cr(account) - self.get_account_dr(account) - def get_ledger(self) -> List[LedgerDict]: - return [_entry.__dict__ for _entry in self.journal.entries] - def get_aging(self, account: str): return get_account_aging(self.config, self.journal.entries, account, self.journal.entries[-1].date) - def add_account_balance(self, account: str, ledger: List[LedgerDict]): - account_type = self.config['accounts'][account]['type'] - positive_col, negative_col = 'cr_amount', 'dr_amount' - if self.config['account_types'][account_type]['balance_type'] == BalanceType.DEBIT.value: - positive_col, negative_col = 'dr_amount', 'cr_amount' - balance = 0 - for row in ledger: - if row['account'] == account: - balance += row[positive_col] - balance -= row[negative_col] - row[account] = balance - return ledger - def get_balance_sheet(self): - ledger = self.get_ledger() + ledger = [_entry.__dict__ for _entry in self.journal.entries] for acct_name in self.config['accounts'].keys(): - ledger = self.add_account_balance(acct_name, ledger) + account_type = self.config['accounts'][acct_name]['type'] + positive_col, negative_col = 'cr_amount', 'dr_amount' + if self.config['account_types'][account_type]['balance_type'] == BalanceType.DEBIT.value: + positive_col, negative_col = 'dr_amount', 'cr_amount' + balance = 0 + for row in ledger: + if row['account'] == acct_name: + balance += row[positive_col] + balance -= row[negative_col] + row[acct_name] = balance return ledger diff --git a/pyluca/tests/test_accountant.py b/pyluca/tests/test_accountant.py index 26cdf4f..d2ea7ad 100644 --- a/pyluca/tests/test_accountant.py +++ b/pyluca/tests/test_accountant.py @@ -16,7 +16,6 @@ def test_base(self): ledger = Ledger(accountant.journal, accountant.config) self.assertEqual(ledger.get_account_balance('SAVINGS_BANK'), 20000) self.assertEqual(ledger.get_account_balance('SALARY'), 20000) - self.assertEqual(len(ledger.get_ledger()), 2) accountant.enter_journal('MUTUAL_FUNDS', 'SAVINGS_BANK', 10000, datetime(2022, 5, 1), 'ELSS') ledger = Ledger(accountant.journal, accountant.config) From 9c6cd21f0c50c46f4836a977fe9ea4f5f7e6fd95 Mon Sep 17 00:00:00 2001 From: Sattyam jain Date: Thu, 28 Apr 2022 14:26:37 +0530 Subject: [PATCH 6/7] refactored --- demo/personal_finance.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/demo/personal_finance.py b/demo/personal_finance.py index 9d37ff0..3101175 100644 --- a/demo/personal_finance.py +++ b/demo/personal_finance.py @@ -52,24 +52,6 @@ assert ledger.get_account_balance('LOANS') == 1000 assert ledger.get_account_balance('SAVINGS_BANK') == 4000 -ledger.get_ledger() -''' -[ - {'sl_no': 0, 'account': 'SAVINGS_BANK', 'dr_amount': 20000, 'cr_amount': 0, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1'}, - {'sl_no': 1, 'account': 'SALARY', 'dr_amount': 0, 'cr_amount': 20000, 'date': datetime.datetime(2022, 4, 30, 0, 0), 'narration': 'March salary', 'key': 'person1'}, - {'sl_no': 2, 'account': 'MUTUAL_FUNDS', 'dr_amount': 10000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1'}, - {'sl_no': 3, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 10000, 'date': datetime.datetime(2022, 5, 1, 0, 0), 'narration': 'Invest in NIFTY 50 Index', 'key': 'person1'}, - {'sl_no': 4, 'account': 'CAR_EMI', 'dr_amount': 5000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1'}, - {'sl_no': 5, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 5000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': '5th EMI', 'key': 'person1'}, - {'sl_no': 6, 'account': 'LOANS', 'dr_amount': 3000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1'}, - {'sl_no': 7, 'account': 'SAVINGS_BANK', 'dr_amount': 0, 'cr_amount': 3000, 'date': datetime.datetime(2022, 5, 5, 0, 0), 'narration': 'Lend to Kalyan', 'key': 'person1'}, - {'sl_no': 8, 'account': 'SAVINGS_BANK', 'dr_amount': 2000, 'cr_amount': 0, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1'}, - {'sl_no': 9, 'account': 'LOANS', 'dr_amount': 0, 'cr_amount': 2000, 'date': datetime.datetime(2022, 5, 15, 0, 0), 'narration': 'Partial payback', 'key': 'person1'} -] - -[10 rows x 7 columns] -''' - # get the balance sheet ledger.get_balance_sheet() ''' From b2c0d0ebbb5cf7d4be9f3d8710c07c5f6518024f Mon Sep 17 00:00:00 2001 From: Sattyam jain Date: Thu, 28 Apr 2022 14:47:00 +0530 Subject: [PATCH 7/7] Removed LedgerDict --- pyluca/ledger.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pyluca/ledger.py b/pyluca/ledger.py index fe8a7e5..b9115fb 100644 --- a/pyluca/ledger.py +++ b/pyluca/ledger.py @@ -1,20 +1,8 @@ -from datetime import datetime -from typing import List, TypedDict from pyluca.account_config import BalanceType from pyluca.aging import get_account_aging from pyluca.journal import Journal -class LedgerDict(TypedDict): - key: str - sl_no: int - account: str - dr_amount: float - cr_amount: float - date: datetime - narration: str - - class Ledger: def __init__(self, journal: Journal, config: dict): self.journal = journal