spree_core 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14ac66f9e7ddcb8372dfead29fd08ba8153910c2
4
- data.tar.gz: 08206ae70c25c4689dddd12fbab62c82e360fbd0
3
+ metadata.gz: 8221f56f22472a62ce9ca4606e761fd718fcc448
4
+ data.tar.gz: 2846b0e62b638dd5ae2071b3cf873dce9d7bd7a5
5
5
  SHA512:
6
- metadata.gz: 6aa9dadaa97ec4cd19384d095b92f3bad8e6b0378906c1fa2de65dc3423837a066c09bc602aafe532e0ba11a9cfae36ef8d8887f44f1ebede67d5f922c77fa34
7
- data.tar.gz: 4d405953434dafed6a819848cc601c2b718d971cb89ff3e9e4413a7692b1f99902f4502a9d56ee870020fa6f61328ac41980d3087f8f793fc67467137d9119a4
6
+ metadata.gz: d39dfb9985e2425eab9de5697248c3cf4d2640dca0b4a3d3d3bfeddfb6b25c27f265e78e397588a6a4ee1f9bbc8713520acf67fae100faa7dd2a3fb3b6a5e4ed
7
+ data.tar.gz: cb69f470e36ebc6b0cb24e1f047763b14e7574fd4a25ac462d7705e82b15e3724e361b84f813018b09ff01163747a7fc1f07d3b6dcb8b20106e9f6ebbc0e8377
@@ -71,11 +71,16 @@ module Spree
71
71
 
72
72
  before_transition :from => :cart, :do => :ensure_line_items_present
73
73
 
74
- before_transition :to => :delivery, :do => :create_proposed_shipments
75
- before_transition :to => :delivery, :do => :ensure_available_shipping_rates
74
+ if states[:address]
75
+ before_transition :from => :address, :do => :create_tax_charge!
76
+ end
77
+
78
+ if states[:delivery]
79
+ before_transition :to => :delivery, :do => :create_proposed_shipments
80
+ before_transition :to => :delivery, :do => :ensure_available_shipping_rates
81
+ end
76
82
 
77
83
  after_transition :to => :complete, :do => :finalize!
78
- after_transition :to => :delivery, :do => :create_tax_charge!
79
84
  after_transition :to => :resumed, :do => :after_resume
80
85
  after_transition :to => :canceled, :do => :after_cancel
81
86
  end
@@ -592,7 +592,7 @@ module Spree
592
592
  end
593
593
 
594
594
  def has_available_payment
595
- return unless delivery?
595
+ return unless has_step?("delivery") && delivery?
596
596
  # errors.add(:base, :no_payment_methods_available) if available_payment_methods.empty?
597
597
  end
598
598
 
@@ -103,8 +103,12 @@ module Spree
103
103
 
104
104
  #line_item are empty when user empties cart
105
105
  if line_items.empty? || round_money(order.payment_total) < round_money(order.total)
106
- if payments.present? && payments.last.state == 'failed'
107
- order.payment_state = 'failed'
106
+ if payments.present?
107
+ if payments.last.state == 'failed'
108
+ order.payment_state = 'failed'
109
+ elsif payments.last.state == 'completed'
110
+ order.payment_state = 'credit_owed'
111
+ end
108
112
  else
109
113
  order.payment_state = 'balance_due'
110
114
  end
@@ -35,21 +35,24 @@ module Spree
35
35
  end
36
36
 
37
37
  def activate(payload)
38
- return unless order_activatable? payload[:order]
39
-
40
- # make sure code is always downcased (old databases might have mixed case codes)
41
- if code.present?
42
- event_code = payload[:coupon_code]
43
- return unless event_code == self.code.downcase.strip
44
- end
45
-
46
- if path.present?
47
- return unless path == payload[:path]
48
- end
49
-
50
- actions.each do |action|
51
- action.perform(payload)
38
+ if order_activatable?(payload[:order]) && eligible?(payload[:order])
39
+ # make sure code is always downcased (old databases might have mixed case codes)
40
+ if code.present?
41
+ event_code = payload[:coupon_code]
42
+ return unless event_code == self.code.downcase.strip
43
+ end
44
+
45
+ if path.present?
46
+ return unless path == payload[:path]
47
+ end
48
+
49
+ actions.each do |action|
50
+ action.perform(payload)
51
+ end
52
+
53
+ return true
52
54
  end
55
+ false
53
56
  end
54
57
 
55
58
  # called anytime order.update! happens
@@ -83,7 +83,8 @@ module Spree
83
83
  def process_return
84
84
  inventory_units.each do |iu|
85
85
  iu.return!
86
- Spree::StockMovement.create!(stock_item_id: iu.find_stock_item.id, quantity: 1)
86
+ stock_item = Spree::StockItem.where(variant_id: iu.variant.id, stock_location_id: stock_location_id).first
87
+ Spree::StockMovement.create!(stock_item_id: stock_item.id, quantity: 1)
87
88
  end
88
89
 
89
90
  credit = Adjustment.new(amount: amount.abs * -1, label: Spree.t(:rma_credit))
@@ -36,7 +36,7 @@ module Spree
36
36
  dependent: :destroy
37
37
 
38
38
  validate :check_price
39
- validates :price, numericality: { greater_than_or_equal_to: 0 }, presence: true, if: proc { Spree::Config[:require_master_price] }
39
+ validates :price, numericality: { greater_than_or_equal_to: 0 }
40
40
  validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true } if self.table_exists? && self.column_names.include?('cost_price')
41
41
 
42
42
  before_validation :set_cost_currency
@@ -0,0 +1,17 @@
1
+ <%= search_form_for @search, :url => spree.sales_total_admin_reports_path do |s| %>
2
+ <div class="date-range-filter field align-center">
3
+ <%= label_tag nil, t(:start), :class => 'inline' %>
4
+ <%= s.text_field :completed_at_gt, :class => 'datepicker datepicker-from', :value => datepicker_field_value(params[:q][:completed_at_gt]) %>
5
+
6
+ <span class="range-divider">
7
+ <i class="icon-arrow-right"></i>
8
+ </span>
9
+
10
+ <%= s.text_field :completed_at_lt, :class => 'datepicker datepicker-to', :value => datepicker_field_value(params[:q][:completed_at_lt]) %>
11
+ <%= label_tag nil, t(:end), :class => 'inline' %>
12
+ </div>
13
+
14
+ <div class="actions filter-actions">
15
+ <%= button t(:search), 'icon-search' %>
16
+ </div>
17
+ <% end %>
@@ -318,13 +318,18 @@ en:
318
318
  delivery_success: Test Mail sent successfully
319
319
  error: ! 'Test Mail error: %{e}'
320
320
  tab:
321
- overview: "Overview"
322
- orders: "Orders"
323
- products: "Products"
324
- reports: "Reports"
325
- configuration: "Configuration"
326
- promotions: "Promotions"
327
- users: "Users"
321
+ configuration: Configuration
322
+ option_types: Option Types
323
+ orders: Orders
324
+ overview: Overview
325
+ products: Products
326
+ promotions: Promotions
327
+ properties: Properties
328
+ prototypes: Prototypes
329
+ reports: Reports
330
+ taxonomies: Taxonomies
331
+ taxons: Taxons
332
+ users: Users
328
333
  administration: Administration
329
334
  agree_to_privacy_policy: Agree to Privacy Policy
330
335
  agree_to_terms_of_service: Agree to Terms of Service
@@ -0,0 +1,11 @@
1
+ class DefaultVariantWeightToZero < ActiveRecord::Migration
2
+ def up
3
+ Spree::Variant.unscoped.where(weight: nil).update_all("weight = 0.0")
4
+
5
+ change_column :spree_variants, :weight, :decimal, precision: 8, scale: 2, default: 0.0
6
+ end
7
+
8
+ def down
9
+ change_column :spree_variants, :weight, :decimal, precision: 8, scale: 2
10
+ end
11
+ end
@@ -53,9 +53,9 @@ module Spree
53
53
  def test_dummy_inject_extension_requirements
54
54
  if DummyGeneratorHelper.inject_extension_requirements
55
55
  inside dummy_path do
56
- inject_require_for('spree_frontend') if Object.const_defined?("Spree::Frontend")
57
- inject_require_for('spree_backend') if Object.const_defined?("Spree::Backend")
58
- inject_require_for('spree_api') if Object.const_defined?("Spree::Api")
56
+ inject_require_for('spree_frontend')
57
+ inject_require_for('spree_backend')
58
+ inject_require_for('spree_api')
59
59
  end
60
60
  end
61
61
  end
@@ -84,7 +84,13 @@ module Spree
84
84
  protected
85
85
 
86
86
  def inject_require_for(requirement)
87
- inject_into_file 'config/application.rb', "require '#{requirement}'\n", :before => /require '#{@lib_name}'/, :verbose => true
87
+ inject_into_file 'config/application.rb', %Q[
88
+ begin
89
+ require '#{requirement}'
90
+ rescue LoadError
91
+ # #{requirement} is not available.
92
+ end
93
+ ], :before => /require '#{@lib_name}'/, :verbose => true
88
94
  end
89
95
 
90
96
  def dummy_path
@@ -11,14 +11,17 @@ module Spree
11
11
  end
12
12
 
13
13
  # The current incomplete order from the session for use in cart and during checkout
14
- def current_order(create_order_if_necessary = false)
14
+ def current_order(options = {})
15
+ options[:create_order_if_necessary] ||= false
16
+ options[:lock] ||= false
15
17
  return @current_order if @current_order
16
18
  if session[:order_id]
17
- current_order = Spree::Order.find_by_id_and_currency(session[:order_id], current_currency, :include => :adjustments)
19
+ current_order = Spree::Order.includes(:adjustments).lock(options[:lock]).where(id: session[:order_id], currency: current_currency).first
18
20
  @current_order = current_order unless current_order.try(:completed?)
19
21
  end
20
- if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)
21
- @current_order = Spree::Order.new(:currency => current_currency)
22
+
23
+ if options[:create_order_if_necessary] and (@current_order.nil? or @current_order.completed?)
24
+ @current_order = Spree::Order.new(currency: current_currency)
22
25
  @current_order.user ||= try_spree_current_user
23
26
  # See issue #3346 for reasons why this line is here
24
27
  @current_order.created_by ||= try_spree_current_user
@@ -60,7 +63,7 @@ module Spree
60
63
  last_incomplete_order = user.last_incomplete_spree_order
61
64
  if session[:order_id].nil? && last_incomplete_order
62
65
  session[:order_id] = last_incomplete_order.id
63
- elsif current_order(true) && last_incomplete_order && current_order != last_incomplete_order
66
+ elsif current_order(create_order_if_necessary: true) && last_incomplete_order && current_order != last_incomplete_order
64
67
  current_order.merge!(last_incomplete_order, user)
65
68
  end
66
69
  end
@@ -23,12 +23,14 @@ module Spree
23
23
  def duplicate_product
24
24
  product.dup.tap do |new_product|
25
25
  new_product.name = "COPY OF #{product.name}"
26
+ new_product.permalink = "copy-of-#{product.permalink}"
26
27
  new_product.taxons = product.taxons
27
28
  new_product.created_at = nil
28
29
  new_product.deleted_at = nil
29
30
  new_product.updated_at = nil
30
31
  new_product.product_properties = reset_properties
31
32
  new_product.master = duplicate_master
33
+ new_product.variants = product.variants.map { |variant| duplicate_variant variant }
32
34
  end
33
35
  end
34
36
 
@@ -43,6 +45,14 @@ module Spree
43
45
  end
44
46
  end
45
47
 
48
+ def duplicate_variant(variant)
49
+ new_variant = variant.dup
50
+ new_variant.sku = "COPY OF #{new_variant.sku}"
51
+ new_variant.deleted_at = nil
52
+ new_variant.option_values = variant.option_values.map { |option_value| option_value.dup}
53
+ new_variant
54
+ end
55
+
46
56
  def duplicate_image(image)
47
57
  new_image = image.dup
48
58
  new_image.assign_attributes(:attachment => image.attachment.clone)
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- "2.0.8"
3
+ "2.0.9"
4
4
  end
5
5
  end
data/lib/spree/money.rb CHANGED
@@ -199,7 +199,7 @@ module Spree
199
199
  if options[:html]
200
200
  # 1) prevent blank, breaking spaces
201
201
  # 2) prevent escaping of HTML character entities
202
- output = output.gsub(" ", "&nbsp;").html_safe
202
+ output = output.sub(" ", "&nbsp;").html_safe
203
203
  end
204
204
  output
205
205
  end
@@ -32,9 +32,12 @@ module Spree
32
32
  return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded?
33
33
 
34
34
  event_name = "spree.checkout.coupon_code_added"
35
- promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
36
- promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
37
- determine_promotion_application_result(promo)
35
+ if promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
36
+ promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
37
+ determine_promotion_application_result(promo)
38
+ else
39
+ return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_eligible) }
40
+ end
38
41
  end
39
42
 
40
43
  def promotion_expired
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -399,6 +399,7 @@ files:
399
399
  - app/models/spree/zone.rb
400
400
  - app/models/spree/zone_member.rb
401
401
  - app/views/spree/admin/orders/customer_details/_autocomplete.js.erb
402
+ - app/views/spree/admin/shared/_report_order_criteria.html.erb
402
403
  - app/views/spree/order_mailer/cancel_email.text.erb
403
404
  - app/views/spree/order_mailer/confirm_email.text.erb
404
405
  - app/views/spree/payments/_payment.html.erb
@@ -503,6 +504,7 @@ files:
503
504
  - db/migrate/20131026154747_add_track_inventory_to_variant.rb
504
505
  - db/migrate/20131113035136_add_channel_to_spree_orders.rb
505
506
  - db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb
507
+ - db/migrate/20140205181631_default_variant_weight_to_zero.rb
506
508
  - db/seeds.rb
507
509
  - lib/generators/spree/custom_user/custom_user_generator.rb
508
510
  - lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt