-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lib/helpers/alaveteli_pro/alternative_price_text_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module AlaveteliPro::AlternativePriceTextHelper | ||
def short_alternative_price_text(price) | ||
amount = format_currency( | ||
price.unit_amount_with_tax, no_cents_if_whole: true | ||
) | ||
|
||
if interval(price) == 'day' && interval_count(price) == 1 | ||
_('or {{amount}} daily', amount: amount) | ||
elsif interval(price) == 'week' && interval_count(price) == 1 | ||
_('or {{amount}} weekly', amount: amount) | ||
elsif interval(price) == 'month' && interval_count(price) == 1 | ||
_('or {{amount}} monthly', amount: amount) | ||
elsif interval(price) == 'year' && interval_count(price) == 1 | ||
_('or {{amount}} annually', amount: amount) | ||
else | ||
_('or {{amount}} every {{interval}}', | ||
amount: amount, | ||
interval: pluralize_interval(price)) | ||
end | ||
end | ||
end |