The first General Journal attempt

Using F# to model Financial Accounting

Continuing my quest to create an accounting system, I will work on creating a Journal. The Journal (or General Journal) is basically the database of all the transactions we want to track.

Following along in the "The Joy of Accounting" book, chapter 8 I need to create the first journal entry. This is a loan for $30,000.

let cashDebit :Debit = {Account=Cash;Amount=30000.00m}
let loanCredit :Credit = {Account=Loan;Amount=30000.00m}
let jeLoan = {Date=DateOnly(2022,01,01);Debits=[cashDebit];Credits=[loanCredit]}

Now I put that in the General Journal and print out.

let generalJournal = {JournalEntries=[jeLoan]}

printfn $"%A{generalJournal}"
{ JournalEntries =
   [{ Date = 1/1/2022
      Debits = [{ Account = Assets { AccountName = "Cash" }
                  Amount = 30000.00M }]
      Credits = [{ Account = Liabilities { AccountName = "Loan" }
                   Amount = 30000.00M }] }] }

OK, seems legit. The next event in the book is to do an equity injection (owner of company puts in investment).

let equityInjectionDebit :Debit = {Account=Cash;Amount=20000.00m}
let equityInjectionCredit :Credit = {Account=IssuedEquity;Amount=20000.00m}
let jeEquityInjection =
    { Date=DateOnly(2022,01,02)
      Debits=[equityInjectionDebit]
      Credits=[equityInjectionCredit]}

let generalJournal2 = {JournalEntries=(generalJournal.JournalEntries @ [jeEquityInjection])}

printfn $"%A{generalJournal2}"
{ JournalEntries =
   [{ Date = 1/1/2022
      Debits = [{ Account = Assets { AccountName = "Cash" }
                  Amount = 30000.00M }]
      Credits = [{ Account = Liabilities { AccountName = "Loan" }
                   Amount = 30000.00M }] };
    { Date = 1/2/2022
      Debits = [{ Account = Assets { AccountName = "Cash" }
                  Amount = 20000.00M }]
      Credits = [{ Account = Equity { AccountName = "Issued Equity" }
                   Amount = 20000.00M }] }] }

Allright. That seems to satisfy this step. I am also a bit impressed by myself that I have a General Journal now. This is not verifying that having multiple debits or credits in one entry works, but my familiarity with lists says it should. There is also no validation yet for the rules of a journal entry like there must be one or more debits and one or more credits and the totals of the debits must match the total of the credits and that the numbers are always positive, etc. Those rules will be coded later.

Next step? The Balance Sheet

UPDATE: After a couple failed attempts at producing a balance sheet, I realized I am not following the traditional flow of accounting procedures.

The next step is the General Ledger.


GIST of code LINK

PREVIOUS related blog post

NEXT related blog post

DISCLAIMER: Links on this blog may earn commissions or other benefits for the author.

REFERENCES:

Scott Wlaschin's amazing F# book:

Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#

The Joy of Accounting: A Game-Changing Approach That Makes Accounting Easy

DotNet 7 preview 5

Blog post about WHY I am working on this: Lofty Goals

Did you find this article valuable?

Support Ivan Rainbolt by becoming a sponsor. Any amount is appreciated!