ledger accounts improvement

This commit is contained in:
Stephan D
2026-01-30 15:54:45 +01:00
parent 51f5b0804a
commit 17dde423f6
40 changed files with 3355 additions and 570 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/tech/sendico/ledger/storage/model"
pkm "github.com/tech/sendico/pkg/model"
"go.mongodb.org/mongo-driver/bson/primitive"
)
@@ -24,13 +25,24 @@ var (
ErrNegativeBalancePolicy = storageError("ledger.storage: negative balance not allowed")
)
// AccountsFilter describes optional filter parameters for listing accounts.
type AccountsFilter struct {
// OwnerRefFilter is a 3-state filter:
// - nil: no filter on owner_ref (return all)
// - pointer to zero ObjectID: filter for accounts where owner_ref is nil
// - pointer to a value: filter for accounts where owner_ref matches
OwnerRefFilter *primitive.ObjectID
}
type AccountsStore interface {
Create(ctx context.Context, account *model.Account) error
Get(ctx context.Context, accountRef primitive.ObjectID) (*model.Account, error)
GetByAccountCode(ctx context.Context, orgRef primitive.ObjectID, accountCode, currency string) (*model.Account, error)
GetDefaultSettlement(ctx context.Context, orgRef primitive.ObjectID, currency string) (*model.Account, error)
ListByOrganization(ctx context.Context, orgRef primitive.ObjectID, limit int, offset int) ([]*model.Account, error)
UpdateStatus(ctx context.Context, accountRef primitive.ObjectID, status model.AccountStatus) error
Create(ctx context.Context, account *pkm.LedgerAccount) error
Get(ctx context.Context, accountRef primitive.ObjectID) (*pkm.LedgerAccount, error)
GetByAccountCode(ctx context.Context, orgRef primitive.ObjectID, accountCode, currency string) (*pkm.LedgerAccount, error)
GetByRole(ctx context.Context, orgRef primitive.ObjectID, currency string, role pkm.AccountRole) (*pkm.LedgerAccount, error)
GetSystemAccount(ctx context.Context, purpose pkm.SystemAccountPurpose, currency string) (*pkm.LedgerAccount, error)
GetDefaultSettlement(ctx context.Context, orgRef primitive.ObjectID, currency string) (*pkm.LedgerAccount, error)
ListByOrganization(ctx context.Context, orgRef primitive.ObjectID, filter *AccountsFilter, limit int, offset int) ([]*pkm.LedgerAccount, error)
UpdateStatus(ctx context.Context, accountRef primitive.ObjectID, status pkm.LedgerAccountStatus) error
}
type JournalEntriesStore interface {