Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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