Last active
July 24, 2022 15:23
-
-
Save IvanRainbolt/06f6b7556b37a25479bf8880869bbb22 to your computer and use it in GitHub Desktop.
Starting from ZERO | Using F# to model Financial Accounting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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