model

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDistributions added in v0.6.0

func CalculateDistributions(totalAmount int64, distributions []Distribution) (map[string]int64, error)

CalculateDistributions calculates and returns the amount for each identifier (source or destination) based on its distribution.

func GenerateUUIDWithSuffix added in v0.6.0

func GenerateUUIDWithSuffix(module string) string

func UpdateBalances

func UpdateBalances(transaction *Transaction, source, destination *Balance) error

Types

type Account

type Account struct {
	AccountID  string                 `json:"account_id"`
	Name       string                 `json:"name" form:"name"`
	Number     string                 `json:"number" form:"number"`
	BankName   string                 `json:"bank_name"`
	Currency   string                 `json:"currency"`
	BalanceID  string                 `json:"balance_id" `
	IdentityID string                 `json:"identity_id" form:"identity_id"`
	LedgerID   string                 `json:"ledger_id"`
	MetaData   map[string]interface{} `json:"meta_data"`
	Ledger     *Ledger                `json:"ledger"`
	Balance    *Balance               `json:"balance"`
	Identity   *Identity              `json:"identity"`
	CreatedAt  time.Time              `json:"created_at"`
}

type AlertCondition

type AlertCondition struct {
	Value    int64  `json:"value"`
	Field    string `json:"field"`
	Operator string `json:"operator"`
}

type Balance

type Balance struct {
	ID                    int64                  `json:"-"`
	Balance               int64                  `json:"balance"`
	InflightBalance       int64                  `json:"inflight_balance"`
	CreditBalance         int64                  `json:"credit_balance"`
	InflightCreditBalance int64                  `json:"inflight_credit_balance"`
	DebitBalance          int64                  `json:"debit_balance"`
	InflightDebitBalance  int64                  `json:"inflight_debit_balance"`
	CurrencyMultiplier    int64                  `json:"preceision"`
	Version               int64                  `json:"version"`
	LedgerID              string                 `json:"ledger_id"`
	IdentityID            string                 `json:"identity_id"`
	BalanceID             string                 `json:"balance_id"`
	Indicator             string                 `json:"indicator"`
	Currency              string                 `json:"currency"`
	Identity              *Identity              `json:"identity,omitempty"`
	Ledger                *Ledger                `json:"ledger,omitempty"`
	CreatedAt             time.Time              `json:"created_at"`
	InflighExpiresAt      time.Time              `json:"inflight_expires_at"`
	MetaData              map[string]interface{} `json:"meta_data"`
}

func (*Balance) CommitInflightCredit added in v0.6.0

func (balance *Balance) CommitInflightCredit(amount int64)

func (*Balance) CommitInflightDebit added in v0.6.0

func (balance *Balance) CommitInflightDebit(amount int64)

func (*Balance) RollbackInflightCredit added in v0.6.0

func (balance *Balance) RollbackInflightCredit(amount int64)

RollbackInflightCredit decreases the InflightCreditBalance by the specified amount

func (*Balance) RollbackInflightDebit added in v0.6.0

func (balance *Balance) RollbackInflightDebit(amount int64)

RollbackInflightDebit decreases the InflightDebitBalance by the specified amount

type BalanceFilter

type BalanceFilter struct {
	ID                 int64     `json:"id"`
	BalanceRange       string    `json:"balance_range"`
	CreditBalanceRange string    `json:"credit_balance_range"`
	DebitBalanceRange  string    `json:"debit_balance_range"`
	Currency           string    `json:"currency"`
	LedgerID           string    `json:"ledger_id"`
	From               time.Time `json:"from"`
	To                 time.Time `json:"to"`
}

type BalanceMonitor

type BalanceMonitor struct {
	MonitorID   string         `json:"monitor_id"`
	BalanceID   string         `json:"balance_id"`
	Description string         `json:"description"`
	CallBackURL string         `json:"call_back_url"`
	CreatedAt   time.Time      `json:"created_at"`
	Condition   AlertCondition `json:"condition"`
}

func (*BalanceMonitor) CheckCondition

func (bm *BalanceMonitor) CheckCondition(b *Balance) bool

type BalanceTracker

type BalanceTracker struct {
	Balances    map[string]*Balance
	Frequencies map[string]int
	Mutex       sync.Mutex
}

type Distribution added in v0.6.0

type Distribution struct {
	Identifier   string `json:"identifier"`
	Distribution string `json:"distribution"` // Can be a percentage (e.g., "10%"), a fixed amount (e.g., "100"), or "left"
}

type Event

type Event struct {
	MapperID  string                 `json:"mapper_id"`
	Drcr      string                 `json:"drcr"`
	BalanceID string                 `json:"balance_id"`
	Data      map[string]interface{} `json:"data"`
}

type EventMapper

type EventMapper struct {
	MapperID           string            `json:"mapper_id"`
	Name               string            `json:"name"`
	MappingInstruction map[string]string `json:"mapping_instruction"`
	CreatedAt          time.Time         `json:"created_at"`
}

type Identity

type Identity struct {
	IdentityID       string                 `json:"identity_id" form:"identity_id"`
	IdentityType     string                 `json:"identity_type" form:"identity_type"`
	OrganizationName string                 `json:"organization_name" form:"organization_name"`
	Category         string                 `json:"category" form:"category"`
	FirstName        string                 `json:"first_name" form:"first_name"`
	LastName         string                 `json:"last_name" form:"last_name"`
	OtherNames       string                 `json:"other_names" form:"other_names"`
	Gender           string                 `json:"gender" form:"gender"`
	EmailAddress     string                 `json:"email_address" form:"email_address"`
	PhoneNumber      string                 `json:"phone_number" form:"phone_number"`
	Nationality      string                 `json:"nationality" form:"nationality"`
	Street           string                 `json:"street" form:"street"`
	Country          string                 `json:"country" form:"country"`
	State            string                 `json:"state" form:"state"`
	PostCode         string                 `json:"post_code" form:"postCode"`
	City             string                 `json:"city" form:"city"`
	MetaData         map[string]interface{} `json:"meta_data" form:"metaData"`
	DOB              time.Time              `json:"dob" form:"dob"`
	CreatedAt        time.Time              `json:"created_at" form:"createdAt"`
}

type Ledger

type Ledger struct {
	ID        int64                  `json:"-"`
	LedgerID  string                 `json:"id"`
	Name      string                 `json:"name"`
	MetaData  map[string]interface{} `json:"meta_data"`
	CreatedAt time.Time              `json:"created_at"`
}

type LedgerFilter

type LedgerFilter struct {
	ID   int64     `json:"id"`
	From time.Time `json:"from"`
	To   time.Time `json:"to"`
}

type Transaction

type Transaction struct {
	ID                int64                  `json:"-"`
	Amount            int64                  `json:"amount"`
	TransactionID     string                 `json:"id"`
	AllowOverdraft    bool                   `json:"allow_overdraft"`
	Inflight          bool                   `json:"infligt"`
	SkipBalanceUpdate bool                   `json:"-"`
	Source            string                 `json:"source,omitempty"`
	Destination       string                 `json:"destination,omitempty"`
	Reference         string                 `json:"reference"`
	Currency          string                 `json:"currency"`
	Description       string                 `json:"description",omitempty`
	Status            string                 `json:"status"`
	Hash              string                 `json:"hash"`
	GroupIds          []string               `json:"group_ids"`
	MetaData          map[string]interface{} `json:"meta_data,omitempty"`
	Sources           []Distribution         `json:"sources,omitempty"`
	Destinations      []Distribution         `json:"destinations,omitempty"`
	CreatedAt         time.Time              `json:"created_at"`
	ScheduledFor      time.Time              `json:"scheduled_for,omitempty"`
}

func (*Transaction) HashTxn added in v0.6.0

func (transaction *Transaction) HashTxn() string

func (*Transaction) SplitTransaction added in v0.6.0

func (transaction *Transaction) SplitTransaction() ([]Transaction, error)

func (*Transaction) ToJSON

func (transaction *Transaction) ToJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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