Pure accounting kernel (normalize/validate/post/project) for Pacioli. No EF/DB/UI dependencies.
License
—
Deps
1
Install Size
—
Vulns
✓ 0
Published
Jan 8, 2026
$ dotnet add package Pacioli.Accounting.KernelEste repositorio contiene un motor contable puro (sin EF/DB/UI) diseñado para usarse como NuGet en:
La idea central es:
Journal (asiento) → Posting → LedgerPostings → Projections (reportes)
Donde:
Pacioli.Accounting.Contracts
Pacioli.Accounting.Kernel
Pacioli.Accounting.Kernel.Tests
Objetivo típico en Master:
PostingRequestSnapshotkernel.PostMany(requests)LedgerPostings resultantes:
Ejemplo (pseudo-código orientativo, sin EF):
using Pacioli.Accounting.Contracts.Enums;
using Pacioli.Accounting.Contracts.Snapshots;
using Pacioli.Accounting.Kernel;
// NOTE: This is an example only. Mapping from DB entities is app-specific.
public static class MasterPostingExample
{
public static void Run()
{
var kernel = new AccountingKernel();
// 1) Load journals from DB (your code)
var journalsFromDb = LoadJournalsFromDb();
// 2) Build requests
var requests = journalsFromDb
.Select(j => MapToPostingRequest(j))
.ToList();
// 3) Post many
var batch = kernel.PostMany(requests);
// 4) Policy decision in Master:
// - Reject all if any failed
// - Or continue with successful postings and log/report violations
if (!batch.OkAll)
{
// Handle violations per journal
// e.g., return a 409/422, log, or mark invalid journals
}
// 5) Use successful postings
var postings = batch.LedgerPostings;
// Option A: Persist postings for fast reporting (recommended if reports are heavy)
SaveLedgerPostings(postings);
// Option B: Project right away
var trialBalances = kernel.ProjectTrialBalanceMany(postings);
// Example: pick the TB for a specific period
// var tb = trialBalances.Single(x => x.PeriodId == targetPeriodId);
}
private static IEnumerable<object> LoadJournalsFromDb()
{
// Return your journal entities
return Array.Empty<object>();
}
private static PostingRequestSnapshot MapToPostingRequest(object journalEntity)
{
// TODO: Map your DB entity to JournalSnapshot + Context + Options.
var context = new PostingContextSnapshot(
periodFrom: new DateTime(2026, 01, 01),
periodToExclusive: new DateTime(2026, 02, 01),
currency: "USD",
internalAmountPrecision: 2,
internalAmountRoundingMode: AmountRoundingMode.HalfUp);
var journal = new JournalSnapshot(
journalId: Guid.NewGuid(),
periodId: Guid.NewGuid(),
postingDate: new DateTime(2026, 01, 15),
documentNo: "J-0001",
reference: "REF-1",
description: "Example",
lines: new[]
{
new JournalLineSnapshot(Guid.NewGuid(), Guid.NewGuid(), DcSide.Debit, 10.00m),
new JournalLineSnapshot(Guid.NewGuid(), Guid.NewGuid(), DcSide.Credit, 10.00m),
});
var options = new PostingOptionsSnapshot(strict: true, autoBalanceRoundingDiff: true);
return new PostingRequestSnapshot(journal, context, options);
}
private static void SaveLedgerPostings(IReadOnlyList<Pacioli.Accounting.Contracts.Results.LedgerPostingSnapshot> postings)
{
// Persist using your repository/EF/Dapper/etc. (outside of the Kernel)
}
}