solidus_core 1.1.4 → 1.2.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/assets/images/logo/solidus_logo.png +0 -0
- data/app/helpers/spree/base_helper.rb +2 -3
- data/app/models/concerns/spree/adjustment_source.rb +1 -1
- data/app/models/concerns/spree/default_price.rb +3 -1
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/user_methods.rb +10 -0
- data/app/models/spree/adjustment.rb +1 -1
- data/app/models/spree/adjustment_reason.rb +2 -4
- data/app/models/spree/app_configuration.rb +36 -0
- data/app/models/spree/base.rb +10 -1
- data/app/models/spree/calculator/tiered_percent.rb +2 -1
- data/app/models/spree/classification.rb +1 -1
- data/app/models/spree/country.rb +3 -3
- data/app/models/spree/credit_card.rb +2 -2
- data/app/models/spree/customer_return.rb +3 -4
- data/app/models/spree/inventory_unit.rb +13 -24
- data/app/models/spree/item_adjustments.rb +5 -5
- data/app/models/spree/line_item.rb +6 -15
- data/app/models/spree/log_entry.rb +1 -1
- data/app/models/spree/option_type.rb +4 -2
- data/app/models/spree/option_type_prototype.rb +6 -0
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order.rb +18 -63
- data/app/models/spree/order/checkout.rb +4 -2
- data/app/models/spree/order_cancellations.rb +52 -1
- data/app/models/spree/order_contents.rb +1 -1
- data/app/models/spree/order_merger.rb +143 -0
- data/app/models/spree/order_shipping.rb +3 -3
- data/app/models/spree/order_update_attributes.rb +42 -0
- data/app/models/spree/order_updater.rb +1 -1
- data/app/models/spree/payment.rb +16 -10
- data/app/models/spree/payment_create.rb +68 -0
- data/app/models/spree/payment_method.rb +0 -1
- data/app/models/spree/preference.rb +1 -1
- data/app/models/spree/price.rb +1 -8
- data/app/models/spree/product.rb +9 -44
- data/app/models/spree/product/scopes.rb +9 -7
- data/app/models/spree/promotion/rules/nth_order.rb +1 -1
- data/app/models/spree/promotion/rules/taxon.rb +2 -1
- data/app/models/spree/promotion_chooser.rb +1 -0
- data/app/models/spree/promotion_code.rb +1 -1
- data/app/models/spree/promotion_rule_taxon.rb +6 -0
- data/app/models/spree/property.rb +2 -1
- data/app/models/spree/property_prototype.rb +6 -0
- data/app/models/spree/prototype.rb +6 -2
- data/app/models/spree/reimbursement.rb +10 -0
- data/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb +1 -1
- data/app/models/spree/return_reason.rb +1 -7
- data/app/models/spree/role_user.rb +3 -5
- data/app/models/spree/shipment.rb +6 -11
- data/app/models/spree/shipping_method.rb +1 -7
- data/app/models/spree/shipping_rate.rb +3 -14
- data/app/models/spree/stock/coordinator.rb +48 -4
- data/app/models/spree/stock/estimator.rb +3 -6
- data/app/models/spree/stock/packer.rb +18 -2
- data/app/models/spree/stock/shipping_rate_selector.rb +16 -0
- data/app/models/spree/stock/shipping_rate_sorter.rb +16 -0
- data/app/models/spree/stock_item.rb +19 -15
- data/app/models/spree/stock_location.rb +2 -12
- data/app/models/spree/stock_transfer.rb +3 -3
- data/app/models/spree/store_credit.rb +2 -2
- data/app/models/spree/tax_category.rb +3 -2
- data/app/models/spree/tax_rate.rb +7 -14
- data/app/models/spree/taxon.rb +4 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/transfer_item.rb +2 -2
- data/app/models/spree/unit_cancel.rb +2 -0
- data/app/models/spree/variant.rb +9 -14
- data/app/models/spree/zone.rb +6 -0
- data/app/models/spree/zone_member.rb +1 -4
- data/app/views/spree/order_mailer/cancel_email.text.erb +0 -0
- data/config/locales/en.yml +7 -5
- data/db/default/spree/countries.rb +1 -1
- data/db/default/spree/zones.rb +5 -11
- data/db/migrate/20130213191427_create_default_stock.rb +1 -1
- data/db/migrate/20130306181701_add_address_fields_to_stock_location.rb +1 -1
- data/db/migrate/20140309033438_create_store_from_preferences.rb +5 -2
- data/db/migrate/20141009204607_add_store_id_to_orders.rb +6 -2
- data/db/migrate/20141215235502_remove_extra_products_slug_index.rb +5 -0
- data/db/migrate/20141217215630_update_product_slug_index.rb +6 -0
- data/db/migrate/20150225205344_move_promotion_code_to_promotion_code_value.rb +2 -2
- data/db/migrate/20150609093816_increase_scale_on_pre_tax_amounts.rb +10 -0
- data/db/migrate/20151117063249_convert_habtm_to_hmt_for_properties_prototypes.rb +17 -0
- data/db/migrate/20151124062500_convert_habtm_to_hmt_for_option_type_prototypes.rb +17 -0
- data/db/migrate/20151126063028_convert_habtm_to_hmt_for_taxons_promotion_rules.rb +15 -0
- data/db/migrate/20151219020209_add_stock_item_unique_index.rb +9 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +1 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +25 -1
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/backend/all.js +3 -0
- data/lib/generators/spree/install/templates/vendor/assets/javascripts/spree/frontend/all.js +3 -0
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/backend/all.css +3 -0
- data/lib/generators/spree/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +3 -0
- data/lib/spree/core/controller_helpers/common.rb +1 -1
- data/lib/spree/core/controller_helpers/order.rb +1 -1
- data/lib/spree/core/controller_helpers/payment_parameters.rb +104 -5
- data/lib/spree/core/engine.rb +3 -2
- data/lib/spree/core/stock_configuration.rb +11 -0
- data/lib/spree/core/unreturned_item_charger.rb +4 -4
- data/lib/spree/core/version.rb +9 -1
- data/lib/spree/permission_sets/restricted_stock_transfer_management.rb +15 -24
- data/lib/spree/permitted_attributes.rb +3 -1
- data/lib/spree/testing_support/capybara_ext.rb +14 -40
- data/lib/spree/testing_support/factories.rb +0 -15
- data/lib/spree/testing_support/factories/address_factory.rb +3 -0
- data/lib/spree/testing_support/factories/adjustment_factory.rb +9 -1
- data/lib/spree/testing_support/factories/carton_factory.rb +4 -1
- data/lib/spree/testing_support/factories/customer_return_factory.rb +4 -0
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +5 -0
- data/lib/spree/testing_support/factories/line_item_factory.rb +3 -0
- data/lib/spree/testing_support/factories/option_type_factory.rb +6 -0
- data/lib/spree/testing_support/factories/{options_factory.rb → option_value_factory.rb} +0 -5
- data/lib/spree/testing_support/factories/order_factory.rb +13 -3
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +3 -0
- data/lib/spree/testing_support/factories/payment_factory.rb +13 -5
- data/lib/spree/testing_support/factories/price_factory.rb +2 -0
- data/lib/spree/testing_support/factories/product_factory.rb +7 -1
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +3 -0
- data/lib/spree/testing_support/factories/product_property_factory.rb +3 -0
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +3 -0
- data/lib/spree/testing_support/factories/promotion_factory.rb +3 -0
- data/lib/spree/testing_support/factories/prototype_factory.rb +2 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +10 -5
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +2 -0
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +4 -4
- data/lib/spree/testing_support/factories/return_item_factory.rb +4 -0
- data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
- data/lib/spree/testing_support/factories/shipment_factory.rb +6 -1
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +22 -10
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +9 -0
- data/lib/spree/testing_support/factories/state_factory.rb +2 -0
- data/lib/spree/testing_support/factories/stock_item_factory.rb +4 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -0
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +2 -0
- data/lib/spree/testing_support/factories/{stock_factory.rb → stock_package_factory.rb} +5 -10
- data/lib/spree/testing_support/factories/stock_packer_factory.rb +13 -0
- data/lib/spree/testing_support/factories/stock_transfer_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +4 -1
- data/lib/spree/testing_support/factories/store_credit_factory.rb +10 -6
- data/lib/spree/testing_support/factories/tax_category_factory.rb +2 -0
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +4 -0
- data/lib/spree/testing_support/factories/taxon_factory.rb +2 -0
- data/lib/spree/testing_support/factories/user_factory.rb +6 -2
- data/lib/spree/testing_support/factories/variant_factory.rb +5 -0
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +3 -0
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +4 -0
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +3 -0
- data/lib/spree/testing_support/factories/zone_factory.rb +6 -0
- data/lib/spree/testing_support/sequences.rb +9 -0
- data/lib/tasks/exchanges.rake +4 -3
- data/lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake +2 -2
- data/solidus_core.gemspec +4 -5
- data/spec/helpers/base_helper_spec.rb +6 -6
- data/spec/helpers/order_helper_spec.rb +1 -1
- data/spec/helpers/products_helper_spec.rb +2 -2
- data/spec/helpers/taxons_helper_spec.rb +1 -1
- data/spec/lib/spree/core/controller_helpers/payment_parameters_spec.rb +107 -7
- data/spec/lib/spree/core/importer/order_spec.rb +1 -1
- data/spec/lib/spree/core/stock_configuration_spec.rb +16 -0
- data/spec/lib/spree/core/testing_support/factories/address_factory_spec.rb +24 -0
- data/spec/lib/spree/core/testing_support/factories/adjustment_factory_spec.rb +18 -0
- data/spec/lib/spree/core/testing_support/factories/adjustment_reason_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/calculator_factory_spec.rb +42 -0
- data/spec/lib/spree/core/testing_support/factories/carton_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/country_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/credit_card_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/customer_return_factory_spec.rb +28 -0
- data/spec/lib/spree/core/testing_support/factories/image_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/inventory_unit_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/line_item_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/option_type_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/option_value_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +49 -0
- data/spec/lib/spree/core/testing_support/factories/order_promotion_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +24 -0
- data/spec/lib/spree/core/testing_support/factories/payment_method_factory_spec.rb +30 -0
- data/spec/lib/spree/core/testing_support/factories/price_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/product_factory_spec.rb +30 -0
- data/spec/lib/spree/core/testing_support/factories/product_option_type_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/product_property_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/promotion_category_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/promotion_code_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/promotion_factory_spec.rb +30 -0
- data/spec/lib/spree/core/testing_support/factories/property_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/prototype_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/refund_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/refund_reason_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/reimbursement_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/reimbursement_type_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/return_authorization_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/return_item_factory_spec.rb +18 -0
- data/spec/lib/spree/core/testing_support/factories/return_reason_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/role_factory_spec.rb +18 -0
- data/spec/lib/spree/core/testing_support/factories/shipment_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/shipping_category_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +28 -0
- data/spec/lib/spree/core/testing_support/factories/shipping_rate_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/state_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/stock_item_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/stock_location_factory_spec.rb +24 -0
- data/spec/lib/spree/core/testing_support/factories/stock_movement_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/stock_package_factory_spec.rb +26 -0
- data/spec/lib/spree/core/testing_support/factories/stock_packer_factory_spec.rb +16 -0
- data/spec/lib/spree/core/testing_support/factories/stock_transfer_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_category_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_event_factory_spec.rb +42 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_type_factory_spec.rb +18 -0
- data/spec/lib/spree/core/testing_support/factories/store_credit_update_reason_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/store_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/tax_category_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/tax_rate_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/taxon_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/taxonomy_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/tracker_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/user_factory_spec.rb +22 -0
- data/spec/lib/spree/core/testing_support/factories/variant_factory_spec.rb +36 -0
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_condition_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/variant_property_rule_value_factory_spec.rb +12 -0
- data/spec/lib/spree/core/testing_support/factories/zone_factory_spec.rb +18 -0
- data/spec/lib/spree/core/unreturned_item_charger_spec.rb +1 -1
- data/spec/lib/spree/core/version_spec.rb +17 -0
- data/spec/lib/spree/money_spec.rb +1 -1
- data/spec/mailers/carton_mailer_spec.rb +1 -1
- data/spec/mailers/order_mailer_spec.rb +1 -1
- data/spec/mailers/reimbursement_mailer_spec.rb +1 -3
- data/spec/mailers/test_mailer_spec.rb +1 -3
- data/spec/models/spree/address_spec.rb +4 -4
- data/spec/models/spree/adjustment_reason_spec.rb +1 -3
- data/spec/models/spree/app_configuration_spec.rb +4 -0
- data/spec/models/spree/calculator/price_sack_spec.rb +3 -3
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +3 -3
- data/spec/models/spree/calculator/tiered_percent_spec.rb +86 -10
- data/spec/models/spree/carton_spec.rb +3 -1
- data/spec/models/spree/classification_spec.rb +3 -3
- data/spec/models/spree/credit_card_spec.rb +16 -16
- data/spec/models/spree/customer_return_spec.rb +1 -1
- data/spec/models/spree/gateway/bogus_simple.rb +1 -1
- data/spec/models/spree/inventory_unit_spec.rb +3 -3
- data/spec/models/spree/item_adjustments_spec.rb +1 -1
- data/spec/models/spree/line_item_spec.rb +2 -2
- 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/callbacks_spec.rb +1 -1
- data/spec/models/spree/order/checkout_spec.rb +16 -11
- data/spec/models/spree/order/payment_spec.rb +24 -22
- data/spec/models/spree/order/state_machine_spec.rb +1 -1
- data/spec/models/spree/order/validations_spec.rb +1 -1
- data/spec/models/spree/order_cancellations_spec.rb +63 -0
- data/spec/models/spree/order_contents_spec.rb +1 -1
- data/spec/models/spree/order_merger_spec.rb +133 -0
- data/spec/models/spree/order_spec.rb +39 -159
- data/spec/models/spree/order_update_attributes_spec.rb +82 -0
- data/spec/models/spree/order_updater_spec.rb +6 -4
- data/spec/models/spree/payment_create_spec.rb +131 -0
- data/spec/models/spree/payment_spec.rb +130 -48
- data/spec/models/spree/permission_sets/restricted_stock_transfer_management_spec.rb +91 -33
- data/spec/models/spree/product_filter_spec.rb +3 -3
- data/spec/models/spree/product_spec.rb +80 -26
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +1 -1
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +2 -2
- data/spec/models/spree/promotion/rules/nth_order_spec.rb +1 -1
- data/spec/models/spree/promotion/rules/user_spec.rb +2 -2
- data/spec/models/spree/promotion_handler/coupon_spec.rb +2 -2
- data/spec/models/spree/promotion_spec.rb +18 -18
- data/spec/models/spree/reimbursement_spec.rb +22 -0
- data/spec/models/spree/return_item_spec.rb +2 -2
- data/spec/models/spree/shipment_spec.rb +28 -12
- data/spec/models/spree/shipping_method_spec.rb +2 -2
- data/spec/models/spree/shipping_rate_spec.rb +3 -3
- data/spec/models/spree/stock/coordinator_spec.rb +5 -0
- data/spec/models/spree/stock/estimator_spec.rb +35 -1
- data/spec/models/spree/stock/package_spec.rb +1 -1
- data/spec/models/spree/stock/packer_spec.rb +2 -3
- data/spec/models/spree/stock/shipping_rate_selector_spec.rb +16 -0
- data/spec/models/spree/stock/shipping_rate_sorter_spec.rb +16 -0
- data/spec/models/spree/stock_item_spec.rb +5 -7
- data/spec/models/spree/stock_location_spec.rb +5 -9
- data/spec/models/spree/stock_transfer_spec.rb +33 -13
- data/spec/models/spree/store_credit_event_spec.rb +1 -1
- data/spec/models/spree/store_credit_spec.rb +1 -1
- data/spec/models/spree/tax_rate_spec.rb +381 -120
- data/spec/models/spree/taxon_spec.rb +3 -3
- data/spec/models/spree/transfer_item_spec.rb +4 -4
- data/spec/models/spree/unit_cancel_spec.rb +1 -1
- data/spec/models/spree/variant_spec.rb +3 -3
- data/spec/models/spree/zone_spec.rb +35 -1
- data/spec/support/concerns/working_factories.rb +9 -0
- data/vendor/assets/javascripts/jquery-migrate-1.0.0.js +498 -0
- data/vendor/assets/javascripts/jquery.payment.js +231 -80
- metadata +103 -27
- data/app/models/spree/order/currency_updater.rb +0 -40
- data/spec/models/spree/order/currency_updater_spec.rb +0 -32
@@ -28,7 +28,7 @@ describe Spree::StoreCreditEvent do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "excludes invalidated store credit events" do
|
31
|
-
invalidated_store_credit = create(:store_credit, invalidated_at: Time.
|
31
|
+
invalidated_store_credit = create(:store_credit, invalidated_at: Time.current)
|
32
32
|
event = create(:store_credit_event, action: Spree::StoreCredit::VOID_ACTION, store_credit: invalidated_store_credit)
|
33
33
|
expect(described_class.exposed_events).not_to include event
|
34
34
|
end
|
@@ -837,7 +837,7 @@ describe Spree::StoreCredit do
|
|
837
837
|
subject { store_credit.invalidate(invalidation_reason, invalidation_user) }
|
838
838
|
|
839
839
|
it "sets the invalidated_at field to the current time" do
|
840
|
-
invalidated_at = Time.
|
840
|
+
invalidated_at = Time.current
|
841
841
|
Timecop.freeze(invalidated_at) do
|
842
842
|
subject
|
843
843
|
expect(store_credit.invalidated_at).to eq invalidated_at
|
@@ -181,7 +181,7 @@ describe Spree::TaxRate, :type => :model do
|
|
181
181
|
allow(Spree::TaxRate).to receive_messages :match => [rate_1, rate_2]
|
182
182
|
end
|
183
183
|
|
184
|
-
it "should apply adjustments for
|
184
|
+
it "should only apply adjustments for matching rates" do
|
185
185
|
expect(rate_1).to receive(:adjust)
|
186
186
|
expect(rate_2).not_to receive(:adjust)
|
187
187
|
Spree::TaxRate.adjust(order.tax_zone, line_items)
|
@@ -195,7 +195,7 @@ describe Spree::TaxRate, :type => :model do
|
|
195
195
|
allow(Spree::TaxRate).to receive_messages :match => [rate_1, rate_2]
|
196
196
|
end
|
197
197
|
|
198
|
-
it "should apply adjustments for
|
198
|
+
it "should apply adjustments for matching rates" do
|
199
199
|
expect(rate_1).to receive(:adjust)
|
200
200
|
expect(rate_2).not_to receive(:adjust)
|
201
201
|
Spree::TaxRate.adjust(order.tax_zone, shipments)
|
@@ -203,173 +203,434 @@ describe Spree::TaxRate, :type => :model do
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
206
|
+
# While the above test is nice and fast - let me tell you a story or two here.
|
207
|
+
context ".adjust" do
|
208
|
+
let(:order) { create :order }
|
209
|
+
let(:book_product) { create :product, price: 20, name: "Book", tax_category: books_category }
|
210
|
+
let(:download_product) { create :product, price: 10, name: "Download", tax_category: digital_category }
|
211
|
+
let(:sweater_product) { create :product, price: 30, name: "Download", tax_category: normal_category }
|
212
|
+
let(:book) { book_product.master }
|
213
|
+
let(:download) { download_product.master }
|
214
|
+
let(:sweater) { sweater_product.master }
|
215
|
+
let(:books_category) { create :tax_category, name: "Books" }
|
216
|
+
let(:normal_category) { create :tax_category, name: "Normal" }
|
217
|
+
let(:digital_category) { create :tax_category, name: "Digital Goods" }
|
218
|
+
|
219
|
+
context 'selling from germany' do
|
220
|
+
let(:germany) { create :country, iso: "DE" }
|
221
|
+
# The weird default_tax boolean is what makes this context one with default included taxes
|
222
|
+
let!(:germany_zone) { create :zone, countries: [germany], default_tax: true }
|
223
|
+
let(:romania) { create(:country, iso: "RO") }
|
224
|
+
let(:romania_zone) { create(:zone, countries: [romania] ) }
|
225
|
+
let(:eu_zone) { create(:zone, countries: [romania, germany]) }
|
226
|
+
let(:world_zone) { create(:zone, :with_country) }
|
227
|
+
|
228
|
+
let!(:german_book_vat) do
|
229
|
+
create(
|
230
|
+
:tax_rate,
|
231
|
+
included_in_price: true,
|
232
|
+
amount: 0.07,
|
233
|
+
tax_category: books_category,
|
234
|
+
zone: eu_zone
|
235
|
+
)
|
236
|
+
end
|
237
|
+
let!(:german_normal_vat) do
|
238
|
+
create(
|
239
|
+
:tax_rate,
|
240
|
+
included_in_price: true,
|
241
|
+
amount: 0.19,
|
242
|
+
tax_category: normal_category,
|
243
|
+
zone: eu_zone
|
244
|
+
)
|
245
|
+
end
|
246
|
+
let!(:german_digital_vat) do
|
247
|
+
create(
|
248
|
+
:tax_rate,
|
249
|
+
included_in_price: true,
|
250
|
+
amount: 0.19,
|
251
|
+
tax_category: digital_category,
|
252
|
+
zone: germany_zone
|
253
|
+
)
|
254
|
+
end
|
255
|
+
let!(:romanian_digital_vat) do
|
256
|
+
create(
|
257
|
+
:tax_rate,
|
258
|
+
included_in_price: true,
|
259
|
+
amount: 0.24,
|
260
|
+
tax_category: digital_category,
|
261
|
+
zone: romania_zone
|
262
|
+
)
|
263
|
+
end
|
232
264
|
|
233
|
-
|
234
|
-
|
235
|
-
|
265
|
+
before do
|
266
|
+
allow(order).to receive(:tax_zone) { tax_zone }
|
267
|
+
order.contents.add(variant)
|
268
|
+
Spree::TaxRate.adjust(order.tax_zone, order.line_items)
|
236
269
|
end
|
237
270
|
|
238
|
-
|
239
|
-
|
240
|
-
|
271
|
+
let(:line_item) { order.line_items.first }
|
272
|
+
|
273
|
+
context 'to germany' do
|
274
|
+
let(:tax_zone) { germany_zone }
|
275
|
+
|
276
|
+
context 'an order with a book' do
|
277
|
+
let(:variant) { book }
|
278
|
+
|
279
|
+
it 'still has the original price' do
|
280
|
+
expect(line_item.price).to eq(20)
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'has one tax adjustment' do
|
284
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'has 1.13 cents of included tax' do
|
288
|
+
expect(line_item.included_tax_total).to eq(1.31)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
context 'an order with a sweater' do
|
293
|
+
let(:variant) { sweater }
|
294
|
+
|
295
|
+
it 'still has the original price' do
|
296
|
+
expect(line_item.price).to eq(30)
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'has one tax adjustment' do
|
300
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'has 4,78 of included tax' do
|
304
|
+
expect(line_item.included_tax_total).to eq(4.79)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context 'an order with a download' do
|
309
|
+
let(:variant) { download }
|
310
|
+
|
311
|
+
it 'still has the original price' do
|
312
|
+
expect(line_item.price).to eq(10)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'has one tax adjustment' do
|
316
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'has 1.60 of included tax' do
|
320
|
+
expect(line_item.included_tax_total).to eq(1.60)
|
321
|
+
end
|
322
|
+
end
|
241
323
|
end
|
242
|
-
end
|
243
324
|
|
244
|
-
|
245
|
-
|
325
|
+
context 'to romania' do
|
326
|
+
let(:tax_zone) { romania_zone }
|
246
327
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
328
|
+
context 'an order with a book' do
|
329
|
+
let(:variant) { book }
|
330
|
+
|
331
|
+
it 'still has the original price' do
|
332
|
+
expect(line_item.price).to eq(20)
|
333
|
+
end
|
334
|
+
|
335
|
+
it 'is adjusted to the original price' do
|
336
|
+
expect(line_item.total).to eq(20)
|
337
|
+
end
|
338
|
+
|
339
|
+
it 'has one tax adjustment' do
|
340
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'has 1.13 cents of included tax' do
|
344
|
+
expect(line_item.included_tax_total).to eq(1.31)
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'has a constant amount pre tax' do
|
348
|
+
expect(line_item.pre_tax_amount).to eq(18.69)
|
349
|
+
end
|
252
350
|
end
|
253
351
|
|
254
|
-
context
|
255
|
-
|
256
|
-
|
257
|
-
|
352
|
+
context 'an order with a sweater' do
|
353
|
+
let(:variant) { sweater }
|
354
|
+
|
355
|
+
it 'still has the original price' do
|
356
|
+
expect(line_item.price).to eq(30)
|
357
|
+
end
|
358
|
+
|
359
|
+
it 'has one tax adjustment' do
|
360
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
361
|
+
end
|
362
|
+
|
363
|
+
# This test fails intermittently - it's a matter of luck
|
364
|
+
xit 'has 4.79 of included tax' do
|
365
|
+
expect(line_item.included_tax_total).to eq(4.79)
|
258
366
|
end
|
259
367
|
|
260
|
-
it
|
261
|
-
|
262
|
-
expect(line_item.adjustments.credit.count).to eq(0)
|
368
|
+
it 'has a constant amount pre tax' do
|
369
|
+
expect(line_item.pre_tax_amount).to eq(25.21)
|
263
370
|
end
|
264
371
|
end
|
265
372
|
|
266
|
-
context
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
373
|
+
context 'an order with a download' do
|
374
|
+
let(:variant) { download }
|
375
|
+
|
376
|
+
it 'still has an adjusted price for romania' do
|
377
|
+
pending "waiting for the MOSS refactoring"
|
378
|
+
expect(line_item.price).to eq(10.42)
|
272
379
|
end
|
273
|
-
|
274
|
-
|
275
|
-
expect(line_item.adjustments.
|
380
|
+
|
381
|
+
it 'has one tax adjustment' do
|
382
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
383
|
+
end
|
384
|
+
|
385
|
+
# Fails intermittently - xit'ed for the time being
|
386
|
+
xit 'has 2.02 of included tax' do
|
387
|
+
expect(line_item.included_tax_total).to eq(2.02)
|
276
388
|
end
|
277
389
|
|
278
|
-
it
|
279
|
-
|
280
|
-
expect(line_item.
|
390
|
+
it 'has a constant amount pre tax' do
|
391
|
+
pending 'but it changes to 8.06, because Spree thinks both VATs apply'
|
392
|
+
expect(line_item.pre_tax_amount).to eq(8.40)
|
281
393
|
end
|
282
394
|
end
|
395
|
+
end
|
283
396
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
397
|
+
# International delivery, no tax applies whatsoever
|
398
|
+
context 'to anywhere else in the world' do
|
399
|
+
let(:tax_zone) { world_zone }
|
400
|
+
|
401
|
+
context 'an order with a book' do
|
402
|
+
let(:variant) { book }
|
403
|
+
|
404
|
+
it 'should sell at the net price' do
|
405
|
+
pending "Prices have to be adjusted"
|
406
|
+
expect(line_item.price).to eq(18.69)
|
291
407
|
end
|
292
408
|
|
293
|
-
it
|
294
|
-
|
295
|
-
expect(line_item.adjustments.charge.count).to eq(0)
|
409
|
+
it 'is adjusted to the net price' do
|
410
|
+
expect(line_item.total).to eq(18.69)
|
296
411
|
end
|
297
412
|
|
298
|
-
it
|
299
|
-
|
300
|
-
expect(line_item.adjustments.
|
413
|
+
it 'has no tax adjustments' do
|
414
|
+
pending "Right now it gets a refund"
|
415
|
+
expect(line_item.adjustments.tax.count).to eq(0)
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'has no included tax' do
|
419
|
+
expect(line_item.included_tax_total).to eq(0)
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'has no additional tax' do
|
423
|
+
pending 'but there is a refund, still'
|
424
|
+
expect(line_item.additional_tax_total).to eq(0)
|
425
|
+
end
|
426
|
+
|
427
|
+
it 'has a constant amount pre tax' do
|
428
|
+
expect(line_item.pre_tax_amount).to eq(18.69)
|
301
429
|
end
|
302
430
|
end
|
303
431
|
|
304
|
-
context
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
432
|
+
context 'an order with a sweater' do
|
433
|
+
let(:variant) { sweater }
|
434
|
+
|
435
|
+
it 'should sell at the net price' do
|
436
|
+
pending 'but prices are not adjusted according to the zone yet'
|
437
|
+
expect(line_item.price).to eq(25.21)
|
438
|
+
end
|
439
|
+
|
440
|
+
it 'has no tax adjustments' do
|
441
|
+
pending 'but it has a refund'
|
442
|
+
expect(line_item.adjustments.tax.count).to eq(0)
|
443
|
+
end
|
444
|
+
|
445
|
+
it 'has no included tax' do
|
446
|
+
expect(line_item.included_tax_total).to eq(0)
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'has no additional tax' do
|
450
|
+
pending 'but it has a refund for included taxes wtf'
|
451
|
+
expect(line_item.additional_tax_total).to eq(0)
|
452
|
+
end
|
453
|
+
|
454
|
+
it 'has a constant amount pre tax' do
|
455
|
+
expect(line_item.pre_tax_amount).to eq(25.21)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
context 'an order with a download' do
|
460
|
+
let(:variant) { download }
|
461
|
+
|
462
|
+
it 'should sell at the net price' do
|
463
|
+
pending 'but prices are not adjusted yet'
|
464
|
+
expect(line_item.price).to eq(8.40)
|
465
|
+
end
|
466
|
+
|
467
|
+
it 'has no tax adjustments' do
|
468
|
+
pending 'but a refund is created'
|
469
|
+
expect(line_item.adjustments.tax.count).to eq(0)
|
470
|
+
end
|
471
|
+
|
472
|
+
it 'has no included tax' do
|
473
|
+
expect(line_item.included_tax_total).to eq(0)
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'has no additional tax' do
|
477
|
+
pending 'but an tax refund that disguises as additional tax is created'
|
478
|
+
expect(line_item.additional_tax_total).to eq(0)
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'has a constant amount pre tax' do
|
482
|
+
expect(line_item.pre_tax_amount).to eq(8.40)
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
# Choosing New York here because in the US, states matter
|
489
|
+
context 'selling from new york' do
|
490
|
+
let(:new_york) { create(:state) }
|
491
|
+
let(:united_states) { create(:country, states: [new_york]) }
|
492
|
+
let(:new_york_zone) { create(:zone, states: [new_york]) }
|
493
|
+
let(:unites_states_zone) { create(:zone, countries: [united_states])}
|
494
|
+
# Creating two rates for books here to
|
495
|
+
# mimick the existing specs
|
496
|
+
let!(:new_york_books_tax) do
|
497
|
+
create(
|
498
|
+
:tax_rate,
|
499
|
+
tax_category: books_category,
|
500
|
+
zone: new_york_zone,
|
501
|
+
included_in_price: false,
|
502
|
+
amount: 0.05
|
503
|
+
)
|
504
|
+
end
|
505
|
+
|
506
|
+
let!(:federal_books_tax) do
|
507
|
+
create(
|
508
|
+
:tax_rate,
|
509
|
+
tax_category: books_category,
|
510
|
+
zone: unites_states_zone,
|
511
|
+
included_in_price: false,
|
512
|
+
amount: 0.10
|
513
|
+
)
|
514
|
+
end
|
515
|
+
|
516
|
+
let!(:federal_digital_tax) do
|
517
|
+
create(
|
518
|
+
:tax_rate,
|
519
|
+
tax_category: digital_category,
|
520
|
+
zone: unites_states_zone,
|
521
|
+
included_in_price: false,
|
522
|
+
amount: 0.20
|
523
|
+
)
|
524
|
+
end
|
525
|
+
|
526
|
+
before do
|
527
|
+
allow(order).to receive(:tax_zone) { tax_zone }
|
528
|
+
order.contents.add(variant)
|
529
|
+
Spree::TaxRate.adjust(order.tax_zone, order.line_items)
|
530
|
+
end
|
531
|
+
|
532
|
+
let(:line_item) { order.line_items.first }
|
533
|
+
|
534
|
+
context 'to new york' do
|
535
|
+
let(:tax_zone) { new_york_zone }
|
536
|
+
|
537
|
+
# A fictional case for an item with two applicable rates
|
538
|
+
context 'an order with a book' do
|
539
|
+
let(:variant) { book }
|
540
|
+
|
541
|
+
it 'still has the original price' do
|
542
|
+
expect(line_item.price).to eq(20)
|
543
|
+
end
|
544
|
+
|
545
|
+
it 'sells for the line items amount plus additional tax' do
|
546
|
+
expect(line_item.total).to eq(23)
|
547
|
+
end
|
548
|
+
|
549
|
+
it 'has two tax adjustments' do
|
550
|
+
expect(line_item.adjustments.tax.count).to eq(2)
|
551
|
+
end
|
552
|
+
|
553
|
+
it 'has no included tax' do
|
554
|
+
expect(line_item.included_tax_total).to eq(0)
|
555
|
+
end
|
556
|
+
|
557
|
+
it 'has 15% additional tax' do
|
558
|
+
expect(line_item.additional_tax_total).to eq(3)
|
313
559
|
end
|
314
560
|
|
315
561
|
it "should delete adjustments for open order when taxrate is deleted" do
|
316
|
-
|
317
|
-
|
562
|
+
new_york_books_tax.destroy!
|
563
|
+
federal_books_tax.destroy!
|
318
564
|
expect(line_item.adjustments.count).to eq(0)
|
319
565
|
end
|
320
566
|
|
321
567
|
it "should not delete adjustments for complete order when taxrate is deleted" do
|
322
|
-
|
323
|
-
|
324
|
-
|
568
|
+
order.update_column :completed_at, Time.now
|
569
|
+
new_york_books_tax.destroy!
|
570
|
+
federal_books_tax.destroy!
|
325
571
|
expect(line_item.adjustments.count).to eq(2)
|
326
572
|
end
|
573
|
+
end
|
327
574
|
|
328
|
-
|
329
|
-
|
330
|
-
|
575
|
+
# This is a fictional case for when no taxes apply at all.
|
576
|
+
context 'an order with a sweater' do
|
577
|
+
let(:variant) { sweater }
|
331
578
|
|
332
|
-
it
|
333
|
-
expect(line_item.
|
579
|
+
it 'still has the original price' do
|
580
|
+
expect(line_item.price).to eq(30)
|
334
581
|
end
|
335
582
|
|
336
|
-
|
337
|
-
|
583
|
+
it 'sells for the line items amount plus additional tax' do
|
584
|
+
expect(line_item.total).to eq(30)
|
585
|
+
end
|
338
586
|
|
339
|
-
|
340
|
-
|
341
|
-
|
587
|
+
it 'has no tax adjustments' do
|
588
|
+
expect(line_item.adjustments.tax.count).to eq(0)
|
589
|
+
end
|
342
590
|
|
343
|
-
|
344
|
-
|
591
|
+
it 'has no included tax' do
|
592
|
+
expect(line_item.included_tax_total).to eq(0)
|
593
|
+
end
|
345
594
|
|
346
|
-
|
347
|
-
|
348
|
-
expect(line_item.adjustments.count).to eq(0)
|
349
|
-
end
|
350
|
-
end
|
595
|
+
it 'has no additional tax' do
|
596
|
+
expect(line_item.additional_tax_total).to eq(0)
|
351
597
|
end
|
352
598
|
end
|
353
599
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
line_item.
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
600
|
+
# A fictional case with one applicable rate
|
601
|
+
context 'an order with a download' do
|
602
|
+
let(:variant) { download }
|
603
|
+
|
604
|
+
it 'still has the original price' do
|
605
|
+
expect(line_item.price).to eq(10)
|
606
|
+
end
|
607
|
+
|
608
|
+
it 'sells for the line items amount plus additional tax' do
|
609
|
+
expect(line_item.total).to eq(12)
|
364
610
|
end
|
365
611
|
|
366
|
-
it
|
367
|
-
expect(
|
612
|
+
it 'has one tax adjustments' do
|
613
|
+
expect(line_item.adjustments.tax.count).to eq(1)
|
368
614
|
end
|
369
615
|
|
370
|
-
it
|
371
|
-
|
372
|
-
|
616
|
+
it 'has no included tax' do
|
617
|
+
expect(line_item.included_tax_total).to eq(0)
|
618
|
+
end
|
619
|
+
|
620
|
+
it 'has 15% additional tax' do
|
621
|
+
expect(line_item.additional_tax_total).to eq(2)
|
622
|
+
end
|
623
|
+
end
|
624
|
+
end
|
625
|
+
|
626
|
+
context 'when no tax zone is given' do
|
627
|
+
let(:tax_zone) { nil }
|
628
|
+
|
629
|
+
context 'and we buy a book' do
|
630
|
+
let(:variant) { book }
|
631
|
+
|
632
|
+
it 'does not create adjustments' do
|
633
|
+
expect(line_item.adjustments.count).to eq(0)
|
373
634
|
end
|
374
635
|
end
|
375
636
|
end
|