HNHacker News
TopNewBestAskShowJobs

omichowdhury

4 karma · joined March 6, 2020

CTO @ Fragment - fragment.dev
submissionscomments
omichowdhury··on Double-entry bookkeeping as a directed graph
I completely forgot what the original post I was replying to was about lol. If it was about lemonade then yup the lemons and the lemonade should be on the books as assets.

I’ve also wondered what to do if you grow your own lemons. I guess you could offset the new asset on your books with a Harvest income account?

One of our customers built an ERP for food distributors, I should ask them how they would handle it.

omichowdhury··on Double-entry bookkeeping as a directed graph
I guess technically this would be selling a service instead of a good.

I was going through the 4 combinations of balanced two-line entries, based on the accounting equation, to show how it helps when thinking through how to record something.

If you get into more than two lines, then yup selling a good would be

  +Asset -Asset +Income
or if you include sales tax and son shipping costs:

  +Asset -Asset +Liability +Income +Expense
Using an updated accounting equation and negative numbers is a lot more intuitive than credits and debits. In this larger example it tells you:

  Cash Asset - COGS Asset - Tax Liability = Sales Income - Shipping Expense

It tells you what types of accounts balance, with a syntax that matches your intuitions: more asset = good, less asset = bad, more expense = bad, less expense = good.
omichowdhury··on Double-entry bookkeeping as a directed graph
Haha that sounds like shut-up-and-calculate to me. The alternative is to update the rules to use our intuition on whether the action we’re tracking is good or bad for us and map that to increasing or decreasing balances that represent what we own, owe, earn and spend.

More deets here: https://news.ycombinator.com/item?id=40021506

omichowdhury··on Double-entry bookkeeping as a directed graph
Yup I think it’s best to leave credits and debits behind. We can use more than 2 bits these days.

I think a far more intuitive system is use negative numbers with a symmetrical accounting equation:

  Assets - Liabilities = Income - Expense
Then you always think in terms of:

- Do I have more or less assets?

- Do I owe more or less liabilities?

- Did I make more of less profits?

- Did I make more or less losses?

You can then use the accounting equation to check your reasoning. I go more into it here: https://news.ycombinator.com/item?id=40021375

omichowdhury··on Double-entry bookkeeping as a directed graph
I don’t think you need to think of income accounts as negative if the ledger you use enforces an updated accounting equation that also uses negative numbers, See https://news.ycombinator.com/item?id=40021506
omichowdhury··on Double-entry bookkeeping as a directed graph
Nope, in these examples the +Asset on the left means you received say cash. The right side shows various ways to balance that out based on the accounting equation

I did an explanation with numbers here: https://news.ycombinator.com/item?id=40021506

omichowdhury··on Double-entry bookkeeping as a directed graph
We implemented negative numbers in our ledger API (https://fragment.dev) and don’t use credits and debits at all. A bunch of engineers who didn’t know double-entry found it a lot easier to pick up. I think the key is to update the accounting equation to:

  (A)ssets - (L)iabilities = (I)ncome - (E)xpense
So if you have more (+100) Assets, then to balance it out, you either need to have:

  +100 Liabilities (100 A - 100 L = 0) → You took out a loan and increased your liabilities

  -100 Assets (100 A - 100 A = 0) → You sold an asset for what it was worth

  +100 Income (100 A = 100 I) → You provided a service and earned income

  -100 Expense (100 A = 0 I - -100 E) → You got a refund for a previous expense
I think that’s much more intuitive. You can think always think in terms of more or less Assets, Liabilities, Income or Expenses, then use the Accounting equation to check your reasoning.

Here’s a deeper explanation: https://fragment.dev/docs#design-your-ledger-ledger-accounts

Disclaimer: I’m CTO at Fragment

omichowdhury··on Double-entry bookkeeping as a directed graph
I think you’re missing the balancing that needs to happen that’s internal to each party’s books. That’s where an expense account would come in, using the accounting equation:

               ∆ State = ∆ Change
                       ↓ 
  Assets - Liabilities = Income - Expense
For example you had:

> 3. The employee submitting their expense report (invoice) to the company for reimbursement (liability to the company, asset to the employee)

So looking just at the company’s books:

  $0 Asset - $100 Liability = $0 Income - $100 Expense
                -$100 State = -$100 Change
Then in step 4: > The employee getting paid by the company for the incurred expense (company converts asset into a discharge of liability, employee converting receivable into cash)

The company’s books would be:

  -$100 Asset + $100 Liability = $0 Income - $0 Expense
                      $0 State = $0 Change
So the net impact on the ledger would be (putting these entries together):

  -$100 Asset - $100 Liability + $100 Liability = $0 Income - $100 Expense
                     -$100 Asset - $0 Liability = $0 Income - $100 Expense
                                    -$100 State = -$100 Change
Which is exactly what the company’s books would have recorded if they were using cash accounting instead of accrual. They spent $100 on an Expense.

So I think it’s super important to make a distinction between Liability and Expense Accounts because they’re on different sides of the accounting equation - State and Change. The same distinction applies to Asset and Income Accounts. [1]

[1] https://fragment.dev/docs#design-your-ledger-ledger-accounts

omichowdhury··on Double-entry bookkeeping as a directed graph
I think you’re right that currency is technically what I meant by money in that sentence. Like you said most people equate the two, which is why I prefer to use the word “value” for the various promises we track in accounting. It just has less baggage with most people since it’s more abstract. Value can definitely be created or destroyed from the perspective of the entity whose net value we’re tracking.

AR and AP accounts track promises, and as you point out, bank accounts and cash are also conceptually no different than other AR account. I call these asset and liability accounts State accounts. They track the current state of your promises and expectations. Since a promise can be reneged or an expectation not met, we need accounts that balance changes in State accounts when value is created or destroyed. That’s what income and expense accounts do — which I call Change accounts [1]

> You don't need accounting for barter.

I get what you’re mean, but I think a good way to get your head around multi-currency accounting is to think of it as double-entry bartering. Each currency only has value because it can be swapped with another currency at a certain rate. Which is basically bartering. How many sheep for how much grain? How many USD for how many GBP?

The interesting part is bringing double-entry into this:

- how do you balance a transaction when the two sides are in different currencies?

- How do you track the exchange rate between currencies?

The answer to each question is the other question. You balance entries by adding two more lines that track gain/loss due to exchange rate fluctuations. I did a talk on this at Fintech Devcon [2] and we cover this in our docs [3]

[1] https://news.ycombinator.com/item?id=39994335

[2] https://youtu.be/uH0SaCPKcPY?si=zKtPAPhvOnOGr8ei

[3] https://fragment.dev/docs#handle-currencies

omichowdhury··on Double-entry bookkeeping as a directed graph
While money can’t be created or destroyed (unless you run a central bank…), value can be. Ledgers always have a specific perspective, and that perspective can assign a different value to something than someone else.

In the case of gifting something, from the perspective of the gifter, they destroyed some value they had on their books and got nothing of value in return. There’s an account type for tracking why your net worth decreased - Expense accounts. The giftee received value and they have an account to track why their net worth increased - Income accounts. If value was objective, then the net worth decrease on one side would exactly equal the net worth increase on the other.

With something like cash, the unit of account and the store of value are the same thing - so 100 USD objectively the same value in everyone’s ledger. But say you were gifted a painting. The gifter may have valued this painting at 100 USD, while the giftee actually thinks it’s worth 50 USD. If the gifter didn’t tell them the price, there would be no way of knowing they recorded different numbers. So in this transaction value was destroyed.

The same thing happens when you buy and sell things. Say the painting was sold instead of gifted, then the difference in what the buyer and seller thought the painting was worth is value that was created and destroyed. Each person’s net worth would go up or down depending on whether they thought the painting was a bargain or overpriced. When providing services, value is created at the moment of usage and a ledger will track the creation of value in your landscaping business.

omichowdhury··on Double-entry bookkeeping as a directed graph
I think the fundamental problem is the traditional accounting equation:

  Assets + Expenses = Liabilities + Equity + Income
We try to group the accounts by left and right side and find a common term for them (credit-normal and debit-normal). But it’s really hard to come up with an intuitive answer for why Assets and Expense should be on one team, and why the rest should be on the other team. So we just pick some team names and say shut-up-and-calculate.

What if we re-arranged the equation to:

  Assets - Liabilities = Income - Expenses
The accounts on the left side track your net worth. The accounts on the right side track why net worth changes. What should be the names for the two sides? I call them State and Change.

You can then ditch credits and debits and ask - what is the impact of this financial transaction on my net worth? The equation will tell you which accounts should go up and go down using positive and negative numbers.

I go more into how this works here: https://news.ycombinator.com/item?id=39994335

omichowdhury··on Double-entry bookkeeping as a directed graph
The reason isn’t to double the amount the work to catch errors. storing both sides genuinely stores extra metadata about the transaction that is not captured by only storing it once.

In double-entry, you’re tracking two different things: - Your current net worth. These are tracked in State accounts (Asset and Liability). - The reasons your current net worth changed. These are tracked in Change accounts (Income and Expense).

Say $5 enters your bank account, that’s recorded as an increase in an Asset account. Whether your net worth changed or not depends on the reason. There’s lots of reasons that could have happened, and that’s recorded as the second entry: - Took out a loan: increase in Liability (no net worth change) - Got paid back for a loan: decrease in Asset (no net worth change) - Sold something: increase in Income (net worth did change) - Got a refund: decrease in Expense (net worth did change)

I agree that re-engineering accounting is necessary for software engineers to build financial systems. I think it’s time to ditch credits and debits and instead deal in State and Change accounts with negative numbers.

PS I go more into it here: https://news.ycombinator.com/item?id=39994335

omichowdhury··on Double-entry bookkeeping as a directed graph
Yup, this is the same way of thinking I described here: https://news.ycombinator.com/item?id=39994335

Instead of grouping together accounts into credit-normal and debit-normal, to make things balance, I think it’s more intuitive to group accounts by usage and use negative numbers.

Asset and Liability accounts appear on a Balance Sheet and are called State accounts. State accounts track the current state of your net worth.

Income and expense accounts appear on an Income Statement and are called Change accounts. Change accounts since they track why your net worth changed.

omichowdhury··on Double-entry bookkeeping as a directed graph
Yeah, I think a more intuitive way is to replace credit and debit with State and Change as the pair of things in double-entry. It means that you don't have to swap meanings based on context and can use negative numbers intuitively.

State Accounts track your net worth

  Assets: what you own

  Liabilities: what you owe
Change Accounts track why your net worth changes

  Income: what you've earned

  Expense: what you've spent
The accounting equation that follows is ∆ State = ∆ Change:

  Assets - Liabilities = Income - Expense

Selling lemonade is +$5 Asset balanced by +$5 Income. If you substitute into the equation, it's: $5 Asset = $5 Income

Taking out a loan is +$10 Asset balanced by +$10 Loan. In the equation: $10 Asset - $10 Liability = $0.

In general, say you have a +Asset action, to balance the equation you can do it 4 ways:

  +Asset -Asset aka swapped for equal value

  +Asset +Liability aka took out a loan

  +Asset +Income aka sold something

  +Asset -Expense aka got a refund
I've left out Equity as a separate account type since you can just treat it mathematically as a Liability account.

This is the system we've implemented in our ledger API (https://fragment.dev)

omichowdhury··on Ledger: Stripe's system for tracking and validating money movement
I don't work at Stripe, but I've talked to a few ledger nerds there.

One thing I'd point out that makes Stripe's ledger different than most others you might have seen or encountered is the granularity of what they consider an account. If you think about a bank ledger, you logically have a single account per customer. Stripe uses multiple accounts for each payment, so processing this number of accounts is a hard scaling problem, especially when most are ephemeral. The saving grace is that this can be done offline and balances can be eventually consistent or materialised on read.

When you have this many accounts, organising them also is a big challenge, since you want to be able to roll them up to something meaningful. Conceptually asset and liability accounts in a ledger represent a financial relationship with an economic actor. If that's the top level account (e.g. how much does bank X owe us right now) you'll want to have a hierarchy of accounts down to each state of each payment. So a lot of effort went into building modelling tools for product teams to design how their financial activity gets represented in the ledger.

Disclaimer: I'm CTO at Fragment (http://fragment.dev) and Stripe led our last round.