service backend
This commit is contained in:
46
api/ledger/internal/model/jentry.go
Normal file
46
api/ledger/internal/model/jentry.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// journal_entry.go
|
||||
package ledger
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// EntryType is a closed set of journal entry kinds.
|
||||
type EntryType string
|
||||
|
||||
const (
|
||||
EntryCredit EntryType = "credit"
|
||||
EntryDebit EntryType = "debit"
|
||||
EntryTransfer EntryType = "transfer"
|
||||
EntryFX EntryType = "fx"
|
||||
EntryFee EntryType = "fee"
|
||||
EntryAdjust EntryType = "adjust"
|
||||
EntryReverse EntryType = "reverse"
|
||||
)
|
||||
|
||||
type JournalEntry struct {
|
||||
model.PermissionBound `bson:",inline" json:",inline"`
|
||||
|
||||
// Idempotency/de-dup within your chosen scope (e.g., org/request)
|
||||
IdempotencyKey string `bson:"idempotencyKey,omitempty" json:"idempotencyKey,omitempty"`
|
||||
EventTime time.Time `bson:"eventTime" json:"eventTime"`
|
||||
EntryType EntryType `bson:"entryType" json:"entryType"`
|
||||
Description string `bson:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// Monotonic ordering within your chosen scope (e.g., per org/ledger)
|
||||
Version int64 `bson:"version" json:"version"`
|
||||
|
||||
// Denormalized set of all affected ledger accounts (for entry-level access control & queries)
|
||||
LedgerAccountRefs []primitive.ObjectID `bson:"ledgerAccountRefs,omitempty" json:"ledgerAccountRefs,omitempty"`
|
||||
|
||||
// Optional backlink for reversals
|
||||
ReversalOf *primitive.ObjectID `bson:"reversalOf,omitempty" json:"reversalOf,omitempty"`
|
||||
}
|
||||
|
||||
func (j *JournalEntry) Collection() string {
|
||||
return mservice.LedgerEntries
|
||||
}
|
||||
Reference in New Issue
Block a user