solidus_core 1.0.0.pre → 1.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/app/mailers/spree/carton_mailer.rb +1 -1
  3. data/app/mailers/spree/reimbursement_mailer.rb +3 -2
  4. data/app/mailers/spree/test_mailer.rb +1 -1
  5. data/app/models/concerns/spree/user_methods.rb +49 -0
  6. data/app/models/spree/ability.rb +2 -0
  7. data/app/models/spree/adjustment.rb +1 -0
  8. data/app/models/spree/adjustment_reason.rb +12 -0
  9. data/app/models/spree/app_configuration.rb +1 -1
  10. data/app/models/spree/carton.rb +1 -1
  11. data/app/models/spree/inventory_unit.rb +10 -6
  12. data/app/models/spree/legacy_user.rb +4 -12
  13. data/app/models/spree/order.rb +15 -15
  14. data/app/models/spree/order/checkout.rb +20 -15
  15. data/app/models/spree/order/payments.rb +1 -5
  16. data/app/models/spree/order_cancellations.rb +1 -1
  17. data/app/models/spree/order_capturing.rb +1 -1
  18. data/app/models/spree/order_mutex.rb +1 -1
  19. data/app/models/spree/order_shipping.rb +1 -1
  20. data/app/models/spree/payment/processing.rb +39 -13
  21. data/app/models/spree/payment_method.rb +2 -2
  22. data/app/models/spree/permission_sets/base.rb +17 -0
  23. data/app/models/spree/permission_sets/configuration_display.rb +24 -0
  24. data/app/models/spree/permission_sets/configuration_management.rb +24 -0
  25. data/app/models/spree/permission_sets/dashboard_display.rb +9 -0
  26. data/app/models/spree/permission_sets/order_display.rb +15 -0
  27. data/app/models/spree/permission_sets/order_management.rb +15 -0
  28. data/app/models/spree/permission_sets/product_display.rb +18 -0
  29. data/app/models/spree/permission_sets/product_management.rb +19 -0
  30. data/app/models/spree/permission_sets/promotion_display.rb +12 -0
  31. data/app/models/spree/permission_sets/promotion_management.rb +12 -0
  32. data/app/models/spree/permission_sets/report_display.rb +9 -0
  33. data/app/models/spree/permission_sets/stock_display.rb +10 -0
  34. data/app/models/spree/permission_sets/stock_management.rb +11 -0
  35. data/app/models/spree/permission_sets/user_display.rb +11 -0
  36. data/app/models/spree/permission_sets/user_management.rb +11 -0
  37. data/app/models/spree/promotion/rules/item_total.rb +12 -33
  38. data/app/models/spree/promotion/rules/user.rb +2 -2
  39. data/app/models/spree/promotion_rule.rb +2 -2
  40. data/app/models/spree/reimbursement.rb +0 -12
  41. data/app/models/spree/return_authorization.rb +2 -2
  42. data/app/models/spree/return_item.rb +1 -0
  43. data/app/models/spree/return_reason.rb +18 -0
  44. data/app/models/spree/role_user.rb +1 -1
  45. data/app/models/spree/shipment.rb +9 -26
  46. data/app/models/spree/store_credit.rb +31 -7
  47. data/app/models/spree/store_credit_event.rb +13 -11
  48. data/app/models/spree/store_credit_update_reason.rb +2 -0
  49. data/app/models/spree/user_class_handle.rb +21 -0
  50. data/app/models/spree/user_stock_location.rb +1 -1
  51. data/config/initializers/spree_user.rb +10 -0
  52. data/config/locales/en.yml +58 -16
  53. data/db/default/spree/return_reasons.rb +9 -0
  54. data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +11 -9
  55. data/db/migrate/20150618212517_create_spree_store_credit_update_reasons.rb +8 -0
  56. data/db/migrate/20150619160613_create_adjustment_reason.rb +18 -0
  57. data/db/migrate/20150622144655_add_update_reason_to_store_credit_events.rb +5 -0
  58. data/db/migrate/20150623194316_add_return_authorization_reason_id_to_return_items.rb +7 -0
  59. data/db/migrate/20150623214058_seed_store_credit_update_reasons.rb +9 -0
  60. data/db/migrate/20150626200816_remove_shipping_method_id_from_spree_orders.rb +9 -0
  61. data/db/seeds.rb +9 -0
  62. data/lib/spree/core.rb +1 -4
  63. data/lib/spree/core/controller_helpers/auth.rb +15 -20
  64. data/lib/spree/core/engine.rb +1 -0
  65. data/lib/spree/core/importer/order.rb +8 -5
  66. data/lib/spree/core/role_configuration.rb +70 -0
  67. data/lib/spree/permitted_attributes.rb +1 -1
  68. data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +6 -0
  69. data/lib/spree/testing_support/factories/order_factory.rb +14 -1
  70. data/lib/spree/testing_support/factories/promotion_factory.rb +2 -4
  71. data/lib/spree/testing_support/factories/return_authorization_factory.rb +3 -3
  72. data/lib/spree/testing_support/factories/return_item_factory.rb +1 -0
  73. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +10 -0
  74. data/lib/spree/testing_support/factories/store_credit_update_reason_factory.rb +5 -0
  75. data/lib/spree/testing_support/factories/store_factory.rb +1 -1
  76. data/lib/spree/testing_support/order_walkthrough.rb +2 -7
  77. metadata +36 -10
  78. data/app/assets/images/logo/solidus.png +0 -0
  79. data/app/models/spree/item_adjustments.rb.orig +0 -93
  80. data/app/models/spree/return_authorization_reason.rb +0 -7
  81. data/app/models/spree/static_model_preferences.rb +0 -32
  82. data/config/initializers/user_class_extensions.rb +0 -42
@@ -7,11 +7,13 @@ class Spree::StoreCredit < ActiveRecord::Base
7
7
  ELIGIBLE_ACTION = 'eligible'
8
8
  AUTHORIZE_ACTION = 'authorize'
9
9
  ALLOCATION_ACTION = 'allocation'
10
+ ADJUSTMENT_ACTION = 'adjustment'
11
+ INVALIDATE_ACTION = 'invalidate'
10
12
 
11
13
  DEFAULT_CREATED_BY_EMAIL = "spree@example.com"
12
14
 
13
- belongs_to :user, class_name: Spree.user_class.to_s
14
- belongs_to :created_by, class_name: Spree.user_class.to_s
15
+ belongs_to :user, class_name: Spree::UserClassHandle.new
16
+ belongs_to :created_by, class_name: Spree::UserClassHandle.new
15
17
  belongs_to :category, class_name: "Spree::StoreCreditCategory"
16
18
  belongs_to :credit_type, class_name: 'Spree::StoreCreditType', :foreign_key => 'type_id'
17
19
  has_many :store_credit_events
@@ -27,11 +29,12 @@ class Spree::StoreCredit < ActiveRecord::Base
27
29
 
28
30
  scope :order_by_priority, -> { includes(:credit_type).order('spree_store_credit_types.priority ASC') }
29
31
 
30
- before_validation :associate_credit_type
31
32
  after_save :store_event
33
+ before_validation :associate_credit_type
34
+ before_validation :validate_category_unchanged, on: :update
32
35
  before_destroy :validate_no_amount_used
33
36
 
34
- attr_accessor :action, :action_amount, :action_originator, :action_authorization_code
37
+ attr_accessor :action, :action_amount, :action_originator, :action_authorization_code, :update_reason
35
38
 
36
39
  extend Spree::DisplayMoney
37
40
  money_methods :amount, :amount_used, :amount_authorized
@@ -174,9 +177,23 @@ class Spree::StoreCredit < ActiveRecord::Base
174
177
  !!invalidated_at
175
178
  end
176
179
 
177
- def invalidate
180
+ def update_amount(amount, reason, user_performing_update)
181
+ previous_amount = self.amount
182
+ self.amount = amount
183
+ self.action_amount = self.amount - previous_amount
184
+ self.action = ADJUSTMENT_ACTION
185
+ self.update_reason = reason
186
+ self.action_originator = user_performing_update
187
+ save
188
+ end
189
+
190
+ def invalidate(reason, user_performing_invalidation)
178
191
  if invalidateable?
179
- touch(:invalidated_at)
192
+ self.action = INVALIDATE_ACTION
193
+ self.update_reason = reason
194
+ self.action_originator = user_performing_invalidation
195
+ self.invalidated_at = Time.now
196
+ save
180
197
  else
181
198
  errors.add(:invalidated_at, Spree.t("store_credit.errors.cannot_invalidate_uncaptured_authorization"))
182
199
  return false
@@ -222,7 +239,7 @@ class Spree::StoreCredit < ActiveRecord::Base
222
239
  end
223
240
 
224
241
  def store_event
225
- return unless amount_changed? || amount_used_changed? || amount_authorized_changed? || action == ELIGIBLE_ACTION
242
+ return unless amount_changed? || amount_used_changed? || amount_authorized_changed? || [ELIGIBLE_ACTION, INVALIDATE_ACTION].include?(action)
226
243
 
227
244
  event = if action
228
245
  store_credit_events.build(action: action)
@@ -235,6 +252,7 @@ class Spree::StoreCredit < ActiveRecord::Base
235
252
  authorization_code: action_authorization_code || event.authorization_code || generate_authorization_code,
236
253
  user_total_amount: user.total_available_store_credit,
237
254
  originator: action_originator,
255
+ update_reason: update_reason,
238
256
  })
239
257
  end
240
258
 
@@ -252,6 +270,12 @@ class Spree::StoreCredit < ActiveRecord::Base
252
270
  end
253
271
  end
254
272
 
273
+ def validate_category_unchanged
274
+ if category_id_changed?
275
+ errors.add(:category, Spree.t('admin.store_credits.errors.cannot_be_modified'))
276
+ end
277
+ end
278
+
255
279
  def validate_no_amount_used
256
280
  if amount_used > 0
257
281
  errors.add(:amount_used, 'is greater than zero. Can not delete store credit')
@@ -4,10 +4,16 @@ module Spree
4
4
 
5
5
  belongs_to :store_credit
6
6
  belongs_to :originator, polymorphic: true
7
+ belongs_to :update_reason, class_name: "Spree::StoreCreditUpdateReason"
8
+
9
+ validates_presence_of :update_reason, if: :action_requires_reason?
10
+
11
+ NON_EXPOSED_ACTIONS = [Spree::StoreCredit::ELIGIBLE_ACTION, Spree::StoreCredit::AUTHORIZE_ACTION]
7
12
 
8
13
  scope :exposed_events, -> { exposable_actions.not_invalidated }
9
- scope :exposable_actions, -> { where.not(action: [Spree::StoreCredit::ELIGIBLE_ACTION, Spree::StoreCredit::AUTHORIZE_ACTION]) }
14
+ scope :exposable_actions, -> { where.not(action: NON_EXPOSED_ACTIONS) }
10
15
  scope :not_invalidated, -> { joins(:store_credit).where(spree_store_credits: { invalidated_at: nil }) }
16
+ scope :chronological, -> { order(:created_at) }
11
17
  scope :reverse_chronological, -> { order(created_at: :desc) }
12
18
 
13
19
  delegate :currency, to: :store_credit
@@ -20,6 +26,10 @@ module Spree
20
26
  action == Spree::StoreCredit::AUTHORIZE_ACTION
21
27
  end
22
28
 
29
+ def action_requires_reason?
30
+ [Spree::StoreCredit::ADJUSTMENT_ACTION, Spree::StoreCredit::INVALIDATE_ACTION].include?(action)
31
+ end
32
+
23
33
  def display_amount
24
34
  Spree::Money.new(amount, { currency: currency })
25
35
  end
@@ -33,16 +43,8 @@ module Spree
33
43
  end
34
44
 
35
45
  def display_action
36
- case action
37
- when Spree::StoreCredit::CAPTURE_ACTION
38
- Spree.t('store_credit.captured')
39
- when Spree::StoreCredit::AUTHORIZE_ACTION
40
- Spree.t('store_credit.authorized')
41
- when Spree::StoreCredit::ALLOCATION_ACTION
42
- Spree.t('store_credit.allocated')
43
- when Spree::StoreCredit::VOID_ACTION, Spree::StoreCredit::CREDIT_ACTION
44
- Spree.t('store_credit.credit')
45
- end
46
+ return if NON_EXPOSED_ACTIONS.include?(action)
47
+ Spree.t("store_credit.display_action.#{action}")
46
48
  end
47
49
 
48
50
  def order
@@ -0,0 +1,2 @@
1
+ class Spree::StoreCreditUpdateReason < ActiveRecord::Base
2
+ end
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ # Placeholder for name of Spree.user_class to ensure later evaluation at
3
+ # runtime.
4
+ #
5
+ # Unfortunately, it is possible for classes to get loaded before
6
+ # Spree.user_class has been set in the initializer. As a result, they end up
7
+ # with class_name: "" in their association definitions. For obvious reasons,
8
+ # that doesn't work.
9
+ #
10
+ # For now, Rails does not call to_s on the instance passed in until runtime.
11
+ # So this little hack provides a wrapper around Spree.user_class so that we
12
+ # can basically lazy-evaluate it. Yay! Problem solved forever.
13
+ class UserClassHandle
14
+ # @return [String] the name of the user class as a string.
15
+ # @raise [RuntimeError] if Spree.user_class is nil
16
+ def to_s
17
+ fail "'Spree.user_class' has not been set yet." unless Spree.user_class
18
+ "::#{Spree.user_class}"
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class UserStockLocation < ActiveRecord::Base
3
- belongs_to :user, class_name: Spree.user_class.to_s, inverse_of: :user_stock_locations
3
+ belongs_to :user, class_name: Spree::UserClassHandle.new, inverse_of: :user_stock_locations
4
4
  belongs_to :stock_location, class_name: "Spree::StockLocation", inverse_of: :user_stock_locations
5
5
  end
6
6
  end
@@ -0,0 +1,10 @@
1
+ # Ensure that Spree.user_class includes the UserMethods concern
2
+ # Previously these methods were injected automatically onto the class, which we
3
+ # are still doing for compatability, but with a warning.
4
+
5
+ Spree::Core::Engine.config.to_prepare do
6
+ unless Spree.user_class.included_modules.include?(Spree::UserMethods)
7
+ ActiveSupport::Deprecation.warn "#{Spree.user_class} must include Spree::UserMethods"
8
+ Spree.user_class.include Spree::UserMethods
9
+ end
10
+ end
@@ -150,6 +150,9 @@ en:
150
150
  spree/address:
151
151
  one: Address
152
152
  other: Addresses
153
+ spree/adjustment_reason:
154
+ one: Adjustment Reason
155
+ other: Adjustment Reasons
153
156
  spree/country:
154
157
  one: Country
155
158
  other: Countries
@@ -207,9 +210,9 @@ en:
207
210
  spree/return_authorization:
208
211
  one: Return Authorization
209
212
  other: Return Authorizations
210
- spree/return_authorization_reason:
211
- one: Return Authorization Reason
212
- other: Return Authorization Reasons
213
+ spree/return_reason:
214
+ one: Return Reason
215
+ other: Return Reasons
213
216
  spree/role:
214
217
  one: Roles
215
218
  other: Roles
@@ -285,6 +288,12 @@ en:
285
288
  base:
286
289
  card_expired: "Card has expired"
287
290
  expiry_invalid: "Card expiration is invalid"
291
+ spree/inventory_unit:
292
+ attributes:
293
+ state:
294
+ cannot_destroy: "Cannot destroy a %{state} inventory unit"
295
+ base:
296
+ cannot_destroy_shipment_state: "Cannot destroy an inventory unit for a %{state} shipment"
288
297
  spree/line_item:
289
298
  attributes:
290
299
  currency:
@@ -303,12 +312,17 @@ en:
303
312
  cannot_be_associated_unless_accepted: cannot be associated to a return item that is not accepted.
304
313
  inventory_unit:
305
314
  other_completed_return_item_exists: "%{inventory_unit_id} has already been taken by return item %{return_item_id}"
315
+ spree/shipment:
316
+ attributes:
317
+ state:
318
+ cannot_destroy: "Cannot destroy a %{state} shipment"
319
+ base:
320
+ cannot_remove_items_shipment_state: "Cannot remove items from a %{state} shipment"
306
321
  spree/store:
307
322
  attributes:
308
323
  base:
309
324
  cannot_destroy_default_store: Cannot destroy the default Store.
310
325
 
311
-
312
326
  devise:
313
327
  confirmations:
314
328
  confirmed: Your account was successfully confirmed. You are now signed in.
@@ -404,6 +418,7 @@ en:
404
418
  adjustable: Adjustable
405
419
  adjustment: Adjustment
406
420
  adjustment_amount: Amount
421
+ adjustment_reasons: Adjustment Reasons
407
422
  adjustment_successfully_closed: Adjustment has been successfully closed!
408
423
  adjustment_successfully_opened: Adjustment has been successfully opened!
409
424
  adjustment_total: Adjustment Total
@@ -436,26 +451,42 @@ en:
436
451
  add: "Add store credit"
437
452
  new: "New store credit"
438
453
  edit: "Editing store credit"
454
+ edit_amount: "Editing store credit amount"
455
+ invalidate_store_credit: "Invalidating store credit"
456
+ back_to_edit: "Back to edit"
439
457
  back_to_user_list: "Back to user list"
440
- back_to_store_credit_list: "Back to store credit list"
458
+ back_to_store_credit_list: "Store credit list"
459
+ change_amount: "Change amount"
460
+ credit_type: "Credit type"
441
461
  credited_html_header: "Amount Credited"
462
+ current_balance: "Current balance"
442
463
  used_html_header: "Amount Used"
443
464
  authed_html_header: "Amount Authorized"
444
465
  type_html_header: "Credit Type"
445
466
  created_by: "Created By"
467
+ history: "Store credit history"
446
468
  invalidated: "Invalidated"
447
469
  issued_on: "Issued On"
470
+ payment_originator: "Payment - Order #%{order_number}"
471
+ reason_for_updating: "Reason for updating"
472
+ refund_originator: "Refund - Order #%{order_number}"
473
+ user_originator: "User - %{email}"
448
474
  select_reason: "Select a reason for this store credit"
475
+ select_amount_update_reason: "Select a reason for updating the amount"
476
+ total_unused: "Total<br/>unused"
449
477
  unable_to_create: "Unable to create store credit"
450
478
  unable_to_update: "Unable to update store credit"
451
479
  unable_to_delete: "Unable to delete store credit"
480
+ unable_to_invalidate: "Unable to invalidate store credit"
452
481
  resource_name: "store credits"
453
482
  no_store_credit_selected: "No store credit was selected"
454
483
  errors:
455
484
  cannot_change_used_store_credit: "Store credit that has been claimed cannot be changed"
485
+ cannot_be_modified: "cannot be modified"
456
486
  amount_used_cannot_be_greater: "cannot be greater than the credited amount"
457
487
  amount_authorized_exceeds_total_credit: " exceeds the available credit"
458
488
  amount_used_not_zero: "is greater than zero. Can not delete store credit"
489
+ update_reason_required: "A reason for the change must be selected"
459
490
  administration: Administration
460
491
  agree_to_privacy_policy: Agree to Privacy Policy
461
492
  agree_to_terms_of_service: Agree to Terms of Service
@@ -495,6 +526,7 @@ en:
495
526
  back_end: Backend
496
527
  backordered: Backordered
497
528
  back_to_adjustments_list: Back To Adjustments List
529
+ back_to_adjustment_reason_list: Back To Adjustment Reason List
498
530
  back_to_customer_return: Back To Customer Return
499
531
  back_to_customer_return_list: Back To Customer Return List
500
532
  back_to_images_list: Back To Images List
@@ -547,6 +579,8 @@ en:
547
579
  cancellation: Cancellation
548
580
  cannot_create_payment_without_payment_methods: You cannot create a payment for an order without any payment methods defined.
549
581
  cannot_create_returns: Cannot create returns as this order has no shipped units.
582
+ cannot_rebuild_shipments_order_completed: Cannot rebuild shipments for a completed order.
583
+ cannot_rebuild_shipments_shipments_not_pending: Cannot rebuild shipments for an order with non-pending shipments.
550
584
  cannot_perform_operation: Cannot perform requested operation
551
585
  cannot_set_shipping_method_without_address: Cannot set shipping method until customer details are provided.
552
586
  capture: Capture
@@ -674,12 +708,14 @@ en:
674
708
  destination: Destination
675
709
  destination_location: Destination location
676
710
  destroy: Destroy
711
+ details: Details
677
712
  discount_amount: Discount Amount
678
713
  dismiss_banner: No. Thanks! I'm not interested, do not display this message again
679
714
  display: Display
680
715
  download_promotion_code_list: Download Code List
681
716
  edit: Edit
682
717
  editing_country: Editing Country
718
+ editing_adjustment_reason: Editing Adjustment Reason
683
719
  editing_option_type: Editing Option Type
684
720
  editing_payment_method: Editing Payment Method
685
721
  editing_product: Editing Product
@@ -708,8 +744,6 @@ en:
708
744
  has_excluded_product: Your cart contains a product that prevents this coupon code from being applied.
709
745
  item_total_less_than: This coupon code can't be applied to orders less than %{amount}.
710
746
  item_total_less_than_or_equal: This coupon code can't be applied to orders less than or equal to %{amount}.
711
- item_total_more_than: This coupon code can't be applied to orders higher than %{amount}.
712
- item_total_more_than_or_equal: This coupon code can't be applied to orders higher than or equal to %{amount}.
713
747
  limit_once_per_user: This coupon code can only be used once per user.
714
748
  missing_product: This coupon code can't be applied because you don't have all of the necessary products in your cart.
715
749
  missing_taxon: You need to add a product from all applicable categories before applying this coupon code.
@@ -841,6 +875,7 @@ en:
841
875
  invalid_payment_provider: Invalid payment provider.
842
876
  invalid_promotion_action: Invalid promotion action.
843
877
  invalid_promotion_rule: Invalid promotion rule.
878
+ invalidate: Invalidate
844
879
  inventory: Inventory
845
880
  inventory_adjustment: Inventory Adjustment
846
881
  inventory_canceled: Inventory canceled
@@ -856,8 +891,6 @@ en:
856
891
  operators:
857
892
  gt: greater than
858
893
  gte: greater than or equal to
859
- lt: less than
860
- lte: less than or equal to
861
894
  items_cannot_be_shipped: We are unable to calculate shipping rates for the selected items.
862
895
  items_in_rmas: Items in Return Authorizations
863
896
  items_to_be_reimbursed: Items to be reimbursed
@@ -920,6 +953,7 @@ en:
920
953
  negative_movement_absent_item: Cannot create negative movement for absent stock item.
921
954
  new: New
922
955
  new_adjustment: New Adjustment
956
+ new_adjustment_reason: New Adjustment Reason
923
957
  new_customer: New Customer
924
958
  new_customer_return: New Customer Return
925
959
  new_country: New Country
@@ -1235,7 +1269,7 @@ en:
1235
1269
  resumed: Resumed
1236
1270
  return: return
1237
1271
  return_authorization: Return Authorization
1238
- return_authorization_reasons: Return Authorization Reasons
1272
+ return_reasons: Return Reasons
1239
1273
  return_authorization_updated: Return authorization updated
1240
1274
  return_authorizations: Return Authorizations
1241
1275
  return_item_inventory_unit_ineligible: Return item's inventory unit must be shipped
@@ -1283,7 +1317,7 @@ en:
1283
1317
  security_settings: Security Settings
1284
1318
  select: Select
1285
1319
  select_from_prototype: Select From Prototype
1286
- select_a_return_authorization_reason: Select a reason for the return authorization
1320
+ select_a_reason: Select a reason
1287
1321
  select_a_stock_location: Select a stock location
1288
1322
  select_stock: Select stock
1289
1323
  selected_quantity_not_available: ! 'selected of %{item} is not available.'
@@ -1382,19 +1416,27 @@ en:
1382
1416
  stop: Stop
1383
1417
  store: Store
1384
1418
  store_credit:
1385
- allocated: "Added"
1386
- authorized: "Authorized"
1387
- captured: "Used"
1388
- credit: "Credit"
1419
+ actions:
1420
+ invalidate: Invalidate
1389
1421
  credit_allocation_memo: "This is a credit from store credit ID %{id}"
1390
1422
  currency_mismatch: "Store credit currency does not match order currency"
1423
+ display_action:
1424
+ adjustment: Adjustment
1425
+ allocation: Added
1426
+ capture: Used
1427
+ credit: Credit
1428
+ invalidate: Invalidated
1429
+ void: Credit
1430
+ admin:
1431
+ authorize: "Authorized"
1432
+ eligible: "Eligibility Verified"
1433
+ void: "Voided"
1391
1434
  errors:
1392
1435
  unable_to_fund: "Unable to pay for order using store credits"
1393
1436
  cannot_invalidate_uncaptured_authorization: "Cannot invalidate a store credit with an uncaptured authorization"
1394
1437
  expiring: Expiring
1395
1438
  insufficient_authorized_amount: "Unable to capture more than authorized amount"
1396
1439
  insufficient_funds: "Store credit amount remaining is not sufficient"
1397
- invalidate: "Invalidate"
1398
1440
  non_expiring: Non-expiring
1399
1441
  select_one_store_credit: "Select store credit to go towards remaining balance"
1400
1442
  store_credit: Store Credit
@@ -0,0 +1,9 @@
1
+ Spree::ReturnReason.find_or_create_by(name: 'Better price available')
2
+ Spree::ReturnReason.find_or_create_by(name: 'Missed estimated delivery date')
3
+ Spree::ReturnReason.find_or_create_by(name: 'Missing parts or accessories')
4
+ Spree::ReturnReason.find_or_create_by(name: 'Damaged/Defective')
5
+ Spree::ReturnReason.find_or_create_by(name: 'Different from what was ordered')
6
+ Spree::ReturnReason.find_or_create_by(name: 'Different from description')
7
+ Spree::ReturnReason.find_or_create_by(name: 'No longer needed/wanted')
8
+ Spree::ReturnReason.find_or_create_by(name: 'Accidental order')
9
+ Spree::ReturnReason.find_or_create_by(name: 'Unauthorized purchase')
@@ -10,15 +10,17 @@ class CreateSpreeReturnAuthorizationReasons < ActiveRecord::Migration
10
10
 
11
11
  reversible do |direction|
12
12
  direction.up do
13
- Spree::ReturnAuthorizationReason.create!(name: 'Better price available')
14
- Spree::ReturnAuthorizationReason.create!(name: 'Missed estimated delivery date')
15
- Spree::ReturnAuthorizationReason.create!(name: 'Missing parts or accessories')
16
- Spree::ReturnAuthorizationReason.create!(name: 'Damaged/Defective')
17
- Spree::ReturnAuthorizationReason.create!(name: 'Different from what was ordered')
18
- Spree::ReturnAuthorizationReason.create!(name: 'Different from description')
19
- Spree::ReturnAuthorizationReason.create!(name: 'No longer needed/wanted')
20
- Spree::ReturnAuthorizationReason.create!(name: 'Accidental order')
21
- Spree::ReturnAuthorizationReason.create!(name: 'Unauthorized purchase')
13
+ if defined?(Spree::ReturnAuthorizationReason)
14
+ Spree::ReturnAuthorizationReason.create!(name: 'Better price available')
15
+ Spree::ReturnAuthorizationReason.create!(name: 'Missed estimated delivery date')
16
+ Spree::ReturnAuthorizationReason.create!(name: 'Missing parts or accessories')
17
+ Spree::ReturnAuthorizationReason.create!(name: 'Damaged/Defective')
18
+ Spree::ReturnAuthorizationReason.create!(name: 'Different from what was ordered')
19
+ Spree::ReturnAuthorizationReason.create!(name: 'Different from description')
20
+ Spree::ReturnAuthorizationReason.create!(name: 'No longer needed/wanted')
21
+ Spree::ReturnAuthorizationReason.create!(name: 'Accidental order')
22
+ Spree::ReturnAuthorizationReason.create!(name: 'Unauthorized purchase')
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -0,0 +1,8 @@
1
+ class CreateSpreeStoreCreditUpdateReasons < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_store_credit_update_reasons do |t|
4
+ t.string :name
5
+ t.timestamps null: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ class CreateAdjustmentReason < ActiveRecord::Migration
2
+ def change
3
+ create_table :spree_adjustment_reasons do |t|
4
+ t.string "name"
5
+ t.string "code"
6
+ t.boolean "active", default: true
7
+
8
+ t.timestamps null: true
9
+ end
10
+
11
+ add_index :spree_adjustment_reasons, :code
12
+ add_index :spree_adjustment_reasons, :active
13
+
14
+ change_table :spree_adjustments do |t|
15
+ t.references :adjustment_reason
16
+ end
17
+ end
18
+ end