Skip to content

Instantly share code, notes, and snippets.

@IvanRainbolt
Last active July 24, 2022 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IvanRainbolt/06f6b7556b37a25479bf8880869bbb22 to your computer and use it in GitHub Desktop.
Save IvanRainbolt/06f6b7556b37a25479bf8880869bbb22 to your computer and use it in GitHub Desktop.
Starting from ZERO | Using F# to model Financial Accounting
// related to blog post:
// Starting from ZERO
// Using F# to model Financial Accounting
// https://crazyivan.blog/starting-from-zero
open System
type Transaction = exn
type AccountData = { AccountName : string }
type Account =
| Assets of AccountData
| Liabilities of AccountData
| Equity of AccountData
| Revenue of AccountData
| Expenses of AccountData
type ChartOfAccounts = { Accounts : Account list }
type Debit =
{ Account : Account
Amount : decimal }
type Credit =
{ Account : Account
Amount : decimal }
type JournalEntry =
{ Date : DateOnly
Debits : Debit list
Credits : Credit list }
type Journal = { JournalEntries : JournalEntry list }
let Cash : Account = Assets {AccountName = "Cash"}
let Loan : Account = Liabilities {AccountName = "Loan"}
let IssuedEquity : Account = Equity {AccountName = "Issued Equity"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment