Live data from Hacker News

Double-entry bookkeeping as a directed graph

matheusportela.com

101–110 of 388 posts

Re: Double-entry bookkeeping as a directed graph

#101
post #82

Earlier quoted context omitted.

Every explanation of double entry accounting seems to do the same thing. If I'm trying to understand the double part of double-entry bookkeeping, what exactly does the "double" refer to? What's being "doubled"? How would you salvage the article to actually explain the "double" part in detail? Could you do it purely from Bob's (or Alice's) perspective?

It’s a checksum; by decomposing every transaction into a double of (credit A, debit B) that must sum to zero, you catch random arithmetic errors. You can think of it as “conservation of value”, so you can’t just create money out of thin air in your payment service (credit), without tying it to some account with a corresponding debit. This originally was intended to protect against typos; eg write a 10 instead of 100,…

> This originally was intended to protect against typos;

Double entry bookkeeping is much older than typing, but, yes, its a check against incorrect entries.

Re: Double-entry bookkeeping as a directed graph

#102
post #88

Earlier quoted context omitted.

Every explanation of double entry accounting seems to do the same thing. If I'm trying to understand the double part of double-entry bookkeeping, what exactly does the "double" refer to? What's being "doubled"? How would you salvage the article to actually explain the "double" part in detail? Could you do it purely from Bob's (or Alice's) perspective?

Every time money is exchanged, it has to come from somewhere and it has to go somewhere -- that's two places it need to be recorded (or "entered in the books"). Money can not be created out of thin air, and it can not be destroyed. Every movement of money has to be accounted for, which is why it's called "accounting". Double-entry accounting means you have to account for where the money comes from, and you have to ac…

> Money can not be created out of thin air, and it can not be destroyed.

Yet accounting is necessary because money is created out of thin air. Money is just the representation of debt, an IOU. There needs to be a record of it in order to know that a debt was created and that a debt was destroyed.

More practically, let's say you give me corn today, and I promise to deliver some of the chickens fed that corn to you after it is ready to for slaughter. Money keeps track of the promise outstanding. We record that promise, or account for it if you will, so that we remember that there is a promise and so that we can later ensure that the promise was delivered upon as agreed. Something that becomes especially important when you realize that promises can be traded on to other people who weren't party to the initial deal. Perhaps you don't really want chicken, but would prefer a watch instead. Luckily the watch maker would like to eat chicken for dinner down the line, so you give him the promise of chicken in exchange for the watch. So on, and so on.

Realistically, double-entry accounting is really quadruple-entry accounting. You record that something was received and you record that a promise was made, then, later on, you record that something was delivered as promised and also record that the promise is no longer outstanding (or in reverse if you are on the opposite end of the transaction). A profit indicates that people still owe you things that you haven't collected upon. A loss indicates that you still owe people things that you haven't yet delivered.

Re: Double-entry bookkeeping as a directed graph

#103
post #88

Earlier quoted context omitted.

Every explanation of double entry accounting seems to do the same thing. If I'm trying to understand the double part of double-entry bookkeeping, what exactly does the "double" refer to? What's being "doubled"? How would you salvage the article to actually explain the "double" part in detail? Could you do it purely from Bob's (or Alice's) perspective?

Every time money is exchanged, it has to come from somewhere and it has to go somewhere -- that's two places it need to be recorded (or "entered in the books"). Money can not be created out of thin air, and it can not be destroyed. Every movement of money has to be accounted for, which is why it's called "accounting". Double-entry accounting means you have to account for where the money comes from, and you have to ac…

> Where it can become confusing is when money leaves you or comes in from an external source. There are still two entries, but one entry is in one party's books and the other entry is the other's. For example, I get a paycheque and I enter my income in a little book with green paper and DB/CR columns. At the same time, my employer has entered an expense in their book. Double entries.

NO.

I mean your employer probably has a set of books, but that's not true in your own local set of books.

In your local set of books you would have something like:

    ACME, inc Employment Income  $100 DEBIT
    Bank Account                 $100 CREDIT
You are accounting for ACME, Inc's Employment expense in your set of books too.

When you send a payment to your Power Company:

    Power Company Expense: $100 CREDIT
    Bank Account:          $100 DEBIT
I mean if you are categorizing expenses you might do something like that. If you aren't, you might title one account "Expenses" and spend it all there, it doesn't really matter what you call the accounts, just that you are consistent.

Re: Double-entry bookkeeping as a directed graph

#104
Double-entry bookkeeping is very easy to understand once you ditch the ridiculous "credit" and "debit" terminology.

Essentially, the goal is to keep the accounting equation true at all times. The equation is: Equity = Assets - Liabilities. Eventually, earnings (Income - Expenses) will become part of equity, so splitting that out, you have: Equity + Income - Expenses = Assets - Liabilities. Rearranging to get rid of the minus signs you get: Equity + Income + Liabilities = Assets + Expenses. This equation must be true or something has gone wrong - like money appearing or disappearing out of nowhere. To keep it true at all times, it should be clear that any time you add money to an account on the left side of the equation (say, to an Income account), you must either add the same amount to an account on the other side or subtract the same amount from the same side.

For example, you sell a lemonade for $5. You add $5 to Sales (Income) and add $5 to Current Account (Assets).

The "credit" and "debit" terminology is ridiculous because their definitions swap around depending on which account you're talking about, which is an utterly absurd (mis)use of language and the main reason people find this confusing.

Re: Double-entry bookkeeping as a directed graph

#105

Earlier quoted context omitted.

Remember, this was all done on paper before software with tagging and such existed. I'll give a description shot, since I've been doing finance work recently. Other people can feel free to correct. A company using double entry (as opposed to single) has a "chart of accounts." This means they have a bunch of imaginary accounts for tracking everything, including: - Assets (e.g. cash on hand.) - Liabilities (e.g. loans)…

How do you determine which thing goes in which account, is it subjective or there is a formal way with a definition

In a general sense, it really doesn't matter, as long as you are consistent.

That said, there are accounting standards that define the general set of accounts for a particular industry, etc.

But every person having a set of books will want to customize it to some degree.

For instance in a personal set of books, if you want to track every person you pay, you might have accounts, 1 for every single person you have ever paid, ever.

That obviously can get pretty big! Others might not care that their electricity provider changed from Tootie inc. to Turtle inc, so they just have Utilities:Electricity as their account name.

Others might not care at all, and just have a very general "Expenses" account for things like that.

Make sense?

The important part is consistency of using the same accounts for the same transactions.

Re: Double-entry bookkeeping as a directed graph

#106

I think I'm missing something here. How does looking at transaction history as a directed graph help anything? Is it an improvement on the centuries-old "double-entry" practice? It seems to barely work with the toy example of couple transactions - imagine what the graph would look like with dozens or hundreds of edges between pairs of nodes. What use would there be for the typical algorithms that work with graphs? Th…

[deleted]

Re: Double-entry bookkeeping as a directed graph

#107

I think people underestimate the beauty and impact of accounting. Just a tiny number of formulas (accounting identities [1]) and statements (P&L, balance sheet, etc.) can represent what's going on in any org in ways that can be roughly comparable. Reminds me of the "fundamental theorem of calculus" or "central dogma of biology". Accounting is also where we get math and written language [2] as ancient Mesopotamian civ…

On the other hand some things in how accounting is traditionally done suffer from accounting predating a lot of "modern" math. Negative numbers were first used around the 3rd century in China and took until the 16th century to be used in Europe. Modern double-entry bookkeeping was invented in the 14th century in Europe. So if you ever wonder why they traditionally use a column for debit and one for credit, with defin…

Negative numbers have no place* in accounting, and people need to stop thinking "oh, credits are just negative numbers" and hopelessly confusing themselves and others by putting nonsensical signs on an unsigned magnitude of flux.

* you can actually think of oddball reasons you might consider a "negative credit/debit", but it's more akin to something like a negative mass in physics

Re: Double-entry bookkeeping as a directed graph

#108

Double-entry bookkeeping is very easy to understand once you ditch the ridiculous "credit" and "debit" terminology. Essentially, the goal is to keep the accounting equation true at all times. The equation is: Equity = Assets - Liabilities. Eventually, earnings (Income - Expenses) will become part of equity, so splitting that out, you have: Equity + Income - Expenses = Assets - Liabilities. Rearranging to get rid of t…

The one thing I remember most from my economics courses in college is that economists have highly idiosyncratic mathematical conventions and they don't care. So many graphs with the independent variable on the Y axis...

Re: Double-entry bookkeeping as a directed graph

#109
Very cool! Well-written, and surprisingly real:

Somewhere VERY close to this modeling patterns has always been an interesting use case for us is large-scale visual analysis of crypto investigations, where the ledger gets shown quite similarly. The bit on taxes is funny too, as that's the first thing to get filtered out because it makes the graph messy :) Often, balances aren't initially known, so a post whole-graph-compute step is done to algorithmically enrich nodes after.

You can also do visual tricks here, like collapse 'multiedges' between the same accounts to get a summary of their p2p history. Analytically, this becomes an easy groupby on a ledger dataframe :)

To a lesser extent, we also see fiat $ investigations here too, imagine correspondent banking. I wish more bigco AML forensic accounting did this internally (erp, credit cards, ..), especially as so much is digital now, but we don't see that as much.

An interesting area becomes when you do things like add identity details to the graph, and can then start realizing the "A" and "Alice" and contra XYZ are all the same person. Another, which helps once you have a lot of data, is to start to be able to decloak transaction $1 "food" is a Costco hotdog, or funny buying patterns. Both are where "graph neural networks" come in, which have really advanced over the last few years. We see this kind of things in finance, like risk analysis. We find most folks are at the viz stage vs AI stage, and it's a multi-year relationship to get them from one to another, but a fun one!

---

Edit: Another practical modeling aha here is that a transaction can involve multiple entities. Formally, that is a hyperedge: it's fine for edges to connect more than 2 nodes. (And why languages like datalog are neat here, even if rare.) Visually that's confusing, so a trick is to make the transaction a node and connect it to all the involved accounts. Keeping transactions as event edges between entities can be nicer when zoomed out as fewer nodes, but having the transaction node is nice when zoomed in, and in the limit, there are asymptomatically fewer nodes+edges when doing the transaction node as you replace strongly connected components (quadtratic in edges) with a hub&spoke, which is linear.

Re: Double-entry bookkeeping as a directed graph

#110
post #46
post #18

Earlier quoted context omitted.

i was about to write the same thing. knowing that double-entry is meant to apply to myself only, i actually found the example confusing, because well, of course bob is going to have an entry in his accounting book, but i don't care about bobs accounts, i don't want to track that. i only care about mine. i buy a book. how do i record this transaction using double entry bookkeeping in my accounting book? and bob is not…

You gained $20 worth of assets, so the counterpart of the $20 leaving your bank account is countered by your assets-account gaining $20 Now each year your book loses 1/5th of its value, due to wear and tear (4$ disappearing from your assets-account), this is countered by your depreciation-account (4$ tax write off, every year!) After 5 years, it is worth $0 according to your books, but you manage to sell it again for…

And how about food? I can understand a book having a resale value I keep in my books, but once I've eaten the hot-dog I bought it is gone forever.
Post reply on HN