spree 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/CHANGELOG +81 -4
- data/CONTRIBUTORS +18 -10
- data/Rakefile +5 -4
- data/app/controllers/admin/adjustments_controller.rb +17 -3
- data/app/controllers/admin/base_controller.rb +2 -2
- data/app/controllers/admin/checkouts_controller.rb +43 -34
- data/app/controllers/admin/line_items_controller.rb +32 -18
- data/app/controllers/admin/option_types_controller.rb +1 -1
- data/app/controllers/admin/orders_controller.rb +28 -7
- data/app/controllers/admin/payments_controller.rb +7 -7
- data/app/controllers/admin/products_controller.rb +12 -23
- data/app/controllers/admin/reports_controller.rb +19 -7
- data/app/controllers/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/admin/shipments_controller.rb +9 -9
- data/app/controllers/admin/users_controller.rb +3 -1
- data/app/controllers/admin/variants_controller.rb +2 -2
- data/app/controllers/checkouts_controller.rb +29 -18
- data/app/controllers/content_controller.rb +1 -1
- data/{vendor/extensions/localization/app → app}/controllers/locale_controller.rb +1 -1
- data/app/controllers/orders_controller.rb +33 -30
- data/app/controllers/password_resets_controller.rb +4 -4
- data/app/controllers/products_controller.rb +0 -6
- data/app/controllers/spree/base_controller.rb +9 -2
- data/app/controllers/user_sessions_controller.rb +18 -18
- data/app/controllers/users_controller.rb +2 -2
- data/app/helpers/admin/base_helper.rb +5 -2
- data/app/helpers/admin/navigation_helper.rb +1 -1
- data/app/helpers/admin/orders_helper.rb +0 -13
- data/app/helpers/admin/products_helper.rb +0 -8
- data/app/helpers/checkouts_helper.rb +5 -5
- data/app/helpers/products_helper.rb +0 -12
- data/app/helpers/spree/base_helper.rb +10 -39
- data/app/helpers/taxons_helper.rb +1 -0
- data/app/models/address.rb +6 -1
- data/app/models/app_configuration.rb +15 -14
- data/app/models/calculator/flexi_rate.rb +2 -1
- data/app/models/calculator/vat.rb +1 -1
- data/app/models/checkout.rb +1 -1
- data/app/models/creditcard.rb +26 -20
- data/app/models/inventory_unit.rb +70 -21
- data/app/models/line_item.rb +25 -11
- data/app/models/order.rb +16 -10
- data/app/models/payment.rb +4 -1
- data/app/models/payment_method.rb +14 -5
- data/app/models/product.rb +12 -4
- data/app/models/role.rb +2 -2
- data/app/models/shipment.rb +21 -2
- data/app/models/tax_category.rb +8 -0
- data/app/models/taxon.rb +8 -0
- data/app/models/user.rb +2 -3
- data/app/models/variant.rb +18 -13
- data/config/boot.rb +1 -5
- data/config/cucumber.yml +7 -0
- data/config/database.yml +20 -37
- data/config/database.yml.example +5 -6
- data/config/environment.rb +6 -5
- data/config/environments/cucumber.rb +30 -0
- data/config/environments/production.rb +1 -4
- data/config/environments/staging.rb +3 -0
- data/config/environments/test.rb +1 -1
- data/config/initializers/cookie_verification_secret.rb +7 -0
- data/config/initializers/locales.rb +4 -2
- data/config/initializers/new_rails_defaults.rb +2 -0
- data/config/initializers/spree.rb +1 -0
- data/config/initializers/workarounds_for_ruby19.rb +0 -25
- data/config/locales/{en-US.yml → en_spree.yml} +18 -4
- data/config/routes.rb +2 -1
- data/db/migrate/20100317120946_add_alt_text_to_images.rb +9 -0
- data/db/migrate/20100427121301_add_display_to_payment_methods.rb +9 -0
- data/db/migrate/20100504142133_add_addresses_checkouts_indexes.rb +16 -0
- data/db/migrate/20100506180619_add_icon_to_taxons.rb +18 -0
- data/db/migrate/20100506185838_add_description_to_taxons.rb +11 -0
- data/db/migrate/20100528155333_index_for_shipments_number.rb +9 -0
- data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +9 -0
- data/db/migrate/20100605152042_add_default_to_tax_categories.rb +9 -0
- data/db/sample/payment_methods.yml +8 -1
- data/db/sample/shipments.yml +2 -2
- data/db/schema.rb +54 -21
- data/features/checkout.feature +98 -0
- data/features/create_admin_user.feature +18 -0
- data/features/search.feature +35 -0
- data/features/sign_in.feature +25 -0
- data/features/sign_out.feature +12 -0
- data/features/sign_up.feature +20 -0
- data/features/step_definitions/error_steps.rb +3 -0
- data/features/step_definitions/model_steps.rb +3 -0
- data/features/step_definitions/pickle_steps.rb +73 -0
- data/features/step_definitions/role_steps.rb +8 -0
- data/features/step_definitions/session_steps.rb +14 -0
- data/features/step_definitions/user_steps.rb +67 -0
- data/features/step_definitions/web_steps.rb +197 -0
- data/features/support/create_admin_user.rb +6 -0
- data/features/support/env.rb +89 -0
- data/features/support/paths.rb +32 -0
- data/features/support/pickle.rb +24 -0
- data/features/work_with_cart.feature +41 -0
- data/lib/generators/extension_model/extension_model_generator.rb +10 -10
- data/lib/generators/instance/templates/databases/mysql.yml +11 -0
- data/lib/scopes/variant.rb +10 -0
- data/lib/spree.rb +3 -3
- data/lib/spree/extensions.rb +1 -1
- data/lib/tasks/cucumber.rake +47 -0
- data/lib/tasks/database.rake +29 -29
- data/public/images/admin/bg/spree_50.png +0 -0
- data/public/images/tile-header.png +0 -0
- data/public/images/tile-slider.png +0 -0
- data/public/javascripts/admin/checkouts/edit.js +33 -0
- data/public/javascripts/dashboard.js +2 -2
- data/public/javascripts/taxonomy.js +2 -2
- data/public/stylesheets/admin/admin-tables.css +4 -0
- data/public/stylesheets/admin/admin.css +31 -16
- data/public/stylesheets/screen.css +16 -3
- data/script/about +3 -2
- data/script/console +2 -2
- data/script/cucumber +10 -0
- data/script/dbconsole +1 -1
- data/script/destroy +2 -2
- data/script/generate +2 -2
- data/script/performance/benchmarker +1 -1
- data/script/performance/profiler +1 -1
- data/script/plugin +2 -2
- data/script/runner +2 -2
- data/script/server +2 -2
- data/test/fixtures/payment_methods.yml +12 -0
- data/test/functional/admin/checkouts_controller_test.rb +0 -2
- data/test/functional/admin/line_items_controller_test.rb +78 -39
- data/test/functional/admin/products_controller_test.rb +4 -5
- data/test/integration/checkout_test.rb +1 -0
- data/test/test_helper.rb +114 -86
- data/test/unit/creditcard_test.rb +28 -7
- data/test/unit/flexi_rate_calculator_test.rb +75 -0
- data/test/unit/helpers/products_helper_test.rb +4 -4
- data/test/unit/inventory_unit_test.rb +39 -5
- data/test/unit/line_item_test.rb +60 -1
- data/test/unit/order_state_test.rb +85 -58
- data/test/unit/order_test.rb +144 -123
- data/test/unit/product_test.rb +21 -0
- data/test/unit/return_authorization_test.rb +22 -28
- data/test/unit/shipment_test.rb +19 -7
- data/test/unit/variant_test.rb +100 -24
- data/vendor/extensions/api/api_extension.rb +2 -2
- data/vendor/extensions/api/app/controllers/api/base_controller.rb +14 -6
- data/vendor/extensions/api/app/controllers/api/countries_controller.rb +4 -0
- data/vendor/extensions/api/app/controllers/api/orders_controller.rb +4 -4
- data/vendor/extensions/api/app/controllers/api/products_controller.rb +5 -1
- data/vendor/extensions/api/app/controllers/api/shipments_controller.rb +7 -7
- data/vendor/extensions/api/app/controllers/api/states_controller.rb +5 -0
- data/vendor/extensions/api/config/locales/{en-US.yml → en.yml} +2 -2
- data/vendor/extensions/api/config/routes.rb +5 -0
- data/vendor/extensions/api/test/integration/orders_api_test.rb +4 -4
- data/vendor/extensions/overview_dashboard/app/views/admin/overview/index.html.erb +1 -1
- data/vendor/extensions/payment_gateway/app/models/gateway.rb +1 -1
- data/vendor/extensions/payment_gateway/app/models/gateway/authorize_net_cim.rb +41 -29
- data/vendor/extensions/payment_gateway/app/models/gateway/bogus.rb +3 -3
- data/vendor/extensions/payment_gateway/app/models/gateway/eway.rb +11 -0
- data/vendor/extensions/payment_gateway/app/models/gateway/sage_pay.rb +9 -0
- data/vendor/extensions/payment_gateway/config/locales/{en-US.yml → en.yml} +1 -1
- data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +46 -56
- data/vendor/extensions/payment_gateway/payment_gateway_extension.rb +9 -10
- data/vendor/extensions/payment_gateway/test/unit/authorize_net_cim_test.rb +7 -6
- data/vendor/extensions/theme_default/app/stylesheets/_checkout.less +10 -3
- data/vendor/extensions/theme_default/app/views/admin/adjustments/index.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/checkouts/_form.html.erb +31 -5
- data/vendor/extensions/theme_default/app/views/admin/checkouts/show.html.erb +27 -16
- data/vendor/extensions/theme_default/app/views/admin/images/_form.html.erb +4 -0
- data/vendor/extensions/theme_default/app/views/admin/images/index.html.erb +16 -13
- data/vendor/extensions/theme_default/app/views/admin/orders/_add_product.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/orders/_form.html.erb +7 -0
- data/vendor/extensions/theme_default/app/views/admin/orders/index.html.erb +5 -5
- data/vendor/extensions/theme_default/app/views/admin/payment_methods/_form.html.erb +12 -6
- data/vendor/extensions/theme_default/app/views/admin/payment_methods/index.html.erb +22 -11
- data/vendor/extensions/theme_default/app/views/admin/product_groups/update.js.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/products/_form.html.erb +6 -4
- data/vendor/extensions/theme_default/app/views/admin/shared/_address_form.html.erb +64 -55
- data/vendor/extensions/theme_default/app/views/admin/shared/_configuration_menu.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/shared/_order_tabs.html.erb +11 -3
- data/vendor/extensions/theme_default/app/views/admin/shared/_product_tabs.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/shipments/_form.html.erb +32 -29
- data/vendor/extensions/theme_default/app/views/admin/shipments/index.html.erb +2 -1
- data/vendor/extensions/theme_default/app/views/admin/tax_categories/_form.html.erb +6 -3
- data/vendor/extensions/theme_default/app/views/admin/tax_categories/index.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_taxon.html.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/taxons/_form.html.erb +11 -1
- data/vendor/extensions/theme_default/app/views/admin/taxons/edit.html.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/users/_form.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/variants/_form.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/checkouts/_confirm.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/checkouts/_delivery.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/checkouts/_summary.html.erb +6 -6
- data/vendor/extensions/theme_default/app/views/checkouts/edit.html.erb +3 -3
- data/vendor/extensions/theme_default/app/views/layouts/admin.html.erb +7 -5
- data/vendor/extensions/theme_default/app/views/layouts/spree_application.html.erb +8 -4
- data/vendor/extensions/theme_default/app/views/orders/_line_item.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/products/index.html.erb +0 -1
- data/vendor/extensions/theme_default/app/views/shared/_footer.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/shared/_products.html.erb +3 -1
- data/vendor/extensions/theme_default/app/views/shared/_user_form.html.erb +1 -1
- data/vendor/extensions/theme_default/public/images/admin/bg/spree_50.png +0 -0
- data/vendor/extensions/theme_default/public/images/tile-header.png +0 -0
- data/vendor/extensions/theme_default/public/images/tile-slider.png +0 -0
- data/vendor/extensions/theme_default/public/javascripts/admin/checkouts/edit.js +50 -0
- data/vendor/extensions/theme_default/public/javascripts/taxonomy.js +2 -2
- data/vendor/extensions/theme_default/public/stylesheets/admin/admin-tables.css +8 -0
- data/vendor/extensions/theme_default/public/stylesheets/admin/admin.css +31 -16
- data/vendor/extensions/theme_default/public/stylesheets/screen.css +16 -3
- data/vendor/plugins/attribute_fu/{tasks → lib/tasks}/attribute_fu_tasks.rake +0 -0
- data/vendor/plugins/enumerable_constants/{tasks → lib/tasks}/enumerable_constants_tasks.rake +0 -0
- data/vendor/plugins/find_by_param/lib/find_by_param.rb +9 -5
- data/vendor/plugins/find_by_param/{tasks → lib/tasks}/find_by_param_tasks.rake +0 -0
- data/vendor/plugins/jrails/{tasks → lib/tasks}/jrails.rake +0 -0
- data/vendor/plugins/jrails_auto_complete/{tasks → lib/tasks}/jrails_auto_complete_tasks.rake +0 -0
- data/vendor/plugins/mail_queue/{tasks → lib/tasks}/mailer_queue_tasks.rake +0 -0
- data/vendor/plugins/open_id_authentication/{tasks → lib/tasks}/open_id_authentication_tasks.rake +0 -0
- data/vendor/plugins/resource_controller/lib/resource_controller/helpers/internal.rb +2 -2
- data/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb +7 -7
- data/vendor/plugins/unobtrusive_date_picker/{tasks → lib/tasks}/datepicker_tasks.rake +0 -0
- metadata +82 -342
- data/app/helpers/admin/adjustments_helper.rb +0 -2
- data/app/helpers/admin/checkouts_helper.rb +0 -2
- data/app/helpers/admin/line_items_helper.rb +0 -2
- data/app/helpers/admin/properties_helper.rb +0 -9
- data/app/helpers/admin/prototypes_helper.rb +0 -18
- data/app/helpers/admin/return_authorizations_helper.rb +0 -2
- data/config/locales/cs-CZ.yml +0 -924
- data/config/locales/cs-CZ_rails.yml +0 -202
- data/config/locales/da.yml +0 -924
- data/config/locales/da_rails.yml +0 -197
- data/config/locales/de-CH.yml +0 -924
- data/config/locales/de-CH_rails.yml +0 -142
- data/config/locales/de.yml +0 -924
- data/config/locales/de_rails.yml +0 -140
- data/config/locales/en-AU.yml +0 -924
- data/config/locales/en-AU_rails.yml +0 -202
- data/config/locales/en-GB.yml +0 -924
- data/config/locales/en-GB_rails.yml +0 -196
- data/config/locales/en-US_rails.yml +0 -200
- data/config/locales/es.yml +0 -924
- data/config/locales/es_rails.yml +0 -173
- data/config/locales/fi.yml +0 -924
- data/config/locales/fi_rails.yml +0 -143
- data/config/locales/fr-FR.yml +0 -924
- data/config/locales/fr-FR_rails.yml +0 -123
- data/config/locales/il.yml +0 -924
- data/config/locales/il_rails.yml +0 -103
- data/config/locales/it.yml +0 -924
- data/config/locales/it_rails.yml +0 -146
- data/config/locales/jp.yml +0 -924
- data/config/locales/jp_rails.yml +0 -135
- data/config/locales/mx.yml +0 -924
- data/config/locales/mx_rails.yml +0 -181
- data/config/locales/nb-NO.yml +0 -924
- data/config/locales/nb-NO_rails.yml +0 -105
- data/config/locales/nl-BE.yml +0 -924
- data/config/locales/nl-BE_rails.yml +0 -155
- data/config/locales/nl-NL.yml +0 -924
- data/config/locales/nl-NL_rails.yml +0 -172
- data/config/locales/pl.yml +0 -924
- data/config/locales/pl_rails.yml +0 -118
- data/config/locales/pt-BR.yml +0 -924
- data/config/locales/pt-BR_rails.yml +0 -138
- data/config/locales/pt-PT.yml +0 -924
- data/config/locales/pt-PT_rails.yml +0 -133
- data/config/locales/ru-RU.yml +0 -924
- data/config/locales/ru-RU_rails.yml +0 -206
- data/config/locales/th.yml +0 -924
- data/config/locales/th_rails.yml +0 -195
- data/config/locales/vn.yml +0 -924
- data/config/locales/vn_rails.yml +0 -202
- data/lib/tasks/translation.rake +0 -102
- data/vendor/extensions/localization/README.rdoc +0 -5
- data/vendor/extensions/localization/Rakefile +0 -120
- data/vendor/extensions/localization/app/controllers/admin/localization_controller.rb +0 -2
- data/vendor/extensions/localization/app/helpers/locale_helper.rb +0 -2
- data/vendor/extensions/localization/app/helpers/localization_helper.rb +0 -2
- data/vendor/extensions/localization/app/views/shared/_language_bar.html.erb +0 -8
- data/vendor/extensions/localization/config/routes.rb +0 -4
- data/vendor/extensions/localization/lib/localization/user_preferences.rb +0 -9
- data/vendor/extensions/localization/lib/tasks/localization_extension_tasks.rake +0 -17
- data/vendor/extensions/localization/localization_extension.rb +0 -21
- data/vendor/extensions/localization/public/images/flags/ad.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ae.png +0 -0
- data/vendor/extensions/localization/public/images/flags/af.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ag.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ai.png +0 -0
- data/vendor/extensions/localization/public/images/flags/al.png +0 -0
- data/vendor/extensions/localization/public/images/flags/am.png +0 -0
- data/vendor/extensions/localization/public/images/flags/an.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ao.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ar.png +0 -0
- data/vendor/extensions/localization/public/images/flags/as.png +0 -0
- data/vendor/extensions/localization/public/images/flags/at.png +0 -0
- data/vendor/extensions/localization/public/images/flags/au.png +0 -0
- data/vendor/extensions/localization/public/images/flags/aw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ax.png +0 -0
- data/vendor/extensions/localization/public/images/flags/az.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ba.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/be.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/br.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/by.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ca.png +0 -0
- data/vendor/extensions/localization/public/images/flags/catalonia.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ch.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ci.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ck.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/co.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cx.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/da.png +0 -0
- data/vendor/extensions/localization/public/images/flags/de.png +0 -0
- data/vendor/extensions/localization/public/images/flags/de_CH.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/do.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ec.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ee.png +0 -0
- data/vendor/extensions/localization/public/images/flags/eg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/eh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/england.png +0 -0
- data/vendor/extensions/localization/public/images/flags/er.png +0 -0
- data/vendor/extensions/localization/public/images/flags/es.png +0 -0
- data/vendor/extensions/localization/public/images/flags/et.png +0 -0
- data/vendor/extensions/localization/public/images/flags/europeanunion.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fam.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ga.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ge.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ht.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/id.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ie.png +0 -0
- data/vendor/extensions/localization/public/images/flags/il.png +0 -0
- data/vendor/extensions/localization/public/images/flags/in.png +0 -0
- data/vendor/extensions/localization/public/images/flags/io.png +0 -0
- data/vendor/extensions/localization/public/images/flags/iq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ir.png +0 -0
- data/vendor/extensions/localization/public/images/flags/is.png +0 -0
- data/vendor/extensions/localization/public/images/flags/it.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ke.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ki.png +0 -0
- data/vendor/extensions/localization/public/images/flags/km.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ky.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/la.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/li.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ls.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ly.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ma.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/md.png +0 -0
- data/vendor/extensions/localization/public/images/flags/me.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ml.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ms.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mx.png +0 -0
- data/vendor/extensions/localization/public/images/flags/my.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/na.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ne.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ng.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ni.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/no.png +0 -0
- data/vendor/extensions/localization/public/images/flags/np.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/om.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pe.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ph.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ps.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/py.png +0 -0
- data/vendor/extensions/localization/public/images/flags/qa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/re.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ro.png +0 -0
- data/vendor/extensions/localization/public/images/flags/rs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ru.png +0 -0
- data/vendor/extensions/localization/public/images/flags/rw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/scotland.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/se.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/si.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/so.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/st.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/td.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/th.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/to.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ua.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ug.png +0 -0
- data/vendor/extensions/localization/public/images/flags/um.png +0 -0
- data/vendor/extensions/localization/public/images/flags/us.png +0 -0
- data/vendor/extensions/localization/public/images/flags/uy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/uz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/va.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ve.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/wales.png +0 -0
- data/vendor/extensions/localization/public/images/flags/wf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ws.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ye.png +0 -0
- data/vendor/extensions/localization/public/images/flags/yt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/za.png +0 -0
- data/vendor/extensions/localization/public/images/flags/zm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/zw.png +0 -0
- data/vendor/extensions/localization/spec/controllers/admin/localization_controller_spec.rb +0 -10
- data/vendor/extensions/localization/spec/controllers/locale_controller_spec.rb +0 -35
- data/vendor/extensions/localization/spec/helpers/locale_helper_spec.rb +0 -5
- data/vendor/extensions/localization/spec/helpers/localization_helper_spec.rb +0 -5
- data/vendor/extensions/localization/spec/spec.opts +0 -6
- data/vendor/extensions/localization/spec/spec_helper.rb +0 -37
- data/vendor/extensions/payment_gateway/app/models/gateway/protx.rb +0 -9
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_manage_products.rhtml +0 -31
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_success.rhtml +0 -1
@@ -21,7 +21,8 @@ class Calculator::FlexiRate < Calculator
|
|
21
21
|
def compute(object)
|
22
22
|
sum = 0
|
23
23
|
max = self.preferred_max_items
|
24
|
-
object.
|
24
|
+
items_count = object.inject(0) {|count, line_item| count + line_item.quantity }
|
25
|
+
items_count.times do |i|
|
25
26
|
if (i % max == 0) && (max > 0)
|
26
27
|
sum += self.preferred_first_item
|
27
28
|
else
|
@@ -47,7 +47,7 @@ class Calculator::Vat < Calculator
|
|
47
47
|
|
48
48
|
return 0 if vat_rates.nil?
|
49
49
|
return 0 unless tax_category = product_or_variant.is_a?(Product) ? product_or_variant.tax_category : product_or_variant.product.tax_category
|
50
|
-
return 0 unless rate = vat_rates.find { | vat_rate | vat_rate.tax_category_id
|
50
|
+
return 0 unless rate = vat_rates.find { | vat_rate | vat_rate.tax_category_id == tax_category.id }
|
51
51
|
|
52
52
|
(product_or_variant.is_a?(Product) ? product_or_variant.price : product_or_variant.price) * rate.amount
|
53
53
|
end
|
data/app/models/checkout.rb
CHANGED
@@ -118,7 +118,7 @@ class Checkout < ActiveRecord::Base
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def process_coupon_code
|
121
|
-
return unless @coupon_code and coupon = Coupon.
|
121
|
+
return unless @coupon_code and coupon = Coupon.find(:first, :conditions => ["UPPER(code) = ?",@coupon_code.upcase])
|
122
122
|
coupon.create_discount(order)
|
123
123
|
# recalculate order totals
|
124
124
|
order.save
|
data/app/models/creditcard.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
class Creditcard < ActiveRecord::Base
|
1
|
+
class Creditcard < ActiveRecord::Base
|
2
2
|
has_many :payments, :as => :source
|
3
3
|
|
4
4
|
before_save :set_last_digits
|
5
|
-
|
5
|
+
|
6
6
|
validates_numericality_of :month, :integer => true
|
7
|
-
validates_numericality_of :year, :integer => true
|
7
|
+
validates_numericality_of :year, :integer => true
|
8
8
|
validates_presence_of :number, :unless => :has_payment_profile?, :on => :create
|
9
9
|
validates_presence_of :verification_value, :unless => :has_payment_profile?, :on => :create
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
|
12
12
|
def process!(payment)
|
13
13
|
begin
|
14
14
|
if Spree::Config[:auto_capture]
|
@@ -19,27 +19,29 @@ class Creditcard < ActiveRecord::Base
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def set_last_digits
|
24
|
-
|
24
|
+
number.to_s.gsub!(/\s/,'') unless number.nil?
|
25
|
+
verification_value.to_s.gsub!(/\s/,'') unless number.nil?
|
26
|
+
self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def name?
|
28
30
|
first_name? && last_name?
|
29
31
|
end
|
30
|
-
|
32
|
+
|
31
33
|
def first_name?
|
32
34
|
!self.first_name.blank?
|
33
35
|
end
|
34
|
-
|
36
|
+
|
35
37
|
def last_name?
|
36
38
|
!self.last_name.blank?
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
def name
|
40
42
|
"#{self.first_name} #{self.last_name}"
|
41
43
|
end
|
42
|
-
|
44
|
+
|
43
45
|
def verification_value?
|
44
46
|
!verification_value.blank?
|
45
47
|
end
|
@@ -48,15 +50,19 @@ class Creditcard < ActiveRecord::Base
|
|
48
50
|
def display_number
|
49
51
|
"XXXX-XXXX-XXXX-#{last_digits}"
|
50
52
|
end
|
51
|
-
|
53
|
+
|
52
54
|
alias :attributes_with_quotes_default :attributes_with_quotes
|
53
|
-
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
|
57
|
+
# needed for some of the ActiveMerchant gateways (eg. SagePay)
|
58
|
+
def brand
|
59
|
+
cc_type
|
60
|
+
end
|
61
|
+
|
62
|
+
|
57
63
|
private
|
58
|
-
|
59
|
-
|
64
|
+
|
65
|
+
|
60
66
|
# Override default behavior of Rails attr_readonly so that its never written to the database (not even on create)
|
61
67
|
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
|
62
68
|
attributes_with_quotes_default(include_primary_key, false, attribute_names)
|
@@ -67,8 +73,8 @@ class Creditcard < ActiveRecord::Base
|
|
67
73
|
attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) }
|
68
74
|
end
|
69
75
|
# extra logic for sanitizing the number and verification value based on preferences
|
70
|
-
attributes.delete_if { |key, value| key == "number" and !Spree::Config[:store_cc] }
|
71
|
-
attributes.delete_if { |key, value| key == "verification_value" and !Spree::Config[:store_cvv] }
|
76
|
+
attributes.delete_if { |key, value| key == "number" and !Spree::Config[:store_cc] }
|
77
|
+
attributes.delete_if { |key, value| key == "verification_value" and !Spree::Config[:store_cvv] }
|
72
78
|
end
|
73
79
|
end
|
74
80
|
|
@@ -34,42 +34,57 @@ class InventoryUnit < ActiveRecord::Base
|
|
34
34
|
|
35
35
|
# grab the appropriate units from inventory, mark as sold and associate with the order
|
36
36
|
def self.sell_units(order)
|
37
|
+
|
38
|
+
# we should not already have inventory associated with the order at this point but we should clear to be safe (#1394)
|
39
|
+
order.inventory_units.destroy_all
|
40
|
+
|
37
41
|
out_of_stock_items = []
|
38
42
|
order.line_items.each do |line_item|
|
39
43
|
variant = line_item.variant
|
40
44
|
quantity = line_item.quantity
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
out_of_stock_items.concat create_units(order, variant, quantity)
|
47
|
+
end
|
48
|
+
out_of_stock_items
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.adjust_units(order)
|
52
|
+
units_by_variant = order.inventory_units.group_by(&:variant_id)
|
53
|
+
out_of_stock_items = []
|
54
|
+
|
55
|
+
#check line items quantities match
|
56
|
+
order.line_items.each do |line_item|
|
57
|
+
variant = line_item.variant
|
58
|
+
quantity = line_item.quantity
|
59
|
+
unit_count = units_by_variant.key?(variant.id) ? units_by_variant[variant.id].size : 0
|
60
|
+
|
61
|
+
if unit_count < quantity
|
62
|
+
out_of_stock_items.concat create_units(order, variant, (quantity - unit_count))
|
63
|
+
elsif unit_count > quantity
|
64
|
+
(unit_count - quantity).times do
|
65
|
+
inventory_unit = units_by_variant[variant.id].pop
|
66
|
+
inventory_unit.restock!
|
60
67
|
end
|
61
|
-
variant.update_attribute(:count_on_hand, 0)
|
62
68
|
end
|
69
|
+
|
70
|
+
#remove it from hash as it's up-to-date
|
71
|
+
units_by_variant.delete(variant.id)
|
63
72
|
end
|
73
|
+
|
74
|
+
#check for deleted line items (if theres anything left in units_by_variant its' extra)
|
75
|
+
units_by_variant.each do |variant_id, units|
|
76
|
+
units.each {|unit| unit.restock!}
|
77
|
+
end
|
78
|
+
|
64
79
|
out_of_stock_items
|
65
80
|
end
|
66
81
|
|
67
82
|
def can_restock?
|
68
|
-
%w(sold shipped).include?(state)
|
83
|
+
%w(sold shipped backordered).include?(state)
|
69
84
|
end
|
70
85
|
|
71
86
|
def restock!
|
72
|
-
variant.update_attribute(:count_on_hand, variant.count_on_hand + 1)
|
87
|
+
variant.update_attribute(:count_on_hand, variant.count_on_hand + 1) if Spree::Config[:track_inventory_levels] && !backordered?
|
73
88
|
delete
|
74
89
|
end
|
75
90
|
|
@@ -85,4 +100,38 @@ class InventoryUnit < ActiveRecord::Base
|
|
85
100
|
Spree::Config[:allow_backorder_shipping] || (state == 'ready_to_ship')
|
86
101
|
end
|
87
102
|
|
103
|
+
def self.create_units(order, variant, quantity)
|
104
|
+
out_of_stock_items = []
|
105
|
+
|
106
|
+
if Spree::Config[:track_inventory_levels]
|
107
|
+
# mark all of these units as sold and associate them with this order
|
108
|
+
remaining_quantity = variant.count_on_hand - quantity
|
109
|
+
if (remaining_quantity >= 0)
|
110
|
+
quantity.times do
|
111
|
+
order.inventory_units.create(:variant => variant, :state => "sold")
|
112
|
+
end
|
113
|
+
variant.update_attribute(:count_on_hand, remaining_quantity)
|
114
|
+
else
|
115
|
+
(quantity + remaining_quantity).times do
|
116
|
+
order.inventory_units.create(:variant => variant, :state => "sold")
|
117
|
+
end
|
118
|
+
if Spree::Config[:allow_backorders]
|
119
|
+
(-remaining_quantity).times do
|
120
|
+
order.inventory_units.create(:variant => variant, :state => "backordered")
|
121
|
+
end
|
122
|
+
else
|
123
|
+
line_item.update_attribute(:quantity, quantity + remaining_quantity)
|
124
|
+
out_of_stock_items << {:line_item => line_item, :count => -remaining_quantity}
|
125
|
+
end
|
126
|
+
variant.update_attribute(:count_on_hand, 0)
|
127
|
+
end
|
128
|
+
else
|
129
|
+
# not tracking stock levels, so just create all inventory_units as sold (for shipping purposes)
|
130
|
+
quantity.times do
|
131
|
+
order.inventory_units.create(:variant => variant, :state => "sold")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
out_of_stock_items
|
135
|
+
end
|
136
|
+
|
88
137
|
end
|
data/app/models/line_item.rb
CHANGED
@@ -2,10 +2,11 @@ class LineItem < ActiveRecord::Base
|
|
2
2
|
before_validation :adjust_quantity
|
3
3
|
belongs_to :order
|
4
4
|
belongs_to :variant
|
5
|
-
|
5
|
+
|
6
6
|
has_one :product, :through => :variant
|
7
7
|
|
8
8
|
before_validation :copy_price
|
9
|
+
before_destroy :ensure_not_shipped
|
9
10
|
|
10
11
|
validates_presence_of :variant, :order
|
11
12
|
validates_numericality_of :quantity, :only_integer => true, :message => I18n.t("validation.must_be_int")
|
@@ -16,19 +17,24 @@ class LineItem < ActiveRecord::Base
|
|
16
17
|
def copy_price
|
17
18
|
self.price = variant.price if variant && self.price.nil?
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
def validate
|
21
22
|
unless quantity && quantity >= 0
|
22
23
|
errors.add(:quantity, I18n.t("validation.must_be_non_negative"))
|
23
24
|
end
|
24
25
|
# avoid reload of order.inventory_units by using direct lookup
|
25
|
-
unless Spree::Config[:
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
unless !Spree::Config[:track_inventory_levels] ||
|
27
|
+
Spree::Config[:allow_backorders] ||
|
28
|
+
order && InventoryUnit.order_id_equals(order).first.present? ||
|
29
|
+
variant && quantity <= variant.on_hand
|
30
|
+
errors.add(:quantity, I18n.t("validation.is_too_large") + " (#{self.variant.name})")
|
31
|
+
end
|
32
|
+
|
33
|
+
if shipped_count = order.shipped_units.nil? ? nil : order.shipped_units[variant]
|
34
|
+
errors.add(:quantity, I18n.t("validation.cannot_be_less_than_shipped_units") ) if quantity < shipped_count
|
29
35
|
end
|
30
36
|
end
|
31
|
-
|
37
|
+
|
32
38
|
def increment_quantity
|
33
39
|
self.quantity += 1
|
34
40
|
end
|
@@ -36,14 +42,22 @@ class LineItem < ActiveRecord::Base
|
|
36
42
|
def decrement_quantity
|
37
43
|
self.quantity -= 1
|
38
44
|
end
|
39
|
-
|
45
|
+
|
40
46
|
def total
|
41
|
-
self.price * self.quantity
|
47
|
+
self.price * self.quantity
|
42
48
|
end
|
43
49
|
alias amount total
|
44
|
-
|
45
|
-
def adjust_quantity
|
50
|
+
|
51
|
+
def adjust_quantity
|
46
52
|
self.quantity = 0 if self.quantity.nil? || self.quantity < 0
|
47
53
|
end
|
54
|
+
|
55
|
+
private
|
56
|
+
def ensure_not_shipped
|
57
|
+
if shipped_count = order.shipped_units.nil? ? nil : order.shipped_units[variant]
|
58
|
+
errors.add_to_base I18n.t("cannot_destory_line_item_as_inventory_units_have_shipped")
|
59
|
+
return false
|
60
|
+
end
|
61
|
+
end
|
48
62
|
end
|
49
63
|
|
data/app/models/order.rb
CHANGED
@@ -52,7 +52,7 @@ class Order < ActiveRecord::Base
|
|
52
52
|
make_permalink :field => :number
|
53
53
|
|
54
54
|
# attr_accessible is a nightmare with attachment_fu, so use attr_protected instead.
|
55
|
-
attr_protected :charge_total, :item_total, :total, :user, :number, :state, :token
|
55
|
+
attr_protected :charge_total, :item_total, :total, :user, :user_id, :number, :state, :token
|
56
56
|
|
57
57
|
def checkout_complete; !!completed_at; end
|
58
58
|
|
@@ -98,7 +98,7 @@ class Order < ActiveRecord::Base
|
|
98
98
|
transition :to => 'shipped', :from => 'paid'
|
99
99
|
end
|
100
100
|
event :return_authorized do
|
101
|
-
transition :to => 'awaiting_return'
|
101
|
+
transition :to => 'awaiting_return'
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -106,6 +106,13 @@ class Order < ActiveRecord::Base
|
|
106
106
|
# pop the resume event so we can see what the event before that was
|
107
107
|
state_events.pop if state_events.last.name == "resume"
|
108
108
|
update_attribute("state", state_events.last.previous_state)
|
109
|
+
|
110
|
+
if paid?
|
111
|
+
InventoryUnit.sell_units(self) if inventory_units.empty?
|
112
|
+
shipment.inventory_units = inventory_units
|
113
|
+
shipment.ready!
|
114
|
+
end
|
115
|
+
|
109
116
|
end
|
110
117
|
|
111
118
|
def make_shipments_shipped
|
@@ -123,13 +130,8 @@ class Order < ActiveRecord::Base
|
|
123
130
|
end
|
124
131
|
|
125
132
|
def shipped_units
|
126
|
-
shipped_units = shipments.inject([]) { |units, shipment| units
|
127
|
-
|
128
|
-
if shipped_units.nil?
|
129
|
-
return nil
|
130
|
-
else
|
131
|
-
shipped_units.flatten!
|
132
|
-
end
|
133
|
+
shipped_units = shipments.inject([]) { |units, shipment| units.concat(shipment.shipped? ? shipment.inventory_units : []) }
|
134
|
+
return nil if shipped_units.empty?
|
133
135
|
|
134
136
|
shipped = {}
|
135
137
|
shipped_units.group_by(&:variant_id).each do |variant_id, ship_units|
|
@@ -286,8 +288,9 @@ class Order < ActiveRecord::Base
|
|
286
288
|
end
|
287
289
|
|
288
290
|
self.adjustment_total = self.charge_total - self.credit_total
|
289
|
-
|
290
291
|
self.total = self.item_total + self.adjustment_total
|
292
|
+
|
293
|
+
self.checkout.enable_validation_group(:register) unless self.checkout.nil?
|
291
294
|
end
|
292
295
|
|
293
296
|
def update_totals!
|
@@ -365,6 +368,7 @@ class Order < ActiveRecord::Base
|
|
365
368
|
end
|
366
369
|
|
367
370
|
def cancel_order
|
371
|
+
make_shipments_pending
|
368
372
|
restock_inventory
|
369
373
|
OrderMailer.deliver_cancel(self)
|
370
374
|
end
|
@@ -373,6 +377,8 @@ class Order < ActiveRecord::Base
|
|
373
377
|
inventory_units.each do |inventory_unit|
|
374
378
|
inventory_unit.restock! if inventory_unit.can_restock?
|
375
379
|
end
|
380
|
+
|
381
|
+
inventory_units.reload
|
376
382
|
end
|
377
383
|
|
378
384
|
def update_line_items
|
data/app/models/payment.rb
CHANGED
@@ -96,7 +96,10 @@ class Payment < ActiveRecord::Base
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def create_payment_profile
|
99
|
-
source.
|
99
|
+
return unless payment_profiles_supported? and source.number and !source.has_payment_profile?
|
100
|
+
source.payment_gateway.create_profile(self)
|
101
|
+
rescue ActiveMerchant::ConnectionError => e
|
102
|
+
gateway_error I18n.t(:unable_to_connect_to_gateway)
|
100
103
|
end
|
101
104
|
|
102
105
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class PaymentMethod < ActiveRecord::Base
|
2
|
+
DISPLAY = [:both, :front_end, :back_end]
|
2
3
|
default_scope :conditions => {:deleted_at => nil}
|
3
4
|
|
4
5
|
@provider = nil
|
@@ -10,11 +11,11 @@ class PaymentMethod < ActiveRecord::Base
|
|
10
11
|
def self.providers
|
11
12
|
@@providers.to_a
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
def provider_class
|
15
16
|
raise "You must implement provider_class method for this gateway."
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
# The class that will process payments for this payment type, used for @payment.source
|
19
20
|
# e.g. Creditcard in the case of a the Gateway payment type
|
20
21
|
# nil means the payment method doesn't require a source e.g. check
|
@@ -22,14 +23,18 @@ class PaymentMethod < ActiveRecord::Base
|
|
22
23
|
raise "You must implement payment_source_class method for this gateway."
|
23
24
|
end
|
24
25
|
|
25
|
-
def self.available
|
26
|
-
PaymentMethod.all.select { |p| p.active
|
26
|
+
def self.available(display=nil)
|
27
|
+
PaymentMethod.all.select { |p| p.active && (p.display == display.to_s || p.display.blank?) && (p.environment == ENV['RAILS_ENV'] || p.environment.blank?) }
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
def self.active?
|
30
31
|
self.count(:conditions => {:type => self.to_s, :environment => RAILS_ENV, :active => true}) > 0
|
31
32
|
end
|
32
33
|
|
34
|
+
def self.current
|
35
|
+
PaymentMethod.find(:first, :conditions => {:active => true, :environment => ENV['RAILS_ENV']})
|
36
|
+
end
|
37
|
+
|
33
38
|
def method_type
|
34
39
|
type.demodulize.downcase
|
35
40
|
end
|
@@ -42,4 +47,8 @@ class PaymentMethod < ActiveRecord::Base
|
|
42
47
|
self.with_exclusive_scope { find(*args) }
|
43
48
|
end
|
44
49
|
|
50
|
+
def payment_profiles_supported?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
45
54
|
end
|
data/app/models/product.rb
CHANGED
@@ -68,7 +68,7 @@ class Product < ActiveRecord::Base
|
|
68
68
|
named_scope :on_hand, { :conditions => "products.count_on_hand > 0" }
|
69
69
|
named_scope :not_deleted, { :conditions => "products.deleted_at is null" }
|
70
70
|
named_scope :available, lambda { |*args| { :conditions => ["products.available_on <= ?", args.first || Time.zone.now] } }
|
71
|
-
|
71
|
+
|
72
72
|
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
|
73
73
|
named_scope :group_by_products_id, { :group => "products." + Product.column_names.join(", products.") } if ActiveRecord::Base.connection.tables.include?("products")
|
74
74
|
else
|
@@ -126,7 +126,7 @@ class Product < ActiveRecord::Base
|
|
126
126
|
|
127
127
|
# adjusts the "on_hand" inventory level for the product up or down to match the given new_level
|
128
128
|
def on_hand=(new_level)
|
129
|
-
raise "cannot set on_hand of product with variants" if has_variants?
|
129
|
+
raise "cannot set on_hand of product with variants" if has_variants? && Spree::Config[:track_inventory_levels]
|
130
130
|
master.on_hand = new_level
|
131
131
|
end
|
132
132
|
|
@@ -135,6 +135,14 @@ class Product < ActiveRecord::Base
|
|
135
135
|
master.in_stock? || !!variants.detect{|v| v.in_stock?}
|
136
136
|
end
|
137
137
|
|
138
|
+
def tax_category
|
139
|
+
if self[:tax_category_id].nil?
|
140
|
+
TaxCategory.first(:conditions => {:is_default => true})
|
141
|
+
else
|
142
|
+
TaxCategory.find(self[:tax_category_id])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
138
146
|
# Adding properties and option types on creation based on a chosen prototype
|
139
147
|
attr_reader :prototype_id
|
140
148
|
def prototype_id=(value)
|
@@ -207,7 +215,7 @@ class Product < ActiveRecord::Base
|
|
207
215
|
# the master on_hand is meaningless once a product has variants as the inventory
|
208
216
|
# units are now "contained" within the product variants
|
209
217
|
def set_master_on_hand_to_zero_when_product_has_variants
|
210
|
-
master.on_hand = 0 if has_variants?
|
218
|
+
master.on_hand = 0 if has_variants? && Spree::Config[:track_inventory_levels]
|
211
219
|
end
|
212
220
|
|
213
221
|
# ensures the master variant is flagged as such
|
@@ -223,5 +231,5 @@ class Product < ActiveRecord::Base
|
|
223
231
|
|
224
232
|
def update_memberships
|
225
233
|
self.product_groups = ProductGroup.all.select{|pg| pg.include?(self)}
|
226
|
-
end
|
234
|
+
end
|
227
235
|
end
|