Documentation
¶
Index ¶
- Constants
- type Periodic
- func (r Periodic) By(m money.Money) money.Money
- func (r Periodic) Equal(other Periodic) bool
- func (r Periodic) IsNonZero() bool
- func (r Periodic) IsZero() bool
- func (r Periodic) NominalToPeriod(period uint) Periodic
- func (r Periodic) PeriodAsString() string
- func (r Periodic) RoundedBy(m money.Money) money.Money
- func (r Periodic) RoundedByWithPeriod(amount money.Money, period uint) money.Money
- func (r Periodic) String() string
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 ¶
NewPeriodicRate creates a new Periodic rate.
func NewPeriodicRateFromFloat64 ¶
NewPeriodicRateFromFloat64 creates a new Periodic rate from a float64.
func NewPeriodicRateFromInt ¶
NewPeriodicRateFromInt creates a new Periodic rate from an int64.
func (Periodic) Equal ¶ added in v1.12.0
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) NominalToPeriod ¶
NominalToPeriod converts the rate to the given period applying linear conversión (Nominal rates).
func (Periodic) PeriodAsString ¶ added in v1.12.0
func (Periodic) RoundedBy ¶
RoundedBy applies the rate to the amount of money with half-even rounding.
func (Periodic) RoundedByWithPeriod ¶
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)
Click to show internal directories.
Click to hide internal directories.