django-hordak icon indicating copy to clipboard operation
django-hordak copied to clipboard

Enter Opening balance in an account.

Open prdpspkt opened this issue 2 years ago • 4 comments

There is no way to input the opening balance. I tried manually and it raises Sum of transaction amounts in each currency must be 0. Currency NPR has non-zero total 10000.00 CONTEXT: PL/pgSQL function check_leg() line 22 at RAISE

prdpspkt avatar Sep 17 '22 03:09 prdpspkt

@prdpspkt I think this is misunderstanding how django-hordak works. It is double accounting tool, meaning that all transactions should have zero total balance across all accounts.

What does that mean for you is, that you have to create on another account called i.e. "Bank" and transfer the money from that account to the accounts you desire to fill with the opening balance.

PetrDlouhy avatar Sep 17 '22 07:09 PetrDlouhy

What if I need to use cash then ?

prdpspkt avatar Sep 18 '22 06:09 prdpspkt

I am no expert in double-entry accounting, but I don't think there is any substantial difference between cash and cashless transactions.

If there is initial balance it had to come from somewhere (e.g. one of the founders of company), so you can create an account for that and create transaction. Even if the accounting starts in the middle I think the balance taken from past time should be recorded in form of an transaction.

PetrDlouhy avatar Sep 18 '22 07:09 PetrDlouhy

@prdpspkt, yes @PetrDlouhy is correct - it's a gap of understanding about double entry accounting.

Here is a more complex example of how to "start an account with existing balance".

A common way to start a Cash balance is to debit the Cash Account and credit Owner's Equity.

In Hordak:

# my_model.py
class MyModel(models.Model):
  self.assets_cash = model.ForeignKey(Account, on_delete=models.CASCADE, related_name='assets_cash')
  self.owners_equity = model.ForeignKey(Account, on_delete=models.CASCADE, related_name='assets_cash')

  def setupAccounts(self):
    self.assets_cash = Account.objects.create(name="Cash", currencies=["EUR"], type=Account.TYPES.assets)
    self.owners_equity = Account.objects.create(name="Owners Equity", currencies=["EUR"], type=Account.TYPES.equity)


# initial_balance.py
my_obj = MyModel.objects.all().first()
my_obj.owner_equity.accounting_transfer_to(my_obj.assets_cash, 1000, "Initial balance")

Please note I'm using accounting_transfer_to which is a new function soon to be released.

nitsujri avatar May 04 '23 02:05 nitsujri