shoppe 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +5 -6
  3. data/app/assets/javascripts/shoppe/application.coffee +19 -0
  4. data/app/assets/stylesheets/shoppe/application.scss +62 -20
  5. data/app/assets/stylesheets/shoppe/{chosen.css → chosen.scss} +18 -24
  6. data/app/assets/stylesheets/shoppe/dialog.scss +17 -2
  7. data/app/controllers/shoppe/orders_controller.rb +9 -7
  8. data/app/controllers/shoppe/payments_controller.rb +33 -0
  9. data/app/controllers/shoppe/settings_controller.rb +4 -0
  10. data/app/controllers/shoppe/tax_rates_controller.rb +1 -1
  11. data/app/controllers/shoppe/users_controller.rb +1 -1
  12. data/app/helpers/shoppe/application_helper.rb +0 -9
  13. data/app/models/shoppe/country.rb +17 -20
  14. data/app/models/shoppe/delivery_service.rb +16 -22
  15. data/app/models/shoppe/delivery_service_price.rb +10 -21
  16. data/app/models/shoppe/order/actions.rb +80 -0
  17. data/app/models/shoppe/order/billing.rb +99 -0
  18. data/app/models/shoppe/order/delivery.rb +196 -0
  19. data/app/models/shoppe/order/states.rb +69 -0
  20. data/app/models/shoppe/order.rb +29 -365
  21. data/app/models/shoppe/order_item.rb +52 -39
  22. data/app/models/shoppe/payment.rb +80 -0
  23. data/app/models/shoppe/product/product_attributes.rb +6 -4
  24. data/app/models/shoppe/product/variants.rb +20 -7
  25. data/app/models/shoppe/product.rb +37 -37
  26. data/app/models/shoppe/product_attribute.rb +13 -20
  27. data/app/models/shoppe/product_category.rb +6 -19
  28. data/app/models/shoppe/setting.rb +9 -0
  29. data/app/models/shoppe/stock_level_adjustment.rb +5 -18
  30. data/app/models/shoppe/tax_rate.rb +18 -21
  31. data/app/models/shoppe/user.rb +8 -15
  32. data/app/views/shoppe/delivery_service_prices/_form.html.haml +9 -3
  33. data/app/views/shoppe/delivery_service_prices/index.html.haml +6 -4
  34. data/app/views/shoppe/delivery_services/_form.html.haml +1 -1
  35. data/app/views/shoppe/orders/edit.html.haml +62 -0
  36. data/app/views/shoppe/orders/index.html.haml +2 -3
  37. data/app/views/shoppe/orders/show.html.haml +100 -63
  38. data/app/views/shoppe/payments/refund.html.haml +14 -0
  39. data/app/views/shoppe/product_categories/_form.html.haml +1 -1
  40. data/app/views/shoppe/products/_form.html.haml +8 -2
  41. data/app/views/shoppe/settings/edit.html.haml +1 -1
  42. data/app/views/shoppe/tax_rates/form.html.haml +5 -4
  43. data/app/views/shoppe/users/_form.html.haml +1 -1
  44. data/app/views/shoppe/variants/form.html.haml +2 -2
  45. data/config/routes.rb +3 -1
  46. data/db/migrate/20130926094549_create_shoppe_initial_schema.rb +1 -1
  47. data/db/migrate/20131024201501_add_address_type_to_shoppe_tax_rates.rb +5 -0
  48. data/db/migrate/20131024204815_create_shoppe_payments.rb +32 -0
  49. data/db/schema.rb +218 -0
  50. data/db/seeds.rb +15 -15
  51. data/lib/shoppe/engine.rb +7 -2
  52. data/lib/shoppe/errors/refund_failed.rb +15 -0
  53. data/lib/shoppe/settings.rb +0 -2
  54. data/lib/shoppe/version.rb +1 -1
  55. data/lib/shoppe/view_helpers.rb +16 -0
  56. data/lib/shoppe.rb +23 -6
  57. data/test/app/db/schema.rb +21 -6
  58. data/test/app/log/development.log +12782 -0
  59. data/test/app/tmp/cache/assets/development/sass/edac894564dae62b78e653a08d1c41f10ade93f9/application.scssc +0 -0
  60. data/test/app/tmp/cache/assets/development/sass/edac894564dae62b78e653a08d1c41f10ade93f9/chosen.scssc +0 -0
  61. data/test/app/tmp/cache/assets/development/sprockets/01d6eb5fc12044a487be4b93584690f2 +0 -0
  62. data/test/app/tmp/cache/assets/development/sprockets/02d3923383f72b56dd7919e301d22d24 +0 -0
  63. data/test/app/tmp/cache/assets/development/sprockets/0a6bca3e510625f255083bd154cc470b +0 -0
  64. data/test/app/tmp/cache/assets/development/sprockets/2f80004fb2e2ce07283a83ac15cf920a +0 -0
  65. data/test/app/tmp/cache/assets/development/sprockets/322295abdd8625fcce4da08f9565cc63 +0 -0
  66. data/test/app/tmp/cache/assets/development/sprockets/4c8cb5cfd87990ebddbaa5b5fd594be5 +0 -0
  67. data/test/app/tmp/cache/assets/development/sprockets/53c0f5159a54836310b1a3f5357bc4c6 +0 -0
  68. data/test/app/tmp/cache/assets/development/sprockets/7938636d16e11b754d4dd046b89863c4 +0 -0
  69. data/test/app/tmp/cache/assets/development/sprockets/7a90d9251a7c5506f33a3c72a224e571 +0 -0
  70. data/test/app/tmp/cache/assets/development/sprockets/9da17bb4868a0b762f8884db45c76ffd +0 -0
  71. data/test/app/tmp/cache/assets/development/sprockets/a692ba7ed6cff183bb840c2622233c87 +0 -0
  72. data/test/app/tmp/cache/assets/development/sprockets/a9befe910d55141b8ba02d8198b8f966 +0 -0
  73. data/test/app/tmp/cache/assets/development/sprockets/accc4dc17ef18d0b510917a005340da5 +0 -0
  74. data/test/app/tmp/cache/assets/development/sprockets/b9ad7ea18b7e55c3626a15d1dae142ed +0 -0
  75. data/test/app/tmp/cache/assets/development/sprockets/c733f1a2fe9d05a3a634ff64a394f64b +0 -0
  76. data/test/app/tmp/cache/assets/development/sprockets/da76586dcb6d9a408b2cf33307790d66 +0 -0
  77. metadata +62 -63
  78. data/README.rdoc +0 -1
@@ -0,0 +1,62 @@
1
+ - @page_title = 'Edit Order #' + @order.number
2
+
3
+ = content_for :header do
4
+ %p.buttons
5
+ = link_to "Back to order", @order, :class => 'button grey'
6
+ %h2.orders Edit Order <b>##{@order.number}</b>
7
+
8
+ = form_for @order do |f|
9
+ = f.error_messages
10
+ = field_set_tag "Billing Address" do
11
+ .splitContainer
12
+ %dl.third
13
+ %dt= f.label :first_name
14
+ %dd= f.text_field :first_name, :class => 'focus text'
15
+ %dl.third
16
+ %dt= f.label :last_name
17
+ %dd= f.text_field :last_name, :class => 'text'
18
+ %dl.third
19
+ %dt= f.label :company
20
+ %dd= f.text_field :company, :class => 'text'
21
+ %dl
22
+ %dt= f.label :billing_address1, "Address"
23
+ %dd.space= f.text_field :billing_address1, :class => 'text'
24
+ %dd.space= f.text_field :billing_address2, :class => 'text'
25
+ %dd.space= f.text_field :billing_address3, :class => 'text'
26
+ %dd.space= f.text_field :billing_address4, :class => 'text'
27
+ %dd.space= f.text_field :billing_postcode, :class => 'text short', :placeholder => "Postcode"
28
+ %dd.space= f.collection_select :billing_country_id, Shoppe::Country.ordered, :id, :name, {}, {:class => 'chosen'}
29
+
30
+ .splitContainer
31
+ %dl.third
32
+ %dt= f.label :email_address
33
+ %dd= f.text_field :email_address, :class => 'text'
34
+ %dl.third
35
+ %dt= f.label :phone_number
36
+ %dd= f.text_field :phone_number, :class => 'text'
37
+ %dl.third
38
+ %dt= f.label :separate_delivery_address
39
+ %dd.checkbox
40
+ = f.check_box :separate_delivery_address
41
+ = f.label :separate_delivery_address, "Use a seperate delivery address?"
42
+
43
+ = field_set_tag "Deilvery Address", :class => 'delivery' do
44
+ %dl
45
+ %dt= f.label :delivery_name
46
+ %dd= f.text_field :delivery_name, :class => 'text'
47
+ %dl
48
+ %dt= f.label :delivery_address1, "Address"
49
+ %dd.space= f.text_field :delivery_address1, :class => 'text'
50
+ %dd.space= f.text_field :delivery_address2, :class => 'text'
51
+ %dd.space= f.text_field :delivery_address3, :class => 'text'
52
+ %dd.space= f.text_field :delivery_address4, :class => 'text'
53
+ %dd.space= f.text_field :delivery_postcode, :class => 'text short', :placeholder => "Postcode"
54
+ %dd.space= f.collection_select :delivery_country_id, Shoppe::Country.ordered, :id, :name, {}, {:class => 'chosen'}
55
+
56
+ = field_set_tag "Notes" do
57
+ %dl
58
+ %dd= f.text_area :notes, :class => 'text'
59
+
60
+ %p.submit
61
+ = f.submit "Save Order", :class => 'button green'
62
+ = link_to "Cancel", @order, :class => 'button'
@@ -42,7 +42,7 @@
42
42
  %th Status
43
43
  %th Products
44
44
  %th Total
45
- %th Paid?
45
+ %th Payment
46
46
  %tbody
47
47
  - if @orders.empty?
48
48
  %tr.empty
@@ -58,6 +58,5 @@
58
58
  - for item in order.order_items
59
59
  %li #{item.quantity} x #{item.ordered_item.full_name}
60
60
  %td= number_to_currency order.total
61
- %td= boolean_tag order.paid?
62
-
61
+ %td= boolean_tag order.paid_in_full?, nil, :true_text => number_to_currency(order.amount_paid), :false_text => number_to_currency(order.amount_paid)
63
62
  = paginate @orders
@@ -2,6 +2,7 @@
2
2
 
3
3
  = content_for :header do
4
4
  %p.buttons
5
+ = link_to "Edit", [:edit, @order], :class => 'button'
5
6
  = link_to "Despatch Note", [:despatch_note, @order], :class => 'button', :rel => 'print'
6
7
  = link_to "Back to orders", :orders, :class => 'button grey'
7
8
  %h2.orders Order <b>##{@order.number}</b>
@@ -33,25 +34,18 @@
33
34
  .right
34
35
  %dl
35
36
  %dt E-Mail Address
36
- %dd= @order.email_address
37
+ %dd= mail_to @order.email_address
37
38
  %dt Telephone
38
39
  %dd= @order.phone_number
39
40
  %dt Weight
40
41
  %dd= number_to_weight @order.total_weight
41
42
  %dt Build Time
42
43
  %dd= distance_of_time_in_words(@order.created_at, @order.received_at)
43
-
44
- - if !@order.paid?
45
- = form_tag [:pay, @order] do
46
- %dl.form
47
- %dt.padding= label_tag 'payment_method', 'Payment Method'
48
- %dd= text_field_tag 'payment_method', '', :class => 'text'
49
- %dl.form
50
- %dt.padding= label_tag 'payment_reference', 'Payment Reference'
51
- %dd= text_field_tag 'payment_reference', '', :class => 'text'
52
- %dl.form
53
- %dd= submit_tag "Mark as paid", :class => 'button green button-mini'
54
-
44
+ - if @order.invoiced?
45
+ %dt Invoice Number
46
+ %dd= @order.invoice_number
47
+ %dt Order Balance
48
+ %dd= boolean_tag @order.paid_in_full?, nil, :true_text => number_to_currency(@order.balance), :false_text => number_to_currency(@order.balance)
55
49
  - if @order.accepted? && !@order.shipped?
56
50
  = form_tag [:ship, @order] do
57
51
  %dl.form
@@ -60,7 +54,7 @@
60
54
  %dl.form
61
55
  %dd= submit_tag "Mark as shipped", :class => 'button green button-mini'
62
56
 
63
- - if @order.paid? && !(@order.accepted? || @order.rejected?)
57
+ - unless @order.accepted? || @order.rejected?
64
58
  %dl.form
65
59
  %dd
66
60
  = link_to "Accept", [:accept, @order], :method => :post, :class => 'button green'
@@ -73,12 +67,6 @@
73
67
  %h4 Order Received
74
68
  %p on #{@order.received_at.to_s(:short)} from #{@order.ip_address}
75
69
 
76
- - if @order.paid?
77
- %li.payment
78
- %h4 Payment Received
79
- %p on #{@order.paid_at.to_s(:short)} using #{@order.payment_method}
80
- %p Reference <b>#{@order.payment_reference}</b>
81
-
82
70
  - if @order.accepted?
83
71
  %li.accepted
84
72
  %h4 Order Accepted
@@ -98,48 +86,97 @@
98
86
  - else
99
87
  %p Consignment # <b>#{@order.consignment_number}</b>
100
88
 
101
- .order_items
102
- .table
103
- %table.data
104
- %thead
105
- %tr
106
- %th.qty Qty
107
- %th Item
108
- %th SKU
109
- %th.money Cost
110
- %th.money Price
111
- %th.money= Shoppe.settings.tax_name
112
- %th.money Sub-Total
113
- %tbody
114
- - for item in @order.order_items
89
+ = field_set_tag "Order Items", :class => 'padded' do
90
+ .order_items
91
+ .table
92
+ %table.data
93
+ %thead
94
+ %tr
95
+ %th.qty Qty
96
+ %th Item
97
+ %th SKU
98
+ %th.money Cost
99
+ %th.money Price
100
+ %th.money= Shoppe.settings.tax_name
101
+ %th.money Sub-Total
102
+ %tbody
103
+ - for item in @order.order_items
104
+ %tr
105
+ %td.qty= item.quantity
106
+ %td.product= item.ordered_item.full_name
107
+ %td.sku= item.ordered_item.sku
108
+ %td.money= number_to_currency item.total_cost
109
+ %td.money= number_to_currency item.sub_total
110
+ %td.money= number_to_currency item.tax_amount
111
+ %td.money= number_to_currency item.total
112
+ - if @order.delivery_service
113
+ %td.qty
114
+ %td.product= link_to @order.delivery_service.name, [:edit, @order.delivery_service]
115
+ %td.sku
116
+ %td.money= number_to_currency @order.delivery_cost_price
117
+ %td.money= number_to_currency @order.delivery_price
118
+ %td.money= number_to_currency @order.delivery_tax_amount
119
+ %td.money= number_to_currency @order.delivery_price + @order.delivery_tax_amount
120
+ %tfoot
115
121
  %tr
116
- %td.qty= item.quantity
117
- %td.product= item.ordered_item.full_name
118
- %td.sku= item.ordered_item.sku
119
- %td.money= number_to_currency item.total_cost
120
- %td.money= number_to_currency item.sub_total
121
- %td.money= number_to_currency item.tax_amount
122
- %td.money= number_to_currency item.total
123
- - if @order.delivery_service
124
- %td.qty
125
- %td.product= link_to @order.delivery_service.name, [:edit, @order.delivery_service]
126
- %td.sku
127
- %td.money= number_to_currency @order.delivery_cost_price
128
- %td.money= number_to_currency @order.delivery_price
129
- %td.money= number_to_currency @order.delivery_tax_amount
130
- %td.money= number_to_currency @order.delivery_price + @order.delivery_tax_amount
131
- %tfoot
132
- %tr
133
- %td.qty= @order.total_items
134
- %td{:colspan => 2}
135
- %td.money= number_to_currency @order.total_cost
136
- %td.money= number_to_currency @order.total_before_tax
137
- %td.money= number_to_currency @order.tax
138
- %td.money= number_to_currency @order.total
139
- .notes
140
- = form_for @order do |f|
141
- %h4
142
- = f.submit "Save Notes", :class => 'button button-mini green'
143
- Order Notes
144
- %p= f.text_area :notes
122
+ %td.qty= @order.total_items
123
+ %td{:colspan => 2}
124
+ %td.money= number_to_currency @order.total_cost
125
+ %td.money= number_to_currency @order.total_before_tax
126
+ %td.money= number_to_currency @order.tax
127
+ %td.money= number_to_currency @order.total
145
128
 
129
+ = field_set_tag "Payments", :class => 'padded orderPayments' do
130
+ - unless @payments.empty?
131
+ .table
132
+ %table.data
133
+ %thead
134
+ %tr
135
+ %th ID
136
+ %th Type
137
+ %th Method
138
+ %th Reference
139
+ %th Amount
140
+ %th Refunded?
141
+ %th
142
+ %tbody
143
+ - for payment in @payments
144
+ %tr
145
+ %td= payment.id
146
+ %td
147
+ = payment.refund? ? 'Refund' : 'Payment'
148
+ %span.float-right= boolean_tag payment.confirmed?
149
+ %td= payment.method
150
+ %td= link_to_if payment.transaction_url, payment.reference, payment.transaction_url
151
+
152
+ - if payment.refund?
153
+ %td{:colspan => 2}
154
+ %b= number_to_currency payment.amount
155
+ from payment ##{payment.parent_payment_id}
156
+ - else
157
+ %td= number_to_currency payment.amount
158
+ %td= boolean_tag payment.refunded?, nil, :true_text => number_to_currency(payment.amount_refunded)
159
+ %td.refund
160
+ - if payment.refundable?
161
+ = link_to "Refund", [:refund, @order, payment], :class => 'button purple button-mini', :rel => 'dialog'
162
+ - else
163
+ = link_to "Delete", [@order, payment], :class => 'button purple button-mini', :data => {:confirm => "Are you sure you wish to remove this payment?"}, :method => :delete
164
+ - else
165
+ %p.notice There are no payments recorded for this order...
166
+
167
+ = form_for [@order, Shoppe::Payment.new(:amount => @order.balance)] do |f|
168
+ %dl.text
169
+ %dt= f.label :method
170
+ %dd= f.text_field :method, :class => 'text'
171
+ %dl.text
172
+ %dt= f.label :reference
173
+ %dd= f.text_field :reference, :class => 'text'
174
+ %dl.amount
175
+ %dt= f.label :amount
176
+ %dd
177
+ .moneyInput
178
+ .currency= Shoppe.settings.currency_unit.html_safe
179
+ = f.text_field :amount, :class => 'text'
180
+ %dl.submit
181
+ %dd= f.submit "Add Payment", :class => 'button green'
182
+
@@ -0,0 +1,14 @@
1
+
2
+ = form_tag [:refund, @order, @payment], :class => 'refundForm' do
3
+ %h2 Issue Refund
4
+ %p.intro
5
+ To issue a refund for this payment, just enter the amount you wish to refund below and click 'Refund'.
6
+ The maximum you can refund is <b>#{number_to_currency @payment.refundable_amount}</b>.
7
+
8
+ .moneyInput
9
+ .currency= Shoppe.settings.currency_unit.html_safe
10
+ = text_field_tag 'amount', @payment.refundable_amount, :class => 'text'
11
+ %p.submit
12
+ = submit_tag "Refund", :class => 'button green'
13
+ = link_to "Close", '#', :class => 'button grey', :rel => 'closeDialog'
14
+
@@ -4,7 +4,7 @@
4
4
  .splitContainer
5
5
  %dl.half
6
6
  %dt= f.label :name
7
- %dd= f.text_field :name, :class => 'text'
7
+ %dd= f.text_field :name, :class => 'focus text'
8
8
  %dl.half
9
9
  %dt= f.label :permalink
10
10
  %dd= f.text_field :permalink, :class => 'text'
@@ -72,10 +72,16 @@
72
72
  .splitContainer
73
73
  %dl.third
74
74
  %dt= f.label :price
75
- %dd= f.text_field :price, :class => 'text'
75
+ %dd
76
+ .moneyInput
77
+ .currency= Shoppe.settings.currency_unit.html_safe
78
+ = f.text_field :price, :class => 'text'
76
79
  %dl.third
77
80
  %dt= f.label :cost_price
78
- %dd= f.text_field :cost_price, :class => 'text'
81
+ %dd
82
+ .moneyInput
83
+ .currency= Shoppe.settings.currency_unit.html_safe
84
+ = f.text_field :cost_price, :class => 'text'
79
85
  %dl.third
80
86
  %dt= f.label :tax_rate_id
81
87
  %dd= f.collection_select :tax_rate_id, Shoppe::TaxRate.ordered, :id, :description, {:include_blank => true}, {:class => 'chosen-with-deselect', :data => {:placeholder => "No tax"}}
@@ -5,7 +5,7 @@
5
5
 
6
6
  = form_tag :url => settings_path do |f|
7
7
 
8
- - Shoppe.setting_groups.each do |group, fields|
8
+ - Shoppe.settings_groups.each do |group, fields|
9
9
  = field_set_tag t(group) do
10
10
  - fields.each do |f|
11
11
  %dl.sided
@@ -1,6 +1,6 @@
1
1
  - @page_title = "Tax Rates"
2
2
  = content_for :header do
3
- %p.buttons= link_to "Back to tax rates", :tax_rates, :class => 'button'
3
+ %p.buttons= link_to "Back to tax rates", :tax_rates, :class => 'button grey'
4
4
  %h2.tax_rates Tax Rates
5
5
 
6
6
  = form_for @tax_rate do |f|
@@ -14,12 +14,13 @@
14
14
  %dt= f.label :rate
15
15
  %dd= f.text_field :rate, :class => 'text'
16
16
 
17
- = field_set_tag "Countries" do
17
+ = field_set_tag "Country Restriction" do
18
+ %dl
19
+ %dd
20
+ = f.select :address_type, Shoppe::TaxRate::ADDRESS_TYPES.map { |a| ["Apply to orders where the #{a} address matches one of the countries below".html_safe, a]}, {}, :class => 'chosen-basic'
18
21
  %dl
19
22
  %dd
20
23
  = f.collection_select :country_ids, Shoppe::Country.ordered, :id, :name, {}, {:class => 'chosen', :multiple => true, :data => {:placeholder => "All countries"}}
21
- %p.help This tax rate will only apply to orders which are billed to addresses of the countries listed above.
22
-
23
24
  %p.submit
24
25
  - unless @tax_rate.new_record?
25
26
  %span.right= link_to "Delete", @tax_rate, :class => 'button purple', :method => :delete, :data => {:confirm => "Are you sure you wish to remove this tax_rate?"}
@@ -4,7 +4,7 @@
4
4
  .splitContainer
5
5
  %dl.half
6
6
  %dt= f.label :first_name
7
- %dd= f.text_field :first_name, :class => 'text'
7
+ %dd= f.text_field :first_name, :class => 'focus text'
8
8
  %dl.half
9
9
  %dt= f.label :last_name
10
10
  %dd= f.text_field :last_name, :class => 'text'
@@ -56,10 +56,10 @@
56
56
  = f.check_box :active
57
57
  = f.label :active, "If checked, this product will be displayed within the public store"
58
58
  %dl.half
59
- %dt= f.label :default, "Default varient?"
59
+ %dt= f.label :default, "Default variant?"
60
60
  %dd.checkbox
61
61
  = f.check_box :default
62
- = f.label :default, "If checked, this varient will be the default"
62
+ = f.label :default, "If checked, this variant will be the default"
63
63
 
64
64
  %p.submit
65
65
  - unless @variant.new_record?
data/config/routes.rb CHANGED
@@ -10,8 +10,10 @@ Shoppe::Engine.routes.draw do
10
10
  post :accept, :on => :member
11
11
  post :reject, :on => :member
12
12
  post :ship, :on => :member
13
- post :pay, :on => :member
14
13
  get :despatch_note, :on => :member
14
+ resources :payments, :only => [:create, :destroy] do
15
+ match :refund, :on => :member, :via => [:get, :post]
16
+ end
15
17
  end
16
18
  resources :stock_level_adjustments, :only => [:index, :create]
17
19
  resources :delivery_services do
@@ -88,7 +88,7 @@ class CreateShoppeInitialSchema < ActiveRecord::Migration
88
88
  t.string "delivery_address2"
89
89
  t.string "delivery_address3"
90
90
  t.string "delivery_address4"
91
- t.string "deilvery_postcode"
91
+ t.string "delivery_postcode"
92
92
  t.integer "delivery_country_id"
93
93
  end
94
94
 
@@ -0,0 +1,5 @@
1
+ class AddAddressTypeToShoppeTaxRates < ActiveRecord::Migration
2
+ def change
3
+ add_column :shoppe_tax_rates, :address_type, :string
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ class CreateShoppePayments < ActiveRecord::Migration
2
+ def up
3
+ create_table :shoppe_payments do |t|
4
+ t.integer :order_id
5
+ t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0
6
+ t.string :reference, :method
7
+ t.boolean :confirmed, :default => true
8
+ t.boolean :refundable, :default => false
9
+ t.decimal :amount_refunded, :precision => 8, :scale => 2, :default => 0.0
10
+ t.integer :parent_payment_id
11
+ t.boolean :exported, :default => false
12
+ t.timestamps
13
+ end
14
+ remove_column :shoppe_orders, :paid_at
15
+ remove_column :shoppe_orders, :payment_reference
16
+ remove_column :shoppe_orders, :payment_method
17
+
18
+ add_column :shoppe_orders, :amount_paid, :decimal, :precision => 8, :scale => 2, :default => 0.0
19
+ add_column :shoppe_orders, :exported, :boolean, :default => false
20
+ add_column :shoppe_orders, :invoice_number, :string
21
+ end
22
+
23
+ def down
24
+ drop_table :shoppe_payments
25
+ add_column :shoppe_orders, :paid_at, :datetime
26
+ add_column :shoppe_orders, :payment_reference, :string
27
+ add_column :shoppe_orders, :payment_method, :string
28
+ remove_column :shoppe_orders, :amount_paid
29
+ remove_column :shoppe_orders, :exported
30
+ remove_column :shoppe_orders, :invoice_number
31
+ end
32
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,218 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20131024204815) do
15
+
16
+ create_table "nifty_attachments", force: true do |t|
17
+ t.integer "parent_id"
18
+ t.string "parent_type"
19
+ t.string "token"
20
+ t.string "digest"
21
+ t.string "role"
22
+ t.string "file_name"
23
+ t.string "file_type"
24
+ t.binary "data", limit: 16777215
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ create_table "nifty_key_value_store", force: true do |t|
30
+ t.integer "parent_id"
31
+ t.string "parent_type"
32
+ t.string "group"
33
+ t.string "name"
34
+ t.string "value"
35
+ end
36
+
37
+ create_table "shoppe_countries", force: true do |t|
38
+ t.string "name"
39
+ t.string "code2"
40
+ t.string "code3"
41
+ t.string "continent"
42
+ t.string "tld"
43
+ t.string "currency"
44
+ t.boolean "eu_member", default: false
45
+ end
46
+
47
+ create_table "shoppe_delivery_service_prices", force: true do |t|
48
+ t.integer "delivery_service_id"
49
+ t.string "code"
50
+ t.decimal "price", precision: 8, scale: 2
51
+ t.decimal "cost_price", precision: 8, scale: 2
52
+ t.integer "tax_rate_id"
53
+ t.decimal "min_weight", precision: 8, scale: 2
54
+ t.decimal "max_weight", precision: 8, scale: 2
55
+ t.datetime "created_at"
56
+ t.datetime "updated_at"
57
+ t.text "country_ids"
58
+ end
59
+
60
+ create_table "shoppe_delivery_services", force: true do |t|
61
+ t.string "name"
62
+ t.string "code"
63
+ t.boolean "default", default: false
64
+ t.boolean "active", default: true
65
+ t.datetime "created_at"
66
+ t.datetime "updated_at"
67
+ t.string "courier"
68
+ t.string "tracking_url"
69
+ end
70
+
71
+ create_table "shoppe_order_items", force: true do |t|
72
+ t.integer "order_id"
73
+ t.integer "ordered_item_id"
74
+ t.string "ordered_item_type"
75
+ t.integer "quantity", default: 1
76
+ t.decimal "unit_price", precision: 8, scale: 2
77
+ t.decimal "unit_cost_price", precision: 8, scale: 2
78
+ t.decimal "tax_amount", precision: 8, scale: 2
79
+ t.decimal "tax_rate", precision: 8, scale: 2
80
+ t.decimal "weight", precision: 8, scale: 3, default: 0.0
81
+ t.datetime "created_at"
82
+ t.datetime "updated_at"
83
+ end
84
+
85
+ create_table "shoppe_orders", force: true do |t|
86
+ t.string "token"
87
+ t.string "first_name"
88
+ t.string "last_name"
89
+ t.string "company"
90
+ t.string "billing_address1"
91
+ t.string "billing_address2"
92
+ t.string "billing_address3"
93
+ t.string "billing_address4"
94
+ t.string "billing_postcode"
95
+ t.integer "billing_country_id"
96
+ t.string "email_address"
97
+ t.string "phone_number"
98
+ t.string "status"
99
+ t.datetime "received_at"
100
+ t.datetime "accepted_at"
101
+ t.datetime "shipped_at"
102
+ t.datetime "created_at"
103
+ t.datetime "updated_at"
104
+ t.integer "delivery_service_id"
105
+ t.decimal "delivery_price", precision: 8, scale: 2
106
+ t.decimal "delivery_cost_price", precision: 8, scale: 2
107
+ t.decimal "delivery_tax_rate", precision: 8, scale: 2
108
+ t.decimal "delivery_tax_amount", precision: 8, scale: 2
109
+ t.integer "accepted_by"
110
+ t.integer "shipped_by"
111
+ t.string "consignment_number"
112
+ t.datetime "rejected_at"
113
+ t.integer "rejected_by"
114
+ t.string "ip_address"
115
+ t.text "notes"
116
+ t.boolean "separate_delivery_address", default: false
117
+ t.string "delivery_name"
118
+ t.string "delivery_address1"
119
+ t.string "delivery_address2"
120
+ t.string "delivery_address3"
121
+ t.string "delivery_address4"
122
+ t.string "delivery_postcode"
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"
141
+ end
142
+
143
+ create_table "shoppe_product_attributes", force: true do |t|
144
+ t.integer "product_id"
145
+ t.string "key"
146
+ t.string "value"
147
+ t.integer "position", default: 1
148
+ t.boolean "searchable", default: true
149
+ t.datetime "created_at"
150
+ t.datetime "updated_at"
151
+ t.boolean "public", default: true
152
+ end
153
+
154
+ create_table "shoppe_product_categories", force: true do |t|
155
+ t.string "name"
156
+ t.string "permalink"
157
+ t.text "description"
158
+ t.datetime "created_at"
159
+ t.datetime "updated_at"
160
+ end
161
+
162
+ create_table "shoppe_products", force: true do |t|
163
+ t.integer "parent_id"
164
+ t.integer "product_category_id"
165
+ t.string "name"
166
+ t.string "sku"
167
+ t.string "permalink"
168
+ t.text "description"
169
+ t.text "short_description"
170
+ t.boolean "active", default: true
171
+ t.decimal "weight", precision: 8, scale: 3, default: 0.0
172
+ t.decimal "price", precision: 8, scale: 2, default: 0.0
173
+ t.decimal "cost_price", precision: 8, scale: 2, default: 0.0
174
+ t.integer "tax_rate_id"
175
+ t.datetime "created_at"
176
+ t.datetime "updated_at"
177
+ t.boolean "featured", default: false
178
+ t.text "in_the_box"
179
+ t.boolean "stock_control", default: true
180
+ t.boolean "default", default: false
181
+ end
182
+
183
+ create_table "shoppe_settings", force: true do |t|
184
+ t.string "key"
185
+ t.string "value"
186
+ t.string "value_type"
187
+ end
188
+
189
+ create_table "shoppe_stock_level_adjustments", force: true do |t|
190
+ t.integer "item_id"
191
+ t.string "item_type"
192
+ t.string "description"
193
+ t.integer "adjustment", default: 0
194
+ t.string "parent_type"
195
+ t.integer "parent_id"
196
+ t.datetime "created_at"
197
+ t.datetime "updated_at"
198
+ end
199
+
200
+ create_table "shoppe_tax_rates", force: true do |t|
201
+ t.string "name"
202
+ t.decimal "rate", precision: 8, scale: 2
203
+ t.datetime "created_at"
204
+ t.datetime "updated_at"
205
+ t.text "country_ids"
206
+ t.string "address_type"
207
+ end
208
+
209
+ create_table "shoppe_users", force: true do |t|
210
+ t.string "first_name"
211
+ t.string "last_name"
212
+ t.string "email_address"
213
+ t.string "password_digest"
214
+ t.datetime "created_at"
215
+ t.datetime "updated_at"
216
+ end
217
+
218
+ end