spree_backend 2.3.13 → 2.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend/address_states.js +1 -3
- data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -2
- data/app/assets/javascripts/spree/backend/admin.js.erb +11 -1
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -20
- data/app/assets/javascripts/spree/backend/line_items.js.coffee +2 -5
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js.erb +50 -0
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +2 -4
- data/app/assets/javascripts/spree/backend/orders/edit_form.js +2 -3
- data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +5 -5
- data/app/assets/javascripts/spree/backend/product_picker.js +2 -4
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +4 -0
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +35 -0
- data/app/assets/javascripts/spree/backend/shipments.js.erb +39 -52
- data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +1 -2
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +1 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +8 -6
- data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +5 -24
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +2 -4
- data/app/assets/javascripts/spree/backend/user_picker.js +2 -3
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +2 -2
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +0 -5
- data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +5 -2
- data/app/assets/stylesheets/spree/backend/sections/_adjustments_table.scss +8 -0
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +4 -0
- data/app/assets/stylesheets/spree/backend/sections/_return_authorizations.scss +24 -0
- data/app/assets/stylesheets/spree/backend/sections/_taxons.scss +1 -7
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +8 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +2 -0
- data/app/assets/stylesheets/spree/backend.css +1 -1
- data/app/controllers/spree/admin/adjustments_controller.rb +1 -7
- data/app/controllers/spree/admin/base_controller.rb +8 -2
- data/app/controllers/spree/admin/customer_returns_controller.rb +67 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
- data/app/controllers/spree/admin/images_controller.rb +1 -1
- data/app/controllers/spree/admin/log_entries_controller.rb +2 -2
- data/app/controllers/spree/admin/option_types_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
- data/app/controllers/spree/admin/orders_controller.rb +21 -10
- data/app/controllers/spree/admin/payment_methods_controller.rb +3 -3
- data/app/controllers/spree/admin/payments_controller.rb +6 -12
- data/app/controllers/spree/admin/product_properties_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +1 -1
- data/app/controllers/spree/admin/promotion_actions_controller.rb +2 -2
- data/app/controllers/spree/admin/promotion_categories_controller.rb +6 -0
- data/app/controllers/spree/admin/promotion_rules_controller.rb +2 -2
- data/app/controllers/spree/admin/promotions_controller.rb +2 -1
- data/app/controllers/spree/admin/refund_reasons_controller.rb +6 -0
- data/app/controllers/spree/admin/refunds_controller.rb +31 -0
- data/app/controllers/spree/admin/reimbursement_types_controller.rb +6 -0
- data/app/controllers/spree/admin/reimbursements_controller.rb +44 -0
- data/app/controllers/spree/admin/resource_controller.rb +2 -2
- data/app/controllers/spree/admin/return_authorization_reasons_controller.rb +6 -0
- data/app/controllers/spree/admin/return_authorizations_controller.rb +35 -5
- data/app/controllers/spree/admin/return_items_controller.rb +9 -0
- data/app/controllers/spree/admin/search_controller.rb +1 -1
- data/app/controllers/spree/admin/shipping_methods_controller.rb +3 -3
- data/app/controllers/spree/admin/states_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_locations_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +2 -2
- data/app/controllers/spree/admin/tax_rates_controller.rb +1 -1
- data/app/controllers/spree/admin/users_controller.rb +4 -4
- data/app/controllers/spree/admin/variants_controller.rb +2 -2
- data/app/controllers/spree/admin/zones_controller.rb +1 -1
- data/app/helpers/spree/admin/customer_returns_helper.rb +9 -0
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/reimbursement_type_helper.rb +9 -0
- data/app/helpers/spree/admin/reimbursements_helper.rb +14 -0
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +7 -3
- data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +36 -0
- data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +50 -0
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +43 -0
- data/app/views/spree/admin/customer_returns/edit.html.erb +65 -0
- data/app/views/spree/admin/customer_returns/index.html.erb +60 -0
- data/app/views/spree/admin/customer_returns/new.html.erb +60 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +6 -0
- data/app/views/spree/admin/images/_form.html.erb +6 -6
- data/app/views/spree/admin/log_entries/_credit_card.html.erb +4 -0
- data/app/views/spree/admin/log_entries/index.html.erb +2 -5
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -7
- data/app/views/spree/admin/option_types/edit.html.erb +9 -2
- data/app/views/spree/admin/orders/_add_line_item.html.erb +18 -0
- data/app/views/spree/admin/orders/_form.html.erb +7 -7
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +40 -0
- data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +5 -4
- data/app/views/spree/admin/orders/cart.html.erb +39 -0
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
- data/app/views/spree/admin/orders/edit.html.erb +2 -2
- data/app/views/spree/admin/orders/index.html.erb +8 -14
- data/app/views/spree/admin/payment_methods/_form.html.erb +7 -7
- data/app/views/spree/admin/payments/_list.html.erb +11 -3
- data/app/views/spree/admin/payments/index.html.erb +13 -1
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +4 -6
- data/app/views/spree/admin/products/_form.html.erb +20 -6
- data/app/views/spree/admin/products/new.html.erb +3 -3
- data/app/views/spree/admin/products/stock.html.erb +1 -1
- data/app/views/spree/admin/promotion_categories/_form.html.erb +10 -0
- data/app/views/spree/admin/promotion_categories/edit.html.erb +17 -0
- data/app/views/spree/admin/promotion_categories/index.html.erb +34 -0
- data/app/views/spree/admin/promotion_categories/new.html.erb +16 -0
- data/app/views/spree/admin/promotion_rules/create.js.erb +2 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +5 -0
- data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +7 -7
- data/app/views/spree/admin/promotions/index.html.erb +16 -6
- data/app/views/spree/admin/promotions/rules/_item_total.html.erb +4 -2
- data/app/views/spree/admin/promotions/rules/_one_use_per_user.html.erb +0 -0
- data/app/views/spree/admin/promotions/rules/_taxon.html.erb +9 -0
- data/app/views/spree/admin/prototypes/_form.html.erb +2 -2
- data/app/views/spree/admin/refund_reasons/edit.html.erb +4 -0
- data/app/views/spree/admin/refund_reasons/index.html.erb +5 -0
- data/app/views/spree/admin/refund_reasons/new.html.erb +4 -0
- data/app/views/spree/admin/refunds/edit.html.erb +31 -0
- data/app/views/spree/admin/refunds/new.html.erb +43 -0
- data/app/views/spree/admin/reimbursement_types/index.html.erb +33 -0
- data/app/views/spree/admin/reimbursements/edit.html.erb +108 -0
- data/app/views/spree/admin/reimbursements/index.html.erb +34 -0
- data/app/views/spree/admin/reimbursements/show.html.erb +94 -0
- data/app/views/spree/admin/return_authorization_reasons/edit.html.erb +4 -0
- data/app/views/spree/admin/return_authorization_reasons/index.html.erb +5 -0
- data/app/views/spree/admin/return_authorization_reasons/new.html.erb +4 -0
- data/app/views/spree/admin/return_authorizations/_form.html.erb +62 -50
- data/app/views/spree/admin/return_authorizations/edit.html.erb +6 -8
- data/app/views/spree/admin/return_authorizations/index.html.erb +3 -4
- data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
- data/app/views/spree/admin/shared/_configuration_menu.html.erb +5 -2
- data/app/views/spree/admin/shared/_destroy.js.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -2
- data/app/views/spree/admin/shared/_order_submenu.html.erb +17 -3
- data/app/views/spree/admin/shared/_order_summary.html.erb +7 -0
- data/app/views/spree/admin/shared/_product_tabs.html.erb +1 -0
- data/app/views/spree/admin/shared/_refunds.html.erb +32 -0
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +12 -12
- data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/named_types/_edit.html.erb +17 -0
- data/app/views/spree/admin/shared/named_types/_form.html.erb +16 -0
- data/app/views/spree/admin/shared/named_types/_index.html.erb +52 -0
- data/app/views/spree/admin/shared/named_types/_new.html.erb +16 -0
- data/app/views/spree/admin/shipping_categories/_form.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +8 -0
- data/app/views/spree/admin/stock_locations/_form.html.erb +77 -59
- data/app/views/spree/admin/stock_transfers/new.html.erb +2 -2
- data/app/views/spree/admin/tax_categories/_form.html.erb +9 -2
- data/app/views/spree/admin/tax_categories/index.html.erb +4 -1
- data/app/views/spree/admin/taxons/index.html.erb +4 -0
- data/app/views/spree/admin/trackers/_form.html.erb +4 -4
- data/app/views/spree/admin/users/_form.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +1 -1
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +49 -0
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -1
- data/app/views/spree/admin/variants/_split.js.erb +1 -1
- data/app/views/spree/admin/zones/_form.html.erb +1 -1
- data/config/initializers/assets.rb +1 -1
- data/config/routes.rb +22 -1
- metadata +62 -32
- data/app/controllers/spree/admin/inventory_units_controller.rb +0 -6
- data/app/controllers/spree/admin/line_items_controller.rb +0 -49
- data/app/controllers/spree/admin/overview_controller.rb +0 -11
- data/app/views/spree/admin/inventory_units/adjust.html.erb +0 -31
- data/app/views/spree/test_mailer/test_email.text.erb +0 -4
- data/config/locales/en.yml +0 -6
@@ -21,8 +21,11 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
.select2-search-choice-close {
|
24
|
-
|
24
|
+
@extend .fa;
|
25
|
+
@extend .fa-times;
|
26
|
+
margin-top: 2px;
|
25
27
|
font-size: 100% !important;
|
28
|
+
background-image: none !important;
|
26
29
|
}
|
27
30
|
}
|
28
31
|
|
@@ -173,7 +176,7 @@
|
|
173
176
|
background-image: none !important;
|
174
177
|
font-size: 85% !important;
|
175
178
|
@extend .fa;
|
176
|
-
@extend .fa-
|
179
|
+
@extend .fa-times;
|
177
180
|
margin-left: 2px;
|
178
181
|
color: $color-1;
|
179
182
|
&:before {
|
@@ -0,0 +1,24 @@
|
|
1
|
+
@import "spree/backend/globals/variables";
|
2
|
+
|
3
|
+
.return-items-table {
|
4
|
+
.refund-amount-input {
|
5
|
+
width: 80px;
|
6
|
+
}
|
7
|
+
.fa-thumbs-up {
|
8
|
+
margin-bottom: 10px;
|
9
|
+
}
|
10
|
+
.select2-container {
|
11
|
+
text-align: left;
|
12
|
+
max-width: 150px;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
.expedited-exchanges-warning {
|
16
|
+
display: none;
|
17
|
+
color: black;
|
18
|
+
padding: 15px;
|
19
|
+
margin: 10px 0;
|
20
|
+
font-weight: bold;
|
21
|
+
background-color: $color-6;
|
22
|
+
border-radius: 4px;
|
23
|
+
opacity: 0.6;
|
24
|
+
}
|
@@ -92,6 +92,14 @@ table {
|
|
92
92
|
background-color: $color-notice;
|
93
93
|
color: $color-1;
|
94
94
|
}
|
95
|
+
.fa-thumbs-up:hover {
|
96
|
+
background-color: $color-success;
|
97
|
+
color: $color-1;
|
98
|
+
}
|
99
|
+
.fa-thumbs-down:hover {
|
100
|
+
background-color: $color-error;
|
101
|
+
color: $color-1;
|
102
|
+
}
|
95
103
|
}
|
96
104
|
|
97
105
|
input[type="number"],
|
@@ -26,6 +26,7 @@
|
|
26
26
|
@import 'spree/backend/plugins/token-input';
|
27
27
|
@import 'spree/backend/plugins/jstree';
|
28
28
|
|
29
|
+
@import 'spree/backend/sections/adjustments_table';
|
29
30
|
@import 'spree/backend/sections/alerts';
|
30
31
|
@import 'spree/backend/sections/orders';
|
31
32
|
@import 'spree/backend/sections/overview';
|
@@ -33,6 +34,7 @@
|
|
33
34
|
@import 'spree/backend/sections/promotions';
|
34
35
|
@import 'spree/backend/sections/edit_checkouts';
|
35
36
|
@import 'spree/backend/sections/bulk_transfer';
|
37
|
+
@import 'spree/backend/sections/return_authorizations';
|
36
38
|
@import 'spree/backend/sections/tax_zones';
|
37
39
|
@import 'spree/backend/sections/log_entries';
|
38
40
|
@import 'spree/backend/sections/taxons';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
3
|
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
4
|
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
|
5
|
+
|
6
6
|
*= require jquery.alerts/jquery.alerts
|
7
7
|
*= require jquery.alerts/jquery.alerts.spree
|
8
8
|
*= require responsive-tables
|
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
destroy.after :update_totals
|
9
9
|
update.after :update_totals
|
10
10
|
|
11
|
-
|
11
|
+
skip_before_action :load_resource, only: [:toggle_state, :edit, :update, :destroy]
|
12
12
|
|
13
13
|
before_action :find_adjustment, only: [:destroy, :edit, :update]
|
14
14
|
|
@@ -27,12 +27,6 @@ module Spree
|
|
27
27
|
@order.reload.update!
|
28
28
|
end
|
29
29
|
|
30
|
-
# Override method used to create a new instance to correctly
|
31
|
-
# associate adjustment with order
|
32
|
-
def build_resource
|
33
|
-
parent.adjustments.build(order: parent)
|
34
|
-
end
|
35
|
-
|
36
30
|
end
|
37
31
|
end
|
38
32
|
end
|
@@ -7,8 +7,8 @@ module Spree
|
|
7
7
|
helper 'spree/admin/tables'
|
8
8
|
layout '/spree/layouts/admin'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
before_action :check_alerts
|
11
|
+
before_action :authorize_admin
|
12
12
|
|
13
13
|
protected
|
14
14
|
|
@@ -87,6 +87,12 @@ module Spree
|
|
87
87
|
Spree::Backend::Config[:locale]
|
88
88
|
end
|
89
89
|
|
90
|
+
def can_not_transition_without_customer_info
|
91
|
+
unless @order.billing_address.present?
|
92
|
+
flash[:notice] = Spree.t(:fill_in_customer_info)
|
93
|
+
redirect_to edit_admin_order_customer_url(@order)
|
94
|
+
end
|
95
|
+
end
|
90
96
|
end
|
91
97
|
end
|
92
98
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class CustomerReturnsController < ResourceController
|
4
|
+
belongs_to 'spree/order', find_by: :number
|
5
|
+
|
6
|
+
before_action :parent # ensure order gets loaded to support our pseudo parent-child relationship
|
7
|
+
before_action :load_form_data, only: [:new, :edit]
|
8
|
+
|
9
|
+
create.before :build_return_items_from_params
|
10
|
+
create.fails :load_form_data
|
11
|
+
|
12
|
+
def edit
|
13
|
+
@pending_return_items = @customer_return.return_items.select(&:pending?)
|
14
|
+
@accepted_return_items = @customer_return.return_items.select(&:accepted?)
|
15
|
+
@rejected_return_items = @customer_return.return_items.select(&:rejected?)
|
16
|
+
@manual_intervention_return_items = @customer_return.return_items.select(&:manual_intervention_required?)
|
17
|
+
@pending_reimbursements = @customer_return.reimbursements.select(&:pending?)
|
18
|
+
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def location_after_save
|
25
|
+
url_for([:edit, :admin, @order, @customer_return])
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_resource
|
29
|
+
Spree::CustomerReturn.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_resource
|
33
|
+
Spree::CustomerReturn.accessible_by(current_ability, :read).find(params[:id])
|
34
|
+
end
|
35
|
+
|
36
|
+
def collection
|
37
|
+
parent # trigger loading the order
|
38
|
+
@collection ||= Spree::ReturnItem
|
39
|
+
.accessible_by(current_ability, :read)
|
40
|
+
.where(inventory_unit_id: @order.inventory_units.pluck(:id))
|
41
|
+
.map(&:customer_return).uniq.compact
|
42
|
+
@customer_returns = @collection
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_form_data
|
46
|
+
return_items = @order.inventory_units.map(&:current_or_new_return_item).reject(&:customer_return_id)
|
47
|
+
@rma_return_items, @new_return_items = return_items.partition(&:return_authorization_id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def permitted_resource_params
|
51
|
+
@permitted_resource_params ||= params.require('customer_return').permit(permitted_customer_return_attributes)
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_return_items_from_params
|
55
|
+
return_items_params = permitted_resource_params.delete(:return_items_attributes).values
|
56
|
+
|
57
|
+
@customer_return.return_items = return_items_params.map do |item_params|
|
58
|
+
next unless item_params.delete('returned') == '1'
|
59
|
+
return_item = item_params[:id] ? Spree::ReturnItem.find(item_params[:id]) : Spree::ReturnItem.new
|
60
|
+
return_item.attributes = item_params
|
61
|
+
return_item
|
62
|
+
end.compact
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class LogEntriesController < Spree::Admin::BaseController
|
4
|
-
|
4
|
+
before_action :find_order_and_payment
|
5
5
|
|
6
6
|
def index
|
7
7
|
@log_entries = @payment.log_entries
|
@@ -16,4 +16,4 @@ module Spree
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
module Admin
|
3
3
|
module Orders
|
4
4
|
class CustomerDetailsController < Spree::Admin::BaseController
|
5
|
-
|
5
|
+
before_action :load_order
|
6
6
|
|
7
7
|
def show
|
8
8
|
edit
|
@@ -27,7 +27,7 @@ module Spree
|
|
27
27
|
|
28
28
|
@order.refresh_shipment_rates
|
29
29
|
flash[:success] = Spree.t('customer_details_updated')
|
30
|
-
redirect_to
|
30
|
+
redirect_to edit_admin_order_url(@order)
|
31
31
|
else
|
32
32
|
render :action => :edit
|
33
33
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class OrdersController < Spree::Admin::BaseController
|
4
|
-
|
5
|
-
|
4
|
+
before_action :initialize_order_events
|
5
|
+
before_action :load_order, only: [:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart]
|
6
6
|
|
7
7
|
respond_to :html
|
8
8
|
|
@@ -20,11 +20,11 @@ module Spree
|
|
20
20
|
|
21
21
|
params[:q].delete(:inventory_units_shipment_id_null) if params[:q][:inventory_units_shipment_id_null] == "0"
|
22
22
|
|
23
|
-
if params[:q][:created_at_gt].
|
23
|
+
if !params[:q][:created_at_gt].blank?
|
24
24
|
params[:q][:created_at_gt] = Time.zone.parse(params[:q][:created_at_gt]).beginning_of_day rescue ""
|
25
25
|
end
|
26
26
|
|
27
|
-
if params[:q][:created_at_lt].
|
27
|
+
if !params[:q][:created_at_lt].blank?
|
28
28
|
params[:q][:created_at_lt] = Time.zone.parse(params[:q][:created_at_lt]).end_of_day rescue ""
|
29
29
|
end
|
30
30
|
|
@@ -49,15 +49,26 @@ module Spree
|
|
49
49
|
|
50
50
|
def new
|
51
51
|
@order = Order.create(order_params)
|
52
|
-
redirect_to
|
52
|
+
redirect_to cart_admin_order_url(@order)
|
53
53
|
end
|
54
54
|
|
55
55
|
def edit
|
56
|
+
can_not_transition_without_customer_info
|
57
|
+
|
56
58
|
unless @order.completed?
|
57
59
|
@order.refresh_shipment_rates
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
def cart
|
64
|
+
unless @order.completed?
|
65
|
+
@order.refresh_shipment_rates
|
66
|
+
end
|
67
|
+
if @order.shipped_shipments.count > 0
|
68
|
+
redirect_to edit_admin_order_url(@order)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
61
72
|
def update
|
62
73
|
if @order.update_attributes(params[:order]) && @order.line_items.present?
|
63
74
|
@order.update!
|
@@ -73,7 +84,7 @@ module Spree
|
|
73
84
|
end
|
74
85
|
|
75
86
|
def cancel
|
76
|
-
@order.
|
87
|
+
@order.canceled_by(try_spree_current_user)
|
77
88
|
flash[:success] = Spree.t(:order_canceled)
|
78
89
|
redirect_to :back
|
79
90
|
end
|
@@ -98,16 +109,16 @@ module Spree
|
|
98
109
|
end
|
99
110
|
|
100
111
|
def open_adjustments
|
101
|
-
adjustments = @order.
|
102
|
-
adjustments.update_all(state
|
112
|
+
adjustments = @order.adjustments.where(:state => 'closed')
|
113
|
+
adjustments.update_all(:state => 'open')
|
103
114
|
flash[:success] = Spree.t(:all_adjustments_opened)
|
104
115
|
|
105
116
|
respond_with(@order) { |format| format.html { redirect_to :back } }
|
106
117
|
end
|
107
118
|
|
108
119
|
def close_adjustments
|
109
|
-
adjustments = @order.
|
110
|
-
adjustments.update_all(state
|
120
|
+
adjustments = @order.adjustments.where(:state => 'open')
|
121
|
+
adjustments.update_all(:state => 'closed')
|
111
122
|
flash[:success] = Spree.t(:all_adjustments_closed)
|
112
123
|
|
113
124
|
respond_with(@order) { |format| format.html { redirect_to :back } }
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class PaymentMethodsController < ResourceController
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
skip_before_action :load_resource, only: :create
|
5
|
+
before_action :load_data
|
6
|
+
before_action :validate_payment_method_provider, only: :create
|
7
7
|
|
8
8
|
respond_to :html
|
9
9
|
|
@@ -3,15 +3,16 @@ module Spree
|
|
3
3
|
class PaymentsController < Spree::Admin::BaseController
|
4
4
|
include Spree::Backend::Callbacks
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
before_action :load_order, only: [:create, :new, :index, :fire]
|
7
|
+
before_action :load_payment, except: [:create, :new, :index]
|
8
|
+
before_action :load_data
|
9
|
+
before_action :can_not_transition_without_customer_info
|
10
10
|
|
11
11
|
respond_to :html
|
12
12
|
|
13
13
|
def index
|
14
|
-
@payments = @order.payments
|
14
|
+
@payments = @order.payments.includes(:refunds => :reason)
|
15
|
+
@refunds = @payments.flat_map(&:refunds)
|
15
16
|
redirect_to new_admin_order_payment_url(@order) if @payments.empty?
|
16
17
|
end
|
17
18
|
|
@@ -84,13 +85,6 @@ module Spree
|
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
def can_transition_to_payment
|
88
|
-
unless @order.billing_address.present?
|
89
|
-
flash[:notice] = Spree.t(:fill_in_customer_info)
|
90
|
-
redirect_to edit_admin_order_customer_url(@order)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
88
|
def load_order
|
95
89
|
@order = Order.find_by_number!(params[:order_id])
|
96
90
|
authorize! action, @order
|
@@ -2,8 +2,8 @@ module Spree
|
|
2
2
|
module Admin
|
3
3
|
class ProductPropertiesController < ResourceController
|
4
4
|
belongs_to 'spree/product', :find_by => :slug
|
5
|
-
|
6
|
-
|
5
|
+
before_action :find_properties
|
6
|
+
before_action :setup_property, only: :index
|
7
7
|
|
8
8
|
private
|
9
9
|
def find_properties
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
class ProductsController < ResourceController
|
4
4
|
helper 'spree/products'
|
5
5
|
|
6
|
-
|
6
|
+
before_action :load_data, except: :index
|
7
7
|
create.before :create_before
|
8
8
|
update.before :update_before
|
9
9
|
helper_method :clone_object_url
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Spree::Admin::PromotionActionsController < Spree::Admin::BaseController
|
2
|
-
|
3
|
-
|
2
|
+
before_action :load_promotion, only: [:create, :destroy]
|
3
|
+
before_action :validate_promotion_action_type, only: :create
|
4
4
|
|
5
5
|
def create
|
6
6
|
@calculators = Spree::Promotion::Actions::CreateAdjustment.calculators
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class Spree::Admin::PromotionRulesController < Spree::Admin::BaseController
|
2
2
|
helper 'spree/promotion_rules'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
before_action :load_promotion, only: [:create, :destroy]
|
5
|
+
before_action :validate_promotion_rule_type, only: :create
|
6
6
|
|
7
7
|
def create
|
8
8
|
# Remove type key from this hash so that we don't attempt
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class PromotionsController < ResourceController
|
4
|
-
|
4
|
+
before_action :load_data
|
5
5
|
|
6
6
|
helper 'spree/promotion_rules'
|
7
7
|
|
@@ -12,6 +12,7 @@ module Spree
|
|
12
12
|
|
13
13
|
def load_data
|
14
14
|
@calculators = Rails.application.config.spree.calculators.promotion_actions_create_adjustments
|
15
|
+
@promotion_categories = Spree::PromotionCategory.order(:name)
|
15
16
|
end
|
16
17
|
|
17
18
|
def collection
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class RefundsController < ResourceController
|
4
|
+
belongs_to 'spree/payment'
|
5
|
+
before_action :load_order
|
6
|
+
|
7
|
+
helper_method :refund_reasons
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def location_after_save
|
12
|
+
admin_order_payments_path(@payment.order)
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_order
|
16
|
+
# the spree/admin/shared/order_tabs partial expects the @order instance variable to be set
|
17
|
+
@order = @payment.order if @payment
|
18
|
+
end
|
19
|
+
|
20
|
+
def refund_reasons
|
21
|
+
@refund_reasons ||= RefundReason.active.all
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_resource
|
25
|
+
super.tap do |refund|
|
26
|
+
refund.amount = refund.payment.credit_allowed
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class ReimbursementsController < ResourceController
|
4
|
+
belongs_to 'spree/order', find_by: :number
|
5
|
+
|
6
|
+
before_action :load_simulated_refunds, only: :edit
|
7
|
+
|
8
|
+
def perform
|
9
|
+
@reimbursement.perform!
|
10
|
+
redirect_to location_after_save
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build_resource
|
16
|
+
if params[:build_from_customer_return_id].present?
|
17
|
+
customer_return = CustomerReturn.find(params[:build_from_customer_return_id])
|
18
|
+
|
19
|
+
Reimbursement.build_from_customer_return(customer_return)
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def location_after_save
|
26
|
+
if @reimbursement.reimbursed?
|
27
|
+
admin_order_reimbursement_path(parent, @reimbursement)
|
28
|
+
else
|
29
|
+
edit_admin_order_reimbursement_path(parent, @reimbursement)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_simulated_refunds
|
34
|
+
@reimbursement_objects = @reimbursement.simulate
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO: Remove this when https://github.com/spree/spree/pull/5158 gets merged in
|
38
|
+
def permitted_resource_params
|
39
|
+
params[object_name].present? ? super : ActionController::Parameters.new
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -2,7 +2,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
2
2
|
include Spree::Backend::Callbacks
|
3
3
|
|
4
4
|
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
|
5
|
-
|
5
|
+
before_action :load_resource, except: :update_positions
|
6
6
|
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
|
7
7
|
|
8
8
|
respond_to :html
|
@@ -239,7 +239,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
239
239
|
#
|
240
240
|
# Other controllers can, should, override it to set custom logic
|
241
241
|
def permitted_resource_params
|
242
|
-
params.require(object_name).permit!
|
242
|
+
params[object_name].present? ? params.require(object_name).permit! : ActionController::Parameters.new
|
243
243
|
end
|
244
244
|
|
245
245
|
def collection_actions
|