spina-shop 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +37 -0
- data/app/assets/config/spina_shop_manifest.js +0 -0
- data/app/assets/fonts/montserrat-bold.ttf +0 -0
- data/app/assets/fonts/montserrat-italic.ttf +0 -0
- data/app/assets/fonts/montserrat-medium.ttf +0 -0
- data/app/assets/fonts/montserrat-regular.ttf +0 -0
- data/app/assets/fonts/montserrat-semibold.ttf +0 -0
- data/app/assets/images/spina/shop/delete-big-confirm.png +0 -0
- data/app/assets/images/spina/shop/delete-big.png +0 -0
- data/app/assets/javascripts/spina/shop/admin/app.infinitescroll.js.coffee +23 -0
- data/app/assets/javascripts/spina/shop/admin/customers.coffee +27 -0
- data/app/assets/javascripts/spina/shop/admin/orders.coffee +18 -0
- data/app/assets/javascripts/spina/shop/admin/product_bundles.coffee +15 -0
- data/app/assets/javascripts/spina/shop/admin/product_categories.coffee +15 -0
- data/app/assets/javascripts/spina/shop/admin/products.coffee +88 -0
- data/app/assets/javascripts/spina/shop/admin/shop.js +10 -0
- data/app/assets/stylesheets/spina/shop/admin/_customers.sass +10 -0
- data/app/assets/stylesheets/spina/shop/admin/_forms.sass +191 -0
- data/app/assets/stylesheets/spina/shop/admin/_product_bundles.sass +12 -0
- data/app/assets/stylesheets/spina/shop/admin/_status_dots.sass +16 -0
- data/app/assets/stylesheets/spina/shop/admin/_tables.sass +2 -0
- data/app/assets/stylesheets/spina/shop/admin/_tooltips.sass +31 -0
- data/app/assets/stylesheets/spina/shop/admin/shop.css.sass +11 -0
- data/app/controllers/spina/shop/admin/admin_controller.rb +8 -0
- data/app/controllers/spina/shop/admin/customer_accounts_controller.rb +38 -0
- data/app/controllers/spina/shop/admin/customers_controller.rb +67 -0
- data/app/controllers/spina/shop/admin/discounts_controller.rb +65 -0
- data/app/controllers/spina/shop/admin/gift_cards_controller.rb +65 -0
- data/app/controllers/spina/shop/admin/invoices_controller.rb +12 -0
- data/app/controllers/spina/shop/admin/order_items_controller.rb +36 -0
- data/app/controllers/spina/shop/admin/orders/packing_slips_controller.rb +27 -0
- data/app/controllers/spina/shop/admin/orders/shipping_labels_controller.rb +19 -0
- data/app/controllers/spina/shop/admin/orders_controller.rb +123 -0
- data/app/controllers/spina/shop/admin/product_reviews_controller.rb +17 -0
- data/app/controllers/spina/shop/admin/products/product_bundles_controller.rb +62 -0
- data/app/controllers/spina/shop/admin/products/stock_forecasts_controller.rb +15 -0
- data/app/controllers/spina/shop/admin/products/stock_level_adjustments_controller.rb +33 -0
- data/app/controllers/spina/shop/admin/products_controller.rb +135 -0
- data/app/controllers/spina/shop/admin/reports_controller.rb +33 -0
- data/app/controllers/spina/shop/admin/settings/product_categories_controller.rb +45 -0
- data/app/controllers/spina/shop/admin/settings/product_category_properties_controller.rb +49 -0
- data/app/controllers/spina/shop/admin/settings/sales_categories_controller.rb +14 -0
- data/app/controllers/spina/shop/admin/settings/shop_controller.rb +9 -0
- data/app/controllers/spina/shop/admin/settings/tax_groups_controller.rb +47 -0
- data/app/controllers/spina/shop/admin/variants_controller.rb +8 -0
- data/app/jobs/spina/shop/in_stock_reminder_job.rb +17 -0
- data/app/jobs/spina/shop/invoice_report_job.rb +23 -0
- data/app/jobs/spina/shop/payments_report_job.rb +23 -0
- data/app/mailers/spina/shop/customer_account_mailer.rb +32 -0
- data/app/mailers/spina/shop/export_mailer.rb +22 -0
- data/app/mailers/spina/shop/in_stock_reminder_mailer.rb +22 -0
- data/app/mailers/spina/shop/order_mailer.rb +32 -0
- data/app/models/concerns/spina/shop/preferable.rb +27 -0
- data/app/models/concerns/spina/shop/tax_rateable.rb +11 -0
- data/app/models/spina/shop/address.rb +19 -0
- data/app/models/spina/shop/application_record.rb +5 -0
- data/app/models/spina/shop/bundled_product.rb +6 -0
- data/app/models/spina/shop/campaign.rb +4 -0
- data/app/models/spina/shop/collectable.rb +8 -0
- data/app/models/spina/shop/country.rb +5 -0
- data/app/models/spina/shop/customer.rb +60 -0
- data/app/models/spina/shop/customer_account.rb +15 -0
- data/app/models/spina/shop/customer_group.rb +9 -0
- data/app/models/spina/shop/delivery_option.rb +27 -0
- data/app/models/spina/shop/discount.rb +39 -0
- data/app/models/spina/shop/discount_action.rb +16 -0
- data/app/models/spina/shop/discount_rule.rb +17 -0
- data/app/models/spina/shop/discounts/actions/percent_off.rb +17 -0
- data/app/models/spina/shop/discounts/rules/all_orders.rb +13 -0
- data/app/models/spina/shop/discounts/rules/collection.rb +14 -0
- data/app/models/spina/shop/discounts/rules/order_total.rb +17 -0
- data/app/models/spina/shop/discounts_order.rb +6 -0
- data/app/models/spina/shop/favorite.rb +8 -0
- data/app/models/spina/shop/gift_card.rb +53 -0
- data/app/models/spina/shop/gift_cards_order.rb +6 -0
- data/app/models/spina/shop/in_stock_reminder.rb +7 -0
- data/app/models/spina/shop/invoice.rb +49 -0
- data/app/models/spina/shop/invoice_line.rb +13 -0
- data/app/models/spina/shop/number_sequence.rb +19 -0
- data/app/models/spina/shop/order.rb +222 -0
- data/app/models/spina/shop/order/billing.rb +85 -0
- data/app/models/spina/shop/order/state_machine_transitions.rb +106 -0
- data/app/models/spina/shop/order_attachment.rb +9 -0
- data/app/models/spina/shop/order_item.rb +101 -0
- data/app/models/spina/shop/order_transition.rb +5 -0
- data/app/models/spina/shop/product.rb +227 -0
- data/app/models/spina/shop/product_bundle.rb +51 -0
- data/app/models/spina/shop/product_bundle_part.rb +13 -0
- data/app/models/spina/shop/product_category.rb +18 -0
- data/app/models/spina/shop/product_category_property.rb +14 -0
- data/app/models/spina/shop/product_collection.rb +8 -0
- data/app/models/spina/shop/product_image.rb +18 -0
- data/app/models/spina/shop/product_item.rb +93 -0
- data/app/models/spina/shop/product_part.rb +13 -0
- data/app/models/spina/shop/product_relation.rb +6 -0
- data/app/models/spina/shop/product_review.rb +22 -0
- data/app/models/spina/shop/property_option.rb +16 -0
- data/app/models/spina/shop/sales_category.rb +43 -0
- data/app/models/spina/shop/sales_category_code.rb +20 -0
- data/app/models/spina/shop/shop_review.rb +19 -0
- data/app/models/spina/shop/stock_level_adjustment.rb +17 -0
- data/app/models/spina/shop/tax_group.rb +62 -0
- data/app/models/spina/shop/tax_rate.rb +20 -0
- data/app/models/spina/shop/zone.rb +11 -0
- data/app/pdfs/spina/shop/invoice_pdf.rb +114 -0
- data/app/pdfs/spina/shop/packing_slip_pdf.rb +74 -0
- data/app/presenters/spina/shop/invoice_presenter.rb +30 -0
- data/app/services/spina/shop/allocate_stock.rb +42 -0
- data/app/services/spina/shop/cache_order.rb +47 -0
- data/app/services/spina/shop/change_stock_level.rb +38 -0
- data/app/services/spina/shop/country_importer.rb +14 -0
- data/app/services/spina/shop/customer_generator.rb +32 -0
- data/app/services/spina/shop/deallocate_stock.rb +17 -0
- data/app/services/spina/shop/invoice_generator.rb +72 -0
- data/app/services/spina/shop/invoice_number_generator.rb +10 -0
- data/app/services/spina/shop/invoices_pdfs_exporter.rb +22 -0
- data/app/services/spina/shop/order_number_generator.rb +10 -0
- data/app/services/spina/shop/payments_excel_exporter.rb +41 -0
- data/app/services/spina/shop/store_address.rb +23 -0
- data/app/state_machines/spina/shop/order_state_machine.rb +116 -0
- data/app/uploaders/spina/shop/exports_uploader.rb +9 -0
- data/app/views/layouts/spina/shop/admin/settings/shop.html.haml +16 -0
- data/app/views/layouts/spina/shop/mail.html.erb +1 -0
- data/app/views/spina/admin/hooks/shop/_head.html.haml +2 -0
- data/app/views/spina/admin/hooks/shop/_primary_navigation.html.haml +31 -0
- data/app/views/spina/admin/hooks/shop/_settings_secondary_navigation.html.haml +2 -0
- data/app/views/spina/admin/page_partables/shop/product_bundle_parts/_form.html.haml +6 -0
- data/app/views/spina/admin/page_partables/shop/product_parts/_form.html.haml +6 -0
- data/app/views/spina/admin/structure_partables/shop/product_parts/_form.html.haml +3 -0
- data/app/views/spina/shop/admin/customer_accounts/_form.html.haml +32 -0
- data/app/views/spina/shop/admin/customer_accounts/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/customers/_address_fields.html.haml +46 -0
- data/app/views/spina/shop/admin/customers/_customer.html.haml +11 -0
- data/app/views/spina/shop/admin/customers/_form.html.haml +67 -0
- data/app/views/spina/shop/admin/customers/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/customers/index.html.haml +52 -0
- data/app/views/spina/shop/admin/customers/index.js.erb +4 -0
- data/app/views/spina/shop/admin/customers/new.html.haml +1 -0
- data/app/views/spina/shop/admin/customers/show.html.haml +121 -0
- data/app/views/spina/shop/admin/discounts/_form.html.haml +60 -0
- data/app/views/spina/shop/admin/discounts/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/discounts/fields/_all_orders.html.haml +0 -0
- data/app/views/spina/shop/admin/discounts/fields/_discount_action_fields.html.haml +8 -0
- data/app/views/spina/shop/admin/discounts/fields/_discount_rule_fields.html.haml +0 -0
- data/app/views/spina/shop/admin/discounts/index.html.haml +36 -0
- data/app/views/spina/shop/admin/discounts/new.html.haml +1 -0
- data/app/views/spina/shop/admin/gift_cards/_form.html.haml +28 -0
- data/app/views/spina/shop/admin/gift_cards/_gift_card.html.haml +17 -0
- data/app/views/spina/shop/admin/gift_cards/index.html.haml +37 -0
- data/app/views/spina/shop/admin/gift_cards/index.js.erb +4 -0
- data/app/views/spina/shop/admin/gift_cards/new.html.haml +1 -0
- data/app/views/spina/shop/admin/gift_cards/show.html.haml +46 -0
- data/app/views/spina/shop/admin/order_items/_modal.html.haml +18 -0
- data/app/views/spina/shop/admin/order_items/new.js.erb +2 -0
- data/app/views/spina/shop/admin/orders/_form.html.haml +159 -0
- data/app/views/spina/shop/admin/orders/_order.html.haml +22 -0
- data/app/views/spina/shop/admin/orders/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/orders/index.html.haml +78 -0
- data/app/views/spina/shop/admin/orders/index.js.erb +4 -0
- data/app/views/spina/shop/admin/orders/new.html.haml +1 -0
- data/app/views/spina/shop/admin/orders/show.html.haml +338 -0
- data/app/views/spina/shop/admin/product_reviews/_product_review.html.haml +22 -0
- data/app/views/spina/shop/admin/product_reviews/index.html.haml +29 -0
- data/app/views/spina/shop/admin/product_reviews/index.js.erb +4 -0
- data/app/views/spina/shop/admin/products/_form.html.haml +259 -0
- data/app/views/spina/shop/admin/products/_new_product_modal.html.haml +15 -0
- data/app/views/spina/shop/admin/products/_price_exception_fields.html.haml +11 -0
- data/app/views/spina/shop/admin/products/_product.html.haml +36 -0
- data/app/views/spina/shop/admin/products/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/products/index.html.haml +73 -0
- data/app/views/spina/shop/admin/products/index.js.erb +4 -0
- data/app/views/spina/shop/admin/products/new.html.haml +1 -0
- data/app/views/spina/shop/admin/products/new_by_category.js.erb +1 -0
- data/app/views/spina/shop/admin/products/product_bundles/_bundled_products_fields.html.haml +11 -0
- data/app/views/spina/shop/admin/products/product_bundles/_form.html.haml +64 -0
- data/app/views/spina/shop/admin/products/product_bundles/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/products/product_bundles/index.html.haml +42 -0
- data/app/views/spina/shop/admin/products/product_bundles/new.html.haml +1 -0
- data/app/views/spina/shop/admin/products/properties/_property_fields.html.haml +37 -0
- data/app/views/spina/shop/admin/products/stock_forecasts/_product.html.haml +49 -0
- data/app/views/spina/shop/admin/products/stock_forecasts/show.html.haml +47 -0
- data/app/views/spina/shop/admin/products/stock_forecasts/show.js.erb +4 -0
- data/app/views/spina/shop/admin/products/stock_level_adjustments/_form.html.haml +37 -0
- data/app/views/spina/shop/admin/products/stock_level_adjustments/_history.html.haml +30 -0
- data/app/views/spina/shop/admin/products/stock_level_adjustments/index.js.erb +1 -0
- data/app/views/spina/shop/admin/products/stock_level_adjustments/new.js.erb +1 -0
- data/app/views/spina/shop/admin/reports/index.html.haml +23 -0
- data/app/views/spina/shop/admin/settings/product_categories/_form.html.haml +18 -0
- data/app/views/spina/shop/admin/settings/product_categories/_product_category.html.haml +3 -0
- data/app/views/spina/shop/admin/settings/product_categories/_property_fields.html.haml +77 -0
- data/app/views/spina/shop/admin/settings/product_categories/edit.html.haml +1 -0
- data/app/views/spina/shop/admin/settings/product_categories/index.html.haml +3 -0
- data/app/views/spina/shop/admin/settings/product_categories/show.html.haml +24 -0
- data/app/views/spina/shop/admin/settings/product_category_properties/_property_options_fields.html.haml +11 -0
- data/app/views/spina/shop/admin/settings/product_category_properties/edit_options.html.haml +16 -0
- data/app/views/spina/shop/admin/settings/sales_categories/_sales_category.html.haml +17 -0
- data/app/views/spina/shop/admin/settings/sales_categories/index.html.haml +1 -0
- data/app/views/spina/shop/admin/settings/tax_groups/_form.html.haml +19 -0
- data/app/views/spina/shop/admin/settings/tax_groups/_tax_group.html.haml +21 -0
- data/app/views/spina/shop/admin/settings/tax_groups/index.html.haml +1 -0
- data/app/views/spina/shop/admin/settings/tax_groups/new.js.erb +1 -0
- data/app/views/spina/shop/admin/shared/_locale_switcher.html.haml +9 -0
- data/app/views/spina/shop/customer_account_mailer/forgot_password.html.erb +1 -0
- data/app/views/spina/shop/customer_account_mailer/forgot_password.txt.erb +1 -0
- data/app/views/spina/shop/export_mailer/exported.html.erb +2 -0
- data/app/views/spina/shop/in_stock_reminder_mailer/reminder.html.erb +1 -0
- data/app/views/spina/shop/in_stock_reminder_mailer/reminder.txt.erb +1 -0
- data/app/views/spina/shop/order_mailer/confirmation.html.erb +5 -0
- data/app/views/spina/shop/order_mailer/confirmation.txt.erb +5 -0
- data/app/views/spina/shop/order_mailer/shipped.html.erb +1 -0
- data/app/views/spina/shop/order_mailer/shipped.txt.erb +1 -0
- data/config/initializers/kaminari_monkey_patch.rb +15 -0
- data/config/locales/en.yml +214 -0
- data/config/locales/nl.yml +452 -0
- data/config/routes.rb +92 -0
- data/db/countries.txt +252 -0
- data/db/migrate/10_create_spina_shop_products_without_items.rb +23 -0
- data/db/migrate/1_create_spina_shop_tables.rb +518 -0
- data/db/migrate/20170701135207_create_spina_shop_bundled_products.rb +11 -0
- data/db/migrate/20170717125930_add_stock_enabled_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170718084146_add_editable_sku_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170718084626_add_deletable_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170719082531_rename_column_order_picked_at_in_spina_shop_orders.rb +5 -0
- data/db/migrate/20170719112920_create_spina_shop_order_attachments.rb +15 -0
- data/db/migrate/20170719184125_add_price_exceptions_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170720133304_add_vat_id_to_spina_shop_customers.rb +5 -0
- data/db/migrate/20170731082027_add_price_includes_tax_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170731132620_add_reverse_charge_vat_to_spina_shop_tax_rates.rb +5 -0
- data/db/migrate/20170731150630_add_vat_id_to_spina_shop_invoices.rb +5 -0
- data/db/migrate/20170801093935_add_price_includes_tax_to_spina_shop_delivery_options.rb +5 -0
- data/db/migrate/20170814092924_add_business_to_spina_shop_orders.rb +6 -0
- data/db/migrate/20170815080839_rename_vat_reverse_charge_column_on_tax_rates.rb +5 -0
- data/db/migrate/20170815081018_add_business_to_spina_shop_tax_rates.rb +5 -0
- data/db/migrate/20170817075706_add_archived_to_spina_shop_products.rb +5 -0
- data/db/migrate/20170824175231_add_metadata_to_photos.rb +7 -0
- data/db/migrate/20170829085402_add_business_to_spina_shop_sales_category_codes.rb +5 -0
- data/db/migrate/20170911121034_add_trend_to_spina_shop_products.rb +5 -0
- data/db/migrate/20171106122225_add_editable_fields_to_spina_shop_product_category_properties.rb +6 -0
- data/db/migrate/20171106122537_create_property_options.rb +19 -0
- data/db/migrate/20171118110256_add_promotional_price_to_spina_shop_products.rb +6 -0
- data/db/migrate/2_create_spina_shop_tax_rates.rb +15 -0
- data/db/migrate/3_create_spina_shop_zones.rb +9 -0
- data/db/migrate/4_add_tax_rateable_to_spina_shop_tax_rates.rb +9 -0
- data/db/migrate/5_add_type_to_spina_shop_zones.rb +5 -0
- data/db/migrate/6_add_code_to_spina_shop_zones.rb +5 -0
- data/db/migrate/7_create_spina_shop_product_collections.rb +16 -0
- data/db/migrate/8_create_spina_shop_sales_category_codes.rb +13 -0
- data/db/migrate/9_create_spina_shop_customer_groups.rb +11 -0
- data/lib/generators/spina/shop/install_generator.rb +44 -0
- data/lib/spina/shop.rb +24 -0
- data/lib/spina/shop/admin_helpers.rb +49 -0
- data/lib/spina/shop/engine.rb +27 -0
- data/lib/spina/shop/errors/empty_order.rb +6 -0
- data/lib/spina/shop/errors/order_already_received.rb +6 -0
- data/lib/spina/shop/railtie.rb +31 -0
- data/lib/spina/shop/simple_linear_regression.rb +36 -0
- data/lib/spina/shop/version.rb +5 -0
- data/lib/spina/shop/view_helpers.rb +11 -0
- data/lib/tasks/spina/shop.rake +32 -0
- metadata +627 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class ProductReviewsController < AdminController
|
4
|
+
|
5
|
+
def index
|
6
|
+
@product_reviews = ProductReview.sorted.page(params[:page]).per(25)
|
7
|
+
add_breadcrumb ProductReview.model_name.human(count: :other)
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete_multiple
|
11
|
+
ProductReview.where(id: params[:product_review_ids]).destroy_all
|
12
|
+
redirect_to spina.shop_admin_product_reviews_path
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Products
|
4
|
+
class ProductBundlesController < AdminController
|
5
|
+
before_action :set_breadcrumbs
|
6
|
+
|
7
|
+
def show
|
8
|
+
@product_bundle = ProductBundle.find(params[:id])
|
9
|
+
redirect_to spina.edit_shop_admin_product_bundle_path(@product_bundle)
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@product_bundle = ProductBundle.new
|
14
|
+
add_breadcrumb t('spina.shop.product_bundles.new')
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@product_bundle = ProductBundle.new(product_bundle_params)
|
19
|
+
if @product_bundle.save
|
20
|
+
redirect_to spina.shop_admin_product_bundles_path
|
21
|
+
else
|
22
|
+
render :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
@product_bundle = ProductBundle.find(params[:id])
|
28
|
+
add_breadcrumb @product_bundle.name
|
29
|
+
end
|
30
|
+
|
31
|
+
def index
|
32
|
+
@product_bundles = ProductBundle.all
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
@product_bundle = ProductBundle.find(params[:id])
|
37
|
+
if @product_bundle.update_attributes(product_bundle_params)
|
38
|
+
redirect_to spina.shop_admin_product_bundles_path
|
39
|
+
else
|
40
|
+
render :edit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
@product_bundle = ProductBundle.find(params[:id])
|
46
|
+
@product_bundle.destroy
|
47
|
+
redirect_to spina.shop_admin_product_bundles_path
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def set_breadcrumbs
|
53
|
+
add_breadcrumb ProductBundle.model_name.human(count: 2), spina.shop_admin_product_bundles_path
|
54
|
+
end
|
55
|
+
|
56
|
+
def product_bundle_params
|
57
|
+
params.require(:product_bundle).permit(:name, :price, :tax_group_id, :sales_category_id, product_images_attributes: [:id, :position, :_destroy], product_images_files: [], bundled_products_attributes: [:id, :quantity, :product_id, :_destroy]).delocalize({price: :number})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Products
|
4
|
+
class StockForecastsController < AdminController
|
5
|
+
|
6
|
+
def show
|
7
|
+
add_breadcrumb "Producten"
|
8
|
+
@products = Product.select('current_date + (floor((stock_level - 4) / trend) :: integer) as restock_date, (ceil(trend * 30) :: integer) as coming_30_days, *').where('trend > ?', 0).active.where(stock_enabled: true, archived: false).includes(:product_images, :translations).where('sales_count > ?', 5).order("#{params[:order] || 'restock_date'} #{params[:direction]}")
|
9
|
+
@products = @products.page(params[:page]).per(20)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Products
|
4
|
+
class StockLevelAdjustmentsController < AdminController
|
5
|
+
before_action :set_product
|
6
|
+
|
7
|
+
def index
|
8
|
+
@stock_level_adjustments = @product.stock_level_adjustments
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@stock_level_adjustment = @product.stock_level_adjustments.build
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
change = ChangeStockLevel.new(@product, stock_level_adjustment_params, send_in_stock_reminders: params[:send_in_stock_reminders])
|
17
|
+
change.save
|
18
|
+
redirect_to spina.shop_admin_product_path(@product)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def set_product
|
24
|
+
@product = Product.find(params[:product_id])
|
25
|
+
end
|
26
|
+
|
27
|
+
def stock_level_adjustment_params
|
28
|
+
params.require(:stock_level_adjustment).permit(:adjustment, :description, :expiration_month, :expiration_year).merge(actor: current_spina_user.name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class ProductsController < AdminController
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
before_action :set_locale
|
6
|
+
|
7
|
+
def index
|
8
|
+
@q = Product.where(archived: false).filtered(filters).order(created_at: :desc).includes(:product_images).joins(:translations).where(spina_shop_product_translations: {locale: I18n.locale}).ransack(params[:q])
|
9
|
+
@products = @q.result.page(params[:page]).per(25)
|
10
|
+
@product_category_properties = Spina::Shop::ProductCategoryProperty.includes(property_options: :translations)
|
11
|
+
|
12
|
+
respond_to do |format|
|
13
|
+
format.html
|
14
|
+
format.js
|
15
|
+
format.json do
|
16
|
+
results = @products.includes(:product_images).map do |product|
|
17
|
+
{ id: product.id,
|
18
|
+
name: product.name,
|
19
|
+
image_url: view_context.attachment_url(product.product_images.first, :file, :fit, 30, 30),
|
20
|
+
price: view_context.number_to_currency(product.price) }
|
21
|
+
end
|
22
|
+
render inline: {results: results, total_count: @q.result.count}.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def archived
|
28
|
+
@q = Product.where(archived: true).filtered(filters).order(created_at: :desc).includes(:product_images).joins(:translations).where(spina_shop_product_translations: {locale: I18n.locale}).ransack(params[:q])
|
29
|
+
@products = @q.result.page(params[:page]).per(25)
|
30
|
+
@product_category_properties = Spina::Shop::ProductCategoryProperty.includes(property_options: :translations)
|
31
|
+
render :index
|
32
|
+
end
|
33
|
+
|
34
|
+
def show
|
35
|
+
@product = Product.find(params[:id])
|
36
|
+
redirect_to spina.edit_shop_admin_product_path(@product)
|
37
|
+
end
|
38
|
+
|
39
|
+
def new_by_category
|
40
|
+
@product_categories = ProductCategory.all
|
41
|
+
end
|
42
|
+
|
43
|
+
def new
|
44
|
+
@product = Product.new
|
45
|
+
add_breadcrumb t('spina.shop.products.new'), spina.new_shop_admin_product_path
|
46
|
+
|
47
|
+
@product_category = ProductCategory.where(id: params[:product_category_id]).first
|
48
|
+
|
49
|
+
# Always build at least one product item
|
50
|
+
@product.product_category = @product_category
|
51
|
+
end
|
52
|
+
|
53
|
+
def create
|
54
|
+
@product = Product.new(product_params)
|
55
|
+
if @product.save
|
56
|
+
redirect_to spina.edit_shop_admin_product_path(@product, params: {locale: @locale})
|
57
|
+
else
|
58
|
+
render :new
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def edit
|
63
|
+
@product = Product.find(params[:id])
|
64
|
+
add_breadcrumb @product.name
|
65
|
+
|
66
|
+
@product_category = @product.product_category
|
67
|
+
end
|
68
|
+
|
69
|
+
def update
|
70
|
+
@product = Product.find(params[:id])
|
71
|
+
if I18n.with_locale(@locale) { @product.update_attributes(product_params) }
|
72
|
+
redirect_to spina.edit_shop_admin_product_path(@product, params: {locale: @locale})
|
73
|
+
else
|
74
|
+
render :edit
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def destroy
|
79
|
+
@product = Product.find(params[:id])
|
80
|
+
@product.destroy
|
81
|
+
redirect_to spina.shop_admin_products_path
|
82
|
+
rescue ActiveRecord::DeleteRestrictionError
|
83
|
+
flash[:alert] = t('spina.shop.products.delete_restriction_error', name: @product.name)
|
84
|
+
flash[:alert_small] = t('spina.shop.products.delete_restriction_error_explanation')
|
85
|
+
redirect_to spina.shop_admin_product_path(@product)
|
86
|
+
end
|
87
|
+
|
88
|
+
def archive
|
89
|
+
@product = Product.find(params[:id])
|
90
|
+
@product.update_attributes(archived: true)
|
91
|
+
redirect_to spina.shop_admin_product_path(@product)
|
92
|
+
end
|
93
|
+
|
94
|
+
def unarchive
|
95
|
+
@product = Product.find(params[:id])
|
96
|
+
@product.update_attributes(archived: false)
|
97
|
+
redirect_to spina.shop_admin_product_path(@product)
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def filters
|
103
|
+
filter_params.to_h.map do |property, value|
|
104
|
+
value.present? ? {field_type: ProductCategoryProperty.find_by(name: property).field_type, property: property, value: value} : {}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def filter_params
|
109
|
+
params.require(:filters).permit! if params[:filters]
|
110
|
+
end
|
111
|
+
|
112
|
+
def product_params
|
113
|
+
I18n.with_locale I18n.default_locale do
|
114
|
+
product_params = params.require(:product).permit!.merge(locale: @locale).delocalize(base_price: :number, promotional_price: :number, cost_price: :number, weight: :number)
|
115
|
+
if product_params[:price_exceptions].present?
|
116
|
+
product_params[:price_exceptions].try(:[], :customer_groups).try(:each) do |price_exception|
|
117
|
+
price_exception["price"] = Delocalize::Parsers::Number.new.parse(price_exception["price"])
|
118
|
+
end
|
119
|
+
else
|
120
|
+
product_params[:price_exceptions] = "{}"
|
121
|
+
end
|
122
|
+
product_params
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def set_breadcrumbs
|
127
|
+
add_breadcrumb Product.model_name.human(count: 2), spina.shop_admin_products_path
|
128
|
+
end
|
129
|
+
|
130
|
+
def set_locale
|
131
|
+
@locale = params[:locale] || I18n.default_locale
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class ReportsController < AdminController
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
|
6
|
+
def index
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
start_date = Date.parse(params[:start_date])
|
11
|
+
end_date = Date.parse(params[:end_date])
|
12
|
+
case params[:report_type]
|
13
|
+
when "invoices"
|
14
|
+
invoice_ids = Invoice.where(date: start_date..end_date).ids
|
15
|
+
InvoiceReportJob.perform_later(invoice_ids, params[:email])
|
16
|
+
when "payments"
|
17
|
+
order_ids = Order.paid.where(paid_at: start_date..end_date).ids
|
18
|
+
PaymentsReportJob.perform_later(order_ids, params[:email])
|
19
|
+
end
|
20
|
+
|
21
|
+
flash[:success] = t('spina.shop.reports.start_exporting_html')
|
22
|
+
redirect_to spina.shop_admin_reports_path
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def set_breadcrumbs
|
28
|
+
add_breadcrumb t('spina.shop.reports.title'), spina.shop_admin_reports_path
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Settings
|
4
|
+
class ProductCategoriesController < ShopController
|
5
|
+
layout 'spina/admin/admin', except: [:index]
|
6
|
+
|
7
|
+
before_action :set_breadcrumbs, except: [:index]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@product_categories = ProductCategory.all
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
@product_category = ProductCategory.find(params[:id])
|
15
|
+
add_breadcrumb @product_category.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
@product_category = ProductCategory.find(params[:id])
|
23
|
+
add_breadcrumb @product_category.name, [:admin, :settings, @product_category]
|
24
|
+
add_breadcrumb t('spina.edit')
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def set_breadcrumbs
|
39
|
+
add_breadcrumb ProductCategory.model_name.human(count: 2), spina.shop_admin_settings_product_categories_path
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Settings
|
4
|
+
class ProductCategoryPropertiesController < ShopController
|
5
|
+
layout 'spina/admin/admin'
|
6
|
+
|
7
|
+
before_action :set_product_category
|
8
|
+
before_action :set_breadcrumbs, except: [:index]
|
9
|
+
before_action :set_locale
|
10
|
+
|
11
|
+
def edit
|
12
|
+
@product_category_property = @product_category.properties.find(params[:id])
|
13
|
+
add_breadcrumb @product_category_property.label
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit_options
|
17
|
+
@product_category_property = @product_category.properties.find(params[:id])
|
18
|
+
add_breadcrumb @product_category_property.label
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
@product_category_property = @product_category.properties.find(params[:id])
|
23
|
+
@product_category_property.update_attributes(product_category_property_params)
|
24
|
+
redirect_to spina.shop_admin_settings_product_category_path(@product_category)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_locale
|
30
|
+
@locale = params[:locale] || I18n.default_locale
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_product_category
|
34
|
+
@product_category = ProductCategory.find(params[:product_category_id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_breadcrumbs
|
38
|
+
add_breadcrumb ProductCategory.model_name.human(count: 2), spina.shop_admin_settings_product_categories_path
|
39
|
+
add_breadcrumb @product_category.name, spina.shop_admin_settings_product_category_path(@product_category)
|
40
|
+
end
|
41
|
+
|
42
|
+
def product_category_property_params
|
43
|
+
params.require(:product_category_property).permit(property_options_attributes: [:id, :name, :label, :_destroy])
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Settings
|
4
|
+
class TaxGroupsController < ShopController
|
5
|
+
layout 'spina/admin/admin', except: [:index]
|
6
|
+
|
7
|
+
def new
|
8
|
+
@tax_group = TaxGroup.new
|
9
|
+
@tax_group.tax_rates.build
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@tax_group = TaxGroup.new(tax_group_params)
|
14
|
+
unless @tax_group.save
|
15
|
+
flash[:alert] = "Failed to save"
|
16
|
+
end
|
17
|
+
redirect_to spina.shop_admin_settings_tax_groups_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def index
|
21
|
+
@tax_groups = TaxGroup.all
|
22
|
+
end
|
23
|
+
|
24
|
+
def edit
|
25
|
+
@tax_group = TaxGroup.find(params[:id])
|
26
|
+
add_breadcrumb @tax_group.name
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@tax_group = TaxGroup.find(params[:id])
|
31
|
+
if @tax_group.update_attributes(tax_group_params)
|
32
|
+
redirect_to spina.shop_admin_settings_tax_groups_path
|
33
|
+
else
|
34
|
+
render :edit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def tax_group_params
|
41
|
+
params.require(:tax_group).permit(:name, tax_rates_attributes: [:rate, :code])
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|