solidus_backend 1.3.0.beta1 → 1.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +10 -5
  4. data/app/controllers/spree/admin/prices_controller.rb +20 -0
  5. data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
  6. data/app/helpers/spree/admin/products_helper.rb +4 -0
  7. data/app/views/spree/admin/payments/_form.html.erb +1 -1
  8. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +1 -1
  9. data/app/views/spree/admin/prices/_form.html.erb +52 -0
  10. data/app/views/spree/admin/prices/_table.html.erb +35 -0
  11. data/app/views/spree/admin/prices/edit.html.erb +12 -0
  12. data/app/views/spree/admin/prices/index.html.erb +73 -0
  13. data/app/views/spree/admin/prices/new.html.erb +7 -0
  14. data/app/views/spree/admin/prices/new.js.erb +2 -0
  15. data/app/views/spree/admin/products/_form.html.erb +11 -6
  16. data/app/views/spree/admin/products/new.html.erb +9 -1
  17. data/app/views/spree/admin/reimbursements/show.html.erb +1 -1
  18. data/app/views/spree/admin/search/products.rabl +1 -1
  19. data/app/views/spree/admin/shared/_product_tabs.html.erb +3 -0
  20. data/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb +12 -0
  21. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +1 -1
  22. data/app/views/spree/admin/shared/_tabs.html.erb +5 -1
  23. data/app/views/spree/admin/store_credits/edit_amount.html.erb +2 -1
  24. data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -1
  25. data/app/views/spree/admin/store_credits/index.html.erb +2 -1
  26. data/app/views/spree/admin/store_credits/new.html.erb +2 -1
  27. data/app/views/spree/admin/store_credits/show.html.erb +2 -1
  28. data/app/views/spree/admin/users/_sidebar.html.erb +2 -29
  29. data/app/views/spree/admin/users/_tabs.html.erb +29 -0
  30. data/app/views/spree/admin/users/addresses.html.erb +2 -1
  31. data/app/views/spree/admin/users/edit.html.erb +2 -1
  32. data/app/views/spree/admin/users/items.html.erb +2 -1
  33. data/app/views/spree/admin/users/orders.html.erb +2 -1
  34. data/app/views/spree/admin/variants/_form.html.erb +4 -0
  35. data/config/routes.rb +1 -0
  36. data/spec/controllers/spree/admin/prices_controller_spec.rb +41 -0
  37. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +12 -0
  38. data/spec/features/admin/orders/payments_spec.rb +21 -0
  39. data/spec/features/admin/products/pricing_spec.rb +92 -0
  40. data/spec/features/admin/reimbursements_spec.rb +16 -0
  41. data/spec/features/admin/stock_transfer_spec.rb +11 -0
  42. data/spec/features/admin/users_spec.rb +3 -3
  43. metadata +18 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7f8257531544954cfb58934778763acca81477
4
- data.tar.gz: e84a434b1008caaf54ce913f3bab66d25916faa1
3
+ metadata.gz: 51cce8989f8468b9b8c46fa6e106fac9ce528a43
4
+ data.tar.gz: 97c4feba8c1f166dd176ad53ac9c25d2a53cc487
5
5
  SHA512:
6
- metadata.gz: ffa2d4bcfa0c61e67b21662adc9ab2be1457f2ba6225202a7c977d2db7784f7173a3e4bb07890bfeda8150960687c44853cc2a9934631e9ab49da8cf6da03888
7
- data.tar.gz: 23c7b13590263d67042317d05b5c1b88a5a14bfa7c2941314f6d3aa6d81798791951e2f932225ba54bbf4bc928ccef66a65a3741b0c84f6726447662f5cc7aca
6
+ metadata.gz: 603dfb79d475ca639c882863bf420f219169aabba2768902fc6c3292db11cb3df60f2c204bf88580c2cebfa6dfad6b09b2628f2cc65e1d582cd3b420e35d59e4
7
+ data.tar.gz: 7be5c607ace3fc7b1b26942312f9a76f7ad2ecb3c8aaf4890992b3a2c0589e50c48f02725794c36ac8ba846dff6f3a661db8c510b265ae0002916a4da9287137
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- eval_gemfile File.expand_path('../../common_spree_dependencies.rb', __FILE__)
1
+ eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
2
2
 
3
3
  gem 'solidus_core', path: '../core'
4
4
  gem 'solidus_api', path: '../api'
@@ -1,7 +1,12 @@
1
1
  $ ->
2
2
  if $('.new_payment').is('*')
3
- $('.payment-method-settings fieldset').addClass('hidden').first().removeClass('hidden')
4
- $('input[name="payment[payment_method_id]"]').click ()->
5
- $('.payment-method-settings fieldset').addClass('hidden')
6
- id = $(this).parents('li').data('id')
7
- $("fieldset[data-id='#{id}']").removeClass('hidden')
3
+ $input = $('input[name="payment[payment_method_id]"]')
4
+ $paymentMethods = $('.payment-method-settings .payment-methods')
5
+
6
+ updateSelected = ->
7
+ id = $input.filter(":checked").val()
8
+ $paymentMethods.addClass('hidden')
9
+ $paymentMethods.filter("#payment_method_#{id}").removeClass('hidden')
10
+
11
+ $input.on('click', updateSelected)
12
+ updateSelected()
@@ -0,0 +1,20 @@
1
+ module Spree
2
+ module Admin
3
+ class PricesController < ResourceController
4
+ belongs_to 'spree/product', find_by: :slug
5
+
6
+ def index
7
+ params[:q] ||= {}
8
+
9
+ @search = @product.prices.accessible_by(current_ability, :index).ransack(params[:q])
10
+ @prices = @search.result
11
+ .currently_valid
12
+ .order(:variant_id, :country_iso, :currency)
13
+ .page(params[:page]).per(Spree::Config.admin_variants_per_page)
14
+ end
15
+
16
+ def edit
17
+ end
18
+ end
19
+ end
20
+ end
@@ -82,7 +82,7 @@ module Spree
82
82
  end
83
83
 
84
84
  def render_after_create_error
85
- load_stock_locations
85
+ load_source_stock_locations
86
86
  super
87
87
  end
88
88
 
@@ -24,6 +24,10 @@ module Spree
24
24
  end
25
25
  safe_join(options)
26
26
  end
27
+
28
+ def show_rebuild_vat_checkbox?
29
+ Spree::TaxRate.included_in_price.exists?
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -10,7 +10,7 @@
10
10
  <label><%= Spree::PaymentMethod.model_name.human %></label>
11
11
  <ul>
12
12
  <% @payment_methods.each do |method| %>
13
- <li data-id="<%= Spree.t(method.name, :scope => :payment_methods, :default => method.name).parameterize %>">
13
+ <li>
14
14
  <label data-hook="payment_method_field">
15
15
  <%= radio_button_tag 'payment[payment_method_id]', method.id, method == @payment_method, { class: "payment_methods_radios" } %>
16
16
  <%= method.name %>
@@ -1,4 +1,4 @@
1
- <fieldset data-id='credit-card' class="no-border-bottom">
1
+ <fieldset class="no-border-bottom">
2
2
  <div class="field" data-hook="previous_cards">
3
3
  <% if previous_cards.any? %>
4
4
  <% previous_cards.each do |card| %>
@@ -0,0 +1,52 @@
1
+ <div data-hook="admin_product_price_fields">
2
+
3
+ <div data-hook="admin_product_price_form">
4
+ <div class="four columns alpha" data-hook="admin_product_price_form_variant">
5
+ <%= f.field_container :variant do %>
6
+ <%= f.label :variant %>
7
+ <%= f.select :variant_id,
8
+ @product.variants_including_master.map { |v| [v.descriptive_name, v.id] },
9
+ {},
10
+ class: "select2 fullwidth", disabled: !f.object.new_record? %>
11
+ <% end %>
12
+ </div>
13
+
14
+ <div class="three columns alpha" data-hook="admin_product_price_form_currency">
15
+ <%= f.field_container :currency do %>
16
+ <%= f.label :currency %>
17
+ <%= f.select :currency,
18
+ Money::Currency.all.map { |c| ["#{c.iso_code} (#{c.name})", c.iso_code] },
19
+ {},
20
+ class: "select2 fullwidth", disabled: !f.object.new_record? %>
21
+ <% end %>
22
+ </div>
23
+
24
+ <div class="three columns" data-hook="admin_product_price_form_country">
25
+ <%= f.field_container :country do %>
26
+ <%= f.label :country %>
27
+ <%= f.collection_select :country_iso, available_countries, :iso, :name,
28
+ {
29
+ include_blank: t(:any_country, scope: [:spree, :admin, :prices]),
30
+ selected: Spree::Config.admin_vat_country_iso
31
+ },
32
+ { class: 'select2 fullwidth', disabled: !f.object.new_record? } %>
33
+ <% end %>
34
+ </div>
35
+
36
+ <div class="three columns" data-hook="admin_product_price_form_amount">
37
+ <%= f.field_container :price do %>
38
+ <%= f.label :price %>
39
+ <%= f.text_field :price, value: f.object.money.format, class: 'fullwidth title' %>
40
+ <% end %>
41
+ </div>
42
+
43
+ <div class="field three columns checkbox omega" data-hook="is_default_price">
44
+ <%= f.label :is_default do %>
45
+ <%= f.check_box :is_default %>
46
+ <%= Spree::Price.human_attribute_name(:is_default) %>
47
+ <% end %>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <div class="clear"></div>
@@ -0,0 +1,35 @@
1
+ <%= paginate prices, theme: "solidus_admin" %>
2
+
3
+ <table class="index prices">
4
+ <thead data-hook="prices_header">
5
+ <tr>
6
+ <th><%= Spree::Variant.model_name.human %> </th>
7
+ <th><%= Spree::Price.human_attribute_name(:country) %></th>
8
+ <th><%= Spree::Price.human_attribute_name(:currency) %></th>
9
+ <th><%= Spree::Price.human_attribute_name(:amount) %></th>
10
+ <th class="actions"></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% prices.each do |price| %>
16
+ <tr id="<%= spree_dom_id price %>" data-hook="prices_row" class="<%= "deleted" if price.deleted? %> <%= cycle('odd', 'even')%>">
17
+ <td><%= price.variant.descriptive_name %></td>
18
+ <td><%= price.display_country %>
19
+ <td><%= price.currency %></td>
20
+ <td class="align-right"><%= price.money.to_html %></td>
21
+ <td class="actions">
22
+ <% if can?(:update, price) %>
23
+ <%= link_to_edit(price, :no_text => true) unless price.deleted? %>
24
+ <% end %>
25
+ <% if can?(:destroy, price) %>
26
+ &nbsp;
27
+ <%= link_to_delete(price, :no_text => true) unless price.deleted? %>
28
+ <% end %>
29
+ </td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+
35
+ <%= paginate prices, theme: "solidus_admin" %>
@@ -0,0 +1,12 @@
1
+ <%= render 'spree/admin/shared/product_tabs', current: 'Prices' %>
2
+
3
+ <%= form_for @price, url: spree.admin_product_price_path(@product, @price) do |f| %>
4
+ <fieldset>
5
+ <legend> <%= t('.edit_price') %> </legend>
6
+ <%= render 'form', f: f %>
7
+
8
+ <% if can?(:update, @product) %>
9
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
10
+ <% end %>
11
+ </fieldset>
12
+ <% end %>
@@ -0,0 +1,73 @@
1
+ <%= render 'spree/admin/shared/product_tabs', current: 'Prices' %>
2
+
3
+ <% content_for :page_actions do %>
4
+ <li id="new_price_link">
5
+ <%= button_link_to t(".new_price"), new_object_url, { :remote => true, :icon => 'plus', :id => 'admin_new_product' } %>
6
+ </li>
7
+ <% end if can?(:create, Spree::Product) %>
8
+
9
+ <% content_for :table_filter_title do %>
10
+ <%= Spree.t(:search) %>
11
+ <% end %>
12
+
13
+ <% content_for :table_filter do %>
14
+ <div data-hook="admin_product_prices_index_search">
15
+ <%= search_form_for [:admin, :product, @search] do |f| %>
16
+
17
+ <div class="alpha four columns">
18
+ <div class="field" data-hook="sku-select">
19
+ <%= label_tag :q_variant_id_eq, Spree::Variant.model_name.human %>
20
+ <%= f.select :variant_id_eq,
21
+ @product.variants_including_master.map { |v| [v.descriptive_name, v.id] },
22
+ {include_blank: true},
23
+ class: "select2 fullwidth" %>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="three columns">
28
+ <div class="field" data-hook="currency-select">
29
+ <%= label_tag :q_currency_eq, Spree::Price.human_attribute_name(:currency) %>
30
+ <%= f.select :currency_eq,
31
+ @prices.map(&:currency).uniq,
32
+ {include_blank: true},
33
+ class: "select2 fullwidth" %>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="three columns">
38
+ <div class="field" data-hook="country-select">
39
+ <%= label_tag :q_country_iso_eq, Spree::Price.human_attribute_name(:country) %>
40
+ <%= f.select :country_iso_eq,
41
+ @prices.map(&:country).compact.uniq.map { |c| [c.name, c.iso]},
42
+ {include_blank: true},
43
+ class: "select2 fullwidth" %>
44
+ </div>
45
+ </div>
46
+
47
+ <div class="three columns">
48
+ <div class="field">
49
+ <%= label_tag :q_amount_gt, t(".amount_greater_than") %>
50
+ <%= f.text_field :amount_gt %>
51
+ </div>
52
+ </div>
53
+
54
+ <div class="omega three columns">
55
+ <div class="field">
56
+ <%= label_tag :q_amount_lt, t(".amount_less_than") %>
57
+ <%= f.text_field :amount_lt %>
58
+ </div>
59
+ </div>
60
+
61
+ <div class="clearfix"></div>
62
+
63
+ <div class="actions filter-actions">
64
+ <div data-hook="admin_orders_index_search_buttons">
65
+ <%= button Spree.t(:filter_results), 'search' %>
66
+ </div>
67
+ </div>
68
+
69
+ <% end %>
70
+ </div>
71
+ <% end %>
72
+
73
+ <%= render 'table', prices: @prices %>
@@ -0,0 +1,7 @@
1
+ <%= form_for [:admin, @product, @product.prices.build] do |f| %>
2
+ <fieldset data-hook="admin_product_price_new_form">
3
+ <legend><%= t('.new_price') %></legend>
4
+ <%= render :partial => 'form', :locals => { :f => f } %>
5
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
6
+ </fieldset>
7
+ <% end %>
@@ -0,0 +1,2 @@
1
+ $(".js-content-below-tabs").html('<%= escape_javascript(render :template => 'spree/admin/prices/new', :formats => [:html], :handlers => [:erb]) %>');
2
+ $(".js-content-below-tabs .select2").select2();
@@ -27,14 +27,19 @@
27
27
  </div>
28
28
 
29
29
  <div class="right four columns omega" data-hook="admin_product_form_right">
30
- <div data-hook="admin_product_form_price">
31
- <%= f.field_container :price do %>
32
- <%= f.label :price, class: 'required' %>
33
- <%= f.text_field :price, :value => number_to_currency(@product.price, :unit => ''), :required => true %>
34
- <%= f.error_message_on :price %>
35
- <% end %>
30
+ <div data-hook="admin_product_form_price" class="alpha omega four columns">
31
+ <%= f.field_container :price do %>
32
+ <%= f.label :price, class: 'required' %>
33
+ <%= f.text_field :price, :value => number_to_currency(@product.price, :unit => ''), :required => true %>
34
+ <%= f.error_message_on :price %>
35
+ <% end %>
36
36
  </div>
37
37
 
38
+ <% if show_rebuild_vat_checkbox? %>
39
+ <%= render "spree/admin/shared/rebuild_vat_prices_checkbox", form: f, model_name: "product", wrapper_class: "alpha omega field four columns" %>
40
+ <div class="clearfix"></div>
41
+ <% end %>
42
+
38
43
  <div data-hook="admin_product_form_cost_price" class="alpha two columns">
39
44
  <%= f.field_container :cost_price do %>
40
45
  <%= f.label :cost_price %>
@@ -49,7 +49,7 @@
49
49
  </div>
50
50
 
51
51
  <div class='row'>
52
- <div data-hook="new_product_shipping_category" class="alpha four columns">
52
+ <div data-hook="new_product_shipping_category" class="alpha field four columns">
53
53
  <%= f.field_container :shipping_category do %>
54
54
  <%= f.label :shipping_category_id, Spree::ShippingCategory.
55
55
  model_name.human, class: 'required' %><br />
@@ -57,6 +57,14 @@
57
57
  <%= f.error_message_on :shipping_category_id %>
58
58
  <% end %>
59
59
  </div>
60
+
61
+ <div data-hook="new_product_tax_category" class="field four columns">
62
+ <%= f.field_container :tax_category do %>
63
+ <%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %>
64
+ <%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2 fullwidth' }) %>
65
+ <%= f.error_message_on :tax_category %>
66
+ <% end %>
67
+ </div>
60
68
  </div>
61
69
 
62
70
  <div class="clearfix" data-hook="product-from-prototype" id="product-from-prototype">
@@ -79,7 +79,7 @@
79
79
  <thead data-hook="customer_return_header">
80
80
  <tr>
81
81
  <th><%= Spree.t(:description) %></th>
82
- <th><%= Spree::ReimbursementCredit.human_attribute_name(:amount) %></th>
82
+ <th><%= Spree::Reimbursement::Credit.human_attribute_name(:amount) %></th>
83
83
  </tr>
84
84
  </thead>
85
85
  <tbody>
@@ -3,7 +3,7 @@ node(:count) { @products.count }
3
3
  node(:total_count) { @products.total_count }
4
4
  node(:current_page) { params[:page] ? params[:page].to_i : 1 }
5
5
  node(:per_page) { params[:per_page] || Kaminari.config.default_per_page }
6
- node(:pages) { @products.num_pages }
6
+ node(:pages) { @products.total_pages }
7
7
  child(@products => :products) do
8
8
  attributes :id, :name
9
9
  end
@@ -14,6 +14,9 @@
14
14
  <%= content_tag :li, :class => ('active' if current == 'Variants') do %>
15
15
  <%= link_to_with_icon 'th-large', Spree::Variant.model_name.human(count: :other), spree.admin_product_variants_url(@product) %>
16
16
  <% end if can?(:admin, Spree::Variant) %>
17
+ <%= content_tag :li, :class => ('active' if current == 'Prices') do %>
18
+ <%= link_to_with_icon 'money', Spree::Price.model_name.human(count: :other), spree.admin_product_prices_url(@product) %>
19
+ <% end if can?(:admin, Spree::Price) %>
17
20
  <%= content_tag :li, :class => ('active' if current == 'Product Properties') do %>
18
21
  <%= link_to_with_icon 'tasks', Spree::ProductProperty.model_name.human(count: :other), spree.admin_product_product_properties_url(@product) %>
19
22
  <% end if can?(:admin, Spree::ProductProperty) %>
@@ -0,0 +1,12 @@
1
+ <div data-hook="admin_<%= model_name %>_form_generate_vat_prices" class="<%= wrapper_class %> checkbox">
2
+ <%= form.label :rebuild_vat_prices do %>
3
+ <%= form.check_box :rebuild_vat_prices, checked: form.object.prices.size <= 1 %>
4
+ <%= Spree::Variant.human_attribute_name(:rebuild_vat_prices) %>
5
+ <% end %>
6
+ </div>
7
+
8
+ <script type="text/javascript">
9
+ $('#<%= model_name %>_price').on('change', function(e) {
10
+ $('#<%= model_name %>_rebuild_vat_prices').prop('checked', true);
11
+ });
12
+ </script>
@@ -21,6 +21,6 @@
21
21
  <% end %>
22
22
 
23
23
  <% if can?(:display, Spree::ShippingMethod) || can?(:display, Spree::ShippingCategory) || can?(:display, Spree::StockLocation) %>
24
- <%= tab :shipping, url: admin_shipping_methods_path %>
24
+ <%= tab :shipping, url: admin_shipping_methods_path, match_path: %r(shipping_methods|shipping_categories|stock_locations) %>
25
25
  <% end %>
26
26
  </ul>
@@ -25,7 +25,11 @@
25
25
  <% end %>
26
26
 
27
27
  <% if can? :admin, Spree::StockItem %>
28
- <%= tab(*Spree::BackendConfiguration::STOCK_TABS, url: spree.admin_stock_items_path, label: :stock, icon: 'cubes', match_path: %r(^/admin/stock)) do %>
28
+ <%= tab(
29
+ *Spree::BackendConfiguration::STOCK_TABS,
30
+ url: spree.admin_stock_items_path,
31
+ label: :stock, icon: 'cubes',
32
+ match_path: %r(^/admin/stock(?!_locations))) do %>
29
33
  <%- render partial: 'spree/admin/shared/stock_sub_menu' %>
30
34
  <%- end %>
31
35
  <% end %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :store_credits } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :store_credits %>
6
7
  <% content_for :page_actions do %>
7
8
  <li><%= link_to_with_icon 'arrow-left', Spree.t("admin.store_credits.back_to_edit"), admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
8
9
  <% end %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :store_credits } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :store_credits %>
6
7
  <% content_for :page_actions do %>
7
8
  <li><%= link_to_with_icon 'arrow-left', Spree.t("admin.store_credits.back_to_edit"), admin_user_store_credit_path(@user, @store_credit), class: 'button' %></li>
8
9
  <% end %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :store_credits } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :store_credits %>
6
7
  <% content_for :page_actions do %>
7
8
  <li><%= link_to_with_icon 'arrow-left', Spree.t("admin.store_credits.back_to_user_list"), admin_users_path, class: 'button' %></li>
8
9
  <% if can?(:create, Spree::StoreCredit) %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :store_credits } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :store_credits %>
6
7
  <% content_for :page_actions do %>
7
8
  <li><%= link_to_with_icon 'arrow-left', Spree.t("admin.store_credits.back_to_store_credit_list"), admin_user_store_credits_path(@user), class: 'button' %></li>
8
9
  <% end %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :store_credits } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :store_credits %>
6
7
  <% content_for :page_actions do %>
7
8
  <li><%= link_to_with_icon 'arrow-left', Spree.t("admin.store_credits.back_to_store_credit_list"), admin_user_store_credits_path(@user), class: 'button' %></li>
8
9
  <% if @store_credit.editable? && can?(:edit, @store_credit) %>
@@ -1,37 +1,10 @@
1
1
  <% content_for :sidebar_title do %>
2
- <%= Spree.t(:"admin.user.user_information") %>
2
+ <%= Spree.t(:lifetime_stats) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :sidebar do %>
6
6
  <nav class="menu">
7
- <ul data-hook="admin_user_tab_options">
8
- <li<%== ' class="active"' if current == :account %>>
9
- <%= link_to_with_icon 'user', Spree.t(:"admin.user.account"), spree.edit_admin_user_path(@user) %>
10
- </li>
11
- <% if can?(:addresses, @user) %>
12
- <li<%== ' class="active"' if current == :address %>>
13
- <%= link_to_with_icon 'user', Spree.t(:"admin.user.addresses"), spree.addresses_admin_user_path(@user) %>
14
- </li>
15
- <% end %>
16
- <% if can?(:orders, @user) %>
17
- <li<%== ' class="active"' if current == :orders %>>
18
- <%= link_to_with_icon 'shopping-cart', Spree.t(:"admin.user.orders"), spree.orders_admin_user_path(@user) %>
19
- </li>
20
- <% end %>
21
- <% if can?(:items, @user) %>
22
- <li<%== ' class="active"' if current == :items %>>
23
- <%= link_to_with_icon 'edit', Spree.t(:"admin.user.items"), spree.items_admin_user_path(@user) %>
24
- </li>
25
- <% end %>
26
- <% if can?(:display, Spree::StoreCredit) %>
27
- <li<%== ' class="active"' if current == :store_credits %>>
28
- <%= link_to_with_icon 'money', Spree.t(:"admin.user.store_credit"), spree.admin_user_store_credits_path(@user) %>
29
- </li>
30
- <% end %>
31
- </ul>
32
-
33
- <fieldset data-hook="admin_user_lifetime_stats">
34
- <legend><%= Spree.t(:lifetime_stats) %></legend>
7
+ <fieldset class='no-border-top' data-hook="admin_user_lifetime_stats">
35
8
  <dl id="user-lifetime-stats">
36
9
  <dt><%= Spree.t(:total_sales) %>:</dt>
37
10
  <dd><%= @user.display_lifetime_value.to_html %></dd>
@@ -0,0 +1,29 @@
1
+ <% content_for :tabs do %>
2
+ <nav>
3
+ <ul class='tabs' data-hook="admin_user_tab_options">
4
+ <li<%== ' class="active"' if current == :account %>>
5
+ <%= link_to_with_icon 'user', Spree.t(:"admin.user.account"), spree.edit_admin_user_path(@user) %>
6
+ </li>
7
+ <% if can?(:addresses, @user) %>
8
+ <li<%== ' class="active"' if current == :address %>>
9
+ <%= link_to_with_icon 'user', Spree.t(:"admin.user.addresses"), spree.addresses_admin_user_path(@user) %>
10
+ </li>
11
+ <% end %>
12
+ <% if can?(:orders, @user) %>
13
+ <li<%== ' class="active"' if current == :orders %>>
14
+ <%= link_to_with_icon 'shopping-cart', Spree.t(:"admin.user.order_history"), spree.orders_admin_user_path(@user) %>
15
+ </li>
16
+ <% end %>
17
+ <% if can?(:items, @user) %>
18
+ <li<%== ' class="active"' if current == :items %>>
19
+ <%= link_to_with_icon 'edit', Spree.t(:"admin.user.items"), spree.items_admin_user_path(@user) %>
20
+ </li>
21
+ <% end %>
22
+ <% if can?(:display, Spree::StoreCredit) %>
23
+ <li<%== ' class="active"' if current == :store_credits %>>
24
+ <%= link_to_with_icon 'money', Spree.t(:"admin.user.store_credit"), spree.admin_user_store_credits_path(@user) %>
25
+ </li>
26
+ <% end %>
27
+ </ul>
28
+ </nav>
29
+ <% end %>
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :address } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :address %>
6
7
  <%= render :partial => 'spree/admin/users/user_page_actions' %>
7
8
 
8
9
  <fieldset data-hook="admin_user_addresses" id="admin_user_edit_addresses" class="alpha twelve columns">
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:editing_user)} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :account } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :account %>
6
7
  <%= render :partial => 'spree/admin/users/user_page_actions' %>
7
8
 
8
9
  <fieldset data-hook="admin_user_edit_general_settings" class="alpha twelve columns">
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:"admin.user.items_purchased")} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :items } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :items %>
6
7
  <%= render :partial => 'spree/admin/users/user_page_actions' %>
7
8
 
8
9
  <fieldset data-hook="admin_user_items_purchased" class="alpha twelve columns">
@@ -2,7 +2,8 @@
2
2
  <%= link_to "#{Spree.t(:"admin.user.order_history")} #{@user.email}", edit_admin_user_url(@user) %>
3
3
  <% end %>
4
4
 
5
- <%= render :partial => 'spree/admin/users/sidebar', :locals => { :current => :orders } %>
5
+ <%= render 'spree/admin/users/sidebar' %>
6
+ <%= render 'spree/admin/users/tabs', current: :orders %>
6
7
  <%= render :partial => 'spree/admin/users/user_page_actions' %>
7
8
 
8
9
  <fieldset data-hook="admin_user_order_history" class="alpha twelve columns">
@@ -53,6 +53,10 @@
53
53
  <%= f.text_field :price, :value => number_to_currency(@variant.price, :unit => ''), :class => 'fullwidth' %>
54
54
  </div>
55
55
 
56
+ <% if show_rebuild_vat_checkbox? %>
57
+ <%= render "spree/admin/shared/rebuild_vat_prices_checkbox", form: f, model_name: "variant", wrapper_class: "field four columns" %>
58
+ <% end %>
59
+
56
60
  <div class="field four columns" data-hook="cost_price">
57
61
  <%= f.label :cost_price %>
58
62
  <%= f.text_field :cost_price, :value => number_to_currency(@variant.cost_price, :unit => ''), :class => 'fullwidth' %>
data/config/routes.rb CHANGED
@@ -50,6 +50,7 @@ Spree::Core::Engine.add_routes do
50
50
  end
51
51
  end
52
52
  resources :variants_including_master, only: [:update]
53
+ resources :prices, only: [:destroy, :index, :edit, :update, :new, :create]
53
54
  end
54
55
  get '/products/:product_slug/stock', to: "stock_items#index", as: :product_stock
55
56
 
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Admin::PricesController do
4
+ stub_authorization!
5
+
6
+ let!(:product) { create(:product) }
7
+
8
+ describe '#index' do
9
+ context "when only given a product" do
10
+ let(:product) { create(:product) }
11
+
12
+ subject { spree_get :index, product_id: product.slug }
13
+
14
+ it { is_expected.to be_success }
15
+
16
+ it 'assigns usable instance variables' do
17
+ subject
18
+ expect(assigns(:search)).to be_a(Ransack::Search)
19
+ expect(assigns(:prices)).to eq(product.prices)
20
+ expect(assigns(:product)).to eq(product)
21
+ end
22
+ end
23
+
24
+ context "when given a product and a variant" do
25
+ let(:variant) { create(:variant) }
26
+ let(:product) { variant.product }
27
+
28
+ subject { spree_get :index, product_id: product.slug, variant_id: variant.id }
29
+
30
+ it { is_expected.to be_success }
31
+
32
+ it 'assigns usable instance variables' do
33
+ subject
34
+ expect(assigns(:search)).to be_a(Ransack::Search)
35
+ expect(assigns(:prices)).to eq(product.prices)
36
+ expect(assigns(:prices)).to include(variant.default_price)
37
+ expect(assigns(:product)).to eq(product)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -97,6 +97,18 @@ module Spree
97
97
  expect(assigns(:stock_transfer).created_by).to eq(user)
98
98
  end
99
99
  end
100
+
101
+ # Regression spec for Solidus issue #1087
102
+ context "missing source_stock_location parameter" do
103
+ subject do
104
+ spree_post :create, stock_transfer: { source_location_id: nil, description: nil }
105
+ end
106
+
107
+ it "sets a flash error" do
108
+ subject
109
+ expect(flash[:error]).to eq assigns(:stock_transfer).errors.full_messages.join(', ')
110
+ end
111
+ end
100
112
  end
101
113
 
102
114
  context "#receive" do
@@ -223,4 +223,25 @@ describe 'Payments', type: :feature do
223
223
  end
224
224
  end
225
225
  end
226
+
227
+ # Previously this would fail unless the method was named "Credit Card"
228
+ context "with an differently named payment method" do
229
+ let(:order) { create(:order_with_line_items, line_items_count: 1) }
230
+ let!(:chequing_payment_method) { create(:check_payment_method) }
231
+ let!(:payment_method) { create(:credit_card_payment_method, name: "Multipass!") }
232
+
233
+ before do
234
+ visit spree.admin_order_payments_path(order.reload)
235
+ end
236
+
237
+ it "is able to create a new payment", js: true do
238
+ choose payment_method.name
239
+ fill_in "Card Number", with: "4111 1111 1111 1111"
240
+ fill_in "Name", with: "Test User"
241
+ fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
242
+ fill_in "Card Code", with: "007"
243
+ click_button "Continue"
244
+ expect(page).to have_content("Payment has been successfully created!")
245
+ end
246
+ end
226
247
  end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Pricing' do
4
+ stub_authorization!
5
+
6
+ let(:product) { create(:product) }
7
+
8
+ before do
9
+ visit spree.edit_admin_product_path(product)
10
+ end
11
+
12
+ it 'has a Prices tab' do
13
+ within(".tabs") do
14
+ expect(page).to have_link("Prices")
15
+ end
16
+ end
17
+
18
+ context "in the prices tab" do
19
+ let!(:country) { create :country, iso: "DE" }
20
+ let(:master_price) { product.master.default_price }
21
+ let!(:other_price) { product.master.prices.create(amount: 34.56, currency: "RUB", country_iso: "DE") }
22
+
23
+ before do
24
+ visit spree.admin_product_prices_path(product)
25
+ end
26
+
27
+ it 'displays a table with the prices' do
28
+ expect(page).to have_content(product.name)
29
+ within(".tabs .active") do
30
+ expect(page).to have_content("Prices")
31
+ end
32
+
33
+ within('table.prices') do
34
+ expect(page).to have_content("$19.99")
35
+ expect(page).to have_content("USD")
36
+ expect(page).to have_content("34.56 ₽")
37
+ expect(page).to have_content("RUB")
38
+ expect(page).to have_content("Master")
39
+ expect(page).to have_content("Any Country")
40
+ expect(page).to have_content("Germany")
41
+ end
42
+ end
43
+
44
+ context "searching" do
45
+ let(:variant) { create(:variant, price: 20) }
46
+ let(:product) { variant.product }
47
+
48
+ before do
49
+ product.master.update(price: 49.99)
50
+ end
51
+
52
+ it 'has a working table filter' do
53
+ expect(page).to have_selector("#table-filter")
54
+ within "#table-filter" do
55
+ within "fieldset legend" do
56
+ expect(page).to have_content("Search")
57
+ end
58
+ end
59
+ select variant.options_text, from: "q_variant_id_eq"
60
+ click_button "Filter Results"
61
+ expect(page).to have_content("20")
62
+ expect(page).to_not have_content("49.99")
63
+ end
64
+ end
65
+
66
+ context "deleting", js: true do
67
+ let(:product) { create(:product, price: 65.43) }
68
+ let!(:variant) { product.master }
69
+ let!(:other_price) { product.master.prices.create(amount: 34.56, currency: "EUR") }
70
+
71
+ it "will delete the non-default price" do
72
+ within "#spree_price_#{other_price.id}" do
73
+ accept_alert do
74
+ click_icon :trash
75
+ end
76
+ end
77
+ expect(page).to have_content("Price has been successfully removed")
78
+ end
79
+
80
+ it "does not break when default price is deleted" do
81
+ within "#spree_price_#{variant.default_price.id}" do
82
+ accept_alert do
83
+ click_icon :trash
84
+ end
85
+ end
86
+ expect(page).to have_content("Price has been successfully removed")
87
+ visit spree.admin_products_path
88
+ expect(page).to have_selector("#spree_product_#{product.id}")
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Promotions', type: :feature do
4
+ stub_authorization!
5
+ let!(:reimbursement) { create(:reimbursement) }
6
+
7
+ it "should display the reimbursements table" do
8
+ visit spree.admin_order_reimbursement_path(reimbursement.order, reimbursement)
9
+ expect(page).to have_css('table thead tr th', text: 'Product')
10
+ expect(page).to have_css('table thead tr th', text: 'Preferred Reimbursement Type')
11
+ expect(page).to have_css('table thead tr th', text: 'Reimbursement Type Override')
12
+ expect(page).to have_css('table thead tr th', text: 'Exchange for')
13
+ expect(page).to have_css('table thead tr th', text: 'Amount Before Sales Tax')
14
+ expect(page).to have_css('table thead tr th', text: 'Total')
15
+ end
16
+ end
@@ -30,6 +30,17 @@ describe 'Stock Transfers', type: :feature, js: true do
30
30
  expect(page).to have_content('Stock Transfer has been successfully updated')
31
31
  expect(page).to have_content("NY")
32
32
  end
33
+
34
+ # Regression spec for Solidus issue #1087
35
+ it 'displays an error if no source location is selected' do
36
+ create(:stock_location_with_items, name: 'NY')
37
+ create(:stock_location, name: 'SF')
38
+ visit spree.new_admin_stock_transfer_path
39
+ fill_in 'stock_transfer_description', with: description
40
+ click_button 'Continue'
41
+
42
+ expect(page).to have_content("Source location can't be blank")
43
+ end
33
44
  end
34
45
 
35
46
  describe 'view a stock transfer' do
@@ -41,7 +41,7 @@ describe 'Users', type: :feature do
41
41
  end
42
42
 
43
43
  it 'can navigate to the order history' do
44
- expect(page).to have_link Spree.t(:"admin.user.orders"), href: spree.orders_admin_user_path(user_a)
44
+ expect(page).to have_link Spree.t(:"admin.user.order_history"), href: spree.orders_admin_user_path(user_a)
45
45
  end
46
46
 
47
47
  it 'can navigate to the items purchased' do
@@ -201,7 +201,7 @@ describe 'Users', type: :feature do
201
201
  before do
202
202
  orders
203
203
  click_link user_a.email
204
- within("#sidebar") { click_link Spree.t(:"admin.user.orders") }
204
+ within(".tabs") { click_link Spree.t(:"admin.user.order_history") }
205
205
  end
206
206
 
207
207
  it_behaves_like 'a user page'
@@ -231,7 +231,7 @@ describe 'Users', type: :feature do
231
231
  before do
232
232
  orders
233
233
  click_link user_a.email
234
- within("#sidebar") { click_link Spree.t(:"admin.user.items") }
234
+ within(".tabs") { click_link Spree.t(:"admin.user.items") }
235
235
  end
236
236
 
237
237
  it_behaves_like 'a user page'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.beta1
4
+ version: 1.3.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_api
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0.beta1
19
+ version: 1.3.0.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0.beta1
26
+ version: 1.3.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: solidus_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.0.beta1
33
+ version: 1.3.0.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.0.beta1
40
+ version: 1.3.0.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sass-rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +300,7 @@ files:
300
300
  - app/controllers/spree/admin/orders_controller.rb
301
301
  - app/controllers/spree/admin/payment_methods_controller.rb
302
302
  - app/controllers/spree/admin/payments_controller.rb
303
+ - app/controllers/spree/admin/prices_controller.rb
303
304
  - app/controllers/spree/admin/product_properties_controller.rb
304
305
  - app/controllers/spree/admin/products_controller.rb
305
306
  - app/controllers/spree/admin/promotion_actions_controller.rb
@@ -440,6 +441,12 @@ files:
440
441
  - app/views/spree/admin/payments/source_views/_check.html.erb
441
442
  - app/views/spree/admin/payments/source_views/_gateway.html.erb
442
443
  - app/views/spree/admin/payments/source_views/_storecredit.html.erb
444
+ - app/views/spree/admin/prices/_form.html.erb
445
+ - app/views/spree/admin/prices/_table.html.erb
446
+ - app/views/spree/admin/prices/edit.html.erb
447
+ - app/views/spree/admin/prices/index.html.erb
448
+ - app/views/spree/admin/prices/new.html.erb
449
+ - app/views/spree/admin/prices/new.js.erb
443
450
  - app/views/spree/admin/product_properties/_product_property_fields.html.erb
444
451
  - app/views/spree/admin/product_properties/index.html.erb
445
452
  - app/views/spree/admin/products/_form.html.erb
@@ -547,6 +554,7 @@ files:
547
554
  - app/views/spree/admin/shared/_product_sub_menu.html.erb
548
555
  - app/views/spree/admin/shared/_product_tabs.html.erb
549
556
  - app/views/spree/admin/shared/_promotion_sub_menu.html.erb
557
+ - app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb
550
558
  - app/views/spree/admin/shared/_refunds.html.erb
551
559
  - app/views/spree/admin/shared/_report_criteria.html.erb
552
560
  - app/views/spree/admin/shared/_report_order_criteria.html.erb
@@ -647,6 +655,7 @@ files:
647
655
  - app/views/spree/admin/users/_addresses_form.html.erb
648
656
  - app/views/spree/admin/users/_form.html.erb
649
657
  - app/views/spree/admin/users/_sidebar.html.erb
658
+ - app/views/spree/admin/users/_tabs.html.erb
650
659
  - app/views/spree/admin/users/_user_page_actions.html.erb
651
660
  - app/views/spree/admin/users/addresses.html.erb
652
661
  - app/views/spree/admin/users/edit.html.erb
@@ -690,6 +699,7 @@ files:
690
699
  - spec/controllers/spree/admin/orders_controller_spec.rb
691
700
  - spec/controllers/spree/admin/payment_methods_controller_spec.rb
692
701
  - spec/controllers/spree/admin/payments_controller_spec.rb
702
+ - spec/controllers/spree/admin/prices_controller_spec.rb
693
703
  - spec/controllers/spree/admin/product_properties_controller_spec.rb
694
704
  - spec/controllers/spree/admin/products_controller_spec.rb
695
705
  - spec/controllers/spree/admin/promotion_actions_controller_spec.rb
@@ -743,6 +753,7 @@ files:
743
753
  - spec/features/admin/products/edit/taxons_spec.rb
744
754
  - spec/features/admin/products/edit/variants_spec.rb
745
755
  - spec/features/admin/products/option_types_spec.rb
756
+ - spec/features/admin/products/pricing_spec.rb
746
757
  - spec/features/admin/products/products_spec.rb
747
758
  - spec/features/admin/products/properties_spec.rb
748
759
  - spec/features/admin/products/prototypes_spec.rb
@@ -752,6 +763,7 @@ files:
752
763
  - spec/features/admin/promotions/option_value_rule_spec.rb
753
764
  - spec/features/admin/promotions/tiered_calculator_spec.rb
754
765
  - spec/features/admin/promotions/user_rule_spec.rb
766
+ - spec/features/admin/reimbursements_spec.rb
755
767
  - spec/features/admin/reports_spec.rb
756
768
  - spec/features/admin/stock_transfer_spec.rb
757
769
  - spec/features/admin/store_credits_spec.rb