piggybak 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/app/controllers/piggybak/orders_controller.rb +12 -5
- data/app/models/piggybak/address.rb +3 -1
- data/app/models/piggybak/country.rb +1 -1
- data/app/models/piggybak/line_item.rb +12 -0
- data/app/models/piggybak/order.rb +1 -0
- data/app/models/piggybak/payment_method_value.rb +1 -1
- data/app/models/piggybak/shipping_method.rb +3 -0
- data/app/models/piggybak/shipping_method_value.rb +1 -0
- data/app/models/piggybak/tax_method.rb +2 -1
- data/app/models/piggybak/tax_method_value.rb +2 -1
- data/app/views/rails_admin/main/_copy_from_billing.html.haml +15 -0
- data/app/views/rails_admin/main/_location_select.html.haml +1 -1
- data/lib/piggybak.rb +8 -0
- data/lib/piggybak/cli.rb +1 -1
- data/lib/piggybak/version.rb +1 -1
- metadata +5 -4
data/Gemfile.lock
CHANGED
@@ -13,11 +13,18 @@ module Piggybak
|
|
13
13
|
@order.create_payment_shipment
|
14
14
|
|
15
15
|
if Piggybak.config.logging
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
clean_params = params[:piggybak_order].clone
|
17
|
+
clean_params[:line_items_attributes].each do |k, li_attr|
|
18
|
+
if li_attr[:line_item_type] == "payment" && li_attr.has_key?(:payment_attributes)
|
19
|
+
if li_attr[:payment_attributes].has_key?(:number)
|
20
|
+
li_attr[:payment_attributes][:number] = li_attr[:payment_attributes][:number].mask_cc_number
|
21
|
+
end
|
22
|
+
if li_attr[:payment_attributes].has_key?(:verification_value)
|
23
|
+
li_attr[:payment_attributes][:verification_value] = li_attr[:payment_attributes][:verification_value].mask_csv
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
logger.info "#{request.remote_ip}:#{Time.now.strftime("%Y-%m-%d %H:%M")} Order received with params #{clean_params.inspect}"
|
21
28
|
end
|
22
29
|
@order.initialize_user(current_user, true)
|
23
30
|
|
@@ -17,7 +17,9 @@ module Piggybak
|
|
17
17
|
after_save :document_address_changes
|
18
18
|
|
19
19
|
attr_accessible :firstname, :lastname, :address1, :location,
|
20
|
-
:address2, :city, :state_id, :zip, :country_id
|
20
|
+
:address2, :city, :state_id, :zip, :country_id,
|
21
|
+
:copy_from_billing
|
22
|
+
attr_accessor :is_shipping
|
21
23
|
|
22
24
|
def set_default_country
|
23
25
|
self.country ||= Country.find_by_abbr(Piggybak.config.default_country)
|
@@ -50,6 +50,18 @@ module Piggybak
|
|
50
50
|
|
51
51
|
return if sellable.nil?
|
52
52
|
|
53
|
+
# Inventory check
|
54
|
+
quantity_change = 0
|
55
|
+
if self.new_record?
|
56
|
+
quantity_change = self.quantity.to_i
|
57
|
+
elsif self.changes.keys.include?("quantity") && self.quantity > self.quantity_was
|
58
|
+
quantity_change = self.quantity - self.quantity_was
|
59
|
+
end
|
60
|
+
if sellable.quantity < quantity_change
|
61
|
+
self.errors.add(:sellable_id, "Insufficient inventory by #{quantity_change - sellable.quantity} unit(s).")
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
53
65
|
self.description = sellable.description
|
54
66
|
self.unit_price = sellable.price
|
55
67
|
self.price = self.unit_price*self.quantity.to_i
|
@@ -8,6 +8,9 @@ module Piggybak
|
|
8
8
|
|
9
9
|
accepts_nested_attributes_for :shipping_method_values, :allow_destroy => true
|
10
10
|
|
11
|
+
attr_accessible :active, :shipment_method_values_attributes, :description,
|
12
|
+
:klass
|
13
|
+
|
11
14
|
validates_each :shipping_method_values do |record, attr, value|
|
12
15
|
if record.klass.present?
|
13
16
|
calculator = record.klass.constantize
|
@@ -7,7 +7,8 @@ module Piggybak
|
|
7
7
|
validates_presence_of :klass
|
8
8
|
|
9
9
|
accepts_nested_attributes_for :tax_method_values, :allow_destroy => true
|
10
|
-
|
10
|
+
attr_accessible :active, :tax_method_values_attributes, :description,
|
11
|
+
:klass
|
11
12
|
validates_each :tax_method_values do |record, attr, value|
|
12
13
|
if record.klass
|
13
14
|
calculator = record.klass.constantize
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<a href="#" id="copy_from_billing">copy from billing</a>
|
2
|
+
|
3
|
+
%script
|
4
|
+
$('#copy_from_billing').click(function() {
|
5
|
+
$.each($('#piggybak_order_billing_address_attributes_field input'), function(i, el) {
|
6
|
+
if($(el).attr('id') != 'piggybak_order_billing_address_attributes_id') {
|
7
|
+
var shipping_id = $(el).attr('id').replace('billing', 'shipping');
|
8
|
+
$('#' + shipping_id).val($(el).val());
|
9
|
+
}
|
10
|
+
});
|
11
|
+
$('#piggybak_order_shipping_address_attributes_country_id').val($('#piggybak_order_billing_address_attributes_country_id').val());
|
12
|
+
piggybak_states.update_state_option('shipping');
|
13
|
+
$('#piggybak_order_shipping_address_attributes_state_id').val($('#piggybak_order_billing_address_attributes_state_id').val());
|
14
|
+
return false;
|
15
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
:ruby
|
2
|
-
type = form.
|
2
|
+
type = form.object.is_shipping ? "shipping" : "billing"
|
3
3
|
|
4
4
|
= form.collection_select "country_id", Piggybak::Country.send(type), :id, :name, { :selected => form.object.country_id.to_s }
|
5
5
|
|
data/lib/piggybak.rb
CHANGED
@@ -266,6 +266,14 @@ module Piggybak
|
|
266
266
|
visible false
|
267
267
|
|
268
268
|
edit do
|
269
|
+
field :copy_from_billing do
|
270
|
+
visible do
|
271
|
+
bindings[:object].is_shipping
|
272
|
+
end
|
273
|
+
partial "copy_from_billing"
|
274
|
+
label "Help"
|
275
|
+
help "Copies address from billing to shipping."
|
276
|
+
end
|
269
277
|
field :firstname
|
270
278
|
field :lastname
|
271
279
|
field :address1
|
data/lib/piggybak/cli.rb
CHANGED
@@ -36,7 +36,7 @@ module Piggybak
|
|
36
36
|
desc "inject_devise", "add devise"
|
37
37
|
def inject_devise
|
38
38
|
puts 'add reference to devise in GEMFILE'
|
39
|
-
insert_into_file "
|
39
|
+
insert_into_file "Gemfile", "gem 'devise'\n", :after => "source 'https://rubygems.org'\n"
|
40
40
|
end
|
41
41
|
|
42
42
|
|
data/lib/piggybak/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-10-
|
14
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- app/helpers/piggybak_helper.rb
|
135
135
|
- app/views/rails_admin/main/_recorded_changer.html.erb
|
136
136
|
- app/views/rails_admin/main/_polymorphic_nested.html.haml
|
137
|
+
- app/views/rails_admin/main/_copy_from_billing.html.haml
|
137
138
|
- app/views/rails_admin/main/_location_select.html.haml
|
138
139
|
- app/views/rails_admin/main/_order_details.html.erb
|
139
140
|
- app/views/rails_admin/main/_ip_address.html.erb
|
@@ -211,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
212
|
version: '0'
|
212
213
|
segments:
|
213
214
|
- 0
|
214
|
-
hash:
|
215
|
+
hash: -716439778691107520
|
215
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
217
|
none: false
|
217
218
|
requirements:
|
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
version: '0'
|
221
222
|
segments:
|
222
223
|
- 0
|
223
|
-
hash:
|
224
|
+
hash: -716439778691107520
|
224
225
|
requirements: []
|
225
226
|
rubyforge_project:
|
226
227
|
rubygems_version: 1.8.23
|