solidus_core 2.3.1 → 2.4.0.beta1
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/app/controllers/spree/base_controller.rb +0 -1
- data/app/models/concerns/spree/calculated_adjustments.rb +2 -0
- data/app/models/concerns/spree/user_methods.rb +19 -3
- data/app/models/spree/address.rb +5 -11
- data/app/models/spree/adjustment.rb +10 -1
- data/app/models/spree/base.rb +4 -0
- data/app/models/spree/calculator/default_tax.rb +7 -18
- data/app/models/spree/calculator/returns/default_refund_amount.rb +3 -3
- data/app/models/spree/calculator.rb +2 -3
- data/app/models/spree/customer_return.rb +6 -3
- data/app/models/spree/exchange.rb +1 -1
- data/app/models/spree/fulfilment_changer.rb +125 -0
- data/app/models/spree/legacy_user.rb +0 -8
- data/app/models/spree/line_item.rb +24 -7
- data/app/models/spree/order/checkout.rb +2 -2
- data/app/models/spree/order.rb +42 -47
- data/app/models/spree/order_cancellations.rb +1 -1
- data/app/models/spree/order_capturing.rb +2 -0
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/order_update_attributes.rb +0 -2
- data/app/models/spree/order_updater.rb +4 -4
- data/app/models/spree/payment/cancellation.rb +60 -0
- data/app/models/spree/payment/processing.rb +1 -2
- data/app/models/spree/payment.rb +4 -7
- data/app/models/spree/payment_method/bogus_credit_card.rb +2 -1
- data/app/models/spree/payment_method/check.rb +1 -2
- data/app/models/spree/payment_method/store_credit.rb +4 -3
- data/app/models/spree/payment_method.rb +19 -2
- data/app/models/spree/promotion.rb +1 -1
- data/app/models/spree/promotion_action.rb +2 -1
- data/app/models/spree/promotion_handler/coupon.rb +1 -1
- data/app/models/spree/promotion_handler/free_shipping.rb +6 -58
- data/app/models/spree/promotion_handler/shipping.rb +55 -0
- data/app/models/spree/refund.rb +4 -2
- data/app/models/spree/reimbursement/credit.rb +17 -15
- data/app/models/spree/return_authorization.rb +8 -5
- data/app/models/spree/return_item/eligibility_validator/base_validator.rb +19 -15
- data/app/models/spree/return_item/eligibility_validator/default.rb +25 -21
- data/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb +15 -11
- data/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb +16 -11
- data/app/models/spree/return_item/eligibility_validator/order_completed.rb +15 -11
- data/app/models/spree/return_item/eligibility_validator/rma_required.rb +15 -11
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +15 -11
- data/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb +37 -35
- data/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb +6 -4
- data/app/models/spree/return_item.rb +6 -3
- data/app/models/spree/shipment.rb +63 -45
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/shipping_rate.rb +2 -0
- data/app/models/spree/shipping_rate_tax.rb +1 -5
- data/app/models/spree/stock/availability.rb +70 -0
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/simple_coordinator.rb +105 -0
- data/app/models/spree/stock/splitter/base.rb +8 -4
- data/app/models/spree/stock/splitter/weight.rb +0 -2
- data/app/models/spree/stock/splitter_chain.rb +32 -0
- data/app/models/spree/stock_quantities.rb +81 -0
- data/app/models/spree/store_credit.rb +7 -15
- data/app/models/spree/store_credit_category.rb +1 -1
- data/app/models/spree/store_credit_type.rb +3 -1
- data/app/models/spree/tax/tax_helpers.rb +3 -35
- data/app/models/spree/tax_rate.rb +2 -5
- data/app/models/spree/taxon.rb +2 -0
- data/app/models/spree/zone.rb +1 -50
- data/app/views/spree/order_mailer/confirm_email.html.erb +1 -1
- data/app/views/spree/order_mailer/confirm_email.text.erb +1 -1
- data/config/locales/en.yml +77 -45
- data/db/default/spree/countries.rb +40 -10
- data/db/default/spree/store_credit.rb +2 -2
- data/db/migrate/20160101010000_solidus_one_four.rb +1153 -0
- data/db/migrate/20170831201542_remove_default_tax_from_spree_zones.rb +5 -0
- data/db/seeds.rb +15 -2
- data/lib/generators/spree/dummy/templates/rails/database.yml +4 -0
- data/lib/generators/spree/install/install_generator.rb +0 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +0 -12
- data/{app/models → lib}/spree/app_configuration.rb +26 -59
- data/lib/spree/config.rb +3 -0
- data/lib/spree/core/controller_helpers/order.rb +0 -2
- data/lib/spree/core/engine.rb +6 -1
- data/lib/spree/core/environment.rb +3 -1
- data/lib/spree/core/search/base.rb +13 -5
- data/lib/spree/core/search/variant.rb +2 -0
- data/lib/spree/core/stock_configuration.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +8 -7
- data/lib/spree/deprecation.rb +2 -0
- data/lib/spree/i18n.rb +1 -0
- data/lib/spree/money.rb +2 -0
- data/lib/spree/permission_sets/product_management.rb +6 -5
- data/{app/models → lib}/spree/preferences/configuration.rb +29 -2
- data/lib/spree/preferences/preferable.rb +142 -0
- data/{app/models → lib}/spree/preferences/preferable_class_methods.rb +0 -0
- data/{app/models → lib}/spree/preferences/scoped_store.rb +0 -0
- data/{app/models → lib}/spree/preferences/static_model_preferences.rb +0 -0
- data/{app/models → lib}/spree/preferences/statically_configurable.rb +0 -0
- data/{app/models → lib}/spree/preferences/store.rb +0 -0
- data/lib/spree/promo/environment.rb +1 -0
- data/lib/spree/testing_support/ability_helpers.rb +9 -9
- data/lib/spree/testing_support/factories/address_factory.rb +2 -3
- data/lib/spree/testing_support/factories/adjustment_factory.rb +2 -2
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/calculator_factory.rb +6 -6
- data/lib/spree/testing_support/factories/carton_factory.rb +1 -1
- data/lib/spree/testing_support/factories/country_factory.rb +1 -1
- data/lib/spree/testing_support/factories/credit_card_factory.rb +1 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -1
- data/lib/spree/testing_support/factories/image_factory.rb +1 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/option_value_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +2 -2
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +1 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +3 -3
- data/lib/spree/testing_support/factories/payment_method_factory.rb +4 -4
- data/lib/spree/testing_support/factories/price_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +1 -1
- data/lib/spree/testing_support/factories/property_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +2 -2
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +3 -3
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/state_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_transfer_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +3 -3
- data/lib/spree/testing_support/factories/store_credit_update_reason_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +1 -1
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +1 -1
- data/lib/spree/testing_support/factories/zone_factory.rb +2 -2
- data/lib/spree/testing_support/preferences.rb +1 -2
- data/lib/spree/testing_support/sequences.rb +6 -1
- data/lib/tasks/core.rake +17 -10
- data/solidus_core.gemspec +0 -6
- data/spec/helpers/base_helper_spec.rb +2 -2
- data/spec/helpers/products_helper_spec.rb +2 -2
- data/spec/helpers/taxons_helper_spec.rb +2 -2
- data/spec/jobs/promotion_code_batch_job_spec.rb +2 -2
- data/spec/lib/calculated_adjustments_spec.rb +2 -2
- data/spec/lib/i18n_spec.rb +2 -2
- data/spec/lib/search/base_spec.rb +10 -8
- data/spec/lib/search/variant_spec.rb +2 -2
- data/spec/lib/spree/core/class_constantizer_spec.rb +2 -1
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/search_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/store_spec.rb +2 -2
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +2 -2
- data/spec/lib/spree/core/current_store_spec.rb +2 -2
- data/spec/lib/spree/core/environment_extension_spec.rb +2 -1
- data/spec/lib/spree/core/importer/order_spec.rb +2 -2
- data/spec/lib/spree/core/role_configuration_spec.rb +2 -2
- data/spec/lib/spree/core/stock_configuration_spec.rb +2 -2
- data/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/adjustment_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/adjustment_reason_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/calculator_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/carton_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/country_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/credit_card_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/customer_return_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/image_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/inventory_unit_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/line_item_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/option_type_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/option_value_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +2 -2
- data/spec/lib/spree/core/testing_support/factories/order_promotion_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/payment_method_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/price_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/product_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/product_option_type_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/product_property_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/promotion_category_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/promotion_code_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/promotion_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/property_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/refund_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/refund_reason_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/reimbursement_type_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/return_authorization_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/return_item_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/return_reason_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/role_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/shipment_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/shipping_category_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +10 -1
- data/spec/lib/spree/core/testing_support/factories/shipping_rate_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/stock_item_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/stock_movement_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/stock_package_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/stock_transfer_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_category_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_event_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_type_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_credit_update_reason_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/store_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/tax_category_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/tax_rate_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/taxonomy_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/user_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/variant_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_condition_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_value_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/factories/zone_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/preferences_spec.rb +1 -1
- data/spec/lib/spree/core/validators/email_spec.rb +3 -2
- data/spec/lib/spree/core/version_spec.rb +1 -1
- data/spec/lib/spree/localized_number_spec.rb +2 -1
- data/spec/lib/spree/migrations_spec.rb +2 -2
- data/spec/lib/spree/money_spec.rb +3 -1
- data/spec/lib/spree/permission_sets/default_customer_spec.rb +2 -2
- data/spec/lib/tasks/dummy_task_spec.rb +2 -2
- data/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +2 -2
- data/spec/mailers/carton_mailer_spec.rb +2 -2
- data/spec/mailers/order_mailer_spec.rb +2 -2
- data/spec/mailers/promotion_code_batch_mailer_spec.rb +2 -2
- data/spec/mailers/reimbursement_mailer_spec.rb +2 -2
- data/spec/mailers/test_mailer_spec.rb +2 -2
- data/spec/models/spree/ability_spec.rb +2 -2
- data/spec/models/spree/address_spec.rb +2 -37
- data/spec/models/spree/adjustment_reason_spec.rb +2 -2
- data/spec/models/spree/adjustment_spec.rb +4 -4
- data/spec/models/spree/app_configuration_spec.rb +2 -2
- data/spec/models/spree/asset_spec.rb +2 -2
- data/spec/models/spree/calculator/default_tax_spec.rb +21 -56
- data/spec/models/spree/calculator/distributed_amount_spec.rb +2 -2
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +2 -2
- data/spec/models/spree/calculator/flat_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/flexi_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/free_shipping_spec.rb +2 -2
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +2 -2
- data/spec/models/spree/calculator/percent_per_item_spec.rb +2 -2
- data/spec/models/spree/calculator/price_sack_spec.rb +2 -2
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +2 -2
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +2 -2
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +2 -2
- data/spec/models/spree/calculator/tiered_percent_spec.rb +2 -2
- data/spec/models/spree/calculator_spec.rb +12 -2
- data/spec/models/spree/carton_spec.rb +2 -2
- data/spec/models/spree/classification_spec.rb +2 -2
- data/spec/models/spree/concerns/display_money_spec.rb +2 -2
- data/spec/models/spree/concerns/ordered_property_value_list_spec.rb +2 -2
- data/spec/models/spree/concerns/user_address_book_spec.rb +26 -26
- data/spec/models/spree/concerns/user_methods_spec.rb +80 -2
- data/spec/models/spree/country_spec.rb +2 -2
- data/spec/models/spree/credit_card_spec.rb +2 -2
- data/spec/models/spree/customer_return_spec.rb +2 -2
- data/spec/models/spree/distributed_amounts_handler_spec.rb +1 -1
- data/spec/models/spree/exchange_spec.rb +2 -2
- data/spec/models/spree/fulfilment_changer_spec.rb +273 -0
- data/spec/models/spree/gateway/bogus_simple.rb +2 -2
- data/spec/models/spree/gateway/bogus_spec.rb +2 -2
- data/spec/models/spree/gateway_spec.rb +2 -2
- data/spec/models/spree/image_spec.rb +2 -2
- data/spec/models/spree/inventory_unit_spec.rb +3 -3
- data/spec/models/spree/line_item_spec.rb +23 -6
- data/spec/models/spree/option_type_spec.rb +2 -2
- data/spec/models/spree/option_value_spec.rb +2 -2
- data/spec/models/spree/order/address_spec.rb +2 -2
- data/spec/models/spree/order/adjustments_spec.rb +2 -2
- data/spec/models/spree/order/callbacks_spec.rb +2 -2
- data/spec/models/spree/order/checkout_spec.rb +6 -6
- data/spec/models/spree/order/finalizing_spec.rb +3 -3
- data/spec/models/spree/order/number_generator_spec.rb +1 -1
- data/spec/models/spree/order/outstanding_balance_integration_spec.rb +3 -3
- data/spec/models/spree/order/payment_spec.rb +61 -30
- data/spec/models/spree/order/risk_assessment_spec.rb +2 -2
- data/spec/models/spree/order/state_machine_spec.rb +2 -2
- data/spec/models/spree/order/totals_spec.rb +2 -2
- data/spec/models/spree/order/updating_spec.rb +3 -3
- data/spec/models/spree/order/validations_spec.rb +2 -2
- data/spec/models/spree/order_cancellations_spec.rb +3 -3
- data/spec/models/spree/order_capturing_spec.rb +7 -143
- data/spec/models/spree/order_contents_spec.rb +2 -2
- data/spec/models/spree/order_inventory_spec.rb +2 -2
- data/spec/models/spree/order_merger_spec.rb +2 -2
- data/spec/models/spree/order_mutex_spec.rb +2 -2
- data/spec/models/spree/order_promotion_spec.rb +2 -2
- data/spec/models/spree/order_shipping_spec.rb +2 -2
- data/spec/models/spree/order_spec.rb +60 -108
- data/spec/models/spree/order_stock_location_spec.rb +2 -2
- data/spec/models/spree/order_taxation_spec.rb +1 -1
- data/spec/models/spree/order_update_attributes_spec.rb +2 -6
- data/spec/models/spree/order_updater_spec.rb +16 -16
- data/spec/models/spree/payment/cancellation_spec.rb +81 -0
- data/spec/models/spree/payment_create_spec.rb +1 -1
- data/spec/models/spree/payment_method/bogus_credit_card_spec.rb +2 -2
- data/spec/models/spree/payment_method/check_spec.rb +8 -8
- data/spec/models/spree/payment_method/credit_card_spec.rb +2 -2
- data/spec/models/spree/payment_method/simple_bogus_credit_card_spec.rb +2 -2
- data/spec/models/spree/payment_method/store_credit_spec.rb +39 -27
- data/spec/models/spree/payment_method_spec.rb +2 -2
- data/spec/models/spree/payment_spec.rb +71 -17
- data/spec/models/spree/permission_sets/base_spec.rb +2 -2
- data/spec/models/spree/permission_sets/configuration_display.rb +2 -2
- data/spec/models/spree/permission_sets/configuration_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/dashboard_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/order_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/order_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/product_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/product_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/promotion_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/promotion_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/report_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/restricted_stock_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/restricted_stock_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/restricted_stock_transfer_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/restricted_stock_transfer_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/stock_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/stock_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/stock_transfer_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/stock_transfer_management_spec.rb +2 -2
- data/spec/models/spree/permission_sets/user_display_spec.rb +2 -2
- data/spec/models/spree/permission_sets/user_management_spec.rb +2 -2
- data/spec/models/spree/preference_spec.rb +2 -2
- data/spec/models/spree/preferences/configuration_spec.rb +2 -2
- data/spec/models/spree/preferences/preferable_spec.rb +2 -2
- data/spec/models/spree/preferences/scoped_store_spec.rb +2 -2
- data/spec/models/spree/preferences/static_model_preferences_spec.rb +1 -1
- data/spec/models/spree/preferences/statically_configurable_spec.rb +1 -1
- data/spec/models/spree/preferences/store_spec.rb +2 -2
- data/spec/models/spree/price_spec.rb +2 -2
- data/spec/models/spree/product/scopes_spec.rb +2 -2
- data/spec/models/spree/product_duplicator_spec.rb +2 -2
- data/spec/models/spree/product_filter_spec.rb +2 -2
- data/spec/models/spree/product_property_spec.rb +2 -2
- data/spec/models/spree/product_spec.rb +2 -2
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +2 -2
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +2 -2
- data/spec/models/spree/promotion/actions/create_quantity_adjustments_spec.rb +4 -4
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/first_order_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/item_total_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/nth_order_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/option_value_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/product_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/taxon_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/user_role_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/user_spec.rb +2 -2
- data/spec/models/spree/promotion_action_spec.rb +2 -2
- data/spec/models/spree/promotion_category_spec.rb +2 -2
- data/spec/models/spree/promotion_code/batch_builder_spec.rb +2 -2
- data/spec/models/spree/promotion_code_batch_spec.rb +2 -2
- data/spec/models/spree/promotion_code_spec.rb +1 -1
- data/spec/models/spree/promotion_handler/cart_spec.rb +3 -3
- data/spec/models/spree/promotion_handler/coupon_spec.rb +2 -2
- data/spec/models/spree/promotion_handler/page_spec.rb +2 -2
- data/spec/models/spree/promotion_handler/{free_shipping_spec.rb → shipping_spec.rb} +28 -3
- data/spec/models/spree/promotion_rule_spec.rb +2 -2
- data/spec/models/spree/promotion_spec.rb +4 -4
- data/spec/models/spree/refund_spec.rb +10 -2
- data/spec/models/spree/reimbursement/credit_spec.rb +2 -2
- data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +2 -2
- data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +2 -2
- data/spec/models/spree/reimbursement_performer_spec.rb +2 -2
- data/spec/models/spree/reimbursement_spec.rb +5 -5
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +2 -2
- data/spec/models/spree/reimbursement_type/credit_spec.rb +2 -2
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +2 -2
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +2 -2
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +2 -2
- data/spec/models/spree/return_authorization_spec.rb +19 -7
- data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +2 -2
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +2 -2
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +2 -2
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +2 -2
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +2 -2
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +2 -2
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +2 -2
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +2 -2
- data/spec/models/spree/return_item_spec.rb +6 -6
- data/spec/models/spree/returns_calculator_spec.rb +2 -2
- data/spec/models/spree/shipment_spec.rb +35 -18
- data/spec/models/spree/shipping_calculator_spec.rb +2 -2
- data/spec/models/spree/shipping_manifest_spec.rb +2 -2
- data/spec/models/spree/shipping_method_spec.rb +2 -2
- data/spec/models/spree/shipping_rate_spec.rb +3 -37
- data/spec/models/spree/shipping_rate_tax_spec.rb +1 -7
- data/spec/models/spree/state_spec.rb +2 -2
- data/spec/models/spree/stock/availability_spec.rb +127 -0
- data/spec/models/spree/stock/availability_validator_spec.rb +2 -2
- data/spec/models/spree/stock/differentiator_spec.rb +2 -2
- data/spec/models/spree/stock/estimator_spec.rb +2 -2
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +2 -2
- data/spec/models/spree/stock/package_spec.rb +2 -2
- data/spec/models/spree/stock/quantifier_spec.rb +3 -3
- data/spec/models/spree/stock/shipping_rate_selector_spec.rb +2 -2
- data/spec/models/spree/stock/shipping_rate_sorter_spec.rb +2 -2
- data/spec/models/spree/stock/{coordinator_spec.rb → simple_coordinator_spec.rb} +47 -28
- data/spec/models/spree/stock/splitter/backordered_spec.rb +5 -5
- data/spec/models/spree/stock/splitter/base_spec.rb +5 -5
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +6 -6
- data/spec/models/spree/stock/splitter/weight_spec.rb +6 -6
- data/spec/models/spree/stock/splitter_chain_spec.rb +64 -0
- data/spec/models/spree/stock_item_spec.rb +2 -2
- data/spec/models/spree/stock_location_spec.rb +2 -2
- data/spec/models/spree/stock_movement_spec.rb +2 -2
- data/spec/models/spree/stock_quantities_spec.rb +247 -0
- data/spec/models/spree/stock_transfer_spec.rb +2 -2
- data/spec/models/spree/store_credit_category_spec.rb +2 -2
- data/spec/models/spree/store_credit_event_spec.rb +2 -2
- data/spec/models/spree/store_credit_spec.rb +2 -2
- data/spec/models/spree/store_selector/by_server_name_spec.rb +2 -2
- data/spec/models/spree/store_selector/legacy_spec.rb +2 -2
- data/spec/models/spree/store_spec.rb +2 -2
- data/spec/models/spree/tax/order_adjuster_spec.rb +1 -1
- data/spec/models/spree/tax/shipping_rate_taxer_spec.rb +2 -2
- data/spec/models/spree/tax/tax_location_spec.rb +1 -1
- data/spec/models/spree/tax/taxation_integration_spec.rb +9 -10
- data/spec/models/spree/tax_calculator/default_spec.rb +1 -1
- data/spec/models/spree/tax_category_spec.rb +2 -2
- data/spec/models/spree/tax_rate_spec.rb +21 -65
- data/spec/models/spree/taxon_spec.rb +2 -2
- data/spec/models/spree/taxonomy_spec.rb +2 -2
- data/spec/models/spree/transfer_item_spec.rb +2 -2
- data/spec/models/spree/unit_cancel_spec.rb +2 -2
- data/spec/models/spree/user_spec.rb +12 -3
- data/spec/models/spree/validations/db_maximum_length_validator_spec.rb +2 -2
- data/spec/models/spree/variant/price_selector_spec.rb +2 -2
- data/spec/models/spree/variant/pricing_options_spec.rb +2 -2
- data/spec/models/spree/variant/scopes_spec.rb +2 -2
- data/spec/models/spree/variant/vat_price_generator_spec.rb +2 -2
- data/spec/models/spree/variant_property_rule_condition_spec.rb +2 -2
- data/spec/models/spree/variant_property_rule_spec.rb +2 -2
- data/spec/models/spree/variant_property_rule_value_spec.rb +2 -2
- data/spec/models/spree/variant_spec.rb +2 -2
- data/spec/models/spree/wallet_payment_source_spec.rb +2 -2
- data/spec/models/spree/wallet_spec.rb +2 -2
- data/spec/models/spree/zone_spec.rb +2 -260
- data/spec/rails_helper.rb +49 -0
- data/spec/shared_examples/calculator_shared_examples.rb +1 -1
- data/spec/spec_helper.rb +3 -40
- data/spec/support/concerns/default_price.rb +1 -1
- data/spec/support/shared_contexts/rake.rb +1 -1
- metadata +28 -414
- data/app/helpers/spree/orders_helper.rb +0 -16
- data/app/models/spree/preferences/preferable.rb +0 -133
- data/app/models/spree/stock/adjuster.rb +0 -28
- data/app/models/spree/stock/coordinator.rb +0 -150
- data/app/models/spree/stock/packer.rb +0 -63
- data/app/models/spree/stock/prioritizer.rb +0 -48
- data/db/migrate/20120831092320_spree_one_two.rb +0 -473
- data/db/migrate/20120831092359_spree_promo_one_two.rb +0 -45
- data/db/migrate/20120905145253_add_tax_rate_label.rb +0 -5
- data/db/migrate/20120905151823_add_toggle_tax_rate_display.rb +0 -5
- data/db/migrate/20120929093553_remove_unused_preference_columns.rb +0 -8
- data/db/migrate/20121009142519_add_lock_version_to_variant.rb +0 -5
- data/db/migrate/20121010142909_add_states_required_to_countries.rb +0 -5
- data/db/migrate/20121012071449_add_on_demand_to_product_and_variant.rb +0 -6
- data/db/migrate/20121017010007_remove_not_null_constraint_from_products_on_hand.rb +0 -11
- data/db/migrate/20121031162139_split_prices_from_variants.rb +0 -31
- data/db/migrate/20121107003422_remove_not_null_from_spree_prices_amount.rb +0 -9
- data/db/migrate/20121107184631_add_currency_to_line_items.rb +0 -5
- data/db/migrate/20121107194006_add_currency_to_orders.rb +0 -5
- data/db/migrate/20121109173623_add_cost_currency_to_variants.rb +0 -5
- data/db/migrate/20121111231553_remove_display_on_from_payment_methods.rb +0 -5
- data/db/migrate/20121124203911_add_position_to_taxonomies.rb +0 -5
- data/db/migrate/20121126040517_add_last_ip_to_spree_orders.rb +0 -5
- data/db/migrate/20121213162028_add_state_to_spree_adjustments.rb +0 -6
- data/db/migrate/20130114053446_add_display_on_to_spree_payment_methods.rb +0 -9
- data/db/migrate/20130120201805_add_position_to_product_properties.spree.rb +0 -5
- data/db/migrate/20130203232234_add_identifier_to_spree_payments.rb +0 -5
- data/db/migrate/20130207155350_add_order_id_index_to_payments.rb +0 -9
- data/db/migrate/20130208032954_add_primary_to_spree_products_taxons.rb +0 -5
- data/db/migrate/20130211190146_create_spree_stock_items.rb +0 -14
- data/db/migrate/20130211191120_create_spree_stock_locations.rb +0 -11
- data/db/migrate/20130213191427_create_default_stock.rb +0 -25
- data/db/migrate/20130222032153_add_order_id_index_to_shipments.rb +0 -5
- data/db/migrate/20130226032817_change_meta_description_on_spree_products_to_text.rb +0 -5
- data/db/migrate/20130226191231_add_stock_location_id_to_spree_shipments.rb +0 -5
- data/db/migrate/20130227143905_add_pending_to_inventory_unit.rb +0 -6
- data/db/migrate/20130228164411_remove_on_demand_from_product_and_variant.rb +0 -6
- data/db/migrate/20130228210442_create_shipping_method_zone.rb +0 -21
- data/db/migrate/20130301162745_remove_shipping_category_id_from_shipping_method.rb +0 -5
- data/db/migrate/20130301162924_create_shipping_method_categories.rb +0 -13
- data/db/migrate/20130301205200_add_tracking_url_to_spree_shipping_methods.rb +0 -5
- data/db/migrate/20130304162240_create_spree_shipping_rates.rb +0 -24
- data/db/migrate/20130304192936_remove_category_match_attributes_from_shipping_method.rb +0 -7
- data/db/migrate/20130305143310_create_stock_movements.rb +0 -12
- data/db/migrate/20130306181701_add_address_fields_to_stock_location.rb +0 -21
- data/db/migrate/20130306191917_add_active_field_to_stock_locations.rb +0 -5
- data/db/migrate/20130306195650_add_backorderable_to_stock_item.rb +0 -5
- data/db/migrate/20130307161754_add_default_quantity_to_stock_movement.rb +0 -5
- data/db/migrate/20130318151756_add_source_and_destination_to_stock_movements.rb +0 -8
- data/db/migrate/20130319062004_change_orders_total_precision.rb +0 -8
- data/db/migrate/20130319063911_change_spree_payments_amount_precision.rb +0 -5
- data/db/migrate/20130319064308_change_spree_return_authorization_amount_precision.rb +0 -5
- data/db/migrate/20130319082943_change_adjustments_amount_precision.rb +0 -5
- data/db/migrate/20130319183250_add_originator_to_stock_movement.rb +0 -7
- data/db/migrate/20130319190507_drop_source_and_destination_from_stock_movement.rb +0 -15
- data/db/migrate/20130325163316_migrate_inventory_unit_sold_to_on_hand.rb +0 -9
- data/db/migrate/20130326175857_add_stock_location_to_rma.rb +0 -5
- data/db/migrate/20130328130308_update_shipment_state_for_canceled_orders.rb +0 -15
- data/db/migrate/20130328195253_add_seo_metas_to_taxons.rb +0 -9
- data/db/migrate/20130329134939_remove_stock_item_and_variant_lock.rb +0 -14
- data/db/migrate/20130413230529_add_name_to_spree_credit_cards.rb +0 -5
- data/db/migrate/20130414000512_update_name_fields_on_spree_credit_cards.rb +0 -13
- data/db/migrate/20130417120034_add_index_to_source_columns_on_adjustments.rb +0 -5
- data/db/migrate/20130417120035_update_adjustment_states.rb +0 -16
- data/db/migrate/20130417123427_add_shipping_rates_to_shipments.rb +0 -15
- data/db/migrate/20130418125341_create_spree_stock_transfers.rb +0 -14
- data/db/migrate/20130423110707_drop_products_count_on_hand.rb +0 -5
- data/db/migrate/20130423223847_set_default_shipping_rate_cost.rb +0 -5
- data/db/migrate/20130509115210_add_number_to_stock_transfer.rb +0 -23
- data/db/migrate/20130514151929_add_sku_index_to_spree_variants.rb +0 -5
- data/db/migrate/20130515180736_add_backorderable_default_to_spree_stock_location.rb +0 -5
- data/db/migrate/20130516151222_add_propage_all_variants_to_spree_stock_location.rb +0 -5
- data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +0 -5
- data/db/migrate/20130611185927_add_user_id_index_to_spree_orders.rb +0 -5
- data/db/migrate/20130618041418_add_updated_at_to_spree_countries.rb +0 -9
- data/db/migrate/20130619012236_add_updated_at_to_spree_states.rb +0 -9
- data/db/migrate/20130626232741_add_cvv_result_code_and_cvv_result_message_to_spree_payments.rb +0 -6
- data/db/migrate/20130628021056_add_unique_index_to_permalink_on_spree_products.rb +0 -5
- data/db/migrate/20130628022817_add_unique_index_to_orders_shipments_and_stock_transfers.rb +0 -7
- data/db/migrate/20130708052307_add_deleted_at_to_spree_tax_rates.rb +0 -5
- data/db/migrate/20130711200933_remove_lock_version_from_inventory_units.rb +0 -6
- data/db/migrate/20130718042445_add_cost_price_to_line_item.rb +0 -5
- data/db/migrate/20130718233855_set_backorderable_to_default_to_false.rb +0 -6
- data/db/migrate/20130725031716_add_created_by_id_to_spree_orders.rb +0 -5
- data/db/migrate/20130729214043_index_completed_at_on_spree_orders.rb +0 -5
- data/db/migrate/20130802014537_add_tax_category_id_to_spree_line_items.rb +0 -5
- data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +0 -10
- data/db/migrate/20130806022521_drop_spree_mail_methods.rb +0 -12
- data/db/migrate/20130806145853_set_default_stock_location_on_shipments.rb +0 -8
- data/db/migrate/20130807024301_upgrade_adjustments.rb +0 -40
- data/db/migrate/20130807024302_rename_adjustment_fields.rb +0 -14
- data/db/migrate/20130809164245_add_admin_name_column_to_spree_shipping_methods.rb +0 -5
- data/db/migrate/20130809164330_add_admin_name_column_to_spree_stock_locations.rb +0 -5
- data/db/migrate/20130813004002_add_shipment_total_to_spree_orders.rb +0 -5
- data/db/migrate/20130813140619_expand_order_number_size.rb +0 -9
- data/db/migrate/20130813232134_rename_activators_to_promotions.rb +0 -5
- data/db/migrate/20130815000406_add_adjustment_total_to_line_items.rb +0 -5
- data/db/migrate/20130815024413_add_adjustment_total_to_shipments.rb +0 -5
- data/db/migrate/20130826062534_add_depth_to_spree_taxons.rb +0 -14
- data/db/migrate/20130828234942_add_tax_total_to_line_items_shipments_and_orders.rb +0 -8
- data/db/migrate/20130830001033_add_shipping_category_to_shipping_methods_and_products.rb +0 -15
- data/db/migrate/20130830001159_migrate_old_shipping_calculators.rb +0 -19
- data/db/migrate/20130903183026_add_code_to_spree_promotion_rules.rb +0 -5
- data/db/migrate/20130909115621_change_states_required_for_countries.rb +0 -9
- data/db/migrate/20130915032339_add_deleted_at_to_spree_stock_items.rb +0 -5
- data/db/migrate/20130917024658_remove_promotions_event_name_field.rb +0 -5
- data/db/migrate/20130924040529_add_promo_total_to_line_items_and_shipments_and_orders.rb +0 -7
- data/db/migrate/20131001013410_remove_unused_credit_card_fields.rb +0 -17
- data/db/migrate/20131026154747_add_track_inventory_to_variant.rb +0 -5
- data/db/migrate/20131107132123_add_tax_category_to_variants.rb +0 -6
- data/db/migrate/20131113035136_add_channel_to_spree_orders.rb +0 -5
- data/db/migrate/20131118043959_add_included_to_adjustments.rb +0 -5
- data/db/migrate/20131118050234_rename_tax_total_fields.rb +0 -11
- data/db/migrate/20131118183431_add_line_item_id_to_spree_inventory_units.rb +0 -20
- data/db/migrate/20131120234456_add_updated_at_to_variants.rb +0 -5
- data/db/migrate/20131127001002_add_position_to_classifications.rb +0 -5
- data/db/migrate/20131211112807_create_spree_orders_promotions.rb +0 -8
- data/db/migrate/20131211192741_unique_shipping_method_categories.rb +0 -24
- data/db/migrate/20131218054603_add_item_count_to_spree_orders.rb +0 -5
- data/db/migrate/20140106065820_remove_value_type_from_spree_preferences.rb +0 -9
- data/db/migrate/20140106224208_rename_permalink_to_slug_for_products.rb +0 -5
- data/db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb +0 -5
- data/db/migrate/20140124023232_rename_activator_id_in_rules_and_actions_to_promotion_id.rb +0 -6
- data/db/migrate/20140129024326_add_deleted_at_to_spree_prices.rb +0 -5
- data/db/migrate/20140203161722_add_approver_id_and_approved_at_to_orders.rb +0 -6
- data/db/migrate/20140204115338_add_confirmation_delivered_to_spree_orders.rb +0 -5
- data/db/migrate/20140204192230_add_auto_capture_to_payment_methods.rb +0 -5
- data/db/migrate/20140205120320_create_spree_payment_capture_events.rb +0 -12
- data/db/migrate/20140205144710_add_uncaptured_amount_to_payments.rb +0 -5
- data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +0 -11
- data/db/migrate/20140207085910_add_tax_category_id_to_shipping_methods.rb +0 -5
- data/db/migrate/20140207093021_add_tax_rate_id_to_shipping_rates.rb +0 -5
- data/db/migrate/20140211040159_add_pre_tax_amount_to_line_items_and_shipments.rb +0 -6
- data/db/migrate/20140213184916_add_more_indexes.rb +0 -13
- data/db/migrate/20140219060952_add_considered_risky_to_orders.rb +0 -5
- data/db/migrate/20140227112348_add_preference_store_to_everything.rb +0 -8
- data/db/migrate/20140307235515_add_user_id_to_spree_credit_cards.rb +0 -13
- data/db/migrate/20140309023735_migrate_old_preferences.rb +0 -52
- data/db/migrate/20140309024355_create_spree_stores.rb +0 -25
- data/db/migrate/20140309033438_create_store_from_preferences.rb +0 -34
- data/db/migrate/20140315053743_add_timestamps_to_spree_assets.rb +0 -6
- data/db/migrate/20140318191500_create_spree_taxons_promotion_rules.rb +0 -8
- data/db/migrate/20140331100557_add_additional_store_fields.rb +0 -8
- data/db/migrate/20140410141842_add_many_missing_indexes.rb +0 -19
- data/db/migrate/20140410150358_correct_some_polymorphic_index_and_add_more_missing.rb +0 -65
- data/db/migrate/20140415041315_add_user_id_created_by_id_index_to_order.rb +0 -5
- data/db/migrate/20140508151342_change_spree_price_amount_precision.rb +0 -8
- data/db/migrate/20140518174634_add_token_to_spree_orders.rb +0 -5
- data/db/migrate/20140530024945_move_order_token_from_tokenized_permission.rb +0 -29
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +0 -22
- data/db/migrate/20140604135309_drop_credit_card_first_name_and_last_name.rb +0 -6
- data/db/migrate/20140609201656_add_deleted_at_to_spree_promotion_actions.rb +0 -6
- data/db/migrate/20140616202624_remove_uncaptured_amount_from_spree_payments.rb +0 -5
- data/db/migrate/20140625214618_create_spree_refunds.rb +0 -12
- data/db/migrate/20140702140656_create_spree_return_authorization_inventory_unit.rb +0 -12
- data/db/migrate/20140707125621_rename_return_authorization_inventory_unit_to_return_items.rb +0 -5
- data/db/migrate/20140708132019_create_order_mutex.rb +0 -11
- data/db/migrate/20140709160534_backfill_line_item_pre_tax_amount.rb +0 -10
- data/db/migrate/20140710041921_recreate_spree_return_authorizations.rb +0 -54
- data/db/migrate/20140710181204_add_amount_fields_to_return_items.rb +0 -7
- data/db/migrate/20140710190048_drop_return_authorization_amount.rb +0 -5
- data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +0 -32
- data/db/migrate/20140713140527_create_spree_refund_reasons.rb +0 -14
- data/db/migrate/20140713142214_rename_return_authorization_reason.rb +0 -5
- data/db/migrate/20140715182625_create_spree_promotion_categories.rb +0 -11
- data/db/migrate/20140716204111_drop_received_at_on_return_items.rb +0 -9
- data/db/migrate/20140716212330_add_reception_and_acceptance_status_to_return_items.rb +0 -6
- data/db/migrate/20140717155155_create_default_refund_reason.rb +0 -9
- data/db/migrate/20140717185932_add_default_to_spree_stock_locations.rb +0 -7
- data/db/migrate/20140718133010_create_spree_customer_returns.rb +0 -9
- data/db/migrate/20140718133349_add_customer_return_id_to_return_item.rb +0 -6
- data/db/migrate/20140718195325_create_friendly_id_slugs.rb +0 -15
- data/db/migrate/20140723004419_rename_spree_refund_return_authorization_id.rb +0 -5
- data/db/migrate/20140723152808_increase_return_item_pre_tax_amount_precision.rb +0 -13
- data/db/migrate/20140723214541_copy_product_slugs_to_slug_history.rb +0 -13
- data/db/migrate/20140725131539_create_spree_reimbursements.rb +0 -21
- data/db/migrate/20140728225422_add_promotionable_to_spree_products.rb +0 -5
- data/db/migrate/20140729133613_add_exchange_inventory_unit_foreign_keys.rb +0 -7
- data/db/migrate/20140730155938_add_acceptance_status_errors_to_return_item.rb +0 -5
- data/db/migrate/20140731150017_create_spree_reimbursement_types.rb +0 -20
- data/db/migrate/20140804185157_add_default_to_shipment_cost.rb +0 -10
- data/db/migrate/20140805171035_add_default_to_spree_credit_cards.rb +0 -5
- data/db/migrate/20140805171219_make_existing_credit_cards_default.rb +0 -11
- data/db/migrate/20140806144901_add_type_to_reimbursement_type.rb +0 -9
- data/db/migrate/20140808184039_create_spree_reimbursement_credits.rb +0 -10
- data/db/migrate/20140827170513_add_meta_title_to_spree_products.rb +0 -7
- data/db/migrate/20140924164824_add_code_to_spree_tax_categories.rb +0 -5
- data/db/migrate/20140927193717_default_pre_tax_amount_should_be_zero.rb +0 -6
- data/db/migrate/20141002191113_add_code_to_spree_shipping_methods.rb +0 -5
- data/db/migrate/20141007230328_add_cancel_audit_fields_to_spree_orders.rb +0 -6
- data/db/migrate/20141009204607_add_store_id_to_orders.rb +0 -12
- data/db/migrate/20141012083513_create_spree_taxons_prototypes.rb +0 -8
- data/db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb +0 -8
- data/db/migrate/20141101231208_fix_adjustment_order_presence.rb +0 -13
- data/db/migrate/20141105213646_update_classifications_positions.rb +0 -9
- data/db/migrate/20141120135441_add_guest_token_index_to_spree_orders.rb +0 -5
- data/db/migrate/20141215235502_remove_extra_products_slug_index.rb +0 -5
- data/db/migrate/20141217215630_update_product_slug_index.rb +0 -8
- data/db/migrate/20141231151320_add_default_column_to_price.rb +0 -5
- data/db/migrate/20150112194216_add_position_to_stock_location.rb +0 -5
- data/db/migrate/20150113002122_create_spree_promotion_codes.rb +0 -13
- data/db/migrate/20150113002123_create_adjustment_promotion_code_association.rb +0 -6
- data/db/migrate/20150121022521_remove_environment_from_payment_method.rb +0 -6
- data/db/migrate/20150121202544_add_restock_inventory_to_stock_location.rb +0 -5
- data/db/migrate/20150122202432_add_code_to_spree_promotion_categories.rb +0 -5
- data/db/migrate/20150127161843_create_order_stock_locations.rb +0 -12
- data/db/migrate/20150203151219_add_fulfillable_to_stock_location.rb +0 -5
- data/db/migrate/20150205210527_add_code_to_refund_reason.rb +0 -5
- data/db/migrate/20150213160148_add_promotion_code_id_to_orders_promotions.rb +0 -7
- data/db/migrate/20150213163612_add_approver_name_to_spree_orders.rb +0 -5
- data/db/migrate/20150225205344_move_promotion_code_to_promotion_code_value.rb +0 -64
- data/db/migrate/20150226195213_downcase_promotion_codes_values.rb +0 -11
- data/db/migrate/20150227161934_add_order_ids_to_adjustments_where_missing.rb +0 -9
- data/db/migrate/20150303212749_add_per_code_usage_limit_to_promotions.rb +0 -5
- data/db/migrate/20150303212826_remove_usage_limit_from_promotion_codes.rb +0 -5
- data/db/migrate/20150304211616_add_timestamps_to_order_promotions.rb +0 -6
- data/db/migrate/20150305043021_create_spree_cartons.rb +0 -24
- data/db/migrate/20150305210403_add_timestamps_to_spree_roles_users.rb +0 -7
- data/db/migrate/20150313140507_remove_considered_risky_from_spree_orders.rb +0 -5
- data/db/migrate/20150313192827_add_index_to_inventory_units_carton_id.rb +0 -5
- data/db/migrate/20150313201235_add_imported_from_shipment_id_to_cartons.rb +0 -8
- data/db/migrate/20150313201503_copy_shipped_shipments_to_cartons.rb +0 -12
- data/db/migrate/20150330144639_create_spree_user_stock_locations.rb +0 -10
- data/db/migrate/20150331134544_add_stock_location_code.rb +0 -5
- data/db/migrate/20150402210430_create_unit_cancels.rb +0 -10
- data/db/migrate/20150407173305_add_fields_to_stock_transfer.rb +0 -12
- data/db/migrate/20150407173531_create_transfer_items.rb +0 -14
- data/db/migrate/20150424143547_drop_stock_transfer_type.rb +0 -10
- data/db/migrate/20150424161102_add_stock_transfer_finalized_at.rb +0 -8
- data/db/migrate/20150429125822_rename_stock_transfer_reference.rb +0 -5
- data/db/migrate/20150430233803_create_line_item_actions.rb +0 -10
- data/db/migrate/20150506181159_create_spree_store_credit_categories.rb +0 -10
- data/db/migrate/20150506181244_create_spree_store_credits.rb +0 -19
- data/db/migrate/20150506181539_create_spree_store_credit_events.rb +0 -17
- data/db/migrate/20150506181611_create_spree_store_credit_payment_method.rb +0 -21
- data/db/migrate/20150506181715_create_store_credit_types.rb +0 -17
- data/db/migrate/20150506182045_create_store_credit_reimbursement_type.rb +0 -5
- data/db/migrate/20150508044622_add_resellable_to_return_items.rb +0 -5
- data/db/migrate/20150514185559_add_invalidated_at_to_spree_store_credits.rb +0 -5
- data/db/migrate/20150514201836_migrate_deleted_store_credits_to_invalidated.rb +0 -13
- data/db/migrate/20150515170322_add_check_stock_on_transfer.rb +0 -5
- data/db/migrate/20150515211137_fix_adjustment_order_id.rb +0 -79
- data/db/migrate/20150528125647_delete_inventory_units_without_shipment.rb +0 -25
- data/db/migrate/20150601191251_add_deleted_at_to_stock_transfers.rb +0 -5
- data/db/migrate/20150601204148_add_deleted_at_to_transfer_items.rb +0 -5
- data/db/migrate/20150609093816_increase_scale_on_pre_tax_amounts.rb +0 -26
- data/db/migrate/20150609193231_add_preferences_to_promotion_actions.rb +0 -5
- data/db/migrate/20150610182638_add_id_to_spree_option_values_variants.rb +0 -5
- data/db/migrate/20150611200247_add_frontend_viewable_to_spree_orders.rb +0 -5
- data/db/migrate/20150612205731_remove_spree_configurations.rb +0 -15
- data/db/migrate/20150616204659_add_preference_source_to_spree_payment_methods.rb +0 -5
- data/db/migrate/20150618191713_remove_credit_card_address_id.rb +0 -7
- data/db/migrate/20150618212517_create_spree_store_credit_update_reasons.rb +0 -8
- data/db/migrate/20150619160613_create_adjustment_reason.rb +0 -18
- data/db/migrate/20150622144655_add_update_reason_to_store_credit_events.rb +0 -5
- data/db/migrate/20150623194316_add_return_authorization_reason_id_to_return_items.rb +0 -7
- data/db/migrate/20150623214058_seed_store_credit_update_reasons.rb +0 -9
- data/db/migrate/20150626200816_remove_shipping_method_id_from_spree_orders.rb +0 -9
- data/db/migrate/20150626214817_remove_counter_cache_from_spree_variants_to_spree_stock_items.rb +0 -10
- data/db/migrate/20150629175931_add_address_id_to_credit_card.rb +0 -5
- data/db/migrate/20150630175644_copy_order_bill_address_to_credit_card.rb +0 -12
- data/db/migrate/20150723224133_remove_unnecessary_indexes.rb +0 -62
- data/db/migrate/20150724163716_remove_state_lock_version_from_order.rb +0 -11
- data/db/migrate/20150731201146_add_spree_user_addresses.rb +0 -15
- data/db/migrate/20150806190833_add_id_and_timestamp_to_promotion_rule_user.rb +0 -13
- data/db/migrate/20150811210350_remove_mandatory_from_adjustments.rb +0 -5
- data/db/migrate/20150811211025_add_finalized_to_spree_adjustments.rb +0 -11
- data/db/migrate/20150820160821_add_store_payment_methods.rb +0 -10
- data/db/migrate/20150824213633_convert_habtm_to_hmt_for_shipping_methods_zones.rb +0 -17
- data/db/migrate/20150824214129_convert_habtm_to_hmt_for_products_promotion_rules.rb +0 -17
- data/db/migrate/20150825204216_drop_spree_gateways.rb +0 -20
- data/db/migrate/20150826002555_convert_habtm_to_hmt_for_taxon_prototypes.rb +0 -15
- data/db/migrate/20150909123605_create_variant_properties_and_rules.rb +0 -28
- data/db/migrate/20151001121454_create_spree_shipping_method_stock_locations.rb +0 -13
- data/db/migrate/20151002023248_add_foreign_key_to_shipping_method_stock_location.rb +0 -6
- data/db/migrate/20151010003252_add_foreign_keys_for_taxons_prototypes.rb +0 -6
- data/db/migrate/20151013222921_remove_token_permissions_table.rb +0 -16
- data/db/migrate/20151014213349_rename_identifier_to_number_for_payment.rb +0 -7
- data/db/migrate/20151015203732_add_foreign_keys_for_product_promotion_rules.rb +0 -9
- data/db/migrate/20151021113730_add_sale_to_spree_promotions.rb +0 -6
- data/db/migrate/20151021163309_convert_sale_promotions.rb +0 -28
- data/db/migrate/20151026093607_change_return_item_pre_tax_amount_to_amount.rb +0 -29
- data/db/migrate/20151117063249_convert_habtm_to_hmt_for_properties_prototypes.rb +0 -17
- data/db/migrate/20151124062500_convert_habtm_to_hmt_for_option_type_prototypes.rb +0 -17
- data/db/migrate/20151126063028_convert_habtm_to_hmt_for_taxons_promotion_rules.rb +0 -15
- data/db/migrate/20151219020209_add_stock_item_unique_index.rb +0 -9
- data/db/migrate/20160111091912_add_column_available_to_all_on_spree_shipping_method.rb +0 -5
- data/db/migrate/20160116133604_add_position_to_spree_payment_methods.rb +0 -5
- data/db/migrate/20160122182105_add_carrier_and_service_level_to_spree_shipping_methods.rb +0 -6
- data/db/migrate/20160224201413_create_spree_shipping_rate_taxes.rb +0 -11
- data/db/migrate/20160229133259_add_cart_tax_country_iso_to_spree_store.rb +0 -5
- data/db/migrate/20160301103333_remove_pre_tax_amount_on_line_item_and_shipment.rb +0 -6
- data/db/migrate/20160308000300_disallow_adjustment_finalized_nulls.rb +0 -19
- data/db/migrate/20160318145302_add_timestamps_to_prices.rb +0 -5
- data/db/migrate/20160330204846_add_missing_timestamp_columns.rb +0 -20
- data/db/migrate/20160420044191_create_spree_wallet_payment_sources.rb +0 -23
- data/db/migrate/20160420181916_migrate_credit_cards_to_wallet_payment_sources.rb +0 -27
- data/db/migrate/20160509181311_add_country_iso_to_prices.rb +0 -8
- data/db/migrate/20160527070401_rename_shipment_address_field.rb +0 -7
- data/db/migrate/20160608162651_ensure_default_store.rb +0 -13
- data/db/migrate/20160608180751_ensure_store_on_orders.rb +0 -12
- data/db/migrate/20160616232103_remove_user_id_from_promotion_rules.rb +0 -11
- data/db/migrate/20160718205341_add_payment_id_index_to_spree_refunds.rb +0 -5
- data/db/migrate/20160718205859_add_reimbursement_id_index_to_spree_refunds.rb +0 -5
- data/lib/spree/core/controller_helpers/respond_with.rb +0 -65
- data/lib/spree/core/price_migrator.rb +0 -30
- data/lib/spree/responder.rb +0 -44
- data/lib/spree/testing_support/factories/stock_packer_factory.rb +0 -13
- data/lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake +0 -172
- data/lib/tasks/migrations/create_vat_prices.rake +0 -15
- data/lib/tasks/upgrade.rake +0 -11
- data/spec/helpers/order_helper_spec.rb +0 -12
- data/spec/lib/spree/core/price_migrator_spec.rb +0 -358
- data/spec/lib/spree/core/testing_support/factories/stock_packer_factory_spec.rb +0 -16
- data/spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb +0 -111
- data/spec/lib/tasks/migrations/create_vat_prices_spec.rb +0 -31
- data/spec/lib/tasks/order_capturing_spec.rb +0 -53
- data/spec/lib/tasks/upgrade_spec.rb +0 -20
- data/spec/models/spree/order/tax_spec.rb +0 -98
- data/spec/models/spree/stock/packer_spec.rb +0 -90
- data/spec/models/spree/stock/prioritizer_spec.rb +0 -125
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 780ddce063f4f0cb4182e2409c326a0c67af6d17
|
4
|
+
data.tar.gz: d07bc3bed5b865e1fa058457b1ea0a29450cdb33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ea1a5401f592da810efbba723f7766bf617c88e9a55803cc6b887374276dafbe798c367615b7f0bb42d6855e307de9f14cee9effe9596d44f0dc19916ec98cf
|
7
|
+
data.tar.gz: aad148fef039045c3c994ca4e32f5fb60b4793079d57e1c598b9f7791bcbe935aef9d70b407663c91b43414585d2bffbb366d4b44b7d0c937bd9027560df7a15
|
@@ -3,7 +3,6 @@ require_dependency 'spree/core/controller_helpers/strong_parameters'
|
|
3
3
|
|
4
4
|
class Spree::BaseController < ApplicationController
|
5
5
|
include Spree::Core::ControllerHelpers::Auth
|
6
|
-
include Spree::Core::ControllerHelpers::RespondWith
|
7
6
|
include Spree::Core::ControllerHelpers::Common
|
8
7
|
include Spree::Core::ControllerHelpers::PaymentParameters
|
9
8
|
include Spree::Core::ControllerHelpers::Search
|
@@ -17,11 +17,13 @@ module Spree
|
|
17
17
|
has_many :stock_locations, through: :user_stock_locations
|
18
18
|
|
19
19
|
has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
|
20
|
-
has_many :orders, foreign_key: "user_id", class_name: "Spree::Order"
|
20
|
+
has_many :orders, foreign_key: "user_id", class_name: "Spree::Order", dependent: :restrict_with_exception
|
21
21
|
|
22
22
|
has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
|
23
23
|
has_many :store_credit_events, through: :store_credits
|
24
|
+
|
24
25
|
money_methods :total_available_store_credit
|
26
|
+
deprecate display_total_available_store_credit: :display_available_store_credit_total, deprecator: Spree::Deprecation
|
25
27
|
|
26
28
|
has_many :credit_cards, class_name: "Spree::CreditCard", foreign_key: :user_id
|
27
29
|
has_many :wallet_payment_sources, foreign_key: 'user_id', class_name: 'Spree::WalletPaymentSource', inverse_of: :user
|
@@ -30,8 +32,8 @@ module Spree
|
|
30
32
|
|
31
33
|
include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
|
32
34
|
|
33
|
-
self.whitelisted_ransackable_associations = %w[addresses]
|
34
|
-
self.whitelisted_ransackable_attributes = %w[id email]
|
35
|
+
self.whitelisted_ransackable_associations = %w[addresses spree_roles]
|
36
|
+
self.whitelisted_ransackable_attributes = %w[id email created_at]
|
35
37
|
end
|
36
38
|
|
37
39
|
def wallet
|
@@ -66,5 +68,19 @@ module Spree
|
|
66
68
|
def total_available_store_credit
|
67
69
|
store_credits.reload.to_a.sum(&:amount_remaining)
|
68
70
|
end
|
71
|
+
deprecate total_available_store_credit: :available_store_credit_total, deprecator: Spree::Deprecation
|
72
|
+
|
73
|
+
def available_store_credit_total(currency:)
|
74
|
+
store_credits.reload.to_a.
|
75
|
+
select { |c| c.currency == currency }.
|
76
|
+
sum(&:amount_remaining)
|
77
|
+
end
|
78
|
+
|
79
|
+
def display_available_store_credit_total(currency:)
|
80
|
+
Spree::Money.new(
|
81
|
+
available_store_credit_total(currency: currency),
|
82
|
+
currency: currency,
|
83
|
+
)
|
84
|
+
end
|
69
85
|
end
|
70
86
|
end
|
data/app/models/spree/address.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'twitter_cldr'
|
2
|
-
|
3
1
|
module Spree
|
4
2
|
# `Spree::Address` provides the foundational ActiveRecord model for recording and
|
5
3
|
# validating address information for `Spree::Order`, `Spree::Shipment`,
|
@@ -15,7 +13,7 @@ module Spree
|
|
15
13
|
validates :zipcode, presence: true, if: :require_zipcode?
|
16
14
|
validates :phone, presence: true, if: :require_phone?
|
17
15
|
|
18
|
-
validate :state_validate
|
16
|
+
validate :state_validate
|
19
17
|
|
20
18
|
alias_attribute :first_name, :firstname
|
21
19
|
alias_attribute :last_name, :lastname
|
@@ -171,6 +169,10 @@ module Spree
|
|
171
169
|
self.country = Spree::Country.find_by!(iso: iso)
|
172
170
|
end
|
173
171
|
|
172
|
+
def country_iso
|
173
|
+
country && country.iso
|
174
|
+
end
|
175
|
+
|
174
176
|
private
|
175
177
|
|
176
178
|
def state_validate
|
@@ -207,13 +209,5 @@ module Spree
|
|
207
209
|
# ensure at least one state field is populated
|
208
210
|
errors.add :state, :blank if state.blank? && state_name.blank?
|
209
211
|
end
|
210
|
-
|
211
|
-
def postal_code_validate
|
212
|
-
return if country.blank? || country.iso.blank? || !require_zipcode?
|
213
|
-
return if !TwitterCldr::Shared::PostalCodes.territories.include?(country.iso.downcase.to_sym)
|
214
|
-
|
215
|
-
postal_code = TwitterCldr::Shared::PostalCodes.for_territory(country.iso)
|
216
|
-
errors.add(:zipcode, :invalid) if !postal_code.valid?(zipcode.to_s)
|
217
|
-
end
|
218
212
|
end
|
219
213
|
end
|
@@ -96,7 +96,7 @@ module Spree
|
|
96
96
|
# admin) or is closed, this is a noop.
|
97
97
|
#
|
98
98
|
# @return [BigDecimal] New amount of this adjustment
|
99
|
-
def
|
99
|
+
def recalculate
|
100
100
|
if finalized? && !tax?
|
101
101
|
return amount
|
102
102
|
end
|
@@ -118,6 +118,15 @@ module Spree
|
|
118
118
|
amount
|
119
119
|
end
|
120
120
|
|
121
|
+
def update!(*args)
|
122
|
+
if args.empty?
|
123
|
+
Spree::Deprecation.warn "Calling adjustment.update! with no arguments to recalculate amounts and eligibility is deprecated, since it conflicts with AR::Base#update! Please use adjustment.recalculate instead"
|
124
|
+
recalculate
|
125
|
+
else
|
126
|
+
super
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
121
130
|
# Calculates based on attached promotion (if this is a promotion
|
122
131
|
# adjustment) whether this promotion is still eligible.
|
123
132
|
# @api private
|
data/app/models/spree/base.rb
CHANGED
@@ -23,6 +23,10 @@ class Spree::Base < ActiveRecord::Base
|
|
23
23
|
|
24
24
|
if Kaminari.config.page_method_name != :page
|
25
25
|
def self.page(num)
|
26
|
+
Spree::Deprecation.warn \
|
27
|
+
"Redefining Spree::Base.page for a different kaminari page name is better done inside " \
|
28
|
+
"your own app. This will be removed from future versions of solidus."
|
29
|
+
|
26
30
|
send Kaminari.config.page_method_name, num
|
27
31
|
end
|
28
32
|
end
|
@@ -13,10 +13,9 @@ module Spree
|
|
13
13
|
rate.tax_categories.include?(line_item.tax_category)
|
14
14
|
end
|
15
15
|
|
16
|
-
line_items_total = matched_line_items.sum(&:
|
16
|
+
line_items_total = matched_line_items.sum(&:total_before_tax)
|
17
17
|
if rate.included_in_price
|
18
|
-
|
19
|
-
refund_if_necessary(order_tax_amount, order.tax_address)
|
18
|
+
round_to_two_places(line_items_total - ( line_items_total / (1 + rate.amount) ) )
|
20
19
|
else
|
21
20
|
round_to_two_places(line_items_total * rate.amount)
|
22
21
|
end
|
@@ -28,7 +27,7 @@ module Spree
|
|
28
27
|
if rate.included_in_price
|
29
28
|
deduced_total_by_rate(item, rate)
|
30
29
|
else
|
31
|
-
round_to_two_places(item.
|
30
|
+
round_to_two_places(item.total_before_tax * rate.amount)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
@@ -47,23 +46,13 @@ module Spree
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def deduced_total_by_rate(item, rate)
|
50
|
-
|
51
|
-
|
52
|
-
round_to_two_places(unrounded_net_amount * rate.amount),
|
53
|
-
item.order.tax_address
|
49
|
+
round_to_two_places(
|
50
|
+
rate.amount * item.total_before_tax / (1 + sum_of_included_tax_rates(item))
|
54
51
|
)
|
55
52
|
end
|
56
53
|
|
57
|
-
def
|
58
|
-
|
59
|
-
amount
|
60
|
-
else
|
61
|
-
amount * -1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def default_zone_or_zone_match?(order_tax_address)
|
66
|
-
Zone.default_tax.try!(:include?, order_tax_address) || rate.zone.include?(order_tax_address)
|
54
|
+
def sum_of_included_tax_rates(item)
|
55
|
+
rates_for_item(item).map(&:amount).sum
|
67
56
|
end
|
68
57
|
end
|
69
58
|
end
|
@@ -16,12 +16,12 @@ module Spree
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def weighted_line_item_amount(inventory_unit)
|
19
|
-
inventory_unit.line_item.
|
19
|
+
inventory_unit.line_item.total_before_tax * percentage_of_line_item(inventory_unit)
|
20
20
|
end
|
21
21
|
|
22
22
|
def percentage_of_order_total(inventory_unit)
|
23
|
-
return 0.0 if inventory_unit.order.
|
24
|
-
weighted_line_item_amount(inventory_unit) / inventory_unit.order.
|
23
|
+
return 0.0 if inventory_unit.order.item_total_before_tax.zero?
|
24
|
+
weighted_line_item_amount(inventory_unit) / inventory_unit.order.item_total_before_tax
|
25
25
|
end
|
26
26
|
|
27
27
|
def percentage_of_line_item(inventory_unit)
|
@@ -25,11 +25,10 @@ module Spree
|
|
25
25
|
|
26
26
|
###################################################################
|
27
27
|
|
28
|
-
def self.register(*_klasses)
|
29
|
-
end
|
30
|
-
|
31
28
|
# Returns all calculators applicable for kind of work
|
32
29
|
def self.calculators
|
30
|
+
Spree::Deprecation.warn("Calling .calculators is deprecated. Please access through Rails.application.config.spree.calculators")
|
31
|
+
|
33
32
|
Rails.application.config.spree.calculators
|
34
33
|
end
|
35
34
|
|
@@ -16,7 +16,8 @@ module Spree
|
|
16
16
|
accepts_nested_attributes_for :return_items
|
17
17
|
|
18
18
|
extend DisplayMoney
|
19
|
-
money_methods :pre_tax_total, :total, :amount
|
19
|
+
money_methods :pre_tax_total, :total, :total_excluding_vat, :amount
|
20
|
+
deprecate display_pre_tax_total: :display_total_excluding_vat, deprecator: Spree::Deprecation
|
20
21
|
|
21
22
|
delegate :currency, to: :order
|
22
23
|
delegate :id, to: :order, prefix: true, allow_nil: true
|
@@ -25,9 +26,11 @@ module Spree
|
|
25
26
|
return_items.map(&:total).sum
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
return_items.map(&:
|
29
|
+
def total_excluding_vat
|
30
|
+
return_items.map(&:total_excluding_vat).sum
|
30
31
|
end
|
32
|
+
alias pre_tax_total total_excluding_vat
|
33
|
+
deprecate pre_tax_total: :total_excluding_vat, deprecator: Spree::Deprecation
|
31
34
|
|
32
35
|
def amount
|
33
36
|
return_items.sum(:amount)
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module Spree
|
2
|
+
# Service class to change fulfilment of inventory units of a particular variant
|
3
|
+
# to another shipment. The other shipment would typically have a different
|
4
|
+
# shipping method, stock location or delivery date, such that we actually change
|
5
|
+
# the planned fulfilment for the items in question.
|
6
|
+
#
|
7
|
+
# Can be used to merge shipments by moving all items to another shipment, because
|
8
|
+
# this class will delete any empty original shipment.
|
9
|
+
#
|
10
|
+
# @attr [Spree::Shipment] current_shipment The shipment we transfer units from
|
11
|
+
# @attr [Spree::Shipment] desired_shipment The shipment we want to move units onto
|
12
|
+
# @attr [Spree::StockLocation] current_stock_location The stock location of the current shipment
|
13
|
+
# @attr [Spree::StockLocation] desired_stock_location The stock location of the desired shipment
|
14
|
+
# @attr [Spree::Variant] variant We only move units that represent this variant
|
15
|
+
# @attr [Integer] quantity How many units we want to move
|
16
|
+
#
|
17
|
+
class FulfilmentChanger
|
18
|
+
include ActiveModel::Validations
|
19
|
+
|
20
|
+
attr_accessor :current_shipment, :desired_shipment
|
21
|
+
attr_reader :variant, :quantity, :current_stock_location, :desired_stock_location
|
22
|
+
|
23
|
+
def initialize(current_shipment:, desired_shipment:, variant:, quantity:)
|
24
|
+
@current_shipment = current_shipment
|
25
|
+
@desired_shipment = desired_shipment
|
26
|
+
@current_stock_location = current_shipment.stock_location
|
27
|
+
@desired_stock_location = desired_shipment.stock_location
|
28
|
+
@variant = variant
|
29
|
+
@quantity = quantity
|
30
|
+
end
|
31
|
+
|
32
|
+
validates :quantity, numericality: { greater_than: 0 }
|
33
|
+
validate :current_shipment_not_already_shipped
|
34
|
+
validate :desired_shipment_different_from_current
|
35
|
+
validates :desired_stock_location, presence: true
|
36
|
+
validate :enough_stock_at_desired_location, if: :handle_stock_counts?
|
37
|
+
|
38
|
+
# Performs the change of fulfilment
|
39
|
+
# @return [true, false] Whether the requested fulfilment change was successful
|
40
|
+
def run!
|
41
|
+
# Validations here are intended to catch all necessary prerequisites.
|
42
|
+
# We return early so all checks have happened already.
|
43
|
+
return false if invalid?
|
44
|
+
desired_shipment.save! if desired_shipment.new_record?
|
45
|
+
|
46
|
+
new_on_hand_quantity = [desired_shipment.stock_location.count_on_hand(variant), quantity].min
|
47
|
+
|
48
|
+
ActiveRecord::Base.transaction do
|
49
|
+
if handle_stock_counts?
|
50
|
+
# We only run this query if we need it.
|
51
|
+
current_on_hand_quantity = [current_shipment.inventory_units.on_hand.size, quantity].min
|
52
|
+
|
53
|
+
# Restock things we will not fulfil from the current shipment anymore
|
54
|
+
current_stock_location.restock(variant, current_on_hand_quantity, current_shipment)
|
55
|
+
# Unstock what we will fulfil with the new shipment
|
56
|
+
desired_stock_location.unstock(variant, new_on_hand_quantity, desired_shipment)
|
57
|
+
end
|
58
|
+
|
59
|
+
# These two statements are the heart of this class. We change the number
|
60
|
+
# of inventory units requested from one shipment to the other.
|
61
|
+
# We order by state, because `'backordered' < 'on_hand'`.
|
62
|
+
current_shipment.
|
63
|
+
inventory_units.
|
64
|
+
where(variant: variant).
|
65
|
+
order(state: :asc).
|
66
|
+
limit(new_on_hand_quantity).
|
67
|
+
update_all(shipment_id: desired_shipment.id, state: :on_hand)
|
68
|
+
|
69
|
+
current_shipment.
|
70
|
+
inventory_units.
|
71
|
+
where(variant: variant).
|
72
|
+
order(state: :asc).
|
73
|
+
limit(quantity - new_on_hand_quantity).
|
74
|
+
update_all(shipment_id: desired_shipment.id, state: :backordered)
|
75
|
+
end
|
76
|
+
|
77
|
+
# We modified the inventory units at the database level for speed reasons.
|
78
|
+
# The downside of that is that we need to reload the associations.
|
79
|
+
current_shipment.inventory_units.reload
|
80
|
+
desired_shipment.inventory_units.reload
|
81
|
+
|
82
|
+
# If the current shipment now has no inventory units left, we won't need it any longer.
|
83
|
+
if current_shipment.inventory_units.length.zero?
|
84
|
+
current_shipment.destroy!
|
85
|
+
else
|
86
|
+
# The current shipment has changed, so we need to make sure that shipping rates
|
87
|
+
# have the correct amount.
|
88
|
+
current_shipment.refresh_rates
|
89
|
+
end
|
90
|
+
|
91
|
+
# The desired shipment has also change, so we need to make sure shipping rates
|
92
|
+
# are up-to-date, too.
|
93
|
+
desired_shipment.refresh_rates
|
94
|
+
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# We don't need to handle stock counts for incomplete orders. Also, if
|
101
|
+
# the new shipment and the desired shipment will ship from the same stock location,
|
102
|
+
# unstocking and restocking will not be necessary.
|
103
|
+
def handle_stock_counts?
|
104
|
+
current_shipment.order.completed? && current_stock_location != desired_stock_location
|
105
|
+
end
|
106
|
+
|
107
|
+
def current_shipment_not_already_shipped
|
108
|
+
if current_shipment.shipped?
|
109
|
+
errors.add(:current_shipment, :has_already_been_shipped)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def enough_stock_at_desired_location
|
114
|
+
unless Spree::Stock::Quantifier.new(variant, desired_stock_location).can_supply?(quantity)
|
115
|
+
errors.add(:desired_shipment, :not_enough_stock_at_desired_location)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def desired_shipment_different_from_current
|
120
|
+
if desired_shipment.id == current_shipment.id
|
121
|
+
errors.add(:desired_shipment, :can_not_transfer_within_same_shipment)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -8,19 +8,11 @@ module Spree
|
|
8
8
|
|
9
9
|
self.table_name = 'spree_users'
|
10
10
|
|
11
|
-
before_destroy :check_completed_orders
|
12
|
-
|
13
11
|
def self.model_name
|
14
12
|
ActiveModel::Name.new Spree::LegacyUser, Spree, 'user'
|
15
13
|
end
|
16
14
|
|
17
15
|
attr_accessor :password
|
18
16
|
attr_accessor :password_confirmation
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def check_completed_orders
|
23
|
-
raise Spree::Core::DestroyWithOrdersError if orders.complete.present?
|
24
|
-
end
|
25
17
|
end
|
26
18
|
end
|
@@ -57,24 +57,41 @@ module Spree
|
|
57
57
|
def discounted_amount
|
58
58
|
amount + promo_total
|
59
59
|
end
|
60
|
+
deprecate discounted_amount: :total_before_tax, deprecator: Spree::Deprecation
|
60
61
|
|
61
62
|
# @return [BigDecimal] the amount of this line item, taking into
|
62
63
|
# consideration all its adjustments.
|
63
|
-
def
|
64
|
+
def total
|
64
65
|
amount + adjustment_total
|
65
66
|
end
|
66
|
-
alias total
|
67
|
+
alias final_amount total
|
68
|
+
deprecate final_amount: :total, deprecator: Spree::Deprecation
|
67
69
|
|
68
|
-
# @return [BigDecimal] the amount of this
|
70
|
+
# @return [BigDecimal] the amount of this item, taking into consideration
|
71
|
+
# all non-tax adjustments.
|
72
|
+
def total_before_tax
|
73
|
+
amount + adjustments.select { |a| !a.tax? && a.eligible? }.sum(&:amount)
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [BigDecimal] the amount of this line item before VAT tax
|
69
77
|
# @note just like `amount`, this does not include any additional tax
|
70
|
-
def
|
71
|
-
|
78
|
+
def total_excluding_vat
|
79
|
+
total_before_tax - included_tax_total
|
72
80
|
end
|
81
|
+
alias pre_tax_amount total_excluding_vat
|
82
|
+
deprecate pre_tax_amount: :total_excluding_vat, deprecator: Spree::Deprecation
|
73
83
|
|
74
84
|
extend Spree::DisplayMoney
|
75
|
-
money_methods :amount, :discounted_amount, :
|
76
|
-
:included_tax_total, :additional_tax_total
|
85
|
+
money_methods :amount, :discounted_amount, :price,
|
86
|
+
:included_tax_total, :additional_tax_total,
|
87
|
+
:total, :total_before_tax, :total_excluding_vat
|
88
|
+
deprecate display_discounted_amount: :display_total_before_tax, deprecator: Spree::Deprecation
|
89
|
+
alias display_final_amount display_total
|
90
|
+
deprecate display_final_amount: :display_total, deprecator: Spree::Deprecation
|
91
|
+
alias display_pre_tax_amount display_total_excluding_vat
|
92
|
+
deprecate display_pre_tax_amount: :display_total_excluding_vat, deprecator: Spree::Deprecation
|
77
93
|
alias discounted_money display_discounted_amount
|
94
|
+
deprecate discounted_money: :display_total_before_tax, deprecator: Spree::Deprecation
|
78
95
|
|
79
96
|
# @return [Spree::Money] the price of this line item
|
80
97
|
alias money_price display_price
|