TabulariusLib 0.0.4
dotnet add package TabulariusLib --version 0.0.4
NuGet\Install-Package TabulariusLib -Version 0.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TabulariusLib" Version="0.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TabulariusLib" Version="0.0.4" />
<PackageReference Include="TabulariusLib" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TabulariusLib --version 0.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TabulariusLib, 0.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TabulariusLib@0.0.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TabulariusLib&version=0.0.4
#tool nuget:?package=TabulariusLib&version=0.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TabulariusLib
A .NET library to handle basic accounting tools to create a journal and accounts.
Features
- Immutable, strongly-typed accounting entities
- Generate ledgers, trial balances, profit and loss statements, and balance sheets
- Designed for use with Entity Framework Core
- Fully unit-tested
Accounting
TabulariusLib is built on core accounting principles:
- Immutability: All main entities (Journal, Ledger, Trial Balance, Profit and Loss Statement, Balance Sheet) are immutable. Once created, they cannot be changed—only new entries can be added. This mirrors real-world accounting, where journals and ledgers are append-only and cannot be altered retroactively.
- Entity Dependencies:
- The Trial Balance is always derived from the current state of the Ledger.
- The Balance Sheet is generated from the Trial Balance after it has been closed (i.e., after income and expense accounts are closed to equity).
- The Profit and Loss Statement is generated directly from the Ledger for a given period.
- Validation: All mutation methods return new instances and enforce validation, ensuring data integrity and auditability.
Installation
Install from NuGet:
dotnet add package TabulariusLib
Requirements
- .NET 7.0 or later
Usage
Add the required namespaces:
using TabulariusLib.Entities;
using TabulariusLib.BaseEntities;
Create Account Codes
public static class ExampleAccountCodes
{
public const string Cash = "1000";
public const string Revenue = "4000";
public const string Expense = "5000";
public const string Capital = "3000";
public const string RetainedEarnings = "3100";
public const string Payable = "2000";
}
Create Accounts
public static List<Account> GetExampleAccounts()
{
return new List<Account>
{
Account.Create("Cash", "Cash Account", ExampleAccountCodes.Cash, AccountType.Asset, null, "Debit"),
Account.Create("Revenue", "Sales Revenue", ExampleAccountCodes.Revenue, AccountType.Income, null, "Credit"),
Account.Create("Expense", "Office Supplies", ExampleAccountCodes.Expense, AccountType.Expense, null, "Debit"),
Account.Create("Capital", "Owner's Capital", ExampleAccountCodes.Capital, AccountType.Equity, null, "Credit"),
Account.Create("Retained Earnings", "Retained Earnings", ExampleAccountCodes.RetainedEarnings, AccountType.Equity, null, "Credit"),
Account.Create("Payable", "Accounts Payable", ExampleAccountCodes.Payable, AccountType.Liability, null, "Credit")
};
}
Create a Journal
public static Journal GetExampleJournal()
{
var accounts = GetExampleAccounts();
var cash = accounts.Find(a => a.Code == ExampleAccountCodes.Cash);
var revenue = accounts.Find(a => a.Code == ExampleAccountCodes.Revenue);
var expense = accounts.Find(a => a.Code == ExampleAccountCodes.Expense);
var capital = accounts.Find(a => a.Code == ExampleAccountCodes.Capital);
var payable = accounts.Find(a => a.Code == ExampleAccountCodes.Payable);
if (cash == null || revenue == null || expense == null || capital == null || payable == null)
throw new InvalidOperationException("One or more required accounts are missing.");
var journal = Journal.Create(Guid.NewGuid(), "Main Journal", "Test Journal", null);
// Sales Invoice: Debit Cash, Credit Revenue
journal = journal.AddJournalEntry(
JournalEntry.Create(
Guid.NewGuid().ToString(),
"Sales Invoice",
DateTime.Today,
"INV-001",
[
JournalLine.Create(Guid.NewGuid(), "Cash from Sales", cash.Code, 1000m, 0m),
JournalLine.Create(Guid.NewGuid(), "Sales Revenue", revenue.Code, 0m, 1000m)
]
));
// Expense: Debit Expense, Credit Cash
journal = journal.AddJournalEntry(
JournalEntry.Create(
Guid.NewGuid().ToString(),
"Office Supplies Expense",
DateTime.Today,
"EXP-001",
[
JournalLine.Create(Guid.NewGuid(), "Office Supplies", expense.Code, 200m, 0m),
JournalLine.Create(Guid.NewGuid(), "Paid Cash", cash.Code, 0m, 200m)
]
));
// Owner's Investment: Debit Cash, Credit Capital
journal = journal.AddJournalEntry(
JournalEntry.Create(
Guid.NewGuid().ToString(),
"Owner's Investment",
DateTime.Today,
"CAP-001",
[
JournalLine.Create(Guid.NewGuid(), "Cash Invested", cash.Code, 5000m, 0m),
JournalLine.Create(Guid.NewGuid(), "Owner's Capital", capital.Code, 0m, 5000m)
]
));
// Liability: Purchase on Credit (Debit Expense, Credit Payable)
journal = journal.AddJournalEntry(
JournalEntry.Create(
Guid.NewGuid().ToString(),
"Office Supplies on Credit",
DateTime.Today,
"EXP-002",
[
JournalLine.Create(Guid.NewGuid(), "Office Supplies (Credit)", expense.Code, 300m, 0m),
JournalLine.Create(Guid.NewGuid(), "Accounts Payable", payable.Code, 0m, 300m)
]
));
return journal;
}
Create a Ledger
Ledger ledger = Ledger.FromJournal("Main Ledger", "Test Ledger", journal, accounts);
Create a Trial Balance
TrialBalance trialBalance = TrialBalance.FromLedger("TB", "Test TB", new DateTime(2024, 12, 31), ledger);
Create a Profit and Loss Statement
ProfitAndLossStatement plStatement = ProfitAndLossStatement.FromLedger(
"P&L", "Test P&L", new DateTime(2024, 1, 1), new DateTime(2024, 12, 31), ledger);
Create a Balance Sheet
TrialBalance closedTrialBalance = trialBalance.CloseAccounts(
accounts.Find(a => a.Code == ExampleAccountCodes.RetainedEarnings)!);
// Create Balance from closed trial balance
Balance balance = Balance.FromTrialBalance("Balance Sheet", "Test Balance", DateTime.Today, closedTrialBalance);
License
Apache-2.0
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release.