# The first General Journal attempt

[Continuing](https://crazyivan.blog/starting-from-zero) 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.


<hr>
GIST of code [LINK](https://gist.github.com/IvanRainbolt/8f69cf26d512353013da54934a3d5523)

[PREVIOUS related blog post](https://crazyivan.blog/starting-from-zero)

[NEXT related blog post](https://crazyivan.blog)


*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#<a href="https://www.amazon.com/Domain-Modeling-Made-Functional-Domain-Driven-dp-1680502549/dp/1680502549?_encoding=UTF8&me=&qid=1658603135&linkCode=li2&tag=crazyivan-20&linkId=8a0d192ac305e7f6d1d050e8875a0bac&language=en_US&ref_=as_li_ss_il" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1680502549&Format=_SL160_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=crazyivan-20&language=en_US" ></a><img src="https://ir-na.amazon-adsystem.com/e/ir?t=crazyivan-20&language=en_US&l=li2&o=1&a=1680502549" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> 

The Joy of Accounting: A Game-Changing Approach That Makes Accounting Easy
<a href="https://www.amazon.com/Joy-Accounting-Game-Changing-Approach-Makes/dp/1735312916?_encoding=UTF8&qid=&sr=&linkCode=li1&tag=crazyivan-20&linkId=923b62b52c80d029df414fa535e01744&language=en_US&ref_=as_li_ss_il" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=1735312916&Format=_SL110_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=crazyivan-20&language=en_US" ></a><img src="https://ir-na.amazon-adsystem.com/e/ir?t=crazyivan-20&language=en_US&l=li1&o=1&a=1735312916" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />

DotNet 7 preview 5

Blog post about WHY I am working on this: [Lofty Goals](https://crazyivan.blog/lofty-goals)

