Double bra * through the eyes of a programmer

  • Tutorial


Most of us have come across accountants. To many, their terminology seems to be a Chinese letter, as for the humanitarians the reverse Polish entry. However, having understood, you understand how convenient and powerful this tool is.

The article is not academic, but reflects a purely simplified view of mine, and for those who have already mastered academic articles, it will be uninteresting. Those who are interested to understand such a simple and powerful tool as “double recording” - please, under cat.

Let's imagine some kind of structure leading activities that have relationships with the outside world, owning some property. It doesn’t matter what kind of structure it is. It can be a company, a household, a website, or a simple citizen. Let's say it will be an online startup. Say we make an elephant trading platform. We will call this project “Slonomarket”.

We will not register any legal entity, IP / FOP and other legal actions. Imagine that just a few friends agreed to launch such a startup, and conduct their activities in the garage.

Balance


In order to understand the general picture of finances in our Elephant Market, we put up a tablet in which we write what we have, what we owe, what we owe, etc. We call this plate “ balance ”, and the lines in our plate are “ balance accounts ”.

Obviously, not all yogurts are equally useful, there is a big difference between accounts reflecting money at the “cash desk” from how much we owe money to suppliers. Accordingly, we divide our plate into two. In one there will be so-called “ active accounts ”, reflecting what we have, what we can manage, etc., in the second half we will enter “ passive accounts ”, where we will reflect our debts to creditors, suppliers, etc. P.

In fact, assets and liabilities (Rzhevsky to be silent!) Are not quite property and debts, but first I propose such a definition so as not to get confused. To memorize, you can use such an association - we can actively manage assets. Give money to a random acquaintance or spend. To forgive the client’s debt (the client’s debt to us is an asset, our debt to the supplier is a liability), break a machine or give the car for scrap. It all depends on us. And with liabilities only passive operations are possible. We can not take and give random homeless our debt to the supplier. We need the consent of both the homeless and the supplier.

Elephant Market Balance Example:

Assets:

  • YandexMoney: 1000rub
  • Paper: 500 rub
  • Cash with Fedi: 1000rub
  • Elephants in stock: 600 rubles (of which already sold but not shipped - 500 rubles)
  • Elephant Market site: 400rub
  • Hosting for a year: 1000rub
  • Customer debt for elephants: 1000rub
  • Not covered losses (from theft of elephants): 500rub

Liabilities:

  • Share capital (what the founders contributed): 2000rub
  • Retained earnings (from the sale of elephants): 1000rub
  • WebMoney Credit: 1000rub
  • Elephants sold but not delivered to the client: 500 rubles
  • Debt to the supplier Vasya: 500rub
  • Duty to the programmer Feday: 500rub
  • Accrued and unpaid dividends: 500 rubles

Some accounts are surprising, for example, it is not clear why profits in liabilities and losses in assets. This is normal, I will explain a little lower.

I want to draw your attention to the fact that the amount of passive accounts is equal to the sum of active accounts. This balance property is fundamental. From here comes the name itself - balance. If an accountant says that his balance does not converge, then usually he means precisely that his assets and liabilities are not equal, which is the first sign of an error.

Another look at which account will be passive or active:


Assets are what we have, what we spent money on, and liabilities are where this money came from.

From this point of view, we cannot reflect the profit in assets, because in fact it is already there - either in the form of money at the cash desk, or in the form of a client's debt, or in any other form. Even if the client paid off and we immediately spent this money on the purchase of elephants in the warehouse, the profit will lie in the form of new elephants, but we already have it reflected in the assets. But where did it come from? We record its origin in liabilities - profit.

Similarly with losses. If we have suffered losses, for example, elephants have been stolen from us, then the origin of these elephants is already reflected in our liabilities. If these were those elephants which we already sold but did not ship, then they are visible in paid but not shipped elephants. If we bought them from the money of the founders, then in the authorized capital, if we were given them for sale or with a delay, then in the form of debt to the supplier. But where did this money (elephants) go? This is our loss from theft.

From the point of view of the ability to manage these losses, and the fact that we “have” there is also no contradiction here - we can forgive the thief. We can "hang the debt" on the guard who missed the thieves, and calculate from his salary. We can exchange these losses for insurance payment (if there was insurance). Well, or corny "cover" the loss from profit, reducing profit and loss by one amount.

Why are equity / equity reflected in liabilities?

By origin, we received money from the founder, which means we somehow “owe” this money to him. Also by functions - we can distribute profits, for example, to dividends, or to increase the authorized capital. Dividends mean that the founder takes them from the company (in the form of assets, money or products, or whatever), and if we increase the authorized capital from profit, it will be as if the founder gave part of the profit due to him to increase the startup’s assets.

If we do not have “excess” profit, but there are losses, and we want to cover these losses, then we will have no choice but to reduce capital. This roughly corresponds to "since the company has no money, I forgive her part of the debt." Those. if our Slonomarket has earned a profit, then it becomes due to the founder more money, and if he lost money, it becomes less.

Why such difficulties? Because we have to have a balance. Both sides of the balance should be equal, so we just can’t take and throw out some balance items (accounts).

Cheat sheet on what it relates to:

Property, what we can dispose of - active accounts
Obligations to us, what we owe - active accounts
Our obligations, what we owe - passive accounts
Profit - passive accounts
Losses - active accounts
Income - passive accounts
Expenses - active accounts
Capital, i.e. investments of founders, authorized capital, etc. - passive accounts

Postings


Here we smoothly approached the second fundamental property of balance - any changes we have are related to at least two accounts. This statement is a direct consequence of the main balance sheet property - both sides of the balance sheet (assets and liabilities) should be equal in total. Accordingly, if we reduce or increase one side, then we must change the other side in the same way. Or they must change another account of the same type (active or passive) but with a different sign (that is, if we increased some asset and did not change liabilities, we must reduce some other asset ... similarly with liabilities).

To make sure that this is enough for us, remember that assets are what we have, and liabilities are where it came from. Accordingly, in similar terms, if we have some kind of asset, it should come from somewhere, and accordingly a similar record will appear in the liabilities, or another asset will decrease.

Let's say we have a product in stock. But he cannot appear just like that. Either we bought it, and then some assets decreased (cash on hand, money in the account, etc.), or we were given a loan (with a deferred payment, for sale, etc.) and then we have a new liability for the same amount. Have they stolen money from us? Money decreased, loss increased. Did we give a loan? We cannot give credit without reducing our assets or increasing other liabilities. After all, we gave something. This is either money, or something borrowed elsewhere (for example, from the founder) or on account of the debt they gave some goods (then the stock in the warehouse decreased) or we returned the goods taken for sale (we reduced the quantity of goods, we reduced the debt to the supplier for this product). Two accounts always change.

So we come to the second fundamental concept - wiring .

Posting is an “atomic” transaction of changing two accounts by the same amount. In paper accounting they use large books in which they record various accounts and operations with them. We need to record each transaction twice - at the first account and at the second. This is called a double entry, and gave the name to the accounting method which is the basis for any accounting in our time.

Any operation in which only one account is affected is erroneous (yes, I know about off-balance accounts, but this is a rudiment of regulated accounting that is a consequence of the fact that accountants are not programmers and in this article I do not consider them, as well as active-passive ones). If you want to make a single entry, either you don’t need to do it, or you lost your soulmate somewhere, or you need to do the recording in the wrong balance (for example, when people start mixing business money and personal money, which is typical for people who have no other founders in the business and do not have a good understanding of accounting).

Theoretically, in one transaction there could be, for example, three accounts, but this would make it difficult to verify correctness, etc., therefore, an atomic operation affects two accounts and only two.

So, we have a balance, which consists of accounts. There are two types of accounts - active and passive. Changes in the balance sheet are made by postings. Posting is an atomic operation with a balance sheet, it affects two accounts and changes them by the same amount.

Operation


Each transaction has one or more transactions. In essence, an operation is a set of transactions connected by a single meaning, a single event (plus information describing the event itself, but for balance we do not need it).
The operation is a kind of entity reflecting the events of the real world. Moving goods, ordering, paying dividends, etc. Those. real operation.
The postings of one operation must be in the same DBMS transaction, and if one posting failed, then the whole operation failed, i.e. the operation has atomicity.

Let's say we got a batch of elephants. Siberian elephants for 100 rubles, African elephants for 400 rubles and American for 500 rubles. As a result, we have several postings:

1) an increase in debt to the supplier by 100 rubles (liabilities), an increase in Siberian elephants in the warehouse by 100 rubles (asset)
2) an increase in debt by 400 rubles, an increase of African elephants in the warehouse by the same amount
3) an increase in debt by 500 rubles and a similar increase in American elephants stock
4) a decrease in vendor debt for prepayment 500rubley, and a decrease of the same amount of our debt to the supplier (ideally these things make a separate official document, and yes I know that through relationships with counterparties active-passive, but let it be so t).

All these transactions are tied to one operation, and are associated with one event, namely, receipt of goods from the supplier, occur simultaneously, etc.

Document


Usually in any accounting we display each event in the form of one or several documents. If a document reflects a change in the balance sheet, then they are reflected in the form of one or more operations. The division of transactions related to one document into various operations does not have clear rules and depends on the specific accounting objectives.

Debit and credit


Let's look at what postings we have.

1) Increase in the active account, increase in the passive (A + P +)
2) Decrease in the active account, decrease in the passive (A-P-)
3) Decrease and increase in two active accounts (A + A-)
4) Decrease and increase in two passive accounts (P + P-)

It turns out four types of postings. The rest do not satisfy the requirement of maintaining balance. Can we simplify this?

Since we have not yet made any sense in the order of accounts, we will write them in a different order:

A + P +
P-A-
A + A-
P-P +

What can we notice in common in these transactions?

1) If the active account is in the first place, then it increases, if passive, then it decreases
2) When the second account is active, it decreases if the second highest score is passive, then it is incremented
Thus we get one type of transaction, which indicates two accounts, let's call them a debit account, and a credit account, and the amount of the transaction.
Well and accordingly write our rules of wiring steps:
1) If the production rate of an active account, it increases if passive, it decreases
2) If the credit is an active account, it is reduced if the passive accounts, it increases

This is the accounting form of conduct balance ends.

Normalize a little more


Let's try to simplify yet.

Let's record the value of the active account as a positive number, and the passive as negative. Simplistically, the structure of the balance sheet will look like this:

ID,
Name,
Type (passive / asset),
Value
A structure of the posting table, respectively:
ID,
Debit (ID of the account being debited),
Credit (ID of the account being credited,
Amount.

Checking the balance with us is even easier - the sum of all accounts must be equal to 0. The

rules for making transactions are also simple:

1) Add the amount of the transaction to the debit account
2) If the account is passive, then check if it has become positive, if so, we interrupt the operation and roll back the transaction
3) deduct the amount from the credited account.
4) If the account is active, then check to see if it has become negative, and if so, then abort the operation and roll back the transaction.

Everything. We already have all the basic properties of accounting.

Of course, in a real database, we will add various fields related to the subject area, for example, postings need a date / time and a link to the document that generated the posting. Accounts need information about something due to this, and connections to other related objects (contractors, goods, etc.), but that's another story.

Perhaps we’ll finish here for now, if it’s interesting, then I’ll tell you how to extract information from the balance to the maximum, I will analyze a few examples of operations, etc.

ADF:Separated the concept of operation and document. During the discussion of the article, it was written here that the operation and the document are one and the same.

Also popular now: