rate

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Daily    = 1
	Weekly   = 7
	BiWeekly = 14
	Monthly  = 30
	Yearly   = 360
	FullYear = 365
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Periodic

type Periodic struct {
	// Period The period of the rate expressed in days.
	Period uint `json:"period" bson:"period"`

	// Value The value of the rate.
	Value percent.Percent `json:"rate" bson:"rate"`
}

func NewPeriodicRate

func NewPeriodicRate(period uint, value percent.Percent) Periodic

NewPeriodicRate creates a new Periodic rate.

func NewPeriodicRateFromFloat64

func NewPeriodicRateFromFloat64(period uint, value float64) Periodic

NewPeriodicRateFromFloat64 creates a new Periodic rate from a float64.

func NewPeriodicRateFromInt

func NewPeriodicRateFromInt(period uint, value int64) Periodic

NewPeriodicRateFromInt creates a new Periodic rate from an int64.

func (Periodic) By

func (r Periodic) By(m money.Money) money.Money

By applies the rate to the amount of money.

func (Periodic) Equal added in v1.12.0

func (r Periodic) Equal(other Periodic) bool

Equal returns true if the other rate is equal to this rate. Two rates are equal if they have the same period and value.

func (Periodic) IsNonZero added in v1.12.0

func (r Periodic) IsNonZero() bool

IsNonZero returns true if the rate is not zero.

func (Periodic) IsZero added in v1.12.0

func (r Periodic) IsZero() bool

IsZero returns true if the rate is zero.

func (Periodic) NominalToPeriod

func (r Periodic) NominalToPeriod(period uint) Periodic

NominalToPeriod converts the rate to the given period applying linear conversión (Nominal rates).

func (Periodic) PeriodAsString added in v1.12.0

func (r Periodic) PeriodAsString() string

func (Periodic) RoundedBy

func (r Periodic) RoundedBy(m money.Money) money.Money

RoundedBy applies the rate to the amount of money with half-even rounding.

func (Periodic) RoundedByWithPeriod

func (r Periodic) RoundedByWithPeriod(amount money.Money, period uint) money.Money

RoundedByWithPeriod applies the rate to the amount of money in the given period. It is equivalent to the following but with less rounding errors:

periodicRate.NominalToPeriod(period).By(amount)

func (Periodic) String added in v1.12.0

func (r Periodic) String() string

Jump to

Keyboard shortcuts

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