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,16 @@
|
|
1
|
+
.status-dot
|
2
|
+
background: #eee
|
3
|
+
border-radius: 10px
|
4
|
+
display: inline-block
|
5
|
+
height: 20px
|
6
|
+
vertical-align: middle
|
7
|
+
width: 20px
|
8
|
+
|
9
|
+
&.status-dot-success
|
10
|
+
background: $success-color
|
11
|
+
|
12
|
+
&.status-dot-warning
|
13
|
+
background: $alert-color
|
14
|
+
|
15
|
+
&.status-dot-danger
|
16
|
+
background: $danger-color
|
@@ -0,0 +1,31 @@
|
|
1
|
+
[data-tooltip]
|
2
|
+
overflow: hidden
|
3
|
+
position: relative
|
4
|
+
|
5
|
+
&:before
|
6
|
+
background: #fff
|
7
|
+
border: 1px solid #ddd
|
8
|
+
border-radius: 3px
|
9
|
+
box-shadow: 0 5px 15px rgba(0, 0, 0, .15)
|
10
|
+
color: #333
|
11
|
+
content: attr(data-tooltip)
|
12
|
+
display: block
|
13
|
+
font-size: 14px
|
14
|
+
font-weight: 500
|
15
|
+
left: 0
|
16
|
+
line-height: 28px
|
17
|
+
opacity: 0
|
18
|
+
padding: 4px 12px
|
19
|
+
position: absolute
|
20
|
+
text-align: left
|
21
|
+
top: 50%
|
22
|
+
transform: translateX(-100%) translateY(-50%)
|
23
|
+
transition: opacity .3s ease, transform .3s ease
|
24
|
+
white-space: nowrap
|
25
|
+
|
26
|
+
&:hover
|
27
|
+
overflow: visible
|
28
|
+
|
29
|
+
&:before
|
30
|
+
opacity: 1
|
31
|
+
transform: translateX(calc(-100% - 15px)) translateY(-50%)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class CustomerAccountsController < AdminController
|
4
|
+
before_action :set_customer
|
5
|
+
before_action :set_breadcrumbs
|
6
|
+
|
7
|
+
def edit
|
8
|
+
@customer_account = @customer.customer_account
|
9
|
+
add_breadcrumb CustomerAccount.model_name.human
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
@customer_account = @customer.customer_account
|
14
|
+
if @customer_account.update_attributes(customer_account_params)
|
15
|
+
redirect_to spina.shop_admin_customer_path(@customer)
|
16
|
+
else
|
17
|
+
add_breadcrumb CustomerAccount.model_name.human
|
18
|
+
render :edit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_customer
|
25
|
+
@customer = Customer.find(params[:customer_id])
|
26
|
+
end
|
27
|
+
|
28
|
+
def customer_account_params
|
29
|
+
params.require(:customer_account).permit(:email, :password, :password_confirmation)
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_breadcrumbs
|
33
|
+
add_breadcrumb Customer.model_name.human(count: 2), spina.shop_admin_orders_path
|
34
|
+
add_breadcrumb @customer.name, spina.shop_admin_customer_path(@customer)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class CustomersController < AdminController
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
|
6
|
+
def index
|
7
|
+
@q = Customer.ransack(params[:q])
|
8
|
+
@customers = @q.result.sorted.page(params[:page]).per(25)
|
9
|
+
@customer_groups = CustomerGroup.all
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@customer = Customer.new
|
14
|
+
add_breadcrumb t('spina.shop.customers.new')
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@customer = Customer.new(customer_params)
|
19
|
+
if @customer.save
|
20
|
+
redirect_to spina.shop_admin_customer_path(@customer)
|
21
|
+
else
|
22
|
+
render :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def show
|
27
|
+
@customer = Customer.find(params[:id])
|
28
|
+
add_breadcrumb @customer.name
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
@customer = Customer.find(params[:id])
|
33
|
+
add_breadcrumb @customer.name, spina.shop_admin_customer_path(@customer)
|
34
|
+
add_breadcrumb t('spina.edit')
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
@customer = Customer.find(params[:id])
|
39
|
+
if @customer.update_attributes(customer_params)
|
40
|
+
redirect_to spina.shop_admin_customer_path(@customer)
|
41
|
+
else
|
42
|
+
add_breadcrumb t('spina.edit')
|
43
|
+
render :edit
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def validate_vat_id
|
48
|
+
@customer = Customer.find(params[:id])
|
49
|
+
if vat_details = Valvat.new(@customer.vat_id).exists?(detail: true)
|
50
|
+
render json: {valid: true, details: vat_details}
|
51
|
+
else
|
52
|
+
render json: {valid: false}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def customer_params
|
59
|
+
params.require(:customer).permit(:first_name, :last_name, :email, :phone, :customer_group_id, :country_id, :vat_id, addresses_attributes: [:id, :_destroy, :street1, :street2, :postal_code, :city, :country_id, :house_number, :house_number_addition, :address_type])
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_breadcrumbs
|
63
|
+
add_breadcrumb Customer.model_name.human(count: 2), spina.shop_admin_customers_path
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class DiscountsController < AdminController
|
4
|
+
before_action :set_discount, only: [:edit, :update, :destroy]
|
5
|
+
before_action :set_breadcrumbs
|
6
|
+
|
7
|
+
def index
|
8
|
+
@discounts = Discount.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@discount = Discount.new(starts_at: Date.today)
|
13
|
+
@discount.build_discount_action(type: 'Spina::Shop::Discounts::Actions::PercentOff')
|
14
|
+
@discount.build_discount_rule(type: 'Spina::Shop::Discounts::Rules::AllOrders')
|
15
|
+
add_breadcrumb t('spina.shop.discounts.new')
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@discount = Discount.new(discount_params)
|
20
|
+
|
21
|
+
if @discount.save
|
22
|
+
redirect_to spina.shop_admin_discounts_path
|
23
|
+
else
|
24
|
+
flash.now[:alert] = "WTF probeer jij nou?!"
|
25
|
+
flash.now[:alert_small] = @discount.errors.full_messages.join("<br />")
|
26
|
+
add_breadcrumb t('spina.shop.discounts.new')
|
27
|
+
render :new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
add_breadcrumb @discount.code
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
if @discount.update_attributes(discount_params)
|
37
|
+
redirect_to spina.shop_admin_discounts_path
|
38
|
+
else
|
39
|
+
flash.now[:alert] = "Discount could not be saved"
|
40
|
+
flash.now[:alert_small] = @discount.errors.full_messages.join("<br />")
|
41
|
+
add_breadcrumb @discount.code
|
42
|
+
render :edit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def set_discount
|
52
|
+
@discount = Discount.find(params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_breadcrumbs
|
56
|
+
add_breadcrumb Discount.model_name.human(count: 2), spina.shop_admin_discounts_path
|
57
|
+
end
|
58
|
+
|
59
|
+
def discount_params
|
60
|
+
params.require(:discount).permit(:code, :starts_at, :expires_at, :description, discount_action_attributes: [:type, :percent_off, :id], discount_rule_attributes: [:type, :collection_id, :id])
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class GiftCardsController < AdminController
|
4
|
+
before_action :set_gift_card, only: [:show, :destroy]
|
5
|
+
before_action :set_breadcrumbs
|
6
|
+
|
7
|
+
def index
|
8
|
+
@q = GiftCard.order(created_at: :desc).ransack(params[:q])
|
9
|
+
@gift_cards = @q.result.page(params[:page]).per(25)
|
10
|
+
end
|
11
|
+
|
12
|
+
def unused
|
13
|
+
@q = GiftCard.order(created_at: :desc).where('value = remaining_balance').ransack(params[:q])
|
14
|
+
@gift_cards = @q.result.page(params[:page]).per(25)
|
15
|
+
render :index
|
16
|
+
end
|
17
|
+
|
18
|
+
def show
|
19
|
+
add_breadcrumb @gift_card.readable_code
|
20
|
+
end
|
21
|
+
|
22
|
+
def new
|
23
|
+
@gift_card = GiftCard.new(expires_at: 1.year.from_now)
|
24
|
+
add_breadcrumb t('spina.shop.gift_cards.new')
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@gift_card = GiftCard.new(gift_card_params)
|
29
|
+
|
30
|
+
if @gift_card.save
|
31
|
+
redirect_to spina.shop_admin_gift_cards_path
|
32
|
+
else
|
33
|
+
flash.now[:alert] = "Error"
|
34
|
+
flash.now[:alert_small] = @gift_card.errors.full_messages.join("<br />")
|
35
|
+
add_breadcrumb t('spina.shop.gift_cards.new')
|
36
|
+
render :new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@gift_card.destroy
|
42
|
+
redirect_to spina.shop_admin_gift_cards_path
|
43
|
+
rescue ActiveRecord::DeleteRestrictionError
|
44
|
+
flash[:alert] = t('spina.shop.gift_cards.delete_restriction_error')
|
45
|
+
flash[:alert_small] = t('spina.shop.gift_cards.delete_restriction_error_explanation')
|
46
|
+
redirect_to spina.shop_admin_gift_card_path(@gift_card)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def set_gift_card
|
52
|
+
@gift_card = GiftCard.find(params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_breadcrumbs
|
56
|
+
add_breadcrumb GiftCard.model_name.human(count: 2), spina.shop_admin_gift_cards_path
|
57
|
+
end
|
58
|
+
|
59
|
+
def gift_card_params
|
60
|
+
params.require(:gift_card).permit(:code, :expires_at, :value)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class InvoicesController < AdminController
|
4
|
+
def show
|
5
|
+
@invoice = Invoice.find(params[:id])
|
6
|
+
presenter = InvoicePresenter.new(@invoice, view_context)
|
7
|
+
pdf = InvoicePdf.new(presenter)
|
8
|
+
send_data pdf.render, filename: @invoice.filename, type: "application/pdf"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class OrderItemsController < AdminController
|
4
|
+
before_action :set_order
|
5
|
+
|
6
|
+
def new
|
7
|
+
@order_item = @order.order_items.build
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@order_item = @order.order_items.build(order_item_params)
|
12
|
+
if @order_item.save
|
13
|
+
redirect_to spina.shop_admin_order_path(@order)
|
14
|
+
else
|
15
|
+
redirect_to spina.shop_admin_order_path(@order)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
@order_item = @order.order_items.find(params[:id])
|
21
|
+
@order_item.destroy
|
22
|
+
redirect_to spina.shop_admin_order_path(@order)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def order_item_params
|
28
|
+
params.require(:order_item).permit(:orderable_id, :orderable_type, :quantity)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_order
|
32
|
+
@order = Order.building.find(params[:order_id])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Orders
|
4
|
+
class PackingSlipsController < AdminController
|
5
|
+
skip_before_action :authorize_spina_user, only: :show
|
6
|
+
|
7
|
+
def show
|
8
|
+
@order = Order.find(params[:order_id])
|
9
|
+
render_pdf
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@order = Order.find(params[:order_id])
|
14
|
+
@order.transition_to! :preparing, user: current_spina_user.name, ip_address: request.remote_ip
|
15
|
+
redirect_to spina.shop_admin_order_path(@order)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def render_pdf
|
21
|
+
pdf = PackingSlipPdf.new(@order)
|
22
|
+
send_data pdf.render, filename: "ps_#{@order.number}.pdf", type: "application/pdf"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
module Orders
|
4
|
+
class ShippingLabelsController < AdminController
|
5
|
+
|
6
|
+
def show
|
7
|
+
@order = Order.find(params[:order_id])
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
# Create label and print it or some shit
|
12
|
+
@order = Order.find(params[:order_id])
|
13
|
+
@order.transition_to! :shipped, user: current_spina_user.name, ip_address: request.remote_ip
|
14
|
+
redirect_to spina.shop_admin_order_path(@order)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module Spina::Shop
|
2
|
+
module Admin
|
3
|
+
class OrdersController < AdminController
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
|
6
|
+
def new
|
7
|
+
@order = Order.new
|
8
|
+
add_breadcrumb t('spina.shop.orders.new')
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
@order = Order.new(order_params)
|
13
|
+
@order.validate_details = true
|
14
|
+
if @order.save
|
15
|
+
redirect_to spina.shop_admin_order_path(@order)
|
16
|
+
else
|
17
|
+
add_breadcrumb t('spina.shop.orders.new')
|
18
|
+
render :new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def cancel
|
23
|
+
@order = Order.find(params[:id])
|
24
|
+
@order.transition_to!(:cancelled, user: current_spina_user.name, ip_address: request.remote_ip)
|
25
|
+
redirect_to spina.shop_admin_order_path(@order)
|
26
|
+
end
|
27
|
+
|
28
|
+
def receive
|
29
|
+
@order = Order.find(params[:id])
|
30
|
+
@order.transition_to!(:received, user: current_spina_user.name, ip_address: request.remote_ip)
|
31
|
+
redirect_to spina.shop_admin_order_path(@order)
|
32
|
+
end
|
33
|
+
|
34
|
+
def pay
|
35
|
+
@order = Order.find(params[:id])
|
36
|
+
@order.transition_to!(:paid, user: current_spina_user.name, ip_address: request.remote_ip)
|
37
|
+
redirect_to spina.shop_admin_order_path(@order)
|
38
|
+
end
|
39
|
+
|
40
|
+
def order_picked_up
|
41
|
+
@order = Order.find(params[:id])
|
42
|
+
@order.transition_to!(:picked_up, user: current_spina_user.name, ip_address: request.remote_ip)
|
43
|
+
redirect_to spina.shop_admin_order_path(@order)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delivered
|
47
|
+
@order = Order.find(params[:id])
|
48
|
+
@order.transition_to!(:delivered, user: current_spina_user.name, ip_address: request.remote_ip)
|
49
|
+
redirect_to spina.shop_admin_order_path(@order)
|
50
|
+
end
|
51
|
+
|
52
|
+
def index
|
53
|
+
@q = Order.ransack(params[:q])
|
54
|
+
@orders = @q.result.confirmed.sorted.includes(:order_items, :order_transitions).page(params[:page]).per(15)
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_process
|
58
|
+
@q = Order.ransack(params[:q])
|
59
|
+
@orders = @q.result.in_state(:paid, :preparing).sorted.includes(:order_items, :order_transitions).page(params[:page]).per(15)
|
60
|
+
render :index
|
61
|
+
end
|
62
|
+
|
63
|
+
def failed
|
64
|
+
@q = Order.ransack(params[:q])
|
65
|
+
@orders = @q.result.in_state(:failed).sorted.includes(:order_items, :order_transitions).page(params[:page]).per(15)
|
66
|
+
render :index
|
67
|
+
end
|
68
|
+
|
69
|
+
def show
|
70
|
+
@order = Order.includes(order_items: :orderable).find(params[:id])
|
71
|
+
add_breadcrumb @order.number || 'Concept'
|
72
|
+
end
|
73
|
+
|
74
|
+
def edit
|
75
|
+
@order = Order.find(params[:id])
|
76
|
+
add_breadcrumb @order.number, spina.shop_admin_order_path(@order)
|
77
|
+
add_breadcrumb t('spina.edit')
|
78
|
+
end
|
79
|
+
|
80
|
+
def update
|
81
|
+
@order = Order.find(params[:id])
|
82
|
+
if @order.update_attributes!(order_params)
|
83
|
+
redirect_to spina.shop_admin_order_path(@order)
|
84
|
+
else
|
85
|
+
render :edit
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def transition
|
90
|
+
@orders = Order.where(id: params[:order_ids])
|
91
|
+
if params[:transition_to] == "preparing_and_shipped"
|
92
|
+
@orders.each do |order|
|
93
|
+
order.transition_to("preparing", user: current_spina_user.name, ip_address: request.remote_ip)
|
94
|
+
order.transition_to("shipped", user: current_spina_user.name, ip_address: request.remote_ip)
|
95
|
+
end
|
96
|
+
else
|
97
|
+
@orders.each do |order|
|
98
|
+
order.transition_to(params[:transition_to], user: current_spina_user.name, ip_address: request.remote_ip)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
if params[:transition_to] == "preparing"
|
103
|
+
flash[:success] = t('spina.shop.orders.start_preparing_success_html')
|
104
|
+
elsif params[:transition_to] == "shipping"
|
105
|
+
flash[:success] = t('spina.shop.orders.ship_order_success_html')
|
106
|
+
else
|
107
|
+
flash[:success] = t('spina.shop.orders.start_preparing_and_ship_success_html')
|
108
|
+
end
|
109
|
+
redirect_to :back
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def order_params
|
115
|
+
params.require(:order).permit!
|
116
|
+
end
|
117
|
+
|
118
|
+
def set_breadcrumbs
|
119
|
+
add_breadcrumb Order.model_name.human(count: 2), spina.shop_admin_orders_path
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|