accounting

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package accounting implements double-entry bookkeeping for okpos. It is invoked by the background job queue after domain events are emitted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service creates and persists double-entry journal entries from domain events.

func NewService

func NewService(repo data.AccountingRepoer, log *slog.Logger) *Service

NewService returns an accounting Service backed by the given repo.

func (*Service) BalanceByAccount

func (s *Service) BalanceByAccount(
	ctx context.Context,
	companyID uuid.UUID,
) ([]model.AccountBalance, error)

BalanceByAccount returns running debit/credit totals per COA account for a company.

func (*Service) Handle

func (s *Service) Handle(ctx context.Context, eventName string, payload map[string]any) error

Handle maps a domain event to the appropriate journal entry and posts it. Unknown events are silently ignored (no error returned).

func (*Service) ListAccounts

func (s *Service) ListAccounts(ctx context.Context) ([]model.Account, error)

ListAccounts returns all chart-of-accounts entries ordered by code.

func (*Service) ListJournalEntries

func (s *Service) ListJournalEntries(
	ctx context.Context,
	companyID uuid.UUID,
	q data.SupportsPagination,
) (*dto.PaginationResults[model.JournalEntry], error)

ListJournalEntries returns a paginated list of journal entries for a company. Lines are not populated; use the repo directly if lines are needed.

func (*Service) Post

func (s *Service) Post(ctx context.Context, entry *model.JournalEntry) error

Post validates that the entry is balanced (∑debit = ∑credit) and persists it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL