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 +4 -4
- data/app/models/spree/order/checkout.rb +8 -3
- data/app/models/spree/order.rb +1 -1
- data/app/models/spree/order_updater.rb +6 -2
- data/app/models/spree/promotion.rb +17 -14
- data/app/models/spree/return_authorization.rb +2 -1
- data/app/models/spree/variant.rb +1 -1
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +17 -0
- data/config/locales/en.yml +12 -7
- data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +11 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +10 -4
- data/lib/spree/core/controller_helpers/order.rb +8 -5
- data/lib/spree/core/product_duplicator.rb +10 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +1 -1
- data/lib/spree/promo/coupon_applicator.rb +6 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8221f56f22472a62ce9ca4606e761fd718fcc448
|
4
|
+
data.tar.gz: 2846b0e62b638dd5ae2071b3cf873dce9d7bd7a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
75
|
-
|
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
|
data/app/models/spree/order.rb
CHANGED
@@ -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?
|
107
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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::
|
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))
|
data/app/models/spree/variant.rb
CHANGED
@@ -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 }
|
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 %>
|
data/config/locales/en.yml
CHANGED
@@ -318,13 +318,18 @@ en:
|
|
318
318
|
delivery_success: Test Mail sent successfully
|
319
319
|
error: ! 'Test Mail error: %{e}'
|
320
320
|
tab:
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
promotions:
|
327
|
-
|
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')
|
57
|
-
inject_require_for('spree_backend')
|
58
|
-
inject_require_for('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',
|
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(
|
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.
|
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
|
-
|
21
|
-
|
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)
|
data/lib/spree/core/version.rb
CHANGED
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.
|
202
|
+
output = output.sub(" ", " ").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
|
-
|
37
|
-
|
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.
|
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-
|
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
|