Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"uneven end date" when the day of month is 29, 30 or 31. #39

Open
arobase-che opened this issue May 31, 2023 · 0 comments · May be fixed by #40
Open

"uneven end date" when the day of month is 29, 30 or 31. #39

arobase-che opened this issue May 31, 2023 · 0 comments · May be fixed by #40

Comments

@arobase-che
Copy link

Hello \o

I got that error when I tried to make a credit simulation at the end of any month.

Can be reproduced with :

package main

import (
	"fmt"
	"time"

	financial "github.com/razorpay/go-financial"
	"github.com/razorpay/go-financial/enums/frequency"
	"github.com/razorpay/go-financial/enums/interesttype"
	"github.com/razorpay/go-financial/enums/paymentperiod"
	"github.com/shopspring/decimal"
)

func main() {
	date := time.Date(2023, 5, 31, 12, 0, 0, 0, time.UTC)
	FinancingDurationInMonths := 12

	config := financial.Config{
		StartDate:      date,
		EndDate:        date.AddDate(0, FinancingDurationInMonths, 0).AddDate(0, 0, -1),
		Frequency:      frequency.MONTHLY,
		AmountBorrowed: decimal.NewFromInt(35_000),
		InterestType:   interesttype.FLAT,
		Interest:       decimal.NewFromFloat(4.20),
		PaymentPeriod:  paymentperiod.BEGINNING,
	}

	amortization, err := financial.NewAmortization(&config)
	if err != nil {
		fmt.Println(err.Error(), "failed to initialize amortization rules")
	} else {
		fmt.Println(amortization)
	}
}

Is it expected or I'm doing something wrong ?

@arobase-che arobase-che linked a pull request Jun 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant