shoppe 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +5 -6
- data/app/assets/javascripts/shoppe/application.coffee +19 -0
- data/app/assets/stylesheets/shoppe/application.scss +62 -20
- data/app/assets/stylesheets/shoppe/{chosen.css → chosen.scss} +18 -24
- data/app/assets/stylesheets/shoppe/dialog.scss +17 -2
- data/app/controllers/shoppe/orders_controller.rb +9 -7
- data/app/controllers/shoppe/payments_controller.rb +33 -0
- data/app/controllers/shoppe/settings_controller.rb +4 -0
- data/app/controllers/shoppe/tax_rates_controller.rb +1 -1
- data/app/controllers/shoppe/users_controller.rb +1 -1
- data/app/helpers/shoppe/application_helper.rb +0 -9
- data/app/models/shoppe/country.rb +17 -20
- data/app/models/shoppe/delivery_service.rb +16 -22
- data/app/models/shoppe/delivery_service_price.rb +10 -21
- data/app/models/shoppe/order/actions.rb +80 -0
- data/app/models/shoppe/order/billing.rb +99 -0
- data/app/models/shoppe/order/delivery.rb +196 -0
- data/app/models/shoppe/order/states.rb +69 -0
- data/app/models/shoppe/order.rb +29 -365
- data/app/models/shoppe/order_item.rb +52 -39
- data/app/models/shoppe/payment.rb +80 -0
- data/app/models/shoppe/product/product_attributes.rb +6 -4
- data/app/models/shoppe/product/variants.rb +20 -7
- data/app/models/shoppe/product.rb +37 -37
- data/app/models/shoppe/product_attribute.rb +13 -20
- data/app/models/shoppe/product_category.rb +6 -19
- data/app/models/shoppe/setting.rb +9 -0
- data/app/models/shoppe/stock_level_adjustment.rb +5 -18
- data/app/models/shoppe/tax_rate.rb +18 -21
- data/app/models/shoppe/user.rb +8 -15
- data/app/views/shoppe/delivery_service_prices/_form.html.haml +9 -3
- data/app/views/shoppe/delivery_service_prices/index.html.haml +6 -4
- data/app/views/shoppe/delivery_services/_form.html.haml +1 -1
- data/app/views/shoppe/orders/edit.html.haml +62 -0
- data/app/views/shoppe/orders/index.html.haml +2 -3
- data/app/views/shoppe/orders/show.html.haml +100 -63
- data/app/views/shoppe/payments/refund.html.haml +14 -0
- data/app/views/shoppe/product_categories/_form.html.haml +1 -1
- data/app/views/shoppe/products/_form.html.haml +8 -2
- data/app/views/shoppe/settings/edit.html.haml +1 -1
- data/app/views/shoppe/tax_rates/form.html.haml +5 -4
- data/app/views/shoppe/users/_form.html.haml +1 -1
- data/app/views/shoppe/variants/form.html.haml +2 -2
- data/config/routes.rb +3 -1
- data/db/migrate/20130926094549_create_shoppe_initial_schema.rb +1 -1
- data/db/migrate/20131024201501_add_address_type_to_shoppe_tax_rates.rb +5 -0
- data/db/migrate/20131024204815_create_shoppe_payments.rb +32 -0
- data/db/schema.rb +218 -0
- data/db/seeds.rb +15 -15
- data/lib/shoppe/engine.rb +7 -2
- data/lib/shoppe/errors/refund_failed.rb +15 -0
- data/lib/shoppe/settings.rb +0 -2
- data/lib/shoppe/version.rb +1 -1
- data/lib/shoppe/view_helpers.rb +16 -0
- data/lib/shoppe.rb +23 -6
- data/test/app/db/schema.rb +21 -6
- data/test/app/log/development.log +12782 -0
- data/test/app/tmp/cache/assets/development/sass/edac894564dae62b78e653a08d1c41f10ade93f9/application.scssc +0 -0
- data/test/app/tmp/cache/assets/development/sass/edac894564dae62b78e653a08d1c41f10ade93f9/chosen.scssc +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/01d6eb5fc12044a487be4b93584690f2 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/02d3923383f72b56dd7919e301d22d24 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/0a6bca3e510625f255083bd154cc470b +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/2f80004fb2e2ce07283a83ac15cf920a +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/322295abdd8625fcce4da08f9565cc63 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/4c8cb5cfd87990ebddbaa5b5fd594be5 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/53c0f5159a54836310b1a3f5357bc4c6 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/7938636d16e11b754d4dd046b89863c4 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/7a90d9251a7c5506f33a3c72a224e571 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/9da17bb4868a0b762f8884db45c76ffd +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/a692ba7ed6cff183bb840c2622233c87 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/a9befe910d55141b8ba02d8198b8f966 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/accc4dc17ef18d0b510917a005340da5 +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/b9ad7ea18b7e55c3626a15d1dae142ed +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/c733f1a2fe9d05a3a634ff64a394f64b +0 -0
- data/test/app/tmp/cache/assets/development/sprockets/da76586dcb6d9a408b2cf33307790d66 +0 -0
- metadata +62 -63
- data/README.rdoc +0 -1
data/db/seeds.rb
CHANGED
@@ -7,30 +7,30 @@ exempt_tax = Shoppe::TaxRate.create(:name => "Exempt VAT", :rate => 0.0, :countr
|
|
7
7
|
# delivery services
|
8
8
|
|
9
9
|
ds = Shoppe::DeliveryService.create!(:name => "Royal Mail (1st class)", :code => 'RMFC', :courier => 'Royal Mail', :tracking_url => 'http://royalmail.com/track/{{consignment_number}}')
|
10
|
-
ds.delivery_service_prices.create!(:min_weight => 0, :max_weight => 0.050, :price => 0.60, :cost_price => 0.55, :tax_rate => exempt_tax, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
10
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 0, :max_weight => 0.050, :price => 0.60, :cost_price => 0.55, :tax_rate => exempt_tax, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
11
11
|
|
12
12
|
|
13
13
|
ds = Shoppe::DeliveryService.create!(:name => "Royal Mail (signed for)", :code => 'RMSF', :courier => 'Royal Mail', :tracking_url => 'http://royalmail.com/track/{{consignment_number}}')
|
14
|
-
ds.delivery_service_prices.create!(:min_weight => 0, :max_weight => 1, :price => 5.0, :cost_price => 4.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
15
|
-
ds.delivery_service_prices.create!(:min_weight => 1, :max_weight => 5, :price => 8.0, :cost_price => 7.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
16
|
-
ds.delivery_service_prices.create!(:min_weight => 5, :max_weight => 10, :price => 10.0, :cost_price => 9.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
17
|
-
ds.delivery_service_prices.create!(:min_weight => 10, :max_weight => 25, :price => 12.0, :cost_price => 11.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
18
|
-
ds.delivery_service_prices.create!(:min_weight => 25, :max_weight => 50, :price => 16.25, :cost_price => 13.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
14
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 0, :max_weight => 1, :price => 5.0, :cost_price => 4.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
15
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 1, :max_weight => 5, :price => 8.0, :cost_price => 7.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
16
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 5, :max_weight => 10, :price => 10.0, :cost_price => 9.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
17
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 10, :max_weight => 25, :price => 12.0, :cost_price => 11.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
18
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 25, :max_weight => 50, :price => 16.25, :cost_price => 13.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
19
19
|
|
20
20
|
ds = Shoppe::DeliveryService.create!(:name => "Next Day Delivery (before 4pm)", :default => true, :code => 'ND16', :courier => 'UPS', :tracking_url => 'http://trackingurl.com/track/{{consignment_number}}')
|
21
|
-
ds.delivery_service_prices.create!(:min_weight => 0, :max_weight => 1, :price => 7.0, :cost_price => 5.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
22
|
-
ds.delivery_service_prices.create!(:min_weight => 1, :max_weight => 5, :price => 9.0, :cost_price => 7.6, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
23
|
-
ds.delivery_service_prices.create!(:min_weight => 5, :max_weight => 20, :price => 11.50, :cost_price => 8.9, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
21
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 0, :max_weight => 1, :price => 7.0, :cost_price => 5.5, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
22
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 1, :max_weight => 5, :price => 9.0, :cost_price => 7.6, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
23
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 5, :max_weight => 20, :price => 11.50, :cost_price => 8.9, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
24
24
|
|
25
25
|
ds = Shoppe::DeliveryService.create!(:name => "Next Day Delivery (before 10am)", :code => 'NS10', :courier => 'UPS', :tracking_url => 'http://trackingurl.com/track/{{consignment_number}}')
|
26
|
-
ds.delivery_service_prices.create!(:min_weight => 0, :max_weight => 1, :price => 17.0, :cost_price => 14.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
27
|
-
ds.delivery_service_prices.create!(:min_weight => 1, :max_weight => 5, :price => 19.0, :cost_price => 16.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
28
|
-
ds.delivery_service_prices.create!(:min_weight => 5, :max_weight => 20, :price => 27.0, :cost_price => 22.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
26
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 0, :max_weight => 1, :price => 17.0, :cost_price => 14.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
27
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 1, :max_weight => 5, :price => 19.0, :cost_price => 16.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
28
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 5, :max_weight => 20, :price => 27.0, :cost_price => 22.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
29
29
|
|
30
30
|
ds = Shoppe::DeliveryService.create!(:name => "Saturday Delivery", :code => 'NDSA16', :courier => 'UPS', :tracking_url => 'http://trackingurl.com/track/{{consignment_number}}')
|
31
|
-
ds.delivery_service_prices.create!(:min_weight => 0, :max_weight => 1, :price => 27.0, :cost_price => 24.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
32
|
-
ds.delivery_service_prices.create!(:min_weight => 1, :max_weight => 5, :price => 29.0, :cost_price => 20.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
33
|
-
ds.delivery_service_prices.create!(:min_weight => 5, :max_weight => 20, :price => 37.0, :cost_price => 32.00,:tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
31
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 0, :max_weight => 1, :price => 27.0, :cost_price => 24.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
32
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 1, :max_weight => 5, :price => 29.0, :cost_price => 20.00, :tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
33
|
+
ds.delivery_service_prices.create!(:code => 'Parcel', :min_weight => 5, :max_weight => 20, :price => 37.0, :cost_price => 32.00,:tax_rate => tax_rate, :country_ids => Shoppe::Country.where(:name => 'United Kingdom').pluck(:id))
|
34
34
|
|
35
35
|
# categories
|
36
36
|
cat1 = Shoppe::ProductCategory.create!(:name => 'VoIP Phones')
|
data/lib/shoppe/engine.rb
CHANGED
@@ -17,9 +17,8 @@ module Shoppe
|
|
17
17
|
end
|
18
18
|
|
19
19
|
initializer 'shoppe.initialize' do |app|
|
20
|
-
|
21
20
|
# Add the default settings
|
22
|
-
Shoppe.
|
21
|
+
Shoppe.add_settings_group :system_settings, [:store_name, :email_address, :currency_unit, :tax_name, :demo_mode]
|
23
22
|
|
24
23
|
# Add middleware
|
25
24
|
app.config.middleware.use Shoppe::SettingsLoader
|
@@ -30,6 +29,12 @@ module Shoppe
|
|
30
29
|
app.config.paths["db/migrate"] << expanded_path
|
31
30
|
end
|
32
31
|
end
|
32
|
+
|
33
|
+
# Load view helpers for the base application
|
34
|
+
ActiveSupport.on_load(:action_view) do
|
35
|
+
require 'shoppe/view_helpers'
|
36
|
+
ActionView::Base.send :include, Shoppe::ViewHelpers
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
40
|
generators do
|
data/lib/shoppe/settings.rb
CHANGED
data/lib/shoppe/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Shoppe
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
# Returns currency values with the currency unit as specified by the Shoppe settings
|
5
|
+
def number_to_currency(number, options = {})
|
6
|
+
options[:unit] ||= Shoppe.settings.currency_unit
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns a number of kilograms with the appropriate suffix
|
11
|
+
def number_to_weight(kg)
|
12
|
+
"#{kg}#{t('shoppe.helpers.number_to_weight.kg', :default => 'kg')}"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/shoppe.rb
CHANGED
@@ -14,29 +14,46 @@ require 'nifty/dialog'
|
|
14
14
|
|
15
15
|
module Shoppe
|
16
16
|
|
17
|
-
class Error < StandardError
|
17
|
+
class Error < StandardError
|
18
|
+
# The Shoppe::Error is the base class for all errors raised by Shoppe.
|
19
|
+
end
|
18
20
|
|
19
21
|
class << self
|
20
22
|
|
23
|
+
# The path to the root of the Shoppe applicatinio
|
24
|
+
#
|
25
|
+
# @return [String]
|
21
26
|
def root
|
22
27
|
File.expand_path('../../', __FILE__)
|
23
28
|
end
|
24
29
|
|
30
|
+
# Shoppe settings as configured in the database
|
31
|
+
#
|
32
|
+
# @return [Shoppe::Settings]
|
25
33
|
def settings
|
26
34
|
Thread.current[:shoppe_settings] ||= Shoppe::Settings.new(Shoppe::Setting.to_hash)
|
27
35
|
end
|
28
36
|
|
37
|
+
# Clears the settings from the thread cache so they will be taken
|
38
|
+
# from the database on next access
|
39
|
+
#
|
40
|
+
# @return [NilClass]
|
29
41
|
def reset_settings
|
30
42
|
Thread.current[:shoppe_settings] = nil
|
31
43
|
end
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
|
45
|
+
# Defines a new set of settings which should be configrable from the settings page
|
46
|
+
# in the Shoppe UI.
|
47
|
+
def add_settings_group(group, fields = [])
|
48
|
+
settings_groups[group] ||= []
|
49
|
+
settings_groups[group] = settings_groups[group] | fields
|
36
50
|
end
|
37
51
|
|
38
|
-
|
39
|
-
|
52
|
+
# All settings groups which are available for configuration on the settings page.
|
53
|
+
#
|
54
|
+
# @return [Hash]
|
55
|
+
def settings_groups
|
56
|
+
@settings_groups ||= {}
|
40
57
|
end
|
41
58
|
|
42
59
|
end
|
data/test/app/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20131024204815) do
|
15
15
|
|
16
16
|
create_table "nifty_attachments", force: true do |t|
|
17
17
|
t.integer "parent_id"
|
@@ -106,15 +106,12 @@ ActiveRecord::Schema.define(version: 20131024101520) do
|
|
106
106
|
t.decimal "delivery_cost_price", precision: 8, scale: 2
|
107
107
|
t.decimal "delivery_tax_rate", precision: 8, scale: 2
|
108
108
|
t.decimal "delivery_tax_amount", precision: 8, scale: 2
|
109
|
-
t.datetime "paid_at"
|
110
109
|
t.integer "accepted_by"
|
111
110
|
t.integer "shipped_by"
|
112
111
|
t.string "consignment_number"
|
113
112
|
t.datetime "rejected_at"
|
114
113
|
t.integer "rejected_by"
|
115
114
|
t.string "ip_address"
|
116
|
-
t.string "payment_reference"
|
117
|
-
t.string "payment_method"
|
118
115
|
t.text "notes"
|
119
116
|
t.boolean "separate_delivery_address", default: false
|
120
117
|
t.string "delivery_name"
|
@@ -122,8 +119,25 @@ ActiveRecord::Schema.define(version: 20131024101520) do
|
|
122
119
|
t.string "delivery_address2"
|
123
120
|
t.string "delivery_address3"
|
124
121
|
t.string "delivery_address4"
|
125
|
-
t.string "
|
122
|
+
t.string "delivery_postcode"
|
126
123
|
t.integer "delivery_country_id"
|
124
|
+
t.decimal "amount_paid", precision: 8, scale: 2, default: 0.0
|
125
|
+
t.boolean "exported", default: false
|
126
|
+
t.string "invoice_number"
|
127
|
+
end
|
128
|
+
|
129
|
+
create_table "shoppe_payments", force: true do |t|
|
130
|
+
t.integer "order_id"
|
131
|
+
t.decimal "amount", precision: 8, scale: 2, default: 0.0
|
132
|
+
t.string "reference"
|
133
|
+
t.string "method"
|
134
|
+
t.boolean "confirmed", default: true
|
135
|
+
t.boolean "refundable", default: false
|
136
|
+
t.decimal "amount_refunded", precision: 8, scale: 2, default: 0.0
|
137
|
+
t.integer "parent_payment_id"
|
138
|
+
t.boolean "exported", default: false
|
139
|
+
t.datetime "created_at"
|
140
|
+
t.datetime "updated_at"
|
127
141
|
end
|
128
142
|
|
129
143
|
create_table "shoppe_product_attributes", force: true do |t|
|
@@ -185,10 +199,11 @@ ActiveRecord::Schema.define(version: 20131024101520) do
|
|
185
199
|
|
186
200
|
create_table "shoppe_tax_rates", force: true do |t|
|
187
201
|
t.string "name"
|
188
|
-
t.decimal "rate",
|
202
|
+
t.decimal "rate", precision: 8, scale: 2
|
189
203
|
t.datetime "created_at"
|
190
204
|
t.datetime "updated_at"
|
191
205
|
t.text "country_ids"
|
206
|
+
t.string "address_type"
|
192
207
|
end
|
193
208
|
|
194
209
|
create_table "shoppe_users", force: true do |t|
|