model

package
v1.27.0-beta.26 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scale added in v1.26.0

func Scale(v, s0, s1 int) float64

Scale func scale: (V * 10^ (S0-S1))

func UndoScale added in v1.26.0

func UndoScale(v float64, s int) int

UndoScale Function to undo the scale calculation

func UpdateAccounts added in v1.26.0

func UpdateAccounts(operation string, fromTo map[string]Amount, accounts []*a.Account, result chan []*a.Account, e chan error)

UpdateAccounts function with some updates values in accounts and

func ValidateAccounts added in v1.26.0

func ValidateAccounts(validate Responses, accounts []*a.Account) error

ValidateAccounts function with some validates in accounts and DSL operations

func ValidateFromToOperation added in v1.26.0

func ValidateFromToOperation(ft FromTo, validate Responses, acc *a.Account) (Amount, Balance, error)

ValidateFromToOperation func that validate operate balance amount

Types

type Amount

type Amount struct {
	Asset string `json:"asset,omitempty"`
	Value int    `json:"value,omitempty"`
	Scale int    `json:"scale,omitempty"`
}

func FindScale added in v1.26.0

func FindScale(asset string, v float64, s int) Amount

FindScale Function to find the scale for any value of a value

type Balance added in v1.26.0

type Balance struct {
	Available int `json:"available"`
	OnHold    int `json:"onHold"`
	Scale     int `json:"scale"`
}

func OperateAmounts added in v1.26.0

func OperateAmounts(amount Amount, balance *a.Balance, operation string) (Balance, error)

OperateAmounts Function to sum or sub two amounts and normalize the scale

type Distribute

type Distribute struct {
	Remaining string   `json:"remaining,omitempty"`
	To        []FromTo `json:"to,omitempty"`
}

type FromTo

type FromTo struct {
	Account         string         `json:"account,omitempty"`
	Amount          *Amount        `json:"amount,omitempty"`
	Share           *Share         `json:"share,omitempty"`
	Remaining       string         `json:"remaining,omitempty"`
	Description     string         `json:"description,omitempty"`
	ChartOfAccounts string         `json:"chartOfAccountsG"`
	Metadata        map[string]any `json:"metadata,omitempty"`
	IsFrom          bool           `json:"isFrom,omitempty"`
}

type Metadata

type Metadata struct {
	Key   string `json:"key,omitempty"`
	Value any    `json:"value,omitempty"`
}

type Responses added in v1.26.0

type Responses struct {
	Total        int
	From         map[string]Amount
	To           map[string]Amount
	Sources      []string
	Destinations []string
	Aliases      []string
}

func ValidateSendSourceAndDistribute added in v1.26.0

func ValidateSendSourceAndDistribute(transaction Transaction) (*Responses, error)

ValidateSendSourceAndDistribute Validate send and distribute totals

type Send

type Send struct {
	Asset  string `json:"asset,omitempty"`
	Value  int    `json:"value,omitempty"`
	Scale  int    `json:"scale,omitempty"`
	Source Source `json:"source,omitempty"`
}

type Share

type Share struct {
	Percentage             int  `json:"percentage,omitempty"`
	PercentageOfPercentage int  `json:"percentageOfPercentage,omitempty"`
	DescWhatever           bool `json:"descWhatever,omitempty"`
}

type Source

type Source struct {
	Remaining string   `json:"remaining,omitempty"`
	From      []FromTo `json:"from,omitempty"`
}

type Transaction

type Transaction struct {
	ChartOfAccountsGroupName string         `json:"chartOfAccountsGroupName"`
	Description              string         `json:"description,omitempty"`
	Code                     string         `json:"code,omitempty"`
	Pending                  bool           `json:"pending,omitempty"`
	Metadata                 map[string]any `json:"metadata,omitempty"`
	Send                     Send           `json:"send,omitempty"`
	Distribute               Distribute     `json:"distribute,omitempty"`
}

Jump to

Keyboard shortcuts

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