interests

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YearDays  = 360
	MonthDays = 30
	YearMonth = 12
)

define days

View Source
const (
	RateTypeDay = iota + 1
	RateTypeMonth
	RateTypeYear
)

日、月、年利率

View Source
const (
	// 普通算法
	CalcTypeDaily = iota + 1
	// 等额本息
	CalcTypeAverageCapitalPlus
	// 等额本金
	CalcTypeAverageCapital
)

利息算法

Variables

View Source
var (
	ErrInvalidInputParams   = errors.New("invalid input params")
	ErrNotSupportedRateType = errors.New("rate type not supported")
	ErrNotSupportedCalcType = errors.New("calculate type not supported")
)

define errors

Functions

This section is empty.

Types

type Interest

type Interest interface {
	CalcPayback(*InterestSets) (*Payback, error)
	CalcAllPaybackAmount(*InterestSets) (int64, error)
	CalcAllInterests(*InterestSets) (int64, error)
}

Interest 利息计算公式

func GetInterestRepo

func GetInterestRepo(typ int) (Interest, error)

GetInterestRepo 获取等额本息Repo

type InterestSets

type InterestSets struct {
	// 利率类型
	RateType int `valid:"gt=0,lt=4"`
	// 利率
	InterestRate float64 `valid:"gte=0.0"`
	// 还款次数,日还款写天数,等额本息和等额本金为月数
	PayTimes int `valid:"gte=0"`
	// 借款金额
	Amount int64 `valid:"gte=0"`
	// 借款开始日
	StartDate string
	// contains filtered or unexported fields
}

InterestSets 利息计算配置

type Payback

type Payback struct {
	// 开始日期
	StartDate string
	// 结束日期
	EndDate string
	// 还款日
	PayBackDay int
	// 本金
	Principal int64
	// 利息
	Interests int64
	// 还款总额
	TotalPayBack int64
	// 按期还款明细
	Backs []PaybackPeriod
}

Payback 还款信息

type PaybackPeriod

type PaybackPeriod struct {
	// 第几期
	RepayTimes int
	// 利息
	Interests int64
	// 本金
	Principal int64
	// 总额
	Total int64
	// 开始日期
	StartDate string
	// 结束日期
	EndDate string
	// 付息日期
	PayDate string
}

PaybackPeriod 还款周期

Jump to

Keyboard shortcuts

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