solidus_core 2.7.4 → 2.8.0
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.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/app/assets/images/logo/solidus.svg +18 -0
- data/app/assets/javascripts/spree.js.erb +2 -2
- data/app/helpers/spree/base_helper.rb +1 -7
- data/app/helpers/spree/taxons_helper.rb +2 -2
- data/app/mailers/spree/carton_mailer.rb +4 -4
- data/app/models/spree/calculator/flat_percent_item_total.rb +4 -1
- data/app/models/spree/calculator/shipping/flat_percent_item_total.rb +5 -3
- data/app/models/spree/calculator/tiered_percent.rb +2 -1
- data/app/models/spree/country.rb +8 -0
- data/app/models/spree/fulfilment_changer.rb +9 -1
- data/app/models/spree/gallery/product_gallery.rb +18 -0
- data/app/models/spree/gallery/variant_gallery.rb +21 -0
- data/app/models/spree/image.rb +11 -1
- data/app/models/spree/inventory_unit.rb +8 -0
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/order.rb +0 -4
- data/app/models/spree/order_cancellations.rb +31 -10
- data/app/models/spree/order_contents.rb +1 -5
- data/app/models/spree/order_inventory.rb +5 -4
- data/app/models/spree/product.rb +9 -0
- data/app/models/spree/product/scopes.rb +3 -4
- data/app/models/spree/promotion.rb +1 -6
- data/app/models/spree/promotion_handler/coupon.rb +15 -0
- data/app/models/spree/reimbursement.rb +21 -6
- data/app/models/spree/reimbursement_performer.rb +12 -6
- data/app/models/spree/reimbursement_type.rb +1 -1
- data/app/models/spree/reimbursement_type/credit.rb +5 -2
- data/app/models/spree/reimbursement_type/exchange.rb +1 -1
- data/app/models/spree/reimbursement_type/original_payment.rb +1 -1
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +6 -6
- data/app/models/spree/reimbursement_type/store_credit.rb +18 -3
- data/app/models/spree/shipment.rb +11 -11
- data/app/models/spree/stock/allocator/base.rb +19 -0
- data/app/models/spree/stock/allocator/on_hand_first.rb +42 -0
- data/app/models/spree/stock/content_item.rb +1 -1
- data/app/models/spree/stock/inventory_units_finalizer.rb +47 -0
- data/app/models/spree/stock/location_sorter/base.rb +38 -0
- data/app/models/spree/stock/location_sorter/default_first.rb +15 -0
- data/app/models/spree/stock/location_sorter/unsorted.rb +14 -0
- data/app/models/spree/stock/simple_coordinator.rb +24 -10
- data/app/models/spree/stock_location.rb +2 -0
- data/app/models/spree/store_credit.rb +4 -12
- data/app/models/spree/store_credit_event.rb +2 -2
- data/app/models/spree/store_credit_reason.rb +11 -0
- data/app/models/spree/taxon.rb +8 -3
- data/app/models/spree/unit_cancel.rb +3 -0
- data/app/models/spree/variant.rb +18 -7
- data/config/initializers/money.rb +5 -0
- data/config/locales/en.yml +661 -527
- data/db/default/spree/store_credit.rb +1 -1
- data/db/default/spree/zones.rb +2 -2
- data/db/migrate/20180710170104_create_spree_store_credit_reasons_table.rb +42 -0
- data/db/migrate/20190106184413_remove_code_from_spree_promotions.rb +41 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +0 -3
- data/lib/generators/spree/install/install_generator.rb +2 -2
- data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +2 -2
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/solidus/migrations/promotions_with_code_handlers.rb +66 -0
- data/lib/spree/app_configuration.rb +20 -4
- data/lib/spree/core/controller_helpers/common.rb +1 -1
- data/lib/spree/core/stock_configuration.rb +12 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/i18n.rb +4 -0
- data/lib/spree/money.rb +13 -11
- data/lib/spree/permission_sets.rb +0 -1
- data/lib/spree/permission_sets/promotion_management.rb +1 -0
- data/lib/spree/testing_support/dummy_app.rb +13 -2
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +5 -5
- data/lib/spree/testing_support/factories/{store_credit_update_reason_factory.rb → store_credit_reason_factory.rb} +1 -1
- data/lib/spree/testing_support/partial_double_verification.rb +13 -0
- data/lib/spree/testing_support/shared_examples/gallery.rb +18 -0
- data/spec/helpers/products_helper_spec.rb +10 -8
- data/spec/helpers/taxons_helper_spec.rb +3 -1
- data/spec/lib/i18n_spec.rb +5 -0
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +6 -2
- data/spec/lib/spree/core/stock_configuration_spec.rb +19 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_reason_factory_spec.rb +14 -0
- data/spec/lib/spree/money_spec.rb +12 -13
- data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +136 -0
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +10 -1
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +18 -6
- data/spec/models/spree/calculator/tiered_percent_spec.rb +7 -1
- data/spec/models/spree/country_spec.rb +76 -0
- data/spec/models/spree/customer_return_spec.rb +2 -1
- data/spec/models/spree/fulfilment_changer_spec.rb +33 -0
- data/spec/models/spree/gallery/product_gallery_spec.rb +21 -0
- data/spec/models/spree/gallery/variant_gallery_spec.rb +21 -0
- data/spec/models/spree/inventory_unit_spec.rb +1 -4
- data/spec/models/spree/order/checkout_spec.rb +6 -6
- data/spec/models/spree/order/finalizing_spec.rb +1 -20
- data/spec/models/spree/order/outstanding_balance_integration_spec.rb +2 -1
- data/spec/models/spree/order/updating_spec.rb +1 -1
- data/spec/models/spree/order_cancellations_spec.rb +55 -14
- data/spec/models/spree/order_inventory_spec.rb +12 -5
- data/spec/models/spree/order_merger_spec.rb +6 -3
- data/spec/models/spree/order_spec.rb +3 -7
- data/spec/models/spree/order_updater_spec.rb +3 -8
- data/spec/models/spree/payment/cancellation_spec.rb +4 -3
- data/spec/models/spree/payment_spec.rb +1 -17
- data/spec/models/spree/permission_sets/promotion_management_spec.rb +2 -0
- data/spec/models/spree/product_spec.rb +10 -1
- data/spec/models/spree/promotion_handler/coupon_spec.rb +62 -8
- data/spec/models/spree/promotion_spec.rb +24 -10
- data/spec/models/spree/refund_spec.rb +2 -1
- data/spec/models/spree/reimbursement_performer_spec.rb +5 -4
- data/spec/models/spree/reimbursement_spec.rb +26 -2
- data/spec/models/spree/reimbursement_type/credit_spec.rb +2 -1
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +2 -1
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +2 -1
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +14 -2
- data/spec/models/spree/return_item_spec.rb +1 -1
- data/spec/models/spree/shipment_spec.rb +20 -13
- data/spec/models/spree/shipping_calculator_spec.rb +13 -3
- data/spec/models/spree/stock/allocator/on_hand_first_spec.rb +146 -0
- data/spec/models/spree/stock/content_item_spec.rb +70 -0
- data/spec/models/spree/stock/estimator_spec.rb +5 -2
- data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +34 -0
- data/spec/models/spree/stock/location_sorter/default_first_spec.rb +20 -0
- data/spec/models/spree/stock/location_sorter/unsorted_spec.rb +19 -0
- data/spec/models/spree/stock/simple_coordinator_spec.rb +17 -0
- data/spec/models/spree/store_credit_event_spec.rb +12 -12
- data/spec/models/spree/store_credit_spec.rb +2 -2
- data/spec/models/spree/unit_cancel_spec.rb +20 -1
- data/spec/models/spree/variant_spec.rb +46 -24
- data/spec/spec_helper.rb +1 -0
- metadata +30 -9
- data/.yardopts +0 -1
- data/app/models/spree/store_credit_update_reason.rb +0 -4
- data/lib/spree/permission_sets/report_display.rb +0 -11
- data/spec/lib/spree/core/testing_support/factories/store_credit_update_reason_factory_spec.rb +0 -14
- data/spec/models/spree/permission_sets/report_display_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfc7af157e2912ba67be54f77a8bbcc9c053609b8aac47a95cf94f8411023a5
|
4
|
+
data.tar.gz: 2c05f398e332a2a57e031b3009b0ca06508b4209760b145423716300bedad757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc600844d181e8d722f84c456e673170287ad5c1eb6a983808fc29af90459b0cb5835e306c16d7ba8ef2c4123ac6bbd7d1485179656b905696f05c1076ee0835
|
7
|
+
data.tar.gz: 79493de4d9e86c27260795466c63f314d82fce1b92da34ab56b6b48c137612ec7f24ad408a45d0790f09274e1cc1cea7cb8ff0abb987f33f609ddbb95bbc1354
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Summary
|
2
2
|
------
|
3
|
-
Solidus Core provides the essential
|
3
|
+
Solidus Core provides the essential ecommerce data models upon which the
|
4
4
|
Solidus system depends.
|
5
5
|
|
6
|
-
Core
|
6
|
+
Core models
|
7
7
|
-----------
|
8
8
|
Solidus implements over 200 [models](https://github.com/solidusio/solidus/tree/master/core/app/models/spree),
|
9
9
|
and thus a deep inspection of each in this README would be overkill. Instead,
|
@@ -15,26 +15,26 @@ Currently, these models remain in the Spree namespace as part of the legacy of
|
|
15
15
|
The documentation of Solidus Core is still in progress. Contributions following
|
16
16
|
this form are welcome and encouraged!
|
17
17
|
|
18
|
-
* [
|
19
|
-
* [
|
20
|
-
* [
|
21
|
-
* [
|
22
|
-
* [
|
18
|
+
* [Order sub-system](#order-sub-system)
|
19
|
+
* [User sub-system](#user-sub-system)
|
20
|
+
* [Payment sub-system](#payment-sub-system)
|
21
|
+
* [Inventory sub-system](#inventory-sub-system)
|
22
|
+
* [Shipments sub-system](#shipments-sub-system)
|
23
23
|
|
24
|
-
##
|
24
|
+
## Order sub-system
|
25
25
|
* `Spree::Store` - Records store specific configuration such as store name and URL.
|
26
26
|
* `Spree::Order` - The customers cart until completed, then acts as
|
27
|
-
|
27
|
+
permanent record of the transaction.
|
28
28
|
* `Spree::LineItem` - Variants placed in the order at a particular price.
|
29
29
|
|
30
|
-
##
|
30
|
+
## User sub-system
|
31
31
|
* `Spree::LegacyUser` - Default implementation of User.
|
32
32
|
* `Spree::UserClassHandle` - Configuration point for User model implementation.
|
33
33
|
* [solidus_auth_devise](https://github.com/solidusio/solidus_auth_devise) -
|
34
|
-
An
|
34
|
+
An official, more robust implementation of a User class with Devise
|
35
35
|
integration.
|
36
36
|
|
37
|
-
##
|
37
|
+
## Payment sub-system
|
38
38
|
* `Spree::Payment` - Manage and process a payment for an order, from a specific
|
39
39
|
source (e.g. `Spree::CreditCard`) using a specific payment method (e.g
|
40
40
|
`Solidus::Gateway::Braintree`).
|
@@ -43,7 +43,7 @@ source (e.g. `Spree::CreditCard`) using a specific payment method (e.g
|
|
43
43
|
See https://github.com/solidusio/solidus_gateway/ for officially supported payment method implementations.
|
44
44
|
* `Spree::CreditCard` - The `source` of a `Spree::Payment` using `Spree::PaymentMethod::CreditCard` as payment method.
|
45
45
|
|
46
|
-
##
|
46
|
+
## Inventory sub-system
|
47
47
|
* `Spree::ReturnAuthorization` - Models the return of Inventory Units to
|
48
48
|
a Stock Location for an Order.
|
49
49
|
* `Spree::StockLocation` - Records the name and addresses from which stock items
|
@@ -54,14 +54,16 @@ shipment and which method has been selected to deliver the shipment.
|
|
54
54
|
* `Spree::ShippingMethod` - Represents a means of having a shipment delivered,
|
55
55
|
such as FedEx or UPS.
|
56
56
|
|
57
|
-
##
|
57
|
+
## Shipments sub-system
|
58
58
|
* `Spree::Shipment` - An order's planned shipments including
|
59
59
|
tracking and cost. Shipments are fulfilled from Stock Locations.
|
60
60
|
|
61
|
-
Developer
|
61
|
+
Developer notes
|
62
62
|
---------------
|
63
63
|
## Testing
|
64
64
|
|
65
|
-
Run the tests
|
65
|
+
Run the tests:
|
66
66
|
|
67
|
-
|
67
|
+
```bash
|
68
|
+
bundle exec rspec
|
69
|
+
```
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="153px" height="52px" viewBox="0 0 153 52" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<!-- Generator: Sketch 52.5 (67469) - http://www.bohemiancoding.com/sketch -->
|
4
|
+
<title>solidus</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
7
|
+
<g id="solidus" transform="translate(7.000000, 9.000000)" fill="#000000">
|
8
|
+
<path d="M3.36538462,26.6135458 C5.12019231,28.501992 8.00480769,29.9601594 10.5528846,29.9601594 C13.3894231,29.9601594 15.0961538,28.3585657 15.0961538,27.0916335 C15.0961538,25.5856574 13.9182692,24.7968127 12.1153846,24.4621514 L9.32692308,23.936255 C2.88461538,22.7410359 1.08173077,20.685259 1.08173077,17.4342629 C1.08173077,13.5856574 4.35096154,10 10.0721154,10 C13.2451923,10 16.0336538,10.9322709 19.1586538,13.1553785 L16.3461538,16.5976096 C13.9423077,14.5657371 11.8028846,14.063745 10.1923077,14.063745 C8.07692308,14.063745 5.98557692,15.0916335 5.98557692,16.9322709 C5.98557692,18.2948207 7.06730769,19.0119522 8.96634615,19.3227092 L13.9423077,20.2549801 C18.0048077,20.9960159 20,22.9322709 20,26.3266932 C20,29.6733068 17.2596154,34 10.3125,34 C6.44230769,34 3.125,32.6374502 0,30.0079681 L3.36538462,26.6135458 Z" id="Path"></path>
|
9
|
+
<path d="M34.5,10 C42.4047619,10 47,15.988024 47,22 C47,28.011976 42.4047619,34 34.5,34 C26.5952381,34 22,28.011976 22,22 C22,15.988024 26.5714286,10 34.5,10 M34.5,29.4251497 C38.7619048,29.4251497 41.8571429,26.1197605 41.8571429,22.0239521 C41.8571429,17.9281437 38.7619048,14.6227545 34.5,14.6227545 C30.2380952,14.6227545 27.1428571,17.9281437 27.1428571,22.0239521 C27.1428571,26.1197605 30.2380952,29.4251497 34.5,29.4251497" id="Shape" fill-rule="nonzero"></path>
|
10
|
+
<path d="M64.5,4 C65.8834951,4 67,5.11650485 67,6.5 C67,7.88349515 65.8834951,9 64.5,9 C63.1165049,9 62,7.88349515 62,6.5 C62,5.11650485 63.1165049,4 64.5,4" id="Path"></path>
|
11
|
+
<rect id="Rectangle" x="62" y="14" width="5" height="20"></rect>
|
12
|
+
<path d="M89.1428571,4 L89.1428571,12.5273159 C87.1428571,11.0783848 84.5714286,10.1995249 81.5,10.1995249 C73.5952381,10.1995249 69,16.1377672 69,22.0997625 C69,28.0617577 73.5952381,34 81.5,34 C84.5714286,34 87.1428571,33.0973872 89.1428571,31.672209 L89.1428571,34 L94,34 L94,4 L89.1428571,4 Z M81.5,29.4394299 C77.2380952,29.4394299 74.1428571,26.1615202 74.1428571,22.0997625 C74.1428571,18.0380048 77.2380952,14.760095 81.5,14.760095 C85.7619048,14.760095 88.8571429,18.0380048 88.8571429,22.0997625 C88.8571429,26.1615202 85.7619048,29.4394299 81.5,29.4394299 Z" id="Shape" fill-rule="nonzero"></path>
|
13
|
+
<path d="M97.0482759,10 L101.972414,10 L101.972414,23.3413174 C101.972414,26.6946108 104.434483,29.0898204 107.524138,29.0898204 C110.613793,29.0898204 113.075862,26.6946108 113.075862,23.3413174 L113.075862,10 L118,10 L118,23.7724551 C118,30.1676647 112.97931,34 107.5,34 C102.044828,34 97,30.1916168 97,23.7724551 L97,10 L97.0482759,10 Z" id="Path"></path>
|
14
|
+
<path d="M122.365385,26.5896414 C124.120192,28.4780876 127.004808,29.936255 129.552885,29.936255 C132.389423,29.936255 134.096154,28.3346614 134.096154,27.0677291 C134.096154,25.561753 132.918269,24.7729084 131.115385,24.438247 L128.326923,23.9123506 C121.908654,22.7410359 120.105769,20.6613546 120.105769,17.4342629 C120.105769,13.5856574 123.375,10 129.096154,10 C132.269231,10 135.057692,10.9322709 138.182692,13.1553785 L135.370192,16.5976096 C132.966346,14.5657371 130.826923,14.063745 129.216346,14.063745 C127.100962,14.063745 125.009615,15.0916335 125.009615,16.9322709 C125.009615,18.2948207 126.091346,19.0119522 127.990385,19.3227092 L132.942308,20.2549801 C137.004808,20.9960159 139,22.9322709 139,26.3266932 C139,29.6733068 136.259615,34 129.3125,34 C125.442308,34 122.125,32.6374502 119,30.0079681 L122.365385,26.5896414 Z" id="Path"></path>
|
15
|
+
<path d="M56.3986486,28.6315789 C55.0506757,27.8442105 54.5067568,26.9614035 54.4358108,24.6708772 L54.4358108,8.87578947 C54.4358108,4.1277193 52.1182432,2.40982456 47.1283784,0 L45,3.84140351 L47.6013514,5.3445614 C48.9493243,6.13192982 49.4932432,7.01473684 49.5641892,9.30526316 L49.5641892,25.1242105 C49.5641892,29.8722807 51.8817568,31.5901754 56.8716216,34 L59,30.1585965 L56.3986486,28.6315789 Z" id="Path"></path>
|
16
|
+
</g>
|
17
|
+
</g>
|
18
|
+
</svg>
|
@@ -45,7 +45,7 @@ Spree.ajax = function(url, options) {
|
|
45
45
|
options = options || {};
|
46
46
|
options = $.extend(options, {
|
47
47
|
headers: {
|
48
|
-
|
48
|
+
'Authorization': 'Bearer ' + Spree.api_key
|
49
49
|
}
|
50
50
|
});
|
51
51
|
return $.ajax(url, options);
|
@@ -54,7 +54,7 @@ Spree.ajax = function(url, options) {
|
|
54
54
|
Spree.routes = {
|
55
55
|
states_search: Spree.pathFor('api/states'),
|
56
56
|
apply_coupon_code: function(order_id) {
|
57
|
-
return Spree.pathFor("api/orders/" + order_id + "/
|
57
|
+
return Spree.pathFor("api/orders/" + order_id + "/coupon_codes");
|
58
58
|
}
|
59
59
|
};
|
60
60
|
|
@@ -111,13 +111,7 @@ module Spree
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def available_countries(restrict_to_zone: Spree::Config[:checkout_zone])
|
114
|
-
|
115
|
-
|
116
|
-
if checkout_zone && checkout_zone.kind == 'country'
|
117
|
-
countries = checkout_zone.country_list
|
118
|
-
else
|
119
|
-
countries = Country.all
|
120
|
-
end
|
114
|
+
countries = Spree::Country.available(restrict_to_zone: restrict_to_zone)
|
121
115
|
|
122
116
|
country_names = Carmen::Country.all.map do |country|
|
123
117
|
[country.code, country.name]
|
@@ -7,12 +7,12 @@ module Spree
|
|
7
7
|
# to show the most popular products for a particular taxon (that is an exercise left to the developer.)
|
8
8
|
def taxon_preview(taxon, max = 4)
|
9
9
|
price_scope = Spree::Price.where(current_pricing_options.search_arguments)
|
10
|
-
products = taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT spree_products.*, spree_products_taxons.position").limit(max)
|
10
|
+
products = taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT (spree_products.id), spree_products.*, spree_products_taxons.position").limit(max)
|
11
11
|
if products.size < max
|
12
12
|
products_arel = Spree::Product.arel_table
|
13
13
|
taxon.descendants.each do |descendent_taxon|
|
14
14
|
to_get = max - products.length
|
15
|
-
products += descendent_taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT spree_products.*, spree_products_taxons.position").where(products_arel[:id].not_in(products.map(&:id))).limit(to_get)
|
15
|
+
products += descendent_taxon.active_products.joins(:prices).merge(price_scope).select("DISTINCT (spree_products.id), spree_products.*, spree_products_taxons.position").where(products_arel[:id].not_in(products.map(&:id))).limit(to_get)
|
16
16
|
break if products.size >= max
|
17
17
|
end
|
18
18
|
end
|
@@ -6,10 +6,10 @@ module Spree
|
|
6
6
|
# shipped. If a carton contains items from multiple orders then this will be
|
7
7
|
# called with that carton one time for each order.
|
8
8
|
#
|
9
|
-
# @
|
10
|
-
# @
|
11
|
-
# @
|
12
|
-
#
|
9
|
+
# @option options carton [Spree::Carton] the shipped carton
|
10
|
+
# @option options order [Spree::Order] one of the orders with items in the carton
|
11
|
+
# @option options resend [Boolean] indicates whether the email is a 'resend' (e.g.
|
12
|
+
# triggered by the admin "resend" button)
|
13
13
|
# @return [Mail::Message]
|
14
14
|
#
|
15
15
|
# Note: The signature of this method has changed. The new (non-deprecated)
|
@@ -7,7 +7,10 @@ module Spree
|
|
7
7
|
preference :flat_percent, :decimal, default: 0
|
8
8
|
|
9
9
|
def compute(object)
|
10
|
-
|
10
|
+
order = object.is_a?(Order) ? object : object.order
|
11
|
+
preferred_currency = order.currency
|
12
|
+
currency_exponent = ::Money::Currency.find(preferred_currency).exponent
|
13
|
+
computed_amount = (object.amount * preferred_flat_percent / 100).round(currency_exponent)
|
11
14
|
|
12
15
|
# We don't want to cause the promotion adjustments to push the order into a negative total.
|
13
16
|
if computed_amount > object.amount
|
@@ -9,12 +9,14 @@ module Spree
|
|
9
9
|
preference :flat_percent, :decimal, default: 0
|
10
10
|
|
11
11
|
def compute_package(package)
|
12
|
-
compute_from_price(total(package.contents))
|
12
|
+
value = compute_from_price(total(package.contents))
|
13
|
+
preferred_currency = package.order.currency
|
14
|
+
currency_exponent = ::Money::Currency.find(preferred_currency).exponent
|
15
|
+
value.round(currency_exponent)
|
13
16
|
end
|
14
17
|
|
15
18
|
def compute_from_price(price)
|
16
|
-
|
17
|
-
value.round(2)
|
19
|
+
price * BigDecimal(preferred_flat_percent.to_s) / 100.0
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -31,7 +31,8 @@ module Spree
|
|
31
31
|
end
|
32
32
|
|
33
33
|
if preferred_currency.casecmp(order.currency).zero?
|
34
|
-
|
34
|
+
currency_exponent = ::Money::Currency.find(preferred_currency).exponent
|
35
|
+
(object.amount * (percent || preferred_base_percent) / 100).round(currency_exponent)
|
35
36
|
else
|
36
37
|
0
|
37
38
|
end
|
data/app/models/spree/country.rb
CHANGED
@@ -17,6 +17,14 @@ module Spree
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.available(restrict_to_zone: Spree::Config[:checkout_zone])
|
21
|
+
checkout_zone = Zone.find_by(name: restrict_to_zone)
|
22
|
+
|
23
|
+
return checkout_zone.country_list if checkout_zone.try(:kind) == 'country'
|
24
|
+
|
25
|
+
all
|
26
|
+
end
|
27
|
+
|
20
28
|
def <=>(other)
|
21
29
|
name <=> other.name
|
22
30
|
end
|
@@ -46,7 +46,7 @@ module Spree
|
|
46
46
|
desired_shipment.save! if desired_shipment.new_record?
|
47
47
|
|
48
48
|
# Retrieve how many on hand items we can take from desired stock location
|
49
|
-
available_quantity = [desired_shipment.stock_location.count_on_hand(variant),
|
49
|
+
available_quantity = [desired_shipment.stock_location.count_on_hand(variant), default_on_hand_quantity].max
|
50
50
|
|
51
51
|
new_on_hand_quantity = [available_quantity, quantity].min
|
52
52
|
unstock_quantity = desired_shipment.stock_location.backorderable?(variant) ? quantity : new_on_hand_quantity
|
@@ -114,6 +114,14 @@ module Spree
|
|
114
114
|
current_shipment.order.completed? && current_stock_location != desired_stock_location
|
115
115
|
end
|
116
116
|
|
117
|
+
def default_on_hand_quantity
|
118
|
+
if current_stock_location != desired_stock_location
|
119
|
+
0
|
120
|
+
else
|
121
|
+
current_shipment.inventory_units.where(variant: variant).on_hand.count
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
117
125
|
def current_shipment_not_already_shipped
|
118
126
|
if current_shipment.shipped?
|
119
127
|
errors.add(:current_shipment, :has_already_been_shipped)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Gallery
|
5
|
+
class ProductGallery
|
6
|
+
def initialize(product)
|
7
|
+
@product = product
|
8
|
+
end
|
9
|
+
|
10
|
+
# A list of all images associated with this gallery
|
11
|
+
#
|
12
|
+
# @return [Enumerable<Spree::Image>] all images in the gallery
|
13
|
+
def images
|
14
|
+
@images ||= @product.variant_images
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module Gallery
|
5
|
+
class VariantGallery
|
6
|
+
def initialize(variant)
|
7
|
+
@variant = variant
|
8
|
+
end
|
9
|
+
|
10
|
+
# A list of all images associated with this gallery
|
11
|
+
#
|
12
|
+
# @return [Enumerable<Spree::Image>] all images in the gallery
|
13
|
+
def images
|
14
|
+
@images ||=
|
15
|
+
@variant.images.presence ||
|
16
|
+
(!@variant.is_master? && @variant.product.master.images).presence ||
|
17
|
+
Spree::Image.none
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/app/models/spree/image.rb
CHANGED
@@ -19,11 +19,21 @@ module Spree
|
|
19
19
|
# we need to look at the write-queue for images which have not been saved yet
|
20
20
|
after_post_process :find_dimensions, if: :valid?
|
21
21
|
|
22
|
-
# used by admin products autocomplete
|
23
22
|
def mini_url
|
23
|
+
Spree::Deprecation.warn(
|
24
|
+
'Spree::Image#mini_url is DEPRECATED. Use Spree::Image#url(:mini) instead.'
|
25
|
+
)
|
24
26
|
attachment.url(:mini, false)
|
25
27
|
end
|
26
28
|
|
29
|
+
def url(size)
|
30
|
+
attachment.url(size)
|
31
|
+
end
|
32
|
+
|
33
|
+
def filename
|
34
|
+
attachment_file_name
|
35
|
+
end
|
36
|
+
|
27
37
|
def find_dimensions
|
28
38
|
temporary = attachment.queued_for_write[:original]
|
29
39
|
filename = temporary.path unless temporary.nil?
|
@@ -81,9 +81,17 @@ module Spree
|
|
81
81
|
|
82
82
|
# Updates the given inventory units to not be pending.
|
83
83
|
#
|
84
|
+
# @deprecated do not use this, use
|
85
|
+
# Spree::Stock::InventoryUnitsFinalizer.new(inventory_units).run!
|
84
86
|
# @param inventory_units [<Spree::InventoryUnit>] the inventory to be
|
85
87
|
# finalized
|
86
88
|
def self.finalize_units!(inventory_units)
|
89
|
+
Spree::Deprecation.warn(
|
90
|
+
"inventory_units.finalize_units!(inventory_units) is deprecated. Please
|
91
|
+
use Spree::Stock::InventoryUnitsFinalizer.new(inventory_units).run!",
|
92
|
+
caller
|
93
|
+
)
|
94
|
+
|
87
95
|
inventory_units.map do |iu|
|
88
96
|
iu.update_columns(
|
89
97
|
pending: false,
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
# Variants placed in the Order at a particular price.
|
5
5
|
#
|
6
6
|
# `Spree::LineItem` is an ActiveRecord model which records which `Spree::Variant`
|
7
|
-
# a customer has chosen to place in their order. It also acts as the
|
7
|
+
# a customer has chosen to place in their order. It also acts as the permanent
|
8
8
|
# record of the customer's order by recording relevant price, taxation, and inventory
|
9
9
|
# concerns. Line items can also have adjustments placed on them as part of the
|
10
10
|
# promotion system.
|
data/app/models/spree/order.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spree/order/checkout'
|
4
|
-
require 'spree/order/number_generator'
|
5
|
-
|
6
3
|
module Spree
|
7
4
|
# The customers cart until completed, then acts as permanent record of the transaction.
|
8
5
|
#
|
@@ -138,7 +135,6 @@ module Spree
|
|
138
135
|
find_by! number: value
|
139
136
|
end
|
140
137
|
|
141
|
-
delegate :update_totals, :persist_totals, to: :updater
|
142
138
|
delegate :firstname, :lastname, to: :bill_address, prefix: true, allow_nil: true
|
143
139
|
alias_method :billing_firstname, :bill_address_firstname
|
144
140
|
alias_method :billing_lastname, :bill_address_lastname
|
@@ -23,10 +23,16 @@ class Spree::OrderCancellations
|
|
23
23
|
# @api public
|
24
24
|
#
|
25
25
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be short shipped
|
26
|
-
# @param [
|
26
|
+
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is short shipping the inventory unit
|
27
|
+
# @param [Spree.user_class] created_by the system or person that is short shipping the inventory unit
|
27
28
|
#
|
28
29
|
# @return [Array<UnitCancel>] the units that have been canceled due to short shipping
|
29
|
-
def short_ship(inventory_units, whodunnit: nil)
|
30
|
+
def short_ship(inventory_units, whodunnit: nil, created_by: nil)
|
31
|
+
if whodunnit
|
32
|
+
created_by ||= whodunnit
|
33
|
+
Spree::Deprecation.warn("Calling #short_ship on #{self} with whodunnit is deprecated, use created_by instead")
|
34
|
+
end
|
35
|
+
|
30
36
|
if inventory_units.map(&:order_id).uniq != [@order.id]
|
31
37
|
raise ArgumentError, "Not all inventory units belong to this order"
|
32
38
|
end
|
@@ -36,7 +42,7 @@ class Spree::OrderCancellations
|
|
36
42
|
Spree::OrderMutex.with_lock!(@order) do
|
37
43
|
Spree::InventoryUnit.transaction do
|
38
44
|
inventory_units.each do |iu|
|
39
|
-
unit_cancels << short_ship_unit(iu,
|
45
|
+
unit_cancels << short_ship_unit(iu, created_by: created_by)
|
40
46
|
end
|
41
47
|
|
42
48
|
update_shipped_shipments(inventory_units)
|
@@ -59,17 +65,23 @@ class Spree::OrderCancellations
|
|
59
65
|
#
|
60
66
|
# @param [InventoryUnit] inventory_unit the inventory unit to be canceled
|
61
67
|
# @param [String] reason the reason that you are canceling the inventory unit
|
62
|
-
# @param [
|
68
|
+
# @param [Spree.user_class] whodunnit (deprecated) the system or person that is canceling the inventory unit
|
69
|
+
# @param [Spree.user_class] created_by the system or person that is canceling the inventory unit
|
63
70
|
#
|
64
71
|
# @return [UnitCancel] the unit that has been canceled
|
65
|
-
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodunnit: nil)
|
72
|
+
def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodunnit: nil, created_by: nil)
|
73
|
+
if whodunnit
|
74
|
+
created_by ||= whodunnit
|
75
|
+
Spree::Deprecation.warn("Calling #cancel_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
76
|
+
end
|
77
|
+
|
66
78
|
unit_cancel = nil
|
67
79
|
|
68
80
|
Spree::OrderMutex.with_lock!(@order) do
|
69
81
|
unit_cancel = Spree::UnitCancel.create!(
|
70
82
|
inventory_unit: inventory_unit,
|
71
83
|
reason: reason,
|
72
|
-
created_by:
|
84
|
+
created_by: created_by
|
73
85
|
)
|
74
86
|
|
75
87
|
inventory_unit.cancel!
|
@@ -82,14 +94,18 @@ class Spree::OrderCancellations
|
|
82
94
|
#
|
83
95
|
# @api public
|
84
96
|
# @param [Array<InventoryUnit>] inventory_units the inventory units to be reimbursed
|
97
|
+
# @param [Spree.user_class] created_by the user that is performing this action
|
85
98
|
# @return [Reimbursement] the reimbursement for inventory being canceled
|
86
|
-
def reimburse_units(inventory_units)
|
99
|
+
def reimburse_units(inventory_units, created_by: nil)
|
100
|
+
unless created_by
|
101
|
+
Spree::Deprecation.warn("Calling #reimburse_units on #{self} without created_by is deprecated")
|
102
|
+
end
|
87
103
|
reimbursement = nil
|
88
104
|
|
89
105
|
Spree::OrderMutex.with_lock!(@order) do
|
90
106
|
return_items = inventory_units.map(&:current_or_new_return_item)
|
91
107
|
reimbursement = Spree::Reimbursement.new(order: @order, return_items: return_items)
|
92
|
-
reimbursement.return_all
|
108
|
+
reimbursement.return_all(created_by: created_by)
|
93
109
|
end
|
94
110
|
|
95
111
|
reimbursement
|
@@ -97,11 +113,16 @@ class Spree::OrderCancellations
|
|
97
113
|
|
98
114
|
private
|
99
115
|
|
100
|
-
def short_ship_unit(inventory_unit, whodunnit: nil)
|
116
|
+
def short_ship_unit(inventory_unit, whodunnit: nil, created_by: nil)
|
117
|
+
if whodunnit
|
118
|
+
created_by ||= whodunnit
|
119
|
+
Spree::Deprecation.warn("Calling #short_ship_unit on #{self} with whodunnit is deprecated, use created_by instead")
|
120
|
+
end
|
121
|
+
|
101
122
|
unit_cancel = Spree::UnitCancel.create!(
|
102
123
|
inventory_unit: inventory_unit,
|
103
124
|
reason: Spree::UnitCancel::SHORT_SHIP,
|
104
|
-
created_by:
|
125
|
+
created_by: created_by
|
105
126
|
)
|
106
127
|
unit_cancel.adjust!
|
107
128
|
inventory_unit.cancel!
|