currency

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseAmountSvc

type BaseAmountSvc interface {
	RecalculateAmountInBaseCurrencyForAll(
		ctx context.Context,
		tx *gorm.DB,
	) error
}

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

func NewConverter

func NewConverter(
	baseCurrency string,
) *Converter

func (*Converter) Convert

func (c *Converter) Convert(
	ctx context.Context,
	fromCurrency string,
	toCurrency string,
	amount decimal.Decimal,
) (decimal.Decimal, error)

func (*Converter) Quote added in v0.3.1

func (c *Converter) Quote(
	ctx context.Context,
	fromCurrency string,
	toCurrency string,
	amount decimal.Decimal,
) (*Quote, error)

type DecimalService

type DecimalService struct {
	// contains filtered or unexported fields
}

func NewDecimalService

func NewDecimalService() *DecimalService

func (*DecimalService) GetCurrencyDecimals

func (s *DecimalService) GetCurrencyDecimals(ctx context.Context, currency string) int32

func (*DecimalService) ToString

func (s *DecimalService) ToString(ctx context.Context, amount decimal.Decimal, currency string) string

type Quote added in v0.3.1

type Quote struct {
	From         string
	To           string
	Amount       decimal.Decimal
	Converted    decimal.Decimal
	FromRate     decimal.Decimal // rate of From vs BaseCurrency
	ToRate       decimal.Decimal // rate of To vs BaseCurrency
	BaseCurrency string
}

type RemoteRates

type RemoteRates struct {
	Base      string                     `json:"b"`
	Rates     map[string]decimal.Decimal `json:"r"`
	UpdatedAt time.Time                  `json:"u"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg configuration.CurrencyConfig) *Service

func (*Service) CreateCurrency

func (*Service) DeleteCurrency

func (*Service) GetCurrencies

func (*Service) UpdateCurrency

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(
	cl httpClient,
	baseAmountSvc BaseAmountSvc,
	config configuration.CurrencyConfig,
) *Syncer

func (*Syncer) RebaseRates

func (s *Syncer) RebaseRates(
	_ context.Context,
	currentRates *RemoteRates,
) (*RemoteRates, error)

func (*Syncer) Sync

func (s *Syncer) Sync(
	ctx context.Context,
	remoteURL string,
) error

Jump to

Keyboard shortcuts

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