Documentation
¶
Overview ¶
Package accounting implements double-entry bookkeeping for okpos. It is invoked by the background job queue after domain events are emitted.
Index ¶
- type Service
- func (s *Service) BalanceByAccount(ctx context.Context, companyID uuid.UUID) ([]model.AccountBalance, error)
- func (s *Service) Handle(ctx context.Context, eventName string, payload map[string]any) error
- func (s *Service) ListAccounts(ctx context.Context) ([]model.Account, error)
- func (s *Service) ListJournalEntries(ctx context.Context, companyID uuid.UUID, q data.SupportsPagination) (*dto.PaginationResults[model.JournalEntry], error)
- func (s *Service) Post(ctx context.Context, entry *model.JournalEntry) error
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 ¶
Handle maps a domain event to the appropriate journal entry and posts it. Unknown events are silently ignored (no error returned).
func (*Service) ListAccounts ¶
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.