Этот коммит содержится в:
Conor Macpherson
2022-12-27 16:03:04 -05:00
родитель 40c94892ee
Коммит c633a1d2fa
5 изменённых файлов: 16 добавлений и 16 удалений

Просмотреть файл

@@ -35,8 +35,8 @@ hwIDAQAB
var LicenseValidator LicenseValidatorIface
const TrueUpReviewDueDay = 15
const BusinessQuaterStep = 3
const trueUpReviewDueDay = 15
const businessQuarterStep = 3
func init() {
if LicenseValidator == nil {
@@ -232,16 +232,16 @@ func GetSanitizedClientLicense(l map[string]string) map[string]string {
func GetNextTrueUpReviewDueDate(now time.Time) time.Time {
quaterEndMonths := []time.Month{time.March, time.June, time.September, time.December}
var nextQuaterEndMonth time.Month = time.March
var nextQuarterEndMonth time.Month = time.March
for _, month := range quaterEndMonths {
if now.Month() <= month && now.Day() <= TrueUpReviewDueDay {
nextQuaterEndMonth = month
if now.Month() <= month && now.Day() <= trueUpReviewDueDay {
nextQuarterEndMonth = month
break
} else if now.Month() <= month && now.Day() > TrueUpReviewDueDay {
nextQuaterEndMonth = month + BusinessQuaterStep
} else if now.Month() <= month && now.Day() > trueUpReviewDueDay {
nextQuarterEndMonth = month + businessQuarterStep
break
}
}
return time.Date(now.Year(), nextQuaterEndMonth, TrueUpReviewDueDay, 0, 0, 0, 0, now.Location())
return time.Date(now.Year(), nextQuarterEndMonth, trueUpReviewDueDay, 0, 0, 0, 0, now.Location())
}

Просмотреть файл

@@ -111,7 +111,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) {
assert.Equal(t, due.Day(), TrueUpReviewDueDay)
})
t.Run("Due date will always be in next quater if the current date is past the 15th", func(t *testing.T) {
t.Run("Due date will always be in next quarter if the current date is past the 15th", func(t *testing.T) {
now := time.Date(2022, time.March, 16, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.June, due.Month())
@@ -129,7 +129,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) {
assert.Equal(t, time.March, due.Month())
})
t.Run("Due date will always be in the current quater if the current date is before or on the 15th", func(t *testing.T) {
t.Run("Due date will always be in the current quarter if the current date is before or on the 15th", func(t *testing.T) {
now := time.Date(2022, time.March, 15, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.March, due.Month())