data-hook="variants_row" class="<%= cycle('odd', 'even')%>">
<%= variant.is_master? ? 'Master' : variant.options_text %> |
- <%= Spree::Money.new(variant.default_price.amount, currency: variant.default_price.currency) %> |
+ <%= Spree::Money.new(variant.default_price.try(:amount), currency: variant.default_price.try(:currency)) %> |
<% if @current_price_book.factored? %>
<%= Spree::Money.new(@prices[variant.id].amount, currency: @prices[variant.id].currency) %>
@@ -52,9 +52,7 @@
<%= Spree.t(:or) %>
<%= button_link_to Spree.t('actions.cancel'), spree.admin_product_url(@product), :icon => 'icon-remove' %>
-
+
<%# this is horrible Jeff S. Why didn't you just keep the product in the route? %>
<%= hidden_field_tag :product_id, @product.id %> <%# due to the goofy way i chose to do my routing/redirecting %>
-
-
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6cf363f..9f2a82e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -12,6 +12,7 @@ en:
spree/price_book:
currency: Currency
default: Default
+ priority: Priority
price_adjustment_factor: Factor
errors:
models:
@@ -27,4 +28,8 @@ en:
one: Price Book
other: Price Books
spree:
+ default_price: Default price
+ new_price_book: New Price Book
+ back_to_price_books_list: Back to price books
editing_currency_rate: Editing Currency Rate
+ editing_price_book: Editing Price Book
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
new file mode 100644
index 0000000..e85df20
--- /dev/null
+++ b/config/locales/ru.yml
@@ -0,0 +1,45 @@
+ru:
+ activerecord:
+ attributes:
+ spree/currency_rate:
+ base_currency: Базовая Валюта
+ currency: Валюта
+ default: По умолчанию
+ exchange_rate: Курс обмена
+ spree/price_book:
+ name: Название
+ active_from: Активно с
+ active_to: Активно до
+ currency: Валюта
+ default: По умолчанию
+ priority: Приоритет
+ role: Роль
+ role_id: Роль
+ discount: Скидка?
+ parent: Родительское ценовое правило
+ price_adjustment_factor: Коэффициент корректировки цены
+ errors:
+ models:
+ spree/price:
+ attributes:
+ currency:
+ match_price_book: Must match price book currency.
+ models:
+ spree/currency_rate:
+ one: Курс обмена
+ few: Курсы обмена
+ many: Курсы обмена
+ other: Курсы обмена
+ spree/price_book:
+ one: Ценовое правило
+ few: Ценовые правила
+ many: Ценовые правила
+ other: Ценовые правила
+ spree:
+ new_currency_rate: Новый курс обмена
+ default_price: Цена по умолчанию
+ new_price_book: Новое ценовое правило
+ back_to_price_books_list: Назад к ценовым правилам
+ back_to_currency_rates_list: Назад к курсам обмена
+ editing_currency_rate: Редактирование курса обмена
+ editing_price_book: Редактирование ценового правила
diff --git a/lib/spree_price_books.rb b/lib/spree_price_books.rb
index f26310c..d33e814 100644
--- a/lib/spree_price_books.rb
+++ b/lib/spree_price_books.rb
@@ -1,4 +1,4 @@
require 'spree_core'
-require 'money/bank/google_currency'
+require 'money/bank/open_exchange_rates_bank'
require 'validates_timeliness'
require 'spree_price_books/engine'
diff --git a/lib/tasks/price_books.rake b/lib/tasks/price_books.rake
index d477591..aa44f94 100644
--- a/lib/tasks/price_books.rake
+++ b/lib/tasks/price_books.rake
@@ -6,19 +6,22 @@ namespace :price_books do
# (optional)
# set the seconds after than the current rates are automatically expired
# by default, they never expire
- Money::Bank::GoogleCurrency.ttl_in_seconds = 86400
- # set default bank to instance of GoogleCurrency
- Money.default_bank = Money::Bank::GoogleCurrency.new
- Money::Currency.all.each do |currency|
- # Limit to only major currencies, which have priority below 100.
- next if currency.priority >= 100
+ oxr = Money::Bank::OpenExchangeRatesBank.new
+ oxr.app_id = Rails.application.config.openExchangeRate[:appId]
+ oxr.update_rates
+ oxr.cache = 'tmp/cache.json'
+ oxr.ttl_in_seconds = 86400
+ oxr.source = Spree::CurrencyRate.default.currency
+ Money.default_bank = oxr
+
+ Spree::Config[:supported_currencies].split(',').each do |currencyCode|
+ currency = Money::Currency.new(currencyCode)
begin
- rate = Money.default_bank.get_rate(Spree::CurrencyRate.default.currency, currency.iso_code)
+ rate = Money.default_bank.get_rate(Spree::CurrencyRate.default.currency, currency)
if cr = Spree::CurrencyRate.find_or_create_by(base_currency: Spree::CurrencyRate.default.currency, currency: currency.iso_code, default: (Spree::Config[:currency] == currency.iso_code))
cr.update_attribute :exchange_rate, rate
end
- rescue Money::Bank::UnknownRate # Google doesn't track this currency.
- rescue Money::Bank::GoogleCurrencyFetchError => ex
+ rescue Exception => ex
puts currency.inspect
puts ex.message
puts ex.backtrace
diff --git a/spree_price_books.gemspec b/spree_price_books.gemspec
index b4b8777..3a199e7 100644
--- a/spree_price_books.gemspec
+++ b/spree_price_books.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_price_books'
- s.version = '2.3.0.beta'
+ s.version = '3.1.0'
s.summary = 'Price books allowing flexible product pricing.'
s.description = s.summary
s.required_ruby_version = '>= 2.0.0'
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'google_currency'
- s.add_dependency 'spree_core', '~> 2.3.0'
+ s.add_dependency 'money-open-exchange-rates', '1.2.0'
+ s.add_dependency 'spree_core', '~> 3.1.0'
s.add_dependency 'validates_timeliness', '~> 3.0'
s.add_development_dependency 'capybara', '~> 2.1'
|