Skip to content

Commit

Permalink
Improve pricePerYear price calculation precision (#3492)
Browse files Browse the repository at this point in the history
### Description
Followup to #3480 

This slightly improves precision when calculating price per year for
weekly subscriptions.
  • Loading branch information
tonidero committed Dec 5, 2023
1 parent ad0f9d9 commit 4f80eda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private extension SubscriptionPeriod {
static let daysPerMonth: Decimal = 30
static let daysPerYear: Decimal = 365
static let weeksPerMonth: Decimal = daysPerYear / monthsPerYear / daysPerWeek
static let weeksPerYear: Decimal = 52.14
static let weeksPerYear: Decimal = daysPerYear / daysPerWeek
static let monthsPerYear: Decimal = 12
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class SubscriptionPeriodTests: TestCase {
.init(p(1, .day), 1, 365),
.init(p(1, .day), 2, 730),
.init(p(15, .day), 5, 121.66),
.init(p(1, .week), 10, 521.4),
.init(p(2, .week), 10, 260.7),
.init(p(1, .week), 10, 521.42),
.init(p(2, .week), 10, 260.71),
.init(p(1, .month), 14.99, 179.88),
.init(p(1, .month), 5, 60),
.init(p(2, .month), 30, 180),
Expand Down

0 comments on commit 4f80eda

Please sign in to comment.