mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Compare commits
134 Commits
v4.1.30
...
v4.2.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fddb76f002 | ||
|
|
3e3fc4a5a2 | ||
|
|
4a2fd10bdb | ||
|
|
1a2c1d004c | ||
|
|
6ff2d4a9d5 | ||
|
|
b3d81154e6 | ||
|
|
4a15ed9b39 | ||
|
|
1d8b8c3be8 | ||
|
|
454a4e3435 | ||
|
|
076efd653d | ||
|
|
4facab0335 | ||
|
|
bea080a9b1 | ||
|
|
86731d7e30 | ||
|
|
b7efa1b018 | ||
|
|
4a0ed99919 | ||
|
|
45995ac984 | ||
|
|
421ffae78c | ||
|
|
f29e569f1b | ||
|
|
727eef3c4f | ||
|
|
ddd9ae6ce2 | ||
|
|
fd1cd4a28a | ||
|
|
9261d7b8fe | ||
|
|
b169f1baf1 | ||
|
|
2e05210596 | ||
|
|
8645277a05 | ||
|
|
f3d9b3d7ed | ||
|
|
c22c1ddf32 | ||
|
|
97f0d76fcd | ||
|
|
d70acb57b6 | ||
|
|
ab52028d1c | ||
|
|
0544baa75c | ||
|
|
acda515c8a | ||
|
|
ad0effc565 | ||
|
|
b7cf397e15 | ||
|
|
fb2279d26d | ||
|
|
cb6cb05eca | ||
|
|
d0acd47935 | ||
|
|
e32797d2fd | ||
|
|
f34b68a6e3 | ||
|
|
f914a37a28 | ||
|
|
641df45fcd | ||
|
|
ec7d4b7c21 | ||
|
|
94f87b3bd7 | ||
|
|
a3d996d5f5 | ||
|
|
8a62d95c48 | ||
|
|
7b2da4dbe4 | ||
|
|
0bb523c399 | ||
|
|
ca3c896b2e | ||
|
|
34286a8f8d | ||
|
|
533acda922 | ||
|
|
be88b95e8c | ||
|
|
f4c7f24cce | ||
|
|
8779ef6b77 | ||
|
|
5dfc3c7a62 | ||
|
|
9873380b94 | ||
|
|
a37f54e4b3 | ||
|
|
03b24bfc38 | ||
|
|
cf687864cc | ||
|
|
d28545a7b2 | ||
|
|
0b71f7298e | ||
|
|
9992f9c83b | ||
|
|
f09b719af6 | ||
|
|
6b3ffddb74 | ||
|
|
0c7f962bf0 | ||
|
|
0f618dfbf9 | ||
|
|
513b26f47c | ||
|
|
2e3023eacc | ||
|
|
2eeeb74374 | ||
|
|
1be3b508bf | ||
|
|
294f7c2fb5 | ||
|
|
89212736e9 | ||
|
|
35b5ca3a51 | ||
|
|
56fab26235 | ||
|
|
b7991e5ae8 | ||
|
|
2008c10c6f | ||
|
|
0218f75f34 | ||
|
|
0545c9de28 | ||
|
|
b54ec4354a | ||
|
|
767afe1fba | ||
|
|
2dd31d970e | ||
|
|
8a943f50ef | ||
|
|
3b01c44eae | ||
|
|
5105ea345f | ||
|
|
b259f59d1e | ||
|
|
eeb525aedb | ||
|
|
9874c7996e | ||
|
|
c7c5965eb5 | ||
|
|
cd30012334 | ||
|
|
42da443901 | ||
|
|
b3e1ffe9e2 | ||
|
|
71aca960ee | ||
|
|
3808398807 | ||
|
|
93751f9ccb | ||
|
|
944d40e093 | ||
|
|
22fe652e89 | ||
|
|
7a9ed7a73c | ||
|
|
b25192c31d | ||
|
|
529858946f | ||
|
|
88bc417868 | ||
|
|
287e8f5845 | ||
|
|
caccbb698b | ||
|
|
452a3fa933 | ||
|
|
288a35f062 | ||
|
|
5f78fdce8b | ||
|
|
392166b57a | ||
|
|
2985d2af15 | ||
|
|
e9513f6172 | ||
|
|
4a99a7d1de | ||
|
|
41c11baa3f | ||
|
|
3d1b61ae6e | ||
|
|
881a708ecf | ||
|
|
9d943625a3 | ||
|
|
e20c2e3ced | ||
|
|
01be6fb1f3 | ||
|
|
1fee45035c | ||
|
|
e55462d18b | ||
|
|
09247b21cd | ||
|
|
209b56ffd7 | ||
|
|
cbb6bd63d4 | ||
|
|
213c0dd060 | ||
|
|
d53d38906a | ||
|
|
1ff98a1d8a | ||
|
|
f012559ca8 | ||
|
|
94d8ada362 | ||
|
|
92677385fa | ||
|
|
86a3f91ca2 | ||
|
|
6a9fcbdd0c | ||
|
|
f5ecc6ffe4 | ||
|
|
9c231a831d | ||
|
|
f2ac888f2c | ||
|
|
c98d669b92 | ||
|
|
11b224f805 | ||
|
|
d7df714280 | ||
|
|
af58ba523c |
7
.env
7
.env
@@ -61,10 +61,3 @@ SMTP_PASSWORD="f00d"
|
||||
# STRIPE_INSTANCE_PUBLISHABLE_KEY="pk_test_xxxx" # This can be a test key or a live key
|
||||
# STRIPE_CLIENT_ID="ca_xxxx" # This can be a development ID or a production ID
|
||||
# STRIPE_ENDPOINT_SECRET="whsec_xxxx"
|
||||
|
||||
# Feature toggles
|
||||
#
|
||||
# Adding user emails separated by commas will enable them the use of certain features. See
|
||||
# config/initializers/feature_toggles.rb for details.
|
||||
#
|
||||
# BETA_TESTERS="ofn@example.com,superadmin@example.com"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400`
|
||||
# on 2022-02-25 01:04:47 UTC using RuboCop version 1.22.2.
|
||||
# on 2022-03-29 16:07:39 UTC using RuboCop version 1.22.2.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@@ -53,7 +53,7 @@ Layout/LeadingCommentSpace:
|
||||
Exclude:
|
||||
- 'spec/system/admin/enterprises_spec.rb'
|
||||
|
||||
# Offense count: 828
|
||||
# Offense count: 856
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
@@ -108,7 +108,6 @@ Layout/LineLength:
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'app/services/products_renderer.rb'
|
||||
- 'app/services/variant_units/variant_and_line_item_naming.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
|
||||
- 'engines/order_management/spec/services/order_management/order/updater_spec.rb'
|
||||
- 'engines/web/app/helpers/web/cookies_policy_helper.rb'
|
||||
@@ -117,15 +116,19 @@ Layout/LineLength:
|
||||
- 'lib/open_food_network/enterprise_fee_applicator.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/enterprise_issue_validator.rb'
|
||||
- 'lib/open_food_network/lettuce_share_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/open_food_network/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/reports/line_items.rb'
|
||||
- 'lib/open_food_network/sales_tax_report.rb'
|
||||
- 'lib/open_food_network/scope_variants_for_search.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/reporting/line_items.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/report_data/enterprise_fee_type_total.rb'
|
||||
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
|
||||
- 'lib/reporting/reports/orders_and_fulfillment/distributor_totals_by_supplier_report.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
- 'lib/reporting/reports/products_and_inventory/lettuce_share_report.rb'
|
||||
- 'lib/reporting/reports/sales_tax/sales_tax_report.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'lib/tasks/data.rake'
|
||||
- 'lib/tasks/enterprises.rake'
|
||||
@@ -176,19 +179,20 @@ Layout/LineLength:
|
||||
- 'spec/helpers/spree/admin/base_helper_spec.rb'
|
||||
- 'spec/jobs/subscription_confirm_job_spec.rb'
|
||||
- 'spec/jobs/subscription_placement_job_spec.rb'
|
||||
- 'spec/lib/open_food_network/customers_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/scope_variant_to_hub_spec.rb'
|
||||
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/lib/reports/customers_report_spec.rb'
|
||||
- 'spec/lib/reports/order_cycle_management_report_spec.rb'
|
||||
- 'spec/lib/reports/order_grouper_spec.rb'
|
||||
- 'spec/lib/reports/orders_and_fulfillment/orders_and_fulfillment_report_spec.rb'
|
||||
- 'spec/lib/reports/packing/packing_report_spec.rb'
|
||||
- 'spec/lib/reports/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/lib/reports/xero_invoices_report_spec.rb'
|
||||
- 'spec/lib/stripe/authorize_response_patcher_spec.rb'
|
||||
- 'spec/mailers/order_mailer_spec.rb'
|
||||
- 'spec/mailers/producer_mailer_spec.rb'
|
||||
@@ -309,7 +313,15 @@ Layout/MultilineMethodCallBraceLayout:
|
||||
Exclude:
|
||||
- 'lib/reporting/queries/joins.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: aligned, indented, indented_relative_to_receiver
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Exclude:
|
||||
- 'lib/reporting/reports/customers/customers_report.rb'
|
||||
|
||||
# Offense count: 20
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowInHeredoc.
|
||||
Layout/TrailingWhitespace:
|
||||
@@ -331,7 +343,7 @@ Lint/ConstantDefinitionInBlock:
|
||||
- 'lib/tasks/users.rake'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/helpers/serializer_helper_spec.rb'
|
||||
- 'spec/lib/open_food_network/reports/line_items_spec.rb'
|
||||
- 'spec/lib/reports/line_items_spec.rb'
|
||||
- 'spec/models/spree/ability_spec.rb'
|
||||
- 'spec/models/spree/gateway_spec.rb'
|
||||
- 'spec/models/spree/preferences/configuration_spec.rb'
|
||||
@@ -398,7 +410,7 @@ Lint/UselessMethodDefinition:
|
||||
- 'app/controllers/spree/user_registrations_controller.rb'
|
||||
- 'app/models/spree/gateway.rb'
|
||||
|
||||
# Offense count: 39
|
||||
# Offense count: 38
|
||||
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max.
|
||||
Metrics/AbcSize:
|
||||
Exclude:
|
||||
@@ -419,22 +431,20 @@ Metrics/AbcSize:
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'app/models/spree/preferences/preferable_class_methods.rb'
|
||||
- 'app/models/spree/return_authorization.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'lib/open_food_network/customers_report.rb'
|
||||
- 'lib/open_food_network/group_buy_report.rb'
|
||||
- 'lib/open_food_network/order_and_distributor_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/customers/customers_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/sales_tax_report.rb'
|
||||
- 'lib/reporting/reports/orders_and_distributors/orders_and_distributors_report.rb'
|
||||
- 'lib/reporting/reports/packing/customer.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
- 'lib/reporting/reports/sales_tax/sales_tax_report.rb'
|
||||
- 'lib/spree/core/controller_helpers/order.rb'
|
||||
- 'lib/spree/core/s3_support.rb'
|
||||
- 'lib/tasks/enterprises.rake'
|
||||
- 'spec/services/order_checkout_restart_spec.rb'
|
||||
|
||||
# Offense count: 45
|
||||
# Offense count: 43
|
||||
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
|
||||
# IgnoredMethods: refine
|
||||
Metrics/BlockLength:
|
||||
@@ -458,13 +468,12 @@ Metrics/BlockLength:
|
||||
- 'spec/factories/subscription_factory.rb'
|
||||
- 'spec/factories/user_factory.rb'
|
||||
- 'spec/factories/variant_factory.rb'
|
||||
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
- 'spec/swagger_helper.rb'
|
||||
- 'spec/support/cancan_helper.rb'
|
||||
- 'spec/support/matchers/select2_matchers.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
- 'spec/swagger_helper.rb'
|
||||
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
|
||||
- 'spec/system/consumer/shopping/checkout_spec.rb'
|
||||
|
||||
@@ -474,7 +483,7 @@ Metrics/BlockNesting:
|
||||
Exclude:
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
|
||||
# Offense count: 49
|
||||
# Offense count: 50
|
||||
# Configuration parameters: CountComments, Max, CountAsOne.
|
||||
Metrics/ClassLength:
|
||||
Exclude:
|
||||
@@ -518,18 +527,17 @@ Metrics/ClassLength:
|
||||
- 'app/services/cart_service.rb'
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'engines/order_management/app/services/order_management/order/updater.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/open_food_network/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/permissions.rb'
|
||||
- 'lib/open_food_network/users_and_enterprises_report.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
|
||||
# Offense count: 40
|
||||
# Offense count: 39
|
||||
# Configuration parameters: IgnoredMethods, Max.
|
||||
Metrics/CyclomaticComplexity:
|
||||
Exclude:
|
||||
@@ -555,20 +563,19 @@ Metrics/CyclomaticComplexity:
|
||||
- 'app/models/spree/tax_rate.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
- 'app/models/spree/zone.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'lib/open_food_network/customers_report.rb'
|
||||
- 'lib/open_food_network/enterprise_issue_validator.rb'
|
||||
- 'lib/open_food_network/group_buy_report.rb'
|
||||
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/customers/customers_report.rb'
|
||||
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
- 'lib/spree/core/controller_helpers/order.rb'
|
||||
- 'lib/spree/core/controller_helpers/respond_with.rb'
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/models/product_importer_spec.rb'
|
||||
|
||||
# Offense count: 31
|
||||
# Offense count: 32
|
||||
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
|
||||
Metrics/MethodLength:
|
||||
Exclude:
|
||||
@@ -578,23 +585,23 @@ Metrics/MethodLength:
|
||||
- 'app/controllers/spree/orders_controller.rb'
|
||||
- 'app/helpers/checkout_helper.rb'
|
||||
- 'app/helpers/spree/admin/navigation_helper.rb'
|
||||
- "app/json_schemas/json_api_schema.rb"
|
||||
- 'app/json_schemas/json_api_schema.rb'
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/gateway/pay_pal_express.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
- 'app/models/spree/preferences/preferable_class_methods.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
- 'lib/open_food_network/order_cycle_management_report.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/enterprise_fee_summary/scope.rb'
|
||||
- 'lib/reporting/reports/order_cycle_management/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_permissions.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
- 'lib/tasks/sample_data/product_factory.rb'
|
||||
|
||||
# Offense count: 51
|
||||
# Offense count: 54
|
||||
# Configuration parameters: CountComments, Max, CountAsOne.
|
||||
Metrics/ModuleLength:
|
||||
Exclude:
|
||||
@@ -625,17 +632,20 @@ Metrics/ModuleLength:
|
||||
- 'spec/controllers/spree/admin/adjustments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
|
||||
- 'spec/lib/open_food_network/address_finder_spec.rb'
|
||||
- 'spec/lib/open_food_network/customers_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_management_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/scope_variant_to_hub_spec.rb'
|
||||
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/lib/reports/customers_report_spec.rb'
|
||||
- 'spec/lib/reports/enterprise_fee_summary/authorizer_spec.rb'
|
||||
- 'spec/lib/reports/order_cycle_management_report_spec.rb'
|
||||
- 'spec/lib/reports/order_grouper_spec.rb'
|
||||
- 'spec/lib/reports/orders_and_fulfillment/customer_totals_report_spec.rb'
|
||||
- 'spec/lib/reports/orders_and_fulfillment/orders_and_fulfillment_report_spec.rb'
|
||||
- 'spec/lib/reports/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/reports/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/models/spree/adjustment_spec.rb'
|
||||
- 'spec/models/spree/credit_card_spec.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
@@ -656,11 +666,11 @@ Metrics/ParameterLists:
|
||||
Exclude:
|
||||
- 'app/helpers/angular_form_builder.rb'
|
||||
- 'app/models/product_import/entry_processor.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/reporting/reports/xero_invoices/base.rb'
|
||||
- 'spec/support/controller_requests_helper.rb'
|
||||
- 'spec/system/admin/reports_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Offense count: 7
|
||||
# Configuration parameters: IgnoredMethods, Max.
|
||||
Metrics/PerceivedComplexity:
|
||||
Exclude:
|
||||
@@ -669,9 +679,8 @@ Metrics/PerceivedComplexity:
|
||||
- 'app/models/enterprise_relationship.rb'
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/open_food_network/group_buy_report.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/reporting/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/reporting/reports/payments/payments_report.rb'
|
||||
|
||||
# Offense count: 9
|
||||
Naming/AccessorMethodName:
|
||||
@@ -716,7 +725,7 @@ Naming/VariableNumber:
|
||||
- 'app/controllers/spree/orders_controller.rb'
|
||||
- 'app/models/content_configuration.rb'
|
||||
- 'app/models/preference_sections/main_links_section.rb'
|
||||
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
|
||||
- 'lib/reporting/reports/orders_and_fulfillment/customer_totals_report.rb'
|
||||
- 'lib/spree/core/controller_helpers/common.rb'
|
||||
- 'spec/controllers/spree/admin/search_controller_spec.rb'
|
||||
- 'spec/factories/stock_location_factory.rb'
|
||||
@@ -895,7 +904,7 @@ Rails/LexicallyScopedActionFilter:
|
||||
- 'app/controllers/spree/admin/zones_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
|
||||
# Offense count: 18
|
||||
# Offense count: 19
|
||||
Rails/OutputSafety:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/reports_controller.rb'
|
||||
@@ -1092,9 +1101,9 @@ Style/MissingRespondToMissing:
|
||||
# Offense count: 1
|
||||
Style/MixinUsage:
|
||||
Exclude:
|
||||
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
|
||||
- 'lib/reporting/reports/orders_and_fulfillment/orders_and_fulfillment_report.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: literals, strict
|
||||
@@ -1118,7 +1127,7 @@ Style/NestedModifier:
|
||||
- 'spec/system/admin/payments_stripe_spec.rb'
|
||||
- 'spec/system/admin/reports_spec.rb'
|
||||
|
||||
# Offense count: 25
|
||||
# Offense count: 26
|
||||
# Configuration parameters: AllowedMethods.
|
||||
# AllowedMethods: respond_to_missing?
|
||||
Style/OptionalBooleanParameter:
|
||||
@@ -1132,16 +1141,7 @@ Style/OptionalBooleanParameter:
|
||||
- 'app/models/spree/order_contents.rb'
|
||||
- 'app/models/spree/preferences/file_configuration.rb'
|
||||
- 'app/models/spree/shipment.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'engines/order_management/app/services/order_management/stock/estimator.rb'
|
||||
- 'lib/open_food_network/customers_report.rb'
|
||||
- 'lib/open_food_network/order_and_distributor_report.rb'
|
||||
- 'lib/open_food_network/order_cycle_management_report.rb'
|
||||
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
|
||||
- 'lib/open_food_network/payments_report.rb'
|
||||
- 'lib/open_food_network/products_and_inventory_report_base.rb'
|
||||
- 'lib/open_food_network/users_and_enterprises_report.rb'
|
||||
- 'lib/open_food_network/xero_invoices_report.rb'
|
||||
- 'lib/spree/core/controller_helpers/order.rb'
|
||||
- 'lib/spree/core/delegate_belongs_to.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
@@ -1161,11 +1161,10 @@ Style/RedundantReturn:
|
||||
Exclude:
|
||||
- 'app/controllers/spree/admin/shipping_methods_controller.rb'
|
||||
|
||||
# Offense count: 213
|
||||
# Offense count: 205
|
||||
Style/Send:
|
||||
Exclude:
|
||||
- 'app/controllers/split_checkout_controller.rb'
|
||||
- 'engines/order_management/spec/services/order_management/reports/bulk_coop/bulk_coop_report_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/payment_gateways/paypal_controller_spec.rb'
|
||||
@@ -1177,13 +1176,10 @@ Style/Send:
|
||||
- 'spec/lib/open_food_network/address_finder_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/lettuce_share_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/products_and_inventory_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/sales_tax_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/tag_rule_applicator_spec.rb'
|
||||
- 'spec/lib/open_food_network/xero_invoices_report_spec.rb'
|
||||
- 'spec/lib/reports/xero_invoices_report_spec.rb'
|
||||
- 'spec/lib/stripe/webhook_handler_spec.rb'
|
||||
- 'spec/models/calculator/weight_spec.rb'
|
||||
- 'spec/models/enterprise_spec.rb'
|
||||
@@ -1208,7 +1204,7 @@ Style/SingleArgumentDig:
|
||||
Exclude:
|
||||
- 'app/services/checkout/form_data_adapter.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/SlicingWithRange:
|
||||
Exclude:
|
||||
@@ -1216,9 +1212,8 @@ Style/SlicingWithRange:
|
||||
- 'app/services/embedded_page_service.rb'
|
||||
- 'engines/order_management/app/services/order_management/subscriptions/validator.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
|
||||
# Offense count: 31
|
||||
# Offense count: 28
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Mode.
|
||||
Style/StringConcatenation:
|
||||
@@ -1235,11 +1230,8 @@ Style/StringConcatenation:
|
||||
- 'app/serializers/api/enterprise_shopfront_list_serializer.rb'
|
||||
- 'app/services/embedded_page_service.rb'
|
||||
- 'app/services/products_renderer.rb'
|
||||
- 'engines/order_management/app/services/order_management/reports/bulk_coop/bulk_coop_report.rb'
|
||||
- 'lib/open_food_network/orders_and_fulfillments_report/customer_totals_report.rb'
|
||||
- 'lib/spree/api/controller_setup.rb'
|
||||
- 'lib/spree/core/environment_extension.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -86,7 +86,6 @@ gem 'bootsnap', require: false
|
||||
gem 'geocoder'
|
||||
gem 'gmaps4rails'
|
||||
gem 'mimemagic', '> 0.3.5'
|
||||
gem 'paperclip', '~> 3.4.1'
|
||||
gem 'paper_trail', '~> 12.1.0'
|
||||
gem 'rack-rewrite'
|
||||
gem 'rack-ssl', require: 'rack/ssl'
|
||||
|
||||
13
Gemfile.lock
13
Gemfile.lock
@@ -219,10 +219,7 @@ GEM
|
||||
rubyzip (>= 1.3.0, < 3)
|
||||
childprocess (4.1.0)
|
||||
chronic (0.10.2)
|
||||
climate_control (0.2.0)
|
||||
cliver (0.3.2)
|
||||
cocaine (0.5.8)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
coderay (1.1.3)
|
||||
coffee-rails (5.0.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
@@ -392,9 +389,6 @@ GEM
|
||||
marcel (1.0.2)
|
||||
matrix (0.4.2)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2021.0225)
|
||||
mimemagic (0.4.3)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
@@ -427,12 +421,6 @@ GEM
|
||||
paper_trail (12.1.0)
|
||||
activerecord (>= 5.2)
|
||||
request_store (~> 1.1)
|
||||
paperclip (3.4.2)
|
||||
activemodel (>= 3.0.0)
|
||||
activerecord (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.0)
|
||||
mime-types
|
||||
parallel (1.21.0)
|
||||
paranoia (2.4.3)
|
||||
activerecord (>= 4.0, < 6.2)
|
||||
@@ -785,7 +773,6 @@ DEPENDENCIES
|
||||
order_management!
|
||||
pagy (~> 5.1)
|
||||
paper_trail (~> 12.1.0)
|
||||
paperclip (~> 3.4.1)
|
||||
paranoia (~> 2.4)
|
||||
paypal-sdk-merchant (= 1.117.2)
|
||||
pdf-reader
|
||||
|
||||
@@ -3,7 +3,7 @@ angular.module('Darkswarm').directive 'mapSearch', ($timeout, Search) ->
|
||||
restrict: 'E'
|
||||
require: ['^uiGmapGoogleMap', 'ngModel']
|
||||
replace: true
|
||||
template: '<input id="pac-input" ng-model="query" placeholder="' + t('location_placeholder') + '"></input>'
|
||||
template: '<input id="pac-input" ng-model="query" placeholder="' + t('location_placeholder') + '" onfocus="this.select()"></input>'
|
||||
scope: {}
|
||||
|
||||
controller: ($scope) ->
|
||||
|
||||
@@ -10,14 +10,14 @@ module Admin
|
||||
|
||||
def update
|
||||
params.each do |name, value|
|
||||
if ContentConfig.has_preference?(name) || ContentConfig.has_attachment?(name)
|
||||
ContentConfig.public_send("#{name}=", value)
|
||||
if value.is_a?(ActionDispatch::Http::UploadedFile)
|
||||
blob = store_file(value)
|
||||
update_preference("#{name}_blob_id", blob.id)
|
||||
else
|
||||
update_preference(name, value)
|
||||
end
|
||||
end
|
||||
|
||||
# Save any uploaded images
|
||||
ContentConfig.save
|
||||
|
||||
flash[:success] =
|
||||
t(:successfully_updated, resource: I18n.t('admin.contents.edit.your_content'))
|
||||
|
||||
@@ -26,6 +26,22 @@ module Admin
|
||||
|
||||
private
|
||||
|
||||
def store_file(attachable)
|
||||
ActiveStorage::Blob.create_and_upload!(
|
||||
io: attachable.open,
|
||||
filename: attachable.original_filename,
|
||||
content_type: attachable.content_type,
|
||||
service_name: :local,
|
||||
identify: false,
|
||||
)
|
||||
end
|
||||
|
||||
def update_preference(name, value)
|
||||
return unless ContentConfig.has_preference?(name)
|
||||
|
||||
ContentConfig.public_send("#{name}=", value)
|
||||
end
|
||||
|
||||
def preference_sections
|
||||
[
|
||||
PreferenceSections::HeaderSection.new,
|
||||
|
||||
@@ -64,6 +64,7 @@ module Admin
|
||||
@order_cycle_form = OrderCycleForm.new(@order_cycle, order_cycle_params, spree_current_user)
|
||||
|
||||
if @order_cycle_form.save
|
||||
update_nil_subscription_line_items_price_estimate(@order_cycle)
|
||||
respond_to do |format|
|
||||
flash[:notice] = I18n.t(:order_cycles_update_notice) if params[:reloading] == '1'
|
||||
format.html { redirect_back(fallback_location: root_path) }
|
||||
@@ -76,6 +77,7 @@ module Admin
|
||||
|
||||
def bulk_update
|
||||
if order_cycle_set&.save
|
||||
bulk_update_nil_subscription_line_items_price_estimate
|
||||
render_as_json @order_cycles,
|
||||
ams_prefix: 'index',
|
||||
current_user: spree_current_user,
|
||||
@@ -86,6 +88,27 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_update_nil_subscription_line_items_price_estimate
|
||||
@collection.upcoming.each do |order_cycle|
|
||||
update_nil_subscription_line_items_price_estimate(order_cycle)
|
||||
end
|
||||
end
|
||||
|
||||
def update_nil_subscription_line_items_price_estimate(order_cycle)
|
||||
order_cycle.schedules.each do |schedule|
|
||||
Subscription.where(schedule_id: schedule.id).each do |subscription|
|
||||
shop = Enterprise.managed_by(spree_current_user).find_by(id: subscription.shop_id)
|
||||
subscription.subscription_line_items.nil_price_estimate.each do |line_item|
|
||||
variant = OrderManagement::Subscriptions::
|
||||
VariantsList.eligible_variants(shop).find_by(id: line_item.variant_id)
|
||||
fee_calculator = OpenFoodNetwork::EnterpriseFeeCalculator.new(shop, order_cycle)
|
||||
price = variant.price + fee_calculator.indexed_fees_for(variant)
|
||||
line_item.update_column(:price_estimate, price)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def clone
|
||||
@order_cycle = OrderCycle.find params[:id]
|
||||
@order_cycle.clone!
|
||||
|
||||
@@ -5,14 +5,23 @@ module Admin
|
||||
include ReportsActions
|
||||
helper ReportsHelper
|
||||
|
||||
before_action :authorize_report
|
||||
before_action :authorize_report, only: [:show]
|
||||
|
||||
# Define model class for Can? permissions
|
||||
def model_class
|
||||
Admin::ReportsController
|
||||
end
|
||||
|
||||
def index
|
||||
@reports = reports.select do |report_type, _description|
|
||||
can? report_type, :report
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
render_report && return if ransack_params.blank?
|
||||
@report = report_class.new(spree_current_user, params, request)
|
||||
|
||||
@report = report_class.new(spree_current_user, ransack_params, report_options)
|
||||
|
||||
if export_spreadsheet?
|
||||
if report_format.present?
|
||||
export_report
|
||||
else
|
||||
render_report
|
||||
@@ -22,33 +31,23 @@ module Admin
|
||||
private
|
||||
|
||||
def export_report
|
||||
render report_format.to_sym => @report.public_send("to_#{report_format}"),
|
||||
:filename => report_filename
|
||||
send_data @report.render_as(report_format, controller: self), filename: report_filename
|
||||
end
|
||||
|
||||
def render_report
|
||||
assign_view_data
|
||||
load_form_options
|
||||
|
||||
render report_type
|
||||
render "show"
|
||||
end
|
||||
|
||||
def assign_view_data
|
||||
@report_type = report_type
|
||||
@report_subtype = report_subtype || report_loader.default_report_subtype
|
||||
@report_subtypes = report_class.report_subtypes.map do |subtype|
|
||||
[t("packing.#{subtype}_report", scope: i18n_scope), subtype]
|
||||
end
|
||||
end
|
||||
@report_subtypes = report_subtypes
|
||||
@report_subtype = report_subtype
|
||||
|
||||
def load_form_options
|
||||
return unless form_options_required?
|
||||
# Initialize data
|
||||
params[:display_summary_row] = true if request.get?
|
||||
|
||||
form_options = Reporting::FrontendData.new(spree_current_user)
|
||||
|
||||
@distributors = form_options.distributors.to_a
|
||||
@suppliers = form_options.suppliers.to_a
|
||||
@order_cycles = form_options.order_cycles.to_a
|
||||
@data = Reporting::FrontendData.new(spree_current_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ module Api
|
||||
respond_to :json
|
||||
|
||||
def destroy
|
||||
unless @enterprise.public_send("#{attachment_name}?")
|
||||
unless @enterprise.public_send(attachment_name).attached?
|
||||
return respond_with_conflict(error: destroy_attachment_does_not_exist_error_message)
|
||||
end
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ module Api
|
||||
authorize! :update, @enterprise
|
||||
|
||||
if params[:logo] && @enterprise.update( logo: params[:logo] )
|
||||
render html: @enterprise.logo.url(:medium), status: :ok
|
||||
elsif params[:promo] && @enterprise.update( promo_image: params[:promo] )
|
||||
render html: @enterprise.promo_image.url(:medium), status: :ok
|
||||
render(html: @enterprise.logo_url(:medium), status: :ok)
|
||||
elsif params[:promo] && @enterprise.update!( promo_image: params[:promo] )
|
||||
render(html: @enterprise.promo_image_url(:medium), status: :ok)
|
||||
else
|
||||
invalid_resource!(@enterprise)
|
||||
end
|
||||
|
||||
@@ -10,7 +10,8 @@ module Api
|
||||
before_action :validate_report, :authorize_report, :validate_query
|
||||
|
||||
def show
|
||||
@report = report_class.new(current_api_user, ransack_params, report_options)
|
||||
params[:report_format] = 'json'
|
||||
@report = report_class.new(current_api_user, params)
|
||||
|
||||
render_report
|
||||
end
|
||||
|
||||
@@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base
|
||||
helper 'footer_links'
|
||||
helper 'discourse'
|
||||
helper 'checkout'
|
||||
helper 'link'
|
||||
helper 'terms_and_conditions'
|
||||
|
||||
protect_from_forgery
|
||||
|
||||
@@ -47,7 +47,7 @@ module CheckoutCallbacks
|
||||
end
|
||||
|
||||
def load_shipping_methods
|
||||
@shipping_methods = available_shipping_methods.sort_by(&:name)
|
||||
@shipping_methods = available_shipping_methods.sort { |a, b| a.name.casecmp(b.name) }
|
||||
end
|
||||
|
||||
def redirect_to_shop?
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
module ReportsActions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def reports
|
||||
Reporting::Reports::List.all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authorize_report
|
||||
authorize! report_type&.to_sym, :report
|
||||
authorize! report_type.to_sym, :report
|
||||
end
|
||||
|
||||
def report_class
|
||||
@@ -23,31 +27,26 @@ module ReportsActions
|
||||
params[:report_type]
|
||||
end
|
||||
|
||||
def report_subtypes
|
||||
reports[report_type.to_sym] || []
|
||||
end
|
||||
|
||||
def report_subtypes_codes
|
||||
report_subtypes.map(&:second).map(&:to_s)
|
||||
end
|
||||
|
||||
def report_subtype
|
||||
params[:report_subtype]
|
||||
params[:report_subtype] || report_subtypes_codes.first
|
||||
end
|
||||
|
||||
def ransack_params
|
||||
raw_params[:q]
|
||||
end
|
||||
|
||||
def report_options
|
||||
raw_params[:options]
|
||||
end
|
||||
|
||||
def report_format
|
||||
params[:report_format]
|
||||
end
|
||||
|
||||
def export_spreadsheet?
|
||||
['xlsx', 'ods', 'csv'].include?(report_format)
|
||||
end
|
||||
|
||||
def form_options_required?
|
||||
[:packing, :customers, :products_and_inventory, :order_cycle_management].
|
||||
include? report_type.to_sym
|
||||
end
|
||||
|
||||
def report_filename
|
||||
"#{report_type || action_name}_#{file_timestamp}.#{report_format}"
|
||||
end
|
||||
|
||||
@@ -39,9 +39,6 @@ module Spree
|
||||
render :new
|
||||
end
|
||||
end
|
||||
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
|
||||
@object.errors.add(:base, t('spree.admin.products.image_upload_error'))
|
||||
respond_with(@object)
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
|
||||
require 'open_food_network/reports/list'
|
||||
require 'open_food_network/order_and_distributor_report'
|
||||
require 'open_food_network/products_and_inventory_report'
|
||||
require 'open_food_network/lettuce_share_report'
|
||||
require 'open_food_network/group_buy_report'
|
||||
require 'open_food_network/order_grouper'
|
||||
require 'open_food_network/customers_report'
|
||||
require 'open_food_network/users_and_enterprises_report'
|
||||
require 'open_food_network/order_cycle_management_report'
|
||||
require 'open_food_network/sales_tax_report'
|
||||
require 'open_food_network/xero_invoices_report'
|
||||
require 'open_food_network/payments_report'
|
||||
require 'open_food_network/orders_and_fulfillments_report'
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
class ReportsController < Spree::Admin::BaseController
|
||||
include Spree::ReportsHelper
|
||||
helper ::ReportsHelper
|
||||
|
||||
ORDER_MANAGEMENT_ENGINE_REPORTS = [
|
||||
:bulk_coop,
|
||||
:enterprise_fee_summary
|
||||
].freeze
|
||||
|
||||
helper_method :render_content?
|
||||
|
||||
before_action :cache_search_state
|
||||
# Fetches user's distributors, suppliers and order_cycles
|
||||
before_action :load_basic_data, only: [:customers, :products_and_inventory, :order_cycle_management]
|
||||
before_action :load_associated_data, only: [:orders_and_fulfillment]
|
||||
|
||||
respond_to :html
|
||||
|
||||
def report_types
|
||||
OpenFoodNetwork::Reports::List.all
|
||||
end
|
||||
|
||||
def index
|
||||
@reports = authorized_reports
|
||||
respond_with(@reports)
|
||||
end
|
||||
|
||||
def customers
|
||||
@report_types = report_types[:customers]
|
||||
@report_type = params[:report_type]
|
||||
@report = OpenFoodNetwork::CustomersReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
render_report(@report.header, @report.table, params[:csv], "customers_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
def order_cycle_management
|
||||
raw_params[:q] ||= {}
|
||||
|
||||
@report_types = report_types[:order_cycle_management]
|
||||
@report_type = params[:report_type]
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@report = OpenFoodNetwork::OrderCycleManagementReport.new spree_current_user,
|
||||
raw_params,
|
||||
render_content?
|
||||
@table = @report.table_items
|
||||
|
||||
render_report(@report.header, @table, params[:csv],
|
||||
"order_cycle_management_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
def orders_and_distributors
|
||||
@report = OpenFoodNetwork::OrderAndDistributorReport.new spree_current_user,
|
||||
raw_params,
|
||||
render_content?
|
||||
@search = @report.search
|
||||
csv_file_name = "orders_and_distributors_#{timestamp}.csv"
|
||||
render_report(@report.header, @report.table, params[:csv], csv_file_name)
|
||||
end
|
||||
|
||||
def sales_tax
|
||||
@distributors = my_distributors
|
||||
@report_type = params[:report_type]
|
||||
@report = OpenFoodNetwork::SalesTaxReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
render_report(@report.header, @report.table, params[:csv], "sales_tax.csv")
|
||||
end
|
||||
|
||||
def payments
|
||||
# -- Prepare Form Options
|
||||
@distributors = my_distributors
|
||||
@report_type = params[:report_type]
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@report = OpenFoodNetwork::PaymentsReport.new spree_current_user, raw_params,
|
||||
render_content?
|
||||
@table = order_grouper_table
|
||||
csv_file_name = "payments_#{timestamp}.csv"
|
||||
|
||||
render_report(@report.header, @table, params[:csv], csv_file_name)
|
||||
end
|
||||
|
||||
def orders_and_fulfillment
|
||||
raw_params[:q] ||= orders_and_fulfillment_default_filters
|
||||
|
||||
@report_types = report_types[:orders_and_fulfillment]
|
||||
@report_type = params[:report_type]
|
||||
|
||||
@include_blank = I18n.t(:all)
|
||||
|
||||
# -- Build Report with Order Grouper
|
||||
@report = OpenFoodNetwork::OrdersAndFulfillmentsReport.new spree_current_user,
|
||||
raw_params,
|
||||
render_content?
|
||||
@table = order_grouper_table
|
||||
csv_file_name = "#{params[:report_type]}_#{timestamp}.csv"
|
||||
|
||||
render_report(@report.header, @table, params[:csv], csv_file_name)
|
||||
end
|
||||
|
||||
def products_and_inventory
|
||||
@report_types = report_types[:products_and_inventory]
|
||||
@report = if params[:report_type] != 'lettuce_share'
|
||||
OpenFoodNetwork::ProductsAndInventoryReport.new spree_current_user,
|
||||
raw_params,
|
||||
render_content?
|
||||
else
|
||||
OpenFoodNetwork::LettuceShareReport.new spree_current_user,
|
||||
raw_params,
|
||||
render_content?
|
||||
end
|
||||
|
||||
render_report @report.header,
|
||||
@report.table,
|
||||
params[:csv],
|
||||
"products_and_inventory_#{timestamp}.csv"
|
||||
end
|
||||
|
||||
def users_and_enterprises
|
||||
@report = OpenFoodNetwork::UsersAndEnterprisesReport.new raw_params, render_content?
|
||||
render_report(@report.header, @report.table, params[:csv],
|
||||
"users_and_enterprises_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
def xero_invoices
|
||||
raw_params[:q] ||= {}
|
||||
|
||||
@distributors = my_distributors
|
||||
@order_cycles = my_order_cycles
|
||||
|
||||
@report = OpenFoodNetwork::XeroInvoicesReport.new(spree_current_user,
|
||||
raw_params,
|
||||
render_content?)
|
||||
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def model_class
|
||||
Spree::Admin::ReportsController
|
||||
end
|
||||
|
||||
# Some actions are changing the `params` object. That is unfortunate Spree
|
||||
# behavior and we are building on it. So we have to look at `params` early
|
||||
# to check if we are searching or just displaying a report search form.
|
||||
def cache_search_state
|
||||
search_keys = [
|
||||
# search parameter for ransack
|
||||
:q,
|
||||
# common in all reports, only set for CSV rendering
|
||||
:csv,
|
||||
# `button` is included in all forms. It's not important for searching,
|
||||
# but the Users & Enterprises report doesn't have any other parameter
|
||||
# for an empty search. So we use this one to display data.
|
||||
:button,
|
||||
# Some reports use filtering by enterprise or order cycle
|
||||
:distributor_id,
|
||||
:supplier_id,
|
||||
:order_cycle_id,
|
||||
# Xero Invoices can be filtered by date
|
||||
:invoice_date,
|
||||
:due_date
|
||||
]
|
||||
@searching = search_keys.any? { |key| raw_params.key? key }
|
||||
end
|
||||
|
||||
# We don't want to render data unless search params are supplied.
|
||||
# Compiling data can take a long time.
|
||||
def render_content?
|
||||
@searching
|
||||
end
|
||||
|
||||
def render_report(header, table, create_csv, csv_file_name)
|
||||
send_data csv_report(header, table), filename: csv_file_name if create_csv
|
||||
@header = header
|
||||
@table = table
|
||||
# Rendering HTML is the default.
|
||||
end
|
||||
|
||||
def load_associated_data
|
||||
form_options = Reporting::FrontendData.new(spree_current_user)
|
||||
|
||||
@distributors = form_options.distributors
|
||||
@suppliers = form_options.suppliers
|
||||
@order_cycles = form_options.order_cycles
|
||||
end
|
||||
|
||||
def csv_report(header, table)
|
||||
CSV.generate do |csv|
|
||||
csv << header
|
||||
table.each { |row| csv << row }
|
||||
end
|
||||
end
|
||||
|
||||
def load_basic_data
|
||||
@distributors = my_distributors
|
||||
@suppliers = my_suppliers | suppliers_of_products_distributed_by(@distributors)
|
||||
@order_cycles = my_order_cycles
|
||||
end
|
||||
|
||||
# Load managed distributor enterprises of current user
|
||||
def my_distributors
|
||||
Enterprise.is_distributor.managed_by(spree_current_user)
|
||||
end
|
||||
|
||||
# Load managed producer enterprises of current user
|
||||
def my_suppliers
|
||||
Enterprise.is_primary_producer.managed_by(spree_current_user)
|
||||
end
|
||||
|
||||
def suppliers_of_products_distributed_by(distributors)
|
||||
supplier_ids = Spree::Product.in_distributors(distributors.select('enterprises.id')).
|
||||
select('spree_products.supplier_id')
|
||||
|
||||
Enterprise.where(id: supplier_ids)
|
||||
end
|
||||
|
||||
# Load order cycles the current user has access to
|
||||
def my_order_cycles
|
||||
OrderCycle.
|
||||
active_or_complete.
|
||||
visible_by(spree_current_user).
|
||||
order('orders_close_at DESC')
|
||||
end
|
||||
|
||||
def order_grouper_table
|
||||
order_grouper = OpenFoodNetwork::OrderGrouper.new @report.rules, @report.columns, @report
|
||||
order_grouper.table(@report.table_items)
|
||||
end
|
||||
|
||||
def authorized_reports
|
||||
all_reports = [
|
||||
:orders_and_distributors,
|
||||
:bulk_coop,
|
||||
:payments,
|
||||
:orders_and_fulfillment,
|
||||
:customers,
|
||||
:products_and_inventory,
|
||||
:users_and_enterprises,
|
||||
:enterprise_fee_summary,
|
||||
:order_cycle_management,
|
||||
:sales_tax,
|
||||
:xero_invoices,
|
||||
:packing
|
||||
]
|
||||
reports = all_reports.select { |action| can? action, Spree::Admin::ReportsController }
|
||||
reports.map { |report| [report, describe_report(report)] }.to_h
|
||||
end
|
||||
|
||||
def describe_report(report)
|
||||
name = I18n.t(:name, scope: [:admin, :reports, report])
|
||||
description = begin
|
||||
I18n.t!(:description, scope: [:admin, :reports, report])
|
||||
rescue I18n::MissingTranslationData
|
||||
render_to_string(
|
||||
partial: "#{report}_description",
|
||||
layout: false,
|
||||
locals: { report_types: report_types[report] }
|
||||
).html_safe
|
||||
end
|
||||
{ name: name, url: url_for_report(report), description: description }
|
||||
end
|
||||
|
||||
def url_for_report(report)
|
||||
if report_in_order_management_engine?(report)
|
||||
main_app.public_send("new_order_management_reports_#{report}_url".to_sym)
|
||||
else
|
||||
spree.public_send("#{report}_admin_reports_url".to_sym)
|
||||
end
|
||||
rescue NoMethodError
|
||||
main_app.admin_reports_url(report_type: report)
|
||||
end
|
||||
|
||||
# List of reports that have been moved to the Order Management engine
|
||||
def report_in_order_management_engine?(report)
|
||||
ORDER_MANAGEMENT_ENGINE_REPORTS.include?(report)
|
||||
end
|
||||
|
||||
def timestamp
|
||||
Time.zone.now.strftime("%Y%m%d")
|
||||
end
|
||||
|
||||
def orders_and_fulfillment_default_filters
|
||||
now = Time.zone.now
|
||||
{ completed_at_gt: (now - 1.month).beginning_of_day,
|
||||
completed_at_lt: (now + 1.day).beginning_of_day }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GroupsHelper
|
||||
module LinkHelper
|
||||
def link_to_service(baseurl, name, html_options = {}, &block)
|
||||
return if name.blank?
|
||||
|
||||
@@ -15,8 +15,4 @@ module GroupsHelper
|
||||
prefix + url
|
||||
end
|
||||
end
|
||||
|
||||
def strip_url(url)
|
||||
url&.sub(%r{^https?://}i, '')
|
||||
end
|
||||
end
|
||||
@@ -9,7 +9,24 @@ module ReportsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def report_subtypes(report)
|
||||
Reporting::ReportLoader.new(report).report_subtypes
|
||||
def report_payment_method_options(orders)
|
||||
orders.map do |order|
|
||||
payment_method = order.payments.last&.payment_method
|
||||
|
||||
next unless payment_method
|
||||
|
||||
[payment_method.name, payment_method.id]
|
||||
end.compact.uniq
|
||||
end
|
||||
|
||||
def report_shipping_method_options(orders)
|
||||
orders.map do |o|
|
||||
sm = o.shipping_method
|
||||
[sm&.name, sm&.id]
|
||||
end.uniq
|
||||
end
|
||||
|
||||
def currency_symbol
|
||||
Spree::Money.currency_symbol
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +77,7 @@ module Spree
|
||||
klass = EnterpriseGroup if klass == :group
|
||||
klass = VariantOverride if klass == :Inventory
|
||||
klass = ProductImport::ProductImporter if klass == :import
|
||||
klass = Spree::Admin::ReportsController if klass == :report
|
||||
klass = ::Admin::ReportsController if klass == :report
|
||||
klass
|
||||
end
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spree/money'
|
||||
|
||||
module Spree
|
||||
module ReportsHelper
|
||||
def report_payment_method_options(orders)
|
||||
orders.map do |order|
|
||||
payment_method = order.payments.last&.payment_method
|
||||
|
||||
next unless payment_method
|
||||
|
||||
[payment_method.name, payment_method.id]
|
||||
end.compact.uniq
|
||||
end
|
||||
|
||||
def report_shipping_method_options(orders)
|
||||
orders.map do |o|
|
||||
sm = o.shipping_method
|
||||
[sm&.name, sm&.id]
|
||||
end.uniq
|
||||
end
|
||||
|
||||
def xero_report_types
|
||||
[[I18n.t(:summary), 'summary'],
|
||||
[I18n.t(:detailed), 'detailed']]
|
||||
end
|
||||
|
||||
def currency_symbol
|
||||
Spree::Money.currency_symbol
|
||||
end
|
||||
end
|
||||
end
|
||||
43
app/models/concerns/file_preferences.rb
Normal file
43
app/models/concerns/file_preferences.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FilePreferences
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
@default_urls = {}
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def file_preference(name, default_url: nil)
|
||||
preference "#{name}_blob_id", :integer
|
||||
@default_urls[name] = default_url if default_url
|
||||
end
|
||||
|
||||
def default_url(name)
|
||||
@default_urls[name]
|
||||
end
|
||||
end
|
||||
|
||||
def preference_type(key)
|
||||
if has_preference?("#{key}_blob_id")
|
||||
:file
|
||||
else
|
||||
super(key)
|
||||
end
|
||||
end
|
||||
|
||||
def url_for(name)
|
||||
blob = blob_for(name)
|
||||
|
||||
if blob
|
||||
Rails.application.routes.url_helpers.url_for(blob)
|
||||
else
|
||||
self.class.default_url(name)
|
||||
end
|
||||
end
|
||||
|
||||
def blob_for(name)
|
||||
blob_id = get_preference("#{name}_blob_id")
|
||||
ActiveStorage::Blob.find_by(id: blob_id) if blob_id
|
||||
end
|
||||
end
|
||||
@@ -1,67 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module HasMigratingFile
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
@migrating_models = []
|
||||
|
||||
def self.migrating_models
|
||||
@migrating_models
|
||||
end
|
||||
|
||||
included do
|
||||
HasMigratingFile.migrating_models.push(name)
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def has_one_migrating(name, paperclip_options = {})
|
||||
# Active Storage declaration
|
||||
has_one_attached name
|
||||
|
||||
# Backup Active Storage methods before they get overridden by Paperclip.
|
||||
alias_method "active_storage_#{name}", name
|
||||
alias_method "active_storage_#{name}=", "#{name}="
|
||||
|
||||
# Paperclip declaration
|
||||
#
|
||||
# This will define the `name` and `name=` methods as well.
|
||||
has_attached_file name, paperclip_options
|
||||
|
||||
# Paperclip callback to duplicate file with Active Storage
|
||||
#
|
||||
# We store files with Paperclip *and* Active Storage while we migrate
|
||||
# old Paperclip files to Active Storage. This enables availability
|
||||
# during the migration.
|
||||
public_send("after_#{name}_post_process") do
|
||||
path = processed_local_file_path(name)
|
||||
if public_send(name).errors.blank? && path.present?
|
||||
attach_file(name, File.open(path))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def attach_file(name, io)
|
||||
attachable = {
|
||||
io: io,
|
||||
filename: public_send("#{name}_file_name"),
|
||||
content_type: public_send("#{name}_content_type"),
|
||||
identify: false,
|
||||
}
|
||||
public_send("active_storage_#{name}=", attachable)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def processed_local_file_path(name)
|
||||
attachment = public_send(name)
|
||||
|
||||
temporary = attachment.queued_for_write[:original]
|
||||
|
||||
if temporary&.path.present?
|
||||
temporary.path
|
||||
else
|
||||
attachment.path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,23 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/paperclippable'
|
||||
|
||||
class ContentConfiguration < Spree::Preferences::FileConfiguration
|
||||
include OpenFoodNetwork::Paperclippable
|
||||
class ContentConfiguration < Spree::Preferences::Configuration
|
||||
include FilePreferences
|
||||
|
||||
# Header
|
||||
preference :logo, :file
|
||||
preference :logo_mobile, :file
|
||||
preference :logo_mobile_svg, :file
|
||||
has_attached_file :logo, default_url: "/default_images/ofn-logo.png"
|
||||
has_attached_file :logo_mobile
|
||||
has_attached_file :logo_mobile_svg, default_url: "/default_images/ofn-logo-mobile.svg"
|
||||
file_preference :logo, default_url: "/default_images/ofn-logo.png"
|
||||
file_preference :logo_mobile
|
||||
file_preference :logo_mobile_svg, default_url: "/default_images/ofn-logo-mobile.svg"
|
||||
|
||||
# Home page
|
||||
preference :home_page_alert_html, :text
|
||||
preference :home_hero, :file
|
||||
file_preference :home_hero, default_url: "/default_images/home.jpg"
|
||||
preference :home_show_stats, :boolean, default: true
|
||||
has_attached_file :home_hero, default_url: "/default_images/home.jpg"
|
||||
|
||||
# Map
|
||||
preference :open_street_map_enabled, :boolean, default: false
|
||||
@@ -66,8 +60,7 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration
|
||||
preference :menu_7_icon_name, :string, default: "ofn-i_013-help"
|
||||
|
||||
# Footer
|
||||
preference :footer_logo, :file
|
||||
has_attached_file :footer_logo, default_url: "/default_images/ofn-logo-footer.png"
|
||||
file_preference :footer_logo, default_url: "/default_images/ofn-logo-footer.png"
|
||||
|
||||
# Other
|
||||
preference :footer_facebook_url, :string, default: "https://www.facebook.com/OpenFoodNet"
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'spree/core/s3_support'
|
||||
|
||||
class Enterprise < ApplicationRecord
|
||||
include HasMigratingFile
|
||||
include Spree::Core::S3Support
|
||||
|
||||
SELLS = %w(unspecified none own any).freeze
|
||||
ENTERPRISE_SEARCH_RADIUS = 100
|
||||
# The next Rails version will have named variants but we need to store them
|
||||
# ourselves for now.
|
||||
LOGO_SIZES = {
|
||||
thumb: { resize_to_limit: [100, 100] },
|
||||
small: { resize_to_limit: [180, 180] },
|
||||
medium: { resize_to_limit: [300, 300] },
|
||||
}.freeze
|
||||
PROMO_IMAGE_SIZES = {
|
||||
thumb: { resize_to_limit: [100, 100] },
|
||||
medium: { resize_to_fill: [720, 156] },
|
||||
large: { resize_to_fill: [1200, 260] },
|
||||
}.freeze
|
||||
|
||||
searchable_attributes :sells, :is_primary_producer
|
||||
searchable_associations :properties
|
||||
@@ -73,31 +80,16 @@ class Enterprise < ApplicationRecord
|
||||
tag_rule[:preferred_customer_tags].blank?
|
||||
}
|
||||
|
||||
has_one_migrating :logo,
|
||||
styles: { medium: "300x300>", small: "180x180>", thumb: "100x100>" },
|
||||
url: '/images/enterprises/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/logos/:id/:style/:basename.:extension'
|
||||
has_one_attached :logo
|
||||
has_one_attached :promo_image
|
||||
has_one_attached :terms_and_conditions
|
||||
|
||||
has_one_migrating :promo_image,
|
||||
styles: {
|
||||
large: ["1200x260#", :jpg],
|
||||
medium: ["720x156#", :jpg],
|
||||
thumb: ["100x100>", :jpg]
|
||||
},
|
||||
url: '/images/enterprises/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension'
|
||||
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
has_one_migrating :terms_and_conditions,
|
||||
url: '/files/enterprises/terms_and_conditions/:id/:basename.:extension',
|
||||
path: 'public/files/enterprises/terms_and_conditions/:id/:basename.:extension'
|
||||
validates_attachment_content_type :terms_and_conditions,
|
||||
content_type: "application/pdf",
|
||||
message: I18n.t(:enterprise_terms_and_conditions_type_error)
|
||||
|
||||
supports_s3 :logo
|
||||
supports_s3 :promo_image
|
||||
validates :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
validates :terms_and_conditions, content_type: {
|
||||
in: "application/pdf",
|
||||
message: I18n.t(:enterprise_terms_and_conditions_type_error),
|
||||
}
|
||||
|
||||
validates :name, presence: true
|
||||
validate :name_is_unique
|
||||
@@ -284,6 +276,22 @@ class Enterprise < ApplicationRecord
|
||||
relatives_including_self.is_primary_producer
|
||||
end
|
||||
|
||||
def logo_url(name)
|
||||
return unless logo.variable?
|
||||
|
||||
Rails.application.routes.url_helpers.url_for(
|
||||
logo.variant(LOGO_SIZES[name])
|
||||
)
|
||||
end
|
||||
|
||||
def promo_image_url(name)
|
||||
return unless promo_image.variable?
|
||||
|
||||
Rails.application.routes.url_helpers.url_for(
|
||||
promo_image.variant(PROMO_IMAGE_SIZES[name])
|
||||
)
|
||||
end
|
||||
|
||||
def website
|
||||
strip_url self[:website]
|
||||
end
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'open_food_network/locking'
|
||||
require 'spree/core/s3_support'
|
||||
|
||||
class EnterpriseGroup < ApplicationRecord
|
||||
include HasMigratingFile
|
||||
include PermalinkGenerator
|
||||
include Spree::Core::S3Support
|
||||
|
||||
acts_as_list
|
||||
|
||||
@@ -28,21 +25,11 @@ class EnterpriseGroup < ApplicationRecord
|
||||
|
||||
delegate :phone, :address1, :address2, :city, :zipcode, :state, :country, to: :address
|
||||
|
||||
has_one_migrating :logo,
|
||||
styles: { medium: "100x100" },
|
||||
url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension'
|
||||
has_one_attached :logo
|
||||
has_one_attached :promo_image
|
||||
|
||||
has_one_migrating :promo_image,
|
||||
styles: { large: ["1200x260#", :jpg] },
|
||||
url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension'
|
||||
|
||||
validates_attachment_content_type :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates_attachment_content_type :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
supports_s3 :logo
|
||||
supports_s3 :promo_image
|
||||
validates :logo, content_type: %r{\Aimage/.*\Z}
|
||||
validates :promo_image, content_type: %r{\Aimage/.*\Z}
|
||||
|
||||
scope :by_position, -> { order('position ASC') }
|
||||
scope :on_front_page, -> { where(on_front_page: true) }
|
||||
|
||||
@@ -236,12 +236,10 @@ module Spree
|
||||
:validate_data, :reset_absent_products], ProductImport::ProductImporter
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management, :packing],
|
||||
Spree::Admin::ReportsController
|
||||
can [:admin, :show, :packing], :report
|
||||
add_bulk_coop_abilities
|
||||
add_enterprise_fee_summary_abilities
|
||||
can [:admin, :index, :show], ::Admin::ReportsController
|
||||
can [:admin, :show, :customers, :orders_and_distributors, :group_buys, :payments,
|
||||
:orders_and_fulfillment, :products_and_inventory, :order_cycle_management,
|
||||
:packing, :enterprise_fee_summary, :bulk_coop], :report
|
||||
end
|
||||
|
||||
def add_order_cycle_management_abilities(user)
|
||||
@@ -317,11 +315,10 @@ module Spree
|
||||
end
|
||||
|
||||
# Reports page
|
||||
can [:admin, :index, :customers, :group_buys, :sales_tax, :payments,
|
||||
can [:admin, :index, :show], ::Admin::ReportsController
|
||||
can [:admin, :customers, :group_buys, :sales_tax, :payments,
|
||||
:orders_and_distributors, :orders_and_fulfillment, :products_and_inventory,
|
||||
:order_cycle_management, :xero_invoices], Spree::Admin::ReportsController
|
||||
add_bulk_coop_abilities
|
||||
add_enterprise_fee_summary_abilities
|
||||
:order_cycle_management, :xero_invoices, :enterprise_fee_summary, :bulk_coop], :report
|
||||
|
||||
can [:create], Customer
|
||||
can [:admin, :index, :update,
|
||||
@@ -346,19 +343,5 @@ module Spree
|
||||
user.enterprises.include?(enterprise_relationship.child)
|
||||
end
|
||||
end
|
||||
|
||||
def add_bulk_coop_abilities
|
||||
# Reveal the report link in spree/admin/reports#index
|
||||
can [:bulk_coop], Spree::Admin::ReportsController
|
||||
# Allow direct access to the report resource
|
||||
can [:admin, :new, :create], :bulk_coop
|
||||
end
|
||||
|
||||
def add_enterprise_fee_summary_abilities
|
||||
# Reveal the report link in spree/admin/reports#index
|
||||
can [:enterprise_fee_summary], Spree::Admin::ReportsController
|
||||
# Allow direct access to the report resource
|
||||
can [:admin, :new, :create], :enterprise_fee_summary
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,6 +105,10 @@ module Spree
|
||||
render_address([city, zipcode, state&.name])
|
||||
end
|
||||
|
||||
def address_and_city
|
||||
[address1, address2, city].select(&:present?).join(' ')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def require_zipcode?
|
||||
|
||||
@@ -1,103 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spree/core/s3_support'
|
||||
|
||||
module Spree
|
||||
class Image < Asset
|
||||
include HasMigratingFile
|
||||
SIZES = {
|
||||
mini: { resize_to_fill: [48, 48] },
|
||||
small: { resize_to_fill: [227, 227] },
|
||||
product: { resize_to_limit: [240, 240] },
|
||||
large: { resize_to_limit: [600, 600] },
|
||||
}.freeze
|
||||
|
||||
validates_attachment_presence :attachment
|
||||
has_one_attached :attachment
|
||||
|
||||
validates :attachment, attached: true, content_type: %r{\Aimage/.*\Z}
|
||||
validate :no_attachment_errors
|
||||
|
||||
# This is where the styles are used in the app:
|
||||
# - mini: used in the BackOffice: Bulk Product Edit page and Order Cycle edit page
|
||||
# - small: used in the FrontOffice: Product List page
|
||||
# - product: used in the BackOffice: Product Image upload modal in the Bulk Product Edit page
|
||||
# and Product image edit page
|
||||
# - large: used in the FrontOffice: product modal
|
||||
has_one_migrating :attachment,
|
||||
styles: { mini: "48x48#", small: "227x227#",
|
||||
product: "240x240>", large: "600x600>" },
|
||||
default_style: :product,
|
||||
url: '/spree/products/:id/:style/:basename.:extension',
|
||||
path: ':rails_root/public/spree/products/:id/:style/:basename.:extension',
|
||||
convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
|
||||
|
||||
# save the w,h of the original image (from which others can be calculated)
|
||||
# we need to look at the write-queue for images which have not been saved yet
|
||||
after_post_process :find_dimensions
|
||||
|
||||
include Spree::Core::S3Support
|
||||
supports_s3 :attachment
|
||||
|
||||
# used by admin products autocomplete
|
||||
def mini_url
|
||||
attachment.url(:mini, false)
|
||||
def variant(name)
|
||||
attachment.variant(SIZES[name])
|
||||
end
|
||||
|
||||
def find_dimensions
|
||||
return if attachment.errors.present?
|
||||
def url(size)
|
||||
return unless attachment.variable?
|
||||
|
||||
geometry = Paperclip::Geometry.from_file(local_filename_of_original)
|
||||
|
||||
self.attachment_width = geometry.width
|
||||
self.attachment_height = geometry.height
|
||||
end
|
||||
|
||||
def local_filename_of_original
|
||||
temporary = attachment.queued_for_write[:original]
|
||||
|
||||
if temporary&.path.present?
|
||||
temporary.path
|
||||
else
|
||||
attachment.path
|
||||
end
|
||||
Rails.application.routes.url_helpers.url_for(variant(size))
|
||||
end
|
||||
|
||||
# if there are errors from the plugin, then add a more meaningful message
|
||||
def no_attachment_errors
|
||||
return if attachment.errors.empty?
|
||||
return if errors[:attachment].empty?
|
||||
|
||||
if errors.all? { |e| e.type == "Paperclip::Errors::NotIdentifiedByImageMagickError" }
|
||||
if errors.all? { |e| e.type == :content_type_invalid }
|
||||
attachment.errors.clear
|
||||
errors.add :base, I18n.t('spree.admin.products.image_upload_error')
|
||||
else
|
||||
errors.add :attachment,
|
||||
I18n.t('spree.admin.products.paperclip_image_error', attachment_file_name: attachment_file_name)
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def self.set_attachment_attribute(attribute_name, attribute_value)
|
||||
attachment_definitions[:attachment][attribute_name] = attribute_value
|
||||
end
|
||||
|
||||
def self.set_storage_attachment_attributes
|
||||
if Spree::Config[:use_s3]
|
||||
set_s3_attachment_attributes
|
||||
else
|
||||
attachment_definitions[:attachment].delete(:storage)
|
||||
end
|
||||
end
|
||||
|
||||
def self.set_s3_attachment_attributes
|
||||
set_attachment_attribute(:storage, :s3)
|
||||
set_attachment_attribute(:s3_credentials, s3_credentials)
|
||||
set_attachment_attribute(:s3_headers,
|
||||
ActiveSupport::JSON.decode(Spree::Config[:s3_headers]))
|
||||
set_attachment_attribute(:bucket, Spree::Config[:s3_bucket])
|
||||
|
||||
# We use :s3_alias_url (virtual host url style) and set the URL on property s3_host_alias
|
||||
set_attachment_attribute(:s3_host_alias, attachment_definitions[:attachment][:url])
|
||||
set_attachment_attribute(:url, ":s3_alias_url")
|
||||
end
|
||||
private_class_method :set_s3_attachment_attributes
|
||||
|
||||
def self.s3_credentials
|
||||
{ access_key_id: Spree::Config[:s3_access_key],
|
||||
secret_access_key: Spree::Config[:s3_secret],
|
||||
bucket: Spree::Config[:s3_bucket] }
|
||||
end
|
||||
private_class_method :s3_credentials
|
||||
end
|
||||
end
|
||||
|
||||
@@ -430,9 +430,10 @@ module Spree
|
||||
|
||||
def empty!
|
||||
line_items.destroy_all
|
||||
adjustments.destroy_all
|
||||
all_adjustments.destroy_all
|
||||
payments.clear
|
||||
shipments.destroy_all
|
||||
restart_checkout_flow if state == "payment"
|
||||
end
|
||||
|
||||
def state_changed(name)
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
module Preferences
|
||||
class FileConfiguration < Configuration
|
||||
def self.preference(name, type, *args)
|
||||
if type == :file
|
||||
# Active Storage blob id:
|
||||
super "#{name}_blob_id", :integer, *args
|
||||
|
||||
# Paperclip attachment attributes:
|
||||
super "#{name}_file_name", :string, *args
|
||||
super "#{name}_content_type", :string, *args
|
||||
super "#{name}_file_size", :integer, *args
|
||||
super "#{name}_updated_at", :string, *args
|
||||
|
||||
else
|
||||
super name, type, *args
|
||||
end
|
||||
end
|
||||
|
||||
def get_preference(key)
|
||||
if !has_preference?(key) && has_attachment?(key)
|
||||
# Call Paperclip's attachment method:
|
||||
public_send key
|
||||
elsif key.ends_with?("_blob")
|
||||
# Find referenced Active Storage blob:
|
||||
blob_id = super("#{key}_id")
|
||||
ActiveStorage::Blob.find_by(id: blob_id)
|
||||
else
|
||||
super key
|
||||
end
|
||||
end
|
||||
alias :[] :get_preference
|
||||
|
||||
def preference_type(name)
|
||||
if has_attachment? name
|
||||
:file
|
||||
else
|
||||
super name
|
||||
end
|
||||
end
|
||||
|
||||
# Spree's Configuration responds to preference methods via method_missing, but doesn't
|
||||
# override respond_to?, which consequently reports those methods as unavailable. Paperclip
|
||||
# errors if respond_to? isn't correct, so we override it here.
|
||||
def respond_to?(method, include_all = false)
|
||||
name = method.to_s.delete('=')
|
||||
reference_name = "#{name}_id"
|
||||
|
||||
super(self.class.preference_getter_method(name), include_all) ||
|
||||
super(reference_name, include_all) ||
|
||||
super(method, include_all)
|
||||
end
|
||||
|
||||
def has_attachment?(name)
|
||||
self.class.respond_to?(:attachment_definitions) &&
|
||||
self.class.attachment_definitions.key?(name.to_sym)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,6 +9,7 @@ class SubscriptionLineItem < ApplicationRecord
|
||||
validates :quantity, presence: true, numericality: { only_integer: true }
|
||||
|
||||
default_scope { order('id ASC') }
|
||||
scope :nil_price_estimate, -> { where(price_estimate: nil) }
|
||||
|
||||
def total_estimate
|
||||
(price_estimate || 0) * (quantity || 0)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TermsOfServiceFile < ApplicationRecord
|
||||
include HasMigratingFile
|
||||
has_one_attached :attachment
|
||||
|
||||
has_one_migrating :attachment
|
||||
|
||||
validates :attachment, presence: true
|
||||
validates :attachment, attached: true
|
||||
|
||||
# The most recently uploaded file is the current one.
|
||||
def self.current
|
||||
@@ -13,7 +11,11 @@ class TermsOfServiceFile < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.current_url
|
||||
current&.attachment&.url || Spree::Config.footer_tos_url
|
||||
if current
|
||||
Rails.application.routes.url_helpers.url_for(current.attachment)
|
||||
else
|
||||
Spree::Config.footer_tos_url
|
||||
end
|
||||
end
|
||||
|
||||
# If no file has been uploaded, we don't know when the old terms have
|
||||
@@ -21,9 +23,4 @@ class TermsOfServiceFile < ApplicationRecord
|
||||
def self.updated_at
|
||||
current&.updated_at || Time.zone.now
|
||||
end
|
||||
|
||||
def touch(_)
|
||||
# Ignore Active Storage changing the timestamp during migrations.
|
||||
# This can be removed once we got rid of Paperclip.
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,21 +22,26 @@ module Api
|
||||
has_one :business_address, serializer: Api::AddressSerializer
|
||||
|
||||
def logo
|
||||
attachment_urls(object.logo, [:thumb, :small, :medium])
|
||||
attachment_urls(object.logo, Enterprise::LOGO_SIZES)
|
||||
end
|
||||
|
||||
def promo_image
|
||||
attachment_urls(object.promo_image, [:thumb, :medium, :large])
|
||||
attachment_urls(object.promo_image, Enterprise::PROMO_IMAGE_SIZES)
|
||||
end
|
||||
|
||||
def terms_and_conditions
|
||||
return unless object.terms_and_conditions.file?
|
||||
return unless object.terms_and_conditions.attached?
|
||||
|
||||
object.terms_and_conditions.url
|
||||
Rails.application.routes.url_helpers.
|
||||
url_for(object.terms_and_conditions)
|
||||
end
|
||||
|
||||
def terms_and_conditions_file_name
|
||||
object.terms_and_conditions_blob&.filename
|
||||
end
|
||||
|
||||
def terms_and_conditions_updated_at
|
||||
object.terms_and_conditions_updated_at&.to_s
|
||||
object.terms_and_conditions_blob&.created_at&.to_s
|
||||
end
|
||||
|
||||
def tag_groups
|
||||
@@ -76,19 +81,19 @@ module Api
|
||||
|
||||
# Returns a hash of URLs for specified versions of an attachment.
|
||||
#
|
||||
# Example:
|
||||
# Example result:
|
||||
#
|
||||
# attachment_urls(object.logo, [:thumb, :small, :medium])
|
||||
# # {
|
||||
# # thumb: LOGO_THUMB_URL,
|
||||
# # small: LOGO_SMALL_URL,
|
||||
# # medium: LOGO_MEDIUM_URL
|
||||
# # }
|
||||
def attachment_urls(attachment, versions)
|
||||
return unless attachment.file?
|
||||
# {
|
||||
# thumb: LOGO_THUMB_URL,
|
||||
# small: LOGO_SMALL_URL,
|
||||
# medium: LOGO_MEDIUM_URL
|
||||
# }
|
||||
def attachment_urls(attachment, styles)
|
||||
return unless attachment.variable?
|
||||
|
||||
versions.each_with_object({}) do |version, urls|
|
||||
urls[version] = attachment.url(version)
|
||||
styles.transform_values do |transformation|
|
||||
Rails.application.routes.url_helpers.
|
||||
url_for(attachment.variant(transformation))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module Api
|
||||
end
|
||||
|
||||
def image_url
|
||||
object.images.present? ? object.images.first.attachment.url(:mini) : nil
|
||||
object.images.first&.url(:mini)
|
||||
end
|
||||
|
||||
def master_id
|
||||
|
||||
@@ -13,19 +13,11 @@ module Api
|
||||
has_one :master, serializer: Api::Admin::VariantSerializer
|
||||
|
||||
def image_url
|
||||
if object.images.present?
|
||||
object.images.first.attachment.url(:product)
|
||||
else
|
||||
"/noimage/product.png"
|
||||
end
|
||||
object.images.first&.url(:product) || "/noimage/product.png"
|
||||
end
|
||||
|
||||
def thumb_url
|
||||
if object.images.present?
|
||||
object.images.first.attachment.url(:mini)
|
||||
else
|
||||
"/noimage/mini.png"
|
||||
end
|
||||
object.images.first&.url(:mini) || "/noimage/mini.png"
|
||||
end
|
||||
|
||||
def on_hand
|
||||
|
||||
@@ -33,9 +33,7 @@ module Api
|
||||
end
|
||||
|
||||
def image
|
||||
return if object.product.images.empty?
|
||||
|
||||
object.product.images.first.mini_url
|
||||
object.product.images.first&.url(:mini)
|
||||
end
|
||||
|
||||
def in_stock
|
||||
|
||||
@@ -44,11 +44,11 @@ module Api
|
||||
end
|
||||
|
||||
def logo
|
||||
enterprise.logo(:medium) if enterprise.logo?
|
||||
enterprise.logo_url(:medium)
|
||||
end
|
||||
|
||||
def promo_image
|
||||
enterprise.promo_image(:large) if enterprise.promo_image?
|
||||
enterprise.promo_image_url(:large)
|
||||
end
|
||||
|
||||
def path
|
||||
|
||||
@@ -41,11 +41,11 @@ module Api
|
||||
end
|
||||
|
||||
def logo
|
||||
enterprise.logo(:medium) if enterprise.logo?
|
||||
enterprise.logo_url(:medium)
|
||||
end
|
||||
|
||||
def promo_image
|
||||
enterprise.promo_image(:large) if enterprise.promo_image?
|
||||
enterprise.promo_image_url(:large)
|
||||
end
|
||||
|
||||
def path
|
||||
|
||||
@@ -4,18 +4,18 @@ class Api::ImageSerializer < ActiveModel::Serializer
|
||||
attributes :id, :alt, :thumb_url, :small_url, :image_url, :large_url
|
||||
|
||||
def thumb_url
|
||||
object.attachment.url(:mini, false)
|
||||
object.url(:mini)
|
||||
end
|
||||
|
||||
def small_url
|
||||
object.attachment.url(:small, false)
|
||||
object.url(:small)
|
||||
end
|
||||
|
||||
def image_url
|
||||
object.attachment.url(:product, false)
|
||||
object.url(:product)
|
||||
end
|
||||
|
||||
def large_url
|
||||
object.attachment.url(:large, false)
|
||||
object.url(:large)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module Api
|
||||
end
|
||||
|
||||
def logo
|
||||
object.logo(:small) if object.logo?
|
||||
object.logo_url(:small)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,11 +35,7 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def thumb_url
|
||||
if object.product.images.present?
|
||||
object.product.images.first.attachment.url(:mini)
|
||||
else
|
||||
"/noimage/mini.png"
|
||||
end
|
||||
object.product.images.first&.url(:mini) || "/noimage/mini.png"
|
||||
end
|
||||
|
||||
def unit_price_price
|
||||
|
||||
@@ -2,21 +2,12 @@
|
||||
|
||||
class ImageImporter
|
||||
def import(url, product)
|
||||
attach(download(url), product)
|
||||
end
|
||||
valid_url = URI.parse(url)
|
||||
file = open(valid_url.to_s)
|
||||
filename = File.basename(valid_url.path)
|
||||
|
||||
private
|
||||
|
||||
def download(url)
|
||||
local_file = Tempfile.new
|
||||
remote_file = open(url)
|
||||
IO.copy_stream(remote_file, local_file)
|
||||
local_file
|
||||
end
|
||||
|
||||
def attach(file, product)
|
||||
Spree::Image.create(
|
||||
attachment: file,
|
||||
attachment: { io: file, filename: filename },
|
||||
viewable_id: product.master.id,
|
||||
viewable_type: Spree::Variant,
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ class TermsOfService
|
||||
return false unless accepted_at = customer&.terms_and_conditions_accepted_at
|
||||
|
||||
accepted_at > if distributor
|
||||
distributor.terms_and_conditions_updated_at
|
||||
distributor.terms_and_conditions_blob.created_at
|
||||
else
|
||||
TermsOfServiceFile.updated_at
|
||||
end
|
||||
@@ -20,6 +20,6 @@ class TermsOfService
|
||||
end
|
||||
|
||||
def self.distributor_terms_required?(distributor)
|
||||
distributor.terms_and_conditions.file?
|
||||
distributor.terms_and_conditions.attached?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,8 +38,13 @@
|
||||
# post.valid? # => false
|
||||
# post.errors[:published_at] # => ["must be valid"]
|
||||
class DateTimeStringValidator < ActiveModel::EachValidator
|
||||
NOT_STRING_ERROR = I18n.t("validators.date_time_string_validator.not_string_error")
|
||||
INVALID_FORMAT_ERROR = I18n.t("validators.date_time_string_validator.invalid_format_error")
|
||||
def self.not_string_error
|
||||
I18n.t("validators.date_time_string_validator.not_string_error")
|
||||
end
|
||||
|
||||
def self.invalid_format_error
|
||||
I18n.t("validators.date_time_string_validator.invalid_format_error")
|
||||
end
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
return if value.nil? || value == ""
|
||||
@@ -53,13 +58,13 @@ class DateTimeStringValidator < ActiveModel::EachValidator
|
||||
def validate_attribute_is_string(record, attribute, value)
|
||||
return if value.is_a?(String)
|
||||
|
||||
record.errors.add(attribute, NOT_STRING_ERROR)
|
||||
record.errors.add(attribute, DateTimeStringValidator.not_string_error)
|
||||
end
|
||||
|
||||
def validate_attribute_is_datetime_string(record, attribute, value)
|
||||
return unless value.is_a?(String)
|
||||
|
||||
datetime = Time.zone.parse(value)
|
||||
record.errors.add(attribute, INVALID_FORMAT_ERROR) if datetime.blank?
|
||||
record.errors.add(attribute, DateTimeStringValidator.invalid_format_error) if datetime.blank?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,8 +35,13 @@
|
||||
# post.valid? # => false
|
||||
# post.errors[:related_post_ids] # => ["must contain only valid integers"]
|
||||
class IntegerArrayValidator < ActiveModel::EachValidator
|
||||
NOT_ARRAY_ERROR = I18n.t("validators.integer_array_validator.not_array_error")
|
||||
INVALID_ELEMENT_ERROR = I18n.t("validators.integer_array_validator.invalid_element_error")
|
||||
def self.not_array_error
|
||||
I18n.t("validators.integer_array_validator.not_array_error")
|
||||
end
|
||||
|
||||
def self.invalid_element_error
|
||||
I18n.t("validators.integer_array_validator.invalid_element_error")
|
||||
end
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
return if value.nil?
|
||||
@@ -50,7 +55,7 @@ class IntegerArrayValidator < ActiveModel::EachValidator
|
||||
def validate_attribute_is_array(record, attribute, value)
|
||||
return if value.is_a?(Array)
|
||||
|
||||
record.errors.add(attribute, NOT_ARRAY_ERROR)
|
||||
record.errors.add(attribute, IntegerArrayValidator.not_array_error)
|
||||
end
|
||||
|
||||
def validate_attribute_elements_are_integer(record, attribute, array)
|
||||
@@ -60,6 +65,6 @@ class IntegerArrayValidator < ActiveModel::EachValidator
|
||||
Integer(element)
|
||||
end
|
||||
rescue ArgumentError
|
||||
record.errors.add(attribute, INVALID_ELEMENT_ERROR)
|
||||
record.errors.add(attribute, IntegerArrayValidator.invalid_element_error)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,5 +8,8 @@
|
||||
- text = t(key)
|
||||
.field
|
||||
= label_tag(key, text + ': ') + tag(:br) if type != :boolean
|
||||
= preference_field_tag(key, ContentConfig[key], :type => type)
|
||||
- if type == :file
|
||||
= file_field_tag(key, type: type)
|
||||
- else
|
||||
= preference_field_tag(key, ContentConfig[key], type: type)
|
||||
= label_tag(key, text) + tag(:br) if type == :boolean
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
%div{'ofn-with-tip' => t('admin_enterprise_groups_data_powertip_logo')}
|
||||
%a= t 'admin.whats_this'
|
||||
.omega.eight.columns
|
||||
= image_tag @object.logo.url if @object.logo.present?
|
||||
= f.file_field :logo
|
||||
= image_tag @object.logo if @object.logo.attached?
|
||||
= f.file_field :logo, accept: "image/*"
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :promo_image, 'ofn-with-tip' => t(:admin_enterprise_groups_data_powertip_promo_image)
|
||||
%div{'ofn-with-tip' => t('admin_enterprise_groups_data_powertip_promo_image')}
|
||||
%a= t 'admin.whats_this'
|
||||
.omega.eight.columns
|
||||
= image_tag @object.promo_image.url if @object.promo_image.present?
|
||||
= f.file_field :promo_image
|
||||
= image_tag @object.promo_image if @object.promo_image.attached?
|
||||
= f.file_field :promo_image, accept: "image/*"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
.ten.columns
|
||||
= select_tag :coordinator_id, options_for_select(permitted_coordinating_enterprise_options_for(@order_cycle)), { 'required' => true, class: 'select2 fullwidth'}
|
||||
.two.columns.alpha
|
||||
.two.columns
|
||||
= f.submit "#{t(:continue)} >"
|
||||
|
||||
.two.columns.omega
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
-# Field used for ransack search. This date range is mostly used for Spree::Order
|
||||
-# so default field is 'completed_at'
|
||||
- field ||= 'completed_at'
|
||||
.row.date-range-filter
|
||||
= label_tag nil, t(:date_range)
|
||||
%br
|
||||
= label_tag nil, t(:start), :class => 'inline'
|
||||
= text_field_tag "q[order_completed_at_gt]", params.dig(:q, :order_completed_at_gt), :class => 'datetimepicker datepicker-from'
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
= text_field_tag "q[order_completed_at_lt]", params.dig(:q, :order_completed_at_lt), :class => 'datetimepicker datepicker-to'
|
||||
= label_tag nil, t(:end), :class => 'inline'
|
||||
.alpha.two.columns= label_tag nil, t(:date_range)
|
||||
.omega.fourteen.columns
|
||||
= f.text_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start)
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
= f.text_field "#{field}_lt", :class => 'datetimepicker datepicker-to', :placeholder => t(:stop)
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
.row.rendering-options
|
||||
= label_tag :report_format, t(".generate_report")
|
||||
%br
|
||||
= select_tag :report_format, options_for_select({t('.on_screen') => '', t('.csv_spreadsheet') => 'csv', t('.excel_spreadsheet') => 'xlsx', t('.openoffice_spreadsheet') => 'ods'})
|
||||
- if @report_subtypes.present? && @report_subtypes.count > 1
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_type)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
|
||||
|
||||
- if @report.header_option? || @report.summary_row_option?
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(".display")
|
||||
.omega.fourteen.columns
|
||||
- if @report.header_option?
|
||||
%span.inline-checkbox{ style: "margin-right: 1rem;" }
|
||||
= check_box_tag :display_header_row, true, params[:display_header_row]
|
||||
= label_tag :display_header_row, t(".header_row")
|
||||
- if @report.summary_row_option?
|
||||
%span.inline-checkbox
|
||||
= check_box_tag :display_summary_row, true, params[:display_summary_row]
|
||||
= label_tag :display_summary_row, t(".summary_row")
|
||||
|
||||
- if @report.available_headers.present?
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hide_columns)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:fields_to_hide, options_for_select(@report.available_headers, params[:fields_to_hide]),
|
||||
class: "select2 fullwidth", multiple: true)
|
||||
|
||||
.row.rendering-options
|
||||
.alpha.two.columns
|
||||
= label_tag :report_format, t(".generate_report")
|
||||
.omega.fourteen.columns
|
||||
= select_tag :report_format, grouped_options_for_select({ |
|
||||
t('.formatted_data') => { t('.on_screen') => '', "PDF" => 'pdf', t('.spreadsheet') => 'xlsx' }, |
|
||||
t('.raw_data') => { "CSV" => 'csv' }, |
|
||||
})
|
||||
|
||||
|
||||
-#.inline-checkbox
|
||||
-# = check_box_tag "options[exclude_summaries]", true, params[:options].andand[:exclude_summaries]
|
||||
-# = label_tag t(".hide_summary_rows")
|
||||
|
||||
22
app/views/admin/reports/_row_group.haml
Normal file
22
app/views/admin/reports/_row_group.haml
Normal file
@@ -0,0 +1,22 @@
|
||||
-# Locals :
|
||||
-# - data
|
||||
-# - report
|
||||
|
||||
- data.each do |group_or_row|
|
||||
- if group_or_row[:is_group].present?
|
||||
/ Header Row
|
||||
- if group_or_row[:header].present? && report.display_header_row?
|
||||
%tr
|
||||
%td.header-row{ colspan: report.table_headers.count, class: group_or_row[:header_class] }
|
||||
= group_or_row[:header].html_safe
|
||||
/ Rows
|
||||
= render partial: 'admin/reports/row_group', locals: { report: report, data: group_or_row[:data] }
|
||||
/ Summary Row
|
||||
- if group_or_row[:summary_row].present? && report.display_summary_row?
|
||||
%tr.summary-row{ class: group_or_row[:summary_row_class] }
|
||||
- group_or_row[:summary_row].to_h.each do |key, value|
|
||||
%td= value
|
||||
- else
|
||||
%tr
|
||||
- group_or_row.row.to_h.each do |key, value|
|
||||
%td= value
|
||||
@@ -1,20 +1,15 @@
|
||||
- if params[:q].present?
|
||||
%table.report__table{id: id}
|
||||
- report ||= @report
|
||||
|
||||
.report__table-container
|
||||
%table.report__table
|
||||
%thead
|
||||
%tr
|
||||
- @report.table_headers.each do |heading|
|
||||
- report.table_headers.each do |heading|
|
||||
%th
|
||||
= t("admin.reports.table.headings.#{heading}")
|
||||
= heading
|
||||
%tbody
|
||||
- @report.table_rows.each do |row|
|
||||
- if row
|
||||
%tr
|
||||
- row.each do |cell|
|
||||
%td
|
||||
= cell
|
||||
- if @report.table_rows.empty?
|
||||
- if report.grouped_data.present?
|
||||
= render partial: 'admin/reports/row_group', locals: { report: report, data: report.grouped_data }
|
||||
- else
|
||||
%tr
|
||||
%td{colspan: @report.table_headers.count}= t(:none)
|
||||
- else
|
||||
%p.report__message
|
||||
= t(".select_and_search", option: msg_option.upcase)
|
||||
%td{colspan: report.table_headers.count}= t(:none)
|
||||
|
||||
6
app/views/admin/reports/filters/_bulk_coop.html.haml
Normal file
6
app/views/admin/reports/filters/_bulk_coop.html.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
18
app/views/admin/reports/filters/_customers.html.haml
Normal file
18
app/views/admin/reports/filters/_customers.html.haml
Normal file
@@ -0,0 +1,18 @@
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_distributor)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:distributor_id,
|
||||
options_from_collection_for_select(@data.distributors, :id, :name, params[:distributor_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_supplier)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:supplier_id,
|
||||
options_from_collection_for_select(@data.suppliers, :id, :name, params[:supplier_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:order_cycle_id,
|
||||
options_for_select(report_order_cycle_options(@data.order_cycles), params[:order_cycle_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
@@ -0,0 +1,31 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :distributor_ids, @report.permissions.allowed_distributors, :id, :name, {selected: params.dig(:q, :distributor_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :producer_ids, @report.permissions.allowed_producers, :id, :name, {selected: params.dig(:q, :producer_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:order_cycles)
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :order_cycle_ids, @report.permissions.allowed_order_cycles, :id, :name, {selected: params.dig(:q, :order_cycle_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_enterprise_fee)
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :enterprise_fee_ids, @report.permissions.allowed_enterprise_fees, :id, :name, {selected: params.dig(:q, :enterprise_fee_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t('spree.shipping_methods')
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :shipping_method_ids, @report.permissions.allowed_shipping_methods, :id, :name, {selected: params.dig(:q, :shipping_method_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_payment)
|
||||
.omega.fourteen.columns
|
||||
= collection_select(:q, :payment_method_ids, @report.permissions.allowed_payment_methods, :id, :name, {selected: params.dig(:q, :payment_method_ids)}, {class: "select2 fullwidth", multiple: true})
|
||||
@@ -0,0 +1,18 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_payment)
|
||||
.omega.fourteen.columns= select_tag(:payment_method_in, options_for_select(report_payment_method_options(@report.query_result), params[:payment_method_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:shipping_methods)
|
||||
.omega.fourteen.columns= select_tag(:shipping_method_in, options_for_select(report_shipping_method_options(@report.query_result), params[:shipping_method_in]), {class: "select2 fullwidth", multiple: true})
|
||||
@@ -0,0 +1 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
14
app/views/admin/reports/filters/_orders_and_fulfillment.html.haml
Executable file
14
app/views/admin/reports/filters/_orders_and_fulfillment.html.haml
Executable file
@@ -0,0 +1,14 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @data.orders_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@data.orders_suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@data.order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
16
app/views/admin/reports/filters/_packing.html.haml
Executable file
16
app/views/admin/reports/filters/_packing.html.haml
Executable file
@@ -0,0 +1,16 @@
|
||||
= render partial: 'admin/reports/date_range_form', locals: { f: f, field: 'order_completed_at' }
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select("q", "order_distributor_id_in", @data.orders_distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@data.orders_suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@data.order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
6
app/views/admin/reports/filters/_payments.html.haml
Normal file
6
app/views/admin/reports/filters/_payments.html.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_distributor)
|
||||
.omega.fourteen.columns
|
||||
= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => t(:report_all)}, {:class => "select2 fullwidth light"})
|
||||
@@ -0,0 +1,20 @@
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_distributor)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:distributor_id,
|
||||
options_from_collection_for_select(@data.distributors, :id, :name, params[:distributor_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_supplier)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:supplier_id,
|
||||
options_from_collection_for_select(@data.suppliers, :id, :name, params[:supplier_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_order_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:order_cycle_id,
|
||||
options_for_select(report_order_cycle_options(@data.order_cycles), params[:order_cycle_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth light"})
|
||||
6
app/views/admin/reports/filters/_sales_tax.html.haml
Normal file
6
app/views/admin/reports/filters/_sales_tax.html.haml
Normal file
@@ -0,0 +1,6 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_distributor)
|
||||
.omega.fourteen.columns
|
||||
= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => t(:all)}, {:class => "select2 fullwidth light"})
|
||||
@@ -0,0 +1,7 @@
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_enterprises)
|
||||
.omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_users)
|
||||
.omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
25
app/views/admin/reports/filters/_xero_invoices.html.haml
Normal file
25
app/views/admin/reports/filters/_xero_invoices.html.haml
Normal file
@@ -0,0 +1,25 @@
|
||||
= render 'admin/reports/date_range_form', f: f
|
||||
|
||||
.row
|
||||
.two.columns.alpha= label_tag nil, t(:report_hubs)
|
||||
.fourteen.columns.omega= f.collection_select(:distributor_id_eq, @data.distributors, :id, :name, {:include_blank => 'All'}, {:class => "select2 fullwidth light"})
|
||||
.row
|
||||
.two.columns.alpha= label_tag nil, t(:report_order_cycle)
|
||||
.fourteen.columns.omega= f.select(:order_cycle_id_eq,
|
||||
options_for_select(report_order_cycle_options(@data.order_cycles), params.dig(:q, :order_cycle_id_eq)),
|
||||
{:include_blank => true}, {:class => "select2 fullwidth light"})
|
||||
|
||||
%fieldset.no-border-bottom.print-hidden{ style: "padding-bottom: 0" }
|
||||
%legend{ align: 'center'}= t(:report_xero_configuration)
|
||||
.row
|
||||
.two.columns.alpha= label_tag :initial_invoice_number, t(:initial_invoice_number)
|
||||
.fourteen.columns.omega= number_field_tag :initial_invoice_number, params[:initial_invoice_number]
|
||||
.row
|
||||
.two.columns.alpha= label_tag :invoice_date, t(:invoice_date)
|
||||
.fourteen.columns.omega= text_field_tag :invoice_date, params[:invoice_date], class: 'datetimepicker'
|
||||
.row
|
||||
.two.columns.alpha= label_tag :due_date, t(:due_date)
|
||||
.fourteen.columns.omega= text_field_tag :due_date, params[:due_date], class: 'datetimepicker'
|
||||
.row
|
||||
.two.columns.alpha= label_tag :account_code, t(:account_code)
|
||||
.fourteen.columns.omega= text_field_tag :account_code, params[:account_code]
|
||||
25
app/views/admin/reports/index.html.haml
Normal file
25
app/views/admin/reports/index.html.haml
Normal file
@@ -0,0 +1,25 @@
|
||||
- content_for :page_title do
|
||||
= t(:listing_reports)
|
||||
|
||||
.columns.twelve
|
||||
%table.index
|
||||
%thead
|
||||
%tr
|
||||
%th= t(:name)
|
||||
%th= t(:description)
|
||||
%tbody
|
||||
- @reports.each do |report_type, report_subtypes|
|
||||
%tr
|
||||
%td
|
||||
- name = I18n.t(:name, scope: [:admin, :reports, report_type])
|
||||
- url = main_app.admin_report_url(report_type: report_type)
|
||||
= link_to name, url
|
||||
%td
|
||||
- begin
|
||||
= I18n.t!(:description, scope: [:admin, :reports, report_type])
|
||||
- rescue I18n::MissingTranslationData
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_subtypes.each do |report_subtype|
|
||||
%li
|
||||
- url = main_app.admin_report_url(report_type: report_type, report_subtype: report_subtype[1])
|
||||
= link_to report_subtype[0], url
|
||||
@@ -1,31 +0,0 @@
|
||||
= form_tag main_app.admin_reports_path, report_type: 'packing' do
|
||||
= render partial: 'date_range_form'
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns
|
||||
= collection_select("q", "order_distributor_id_in", @distributors, :id, :name, {selected: params.dig(:q, :order_distributor_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[supplier_id_in]", options_from_collection_for_select(@suppliers, :id, :name, params.dig(:q, :supplier_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= select_tag("q[order_cycle_id_in]", options_for_select(report_order_cycle_options(@order_cycles), params.dig(:q, :order_cycle_id_in)), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_type)
|
||||
.omega.fourteen.columns
|
||||
= select_tag(:report_subtype, options_for_select(@report_subtypes, @report_subtype))
|
||||
|
||||
= render partial: "rendering_options"
|
||||
|
||||
.row
|
||||
= button t(:search)
|
||||
|
||||
= render partial: "spree/admin/reports/customer_names_message"
|
||||
|
||||
= render "table", id: "listing_orders", msg_option: t(:search)
|
||||
22
app/views/admin/reports/show.html.haml
Normal file
22
app/views/admin/reports/show.html.haml
Normal file
@@ -0,0 +1,22 @@
|
||||
= form_for @report.search, :url => url_for(only_path: false) do |f|
|
||||
%fieldset.no-border-bottom.print-hidden
|
||||
%legend{ align: 'center'}= t(:report_filters)
|
||||
= render partial: "admin/reports/filters/#{@report_type}", locals: { f: f }
|
||||
|
||||
%fieldset.print-hidden
|
||||
%legend{ align: 'center'}= t(:report_render_options)
|
||||
= render partial: "rendering_options"
|
||||
|
||||
.actions.filter-actions
|
||||
= button t(:go), "report__submit-btn"
|
||||
|
||||
.report__header.print-hidden
|
||||
- if @report.message.present?
|
||||
%p.report__message= @report.message
|
||||
- if request.post?
|
||||
%button.btn-print.icon-print{ onclick: "window.print()"}= t(:report_print)
|
||||
|
||||
/ We don't want to render data unless search params are supplied.
|
||||
/ Compiling data can take a long time.
|
||||
- if request.post?
|
||||
= render "table"
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
.admin-current-terms-of-service
|
||||
- if @current_file
|
||||
%p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment.url), datetime: @current_file.updated_at)
|
||||
%p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment), datetime: @current_file.updated_at)
|
||||
%p= link_to t(".delete"), main_app.admin_terms_of_service_files_path, method: "delete", data: { confirm: t(".confirm_delete") }
|
||||
- else
|
||||
%p
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
%p
|
||||
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted = #{all_terms_and_conditions_already_accepted?}" } }
|
||||
%label.small{for: "accept_terms"}
|
||||
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms)
|
||||
= t('.message_html', terms_and_conditions_link: link_to( t(".terms_and_conditions"), current_order.distributor.terms_and_conditions, target: '_blank'), tos_link: link_to_platform_terms)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
%p
|
||||
%input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_accepted=#{terms_and_conditions_already_accepted?}" } }
|
||||
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank'))
|
||||
%label.small{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions, target: '_blank'))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- content_for(:description) do
|
||||
= current_distributor.description
|
||||
- content_for(:image) do
|
||||
= current_distributor.logo.url
|
||||
= url_for(current_distributor.logo) if current_distributor.logo.attached?
|
||||
|
||||
- content_for :injection_data do
|
||||
- cache(*CacheService::FragmentCaching.ams_shop(@enterprise)) do
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- content_for(:description) do
|
||||
= @group.description
|
||||
- content_for(:image) do
|
||||
= @group.logo.url
|
||||
= url_for(@group.logo) if @group.logo.attached?
|
||||
|
||||
- content_for :scripts do
|
||||
= render partial: "shared/google_maps_js"
|
||||
@@ -22,14 +22,13 @@
|
||||
%header
|
||||
.row
|
||||
.small-12.columns
|
||||
- if @group.promo_image.present?
|
||||
%img{"src" => @group.promo_image}
|
||||
= image_tag @group.promo_image.variant(resize_to_limit: [1200, 260]) if @group.promo_image.variable?
|
||||
.row
|
||||
.small-12.columns.group-header.pad-top
|
||||
- if @group.logo.present?
|
||||
%img.group-logo{"src" => @group.logo}
|
||||
- if @group.logo.variable?
|
||||
= image_tag @group.logo.variant(resize_to_limit: [100, 100]), class: "group-logo"
|
||||
- else
|
||||
%img.group-logo{"src" => '/noimage/group.png' }
|
||||
= image_tag "/noimage/group.png", class: "group-logo"
|
||||
%h2.group-name= @group.name
|
||||
%p= @group.description
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
:css
|
||||
#tagline:before { background-image: url("#{ContentConfig.home_hero.url}") }
|
||||
#tagline:before { background-image: url("#{ContentConfig.url_for(:home_hero)}") }
|
||||
|
||||
|
||||
- content_for :page_alert do
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
%meta{name: 'viewport', content: "width=device-width,initial-scale=1.0"}/
|
||||
%meta{property: "og:title", content: content_for?(:title) ? yield(:title) : t(:title)}
|
||||
%meta{property: "og:description", content: content_for?(:description) ? yield(:description) : t(:site_meta_description)}
|
||||
%meta{property: "og:image", content: content_for?(:image) ? yield(:image) : ContentConfig.logo.url}
|
||||
%meta{property: "og:image", content: content_for?(:image) ? yield(:image) : ContentConfig.url_for(:logo)}
|
||||
- if !Rails.env.production? || @noindex_meta_tag
|
||||
%meta{name: "robots", content: "noindex"}
|
||||
%title= content_for?(:title) ? "#{yield(:title)} - #{t(:title)}".html_safe : "#{t(:welcome_to)} #{t(:title)}"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
%table{:bgcolor => "#f2f2f2"}
|
||||
%tr
|
||||
%td
|
||||
%img{src: ContentConfig.footer_logo.url, width: "144", height: "50"}/
|
||||
%img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/
|
||||
%td{:align => "right"}
|
||||
%h6.collapse
|
||||
= Spree::Config[:site_name]
|
||||
|
||||
56
app/views/layouts/pdf.html.haml
Normal file
56
app/views/layouts/pdf.html.haml
Normal file
@@ -0,0 +1,56 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{charset: 'utf-8'}
|
||||
-# Using wicked_pdf_stylesheet_pack_tag with a new pdf pack was not working when using
|
||||
-# WickedPdf.new.pdf_from_string cause the css file reference was not absolute
|
||||
-# So I ended up putting inline css here, so it's included for sure in the PDF
|
||||
:css
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
|
||||
color: #212529;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
th, td {
|
||||
padding: 7px 5px;
|
||||
vertical-align: middle;
|
||||
text-overflow: ellipsis;
|
||||
padding-top: 12px;
|
||||
}
|
||||
tr {
|
||||
border-bottom: 1px solid #e2e2e2;
|
||||
}
|
||||
thead {
|
||||
background-color: #f6f6f6;
|
||||
border-bottom: 1px solid grey;
|
||||
}
|
||||
.h1, .h2, .h3 {
|
||||
font-weight: bold;
|
||||
padding-top: 15px;
|
||||
}
|
||||
.h1 {
|
||||
font-size: 1.6rem;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.h2 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
.h3 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
.text-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
%body
|
||||
= yield
|
||||
@@ -96,7 +96,7 @@
|
||||
.row.legal
|
||||
.small-12.medium-3.medium-offset-2.columns.text-left
|
||||
%a{href: main_app.root_path}
|
||||
%img{src: ContentConfig.footer_logo.url, width: "220"}
|
||||
%img{src: ContentConfig.url_for(:footer_logo), width: "220"}
|
||||
.small-12.medium-5.columns.text-left
|
||||
%p.text-small
|
||||
= t '.footer_legal_call'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
%ul.nav-logo
|
||||
%li.ofn-logo
|
||||
%a{href: main_app.root_path}
|
||||
%img{src: ContentConfig.logo.url}
|
||||
%img{src: ContentConfig.url_for(:logo)}
|
||||
%li.powered-by
|
||||
%img{src: '/favicon.ico'}
|
||||
%span
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
%section.left
|
||||
.ofn-logo
|
||||
%a{href: main_app.root_path}
|
||||
%img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"}
|
||||
%img{src: ContentConfig.url_for(:logo_mobile), srcset: ContentConfig.url_for(:logo_mobile_svg), width: "75", height: "26"}
|
||||
|
||||
%section.right{"ng-cloak" => true}
|
||||
%span.cart-span{"ng-class" => "{ dirty: Cart.dirty || Cart.empty(), 'pure-dirty': Cart.dirty }"}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
%ul.off-canvas-list
|
||||
%li.ofn-logo
|
||||
%a{href: main_app.root_path}
|
||||
%img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"}
|
||||
%img{src: ContentConfig.url_for(:logo_mobile), srcset: ContentConfig.url_for(:logo_mobile_svg), width: "75", height: "26"}
|
||||
- [*1..7].each do |menu_number|
|
||||
- menu_name = "menu_#{menu_number}"
|
||||
- if ContentConfig[menu_name].present?
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
%distributor.details.row
|
||||
.small-12.medium-12.large-8.columns
|
||||
#distributor_title
|
||||
- if distributor.logo?
|
||||
%img.left{src: distributor.logo.url(:thumb)}
|
||||
- if distributor.logo.variable?
|
||||
= image_tag distributor.logo_url(:thumb), class: "left"
|
||||
= render DistributorTitleComponent.new(name: distributor.name)
|
||||
%location= distributor.address.city
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- if platform_terms_required? && distributor_terms_required?
|
||||
= f.check_box :accept_terms, { name: "accept_terms", checked: all_terms_and_conditions_already_accepted? }, 1, nil
|
||||
= f.label :accept_terms do
|
||||
= t('split_checkout.step3.all_terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'), tos_link: link_to_platform_terms)
|
||||
= t('split_checkout.step3.all_terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions, target: '_blank'), tos_link: link_to_platform_terms)
|
||||
- elsif platform_terms_required?
|
||||
= f.check_box :accept_terms, { name: "accept_terms", checked: platform_tos_already_accepted? }, 1, nil
|
||||
= f.label :accept_terms do
|
||||
@@ -11,7 +11,7 @@
|
||||
- elsif distributor_terms_required?
|
||||
= f.check_box :accept_terms, { name: "accept_terms", checked: terms_and_conditions_already_accepted? }, 1, nil
|
||||
= f.label :accept_terms do
|
||||
= t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions.url, target: '_blank'))
|
||||
= t('split_checkout.step3.terms_and_conditions.message_html', terms_and_conditions_link: link_to( t("split_checkout.step3.terms_and_conditions.link_text"), @order.distributor.terms_and_conditions, target: '_blank'))
|
||||
|
||||
= f.error_message_on :terms_and_conditions, standalone: true
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
.field.alpha.three.columns.align-center
|
||||
= f.label t('spree.thumbnail')
|
||||
%br/
|
||||
= link_to image_tag(@image.attachment.url(:small)), @image.attachment.url(:product)
|
||||
- # A Rails bug makes it necessary to call `main_app.url_for` here.
|
||||
- # https://github.com/rails/rails/issues/31325
|
||||
= link_to image_tag(main_app.url_for(@image.variant(:small))), main_app.url_for(@image.variant(:product))
|
||||
.nine.columns.omega
|
||||
= render partial: 'form', locals: { f: f }
|
||||
.clear
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
%td.no-border
|
||||
%span.handle
|
||||
%td
|
||||
= link_to image_tag(image.attachment.url(:mini)), image.attachment.url(:product)
|
||||
- # A Rails bug makes it necessary to call `main_app.url_for` here.
|
||||
- # https://github.com/rails/rails/issues/31325
|
||||
= link_to image_tag(main_app.url_for(image.variant(:mini))), main_app.url_for(image.variant(:product))
|
||||
%td= options_text_for(image)
|
||||
%td= image.alt
|
||||
%td.actions
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
%td{ :align => "left" }
|
||||
%h4
|
||||
= t :tax_invoice
|
||||
- if @order.distributor.display_invoice_logo? && @order.distributor.logo.present?
|
||||
- if @order.distributor.display_invoice_logo? && @order.distributor.logo.variable?
|
||||
%td{ :align => "right", rowspan: 2 }
|
||||
= wicked_pdf_image_tag @order.distributor.logo(:small), width: 150, height: 150
|
||||
= wicked_pdf_image_tag @order.distributor.logo.variant(resize_to_limit: [150, 150])
|
||||
%tr{ valign: "top" }
|
||||
%td{ :align => "left" }
|
||||
- if @order.distributor.business_address.blank?
|
||||
@@ -66,6 +66,12 @@
|
||||
%br
|
||||
- if @order.bill_address
|
||||
= @order.bill_address.address_part2
|
||||
- if @order.bill_address.phone.present?
|
||||
%br
|
||||
= @order.bill_address.phone
|
||||
- if @order&.customer&.email.present?
|
||||
%br
|
||||
= @order.customer.email
|
||||
|
||||
= render 'spree/admin/orders/invoice_table2'
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
%p.customer-names-tip
|
||||
= t(".customer_names_tip")
|
||||
@@ -1,4 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_types.each do |report_type|
|
||||
%li
|
||||
= link_to report_type[0], "#{customers_admin_reports_url}?report_type=#{report_type[1]}"
|
||||
@@ -1,9 +0,0 @@
|
||||
.row.date-range-filter
|
||||
= label_tag nil, t(:date_range)
|
||||
%br
|
||||
= label_tag nil, t(:start), :class => 'inline'
|
||||
= f.text_field :completed_at_gt, :class => 'datetimepicker datepicker-from'
|
||||
%span.range-divider
|
||||
%i.icon-arrow-right
|
||||
= f.text_field :completed_at_lt, :class => 'datetimepicker datepicker-to'
|
||||
= label_tag nil, t(:end), :class => 'inline'
|
||||
@@ -1,2 +0,0 @@
|
||||
- order_number = value
|
||||
= link_to order_number, edit_admin_order_url(order_number), class: 'edit-order'
|
||||
@@ -1,4 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_types.each do |report_type|
|
||||
%li
|
||||
= link_to report_type[0], "#{order_cycle_management_admin_reports_url}?report_type=#{report_type[1]}"
|
||||
@@ -1,5 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_types.each do |report_type|
|
||||
%li
|
||||
= link_to report_type[0], "#{orders_and_fulfillment_admin_reports_url}?report_type=#{report_type[1]}"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_subtypes("packing").each do |report_subtype|
|
||||
%li
|
||||
= link_to t("admin.reports.packing.#{report_subtype}_report"),
|
||||
main_app.admin_reports_url(report_type: 'packing', report_subtype: report_subtype)
|
||||
@@ -1,4 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_types.each do |report_type|
|
||||
%li
|
||||
= link_to report_type[0], "#{products_and_inventory_admin_reports_url}?report_type=#{report_type[1]}"
|
||||
@@ -1,4 +0,0 @@
|
||||
%ul{style: "margin-left: 12pt"}
|
||||
- report_types.each do |report_type|
|
||||
%li
|
||||
= link_to report_type[0], "#{sales_tax_admin_reports_url}?report_type=#{report_type[1]}"
|
||||
@@ -1,23 +0,0 @@
|
||||
- column_partials ||= {}
|
||||
- if render_content?
|
||||
%table.report__table{id: id}
|
||||
%thead
|
||||
%tr
|
||||
- @header.each do |heading|
|
||||
%th= heading
|
||||
%tbody
|
||||
- @table.each do |row|
|
||||
%tr
|
||||
- row.each_with_index do |cell_value, column_index|
|
||||
%td
|
||||
- partial = column_partials[column_index]
|
||||
- if partial
|
||||
= render partial, value: cell_value
|
||||
- else
|
||||
= cell_value
|
||||
- if @table.empty?
|
||||
%tr
|
||||
%td{colspan: @header.count}= t(:none)
|
||||
- else
|
||||
%p.report__message
|
||||
= t(".select_and_search", option: msg_option.upcase)
|
||||
@@ -1,32 +0,0 @@
|
||||
= form_tag spree.customers_admin_reports_url do |f|
|
||||
%br
|
||||
.row
|
||||
.four.columns.alpha
|
||||
= label_tag nil, t(:report_customers_distributor)
|
||||
= select_tag(:distributor_id,
|
||||
options_from_collection_for_select(@distributors, :id, :name, params[:distributor_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth"})
|
||||
|
||||
.four.columns
|
||||
= label_tag nil, t(:report_customers_supplier)
|
||||
= select_tag(:supplier_id,
|
||||
options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth"})
|
||||
|
||||
.six.columns
|
||||
= label_tag nil, t(:report_customers_cycle)
|
||||
= select_tag(:order_cycle_id,
|
||||
options_for_select(report_order_cycle_options(@order_cycles), params[:order_cycle_id]),
|
||||
{:include_blank => true, :class => "select2 fullwidth"})
|
||||
|
||||
= label_tag nil, t(:report_customers_type)
|
||||
= select_tag(:report_type, options_for_select(@report_types, @report_type))
|
||||
|
||||
%br
|
||||
%br
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, t(:report_customers_csv)
|
||||
%br
|
||||
= button t(:go)
|
||||
|
||||
= render "table", id: "listing_customers", msg_option: t(:go)
|
||||
@@ -1,14 +0,0 @@
|
||||
- content_for :page_title do
|
||||
= t(:listing_reports)
|
||||
|
||||
.columns.twelve
|
||||
%table.index
|
||||
%thead
|
||||
%tr
|
||||
%th= t(:name)
|
||||
%th= t(:description)
|
||||
%tbody
|
||||
- @reports.each do |key, value|
|
||||
%tr
|
||||
%td= link_to value[:name], value[:url]
|
||||
%td= value[:description]
|
||||
@@ -1,32 +0,0 @@
|
||||
= form_for @report.search, :url => spree.order_cycle_management_admin_reports_path do |f|
|
||||
= render 'date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_payment)
|
||||
.omega.fourteen.columns= select_tag(:payment_method_in, options_for_select(report_payment_method_options(@report.orders), params[:payment_method_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "#{t(:shipping_methods)}: "
|
||||
.omega.fourteen.columns= select_tag(:shipping_method_in, options_for_select(report_shipping_method_options(@report.orders), params[:shipping_method_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, "#{t(:report_type)}: "
|
||||
.omega.fourteen.columns= select_tag(:report_type, options_for_select(@report_types, @report_type))
|
||||
|
||||
.row
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, t(:report_customers_csv)
|
||||
|
||||
.row
|
||||
= button t(:search)
|
||||
|
||||
= render "table", id: "listing_ocm_orders", msg_option: t(:search)
|
||||
@@ -1,11 +0,0 @@
|
||||
= form_for @search, :url => spree.orders_and_distributors_admin_reports_path do |f|
|
||||
= render 'date_range_form', f: f
|
||||
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, t(:report_customers_csv)
|
||||
%br
|
||||
= button t(:search)
|
||||
|
||||
= render partial: "customer_names_message"
|
||||
|
||||
= render "table", id: "listing_orders", msg_option: t(:search)
|
||||
@@ -1,30 +0,0 @@
|
||||
= form_for @report.search, :url => spree.orders_and_fulfillment_admin_reports_path do |f|
|
||||
= render 'date_range_form', f: f
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_hubs)
|
||||
.omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_producers)
|
||||
.omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_customers_cycle)
|
||||
.omega.fourteen.columns
|
||||
= f.select(:order_cycle_id_in, report_order_cycle_options(@order_cycles), {selected: params.dig(:q, :order_cycle_id_in)}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.alpha.two.columns= label_tag nil, t(:report_type)
|
||||
.omega.fourteen.columns= select_tag(:report_type, options_for_select(@report_types, @report_type))
|
||||
|
||||
.row
|
||||
= check_box_tag :csv
|
||||
= label_tag :csv, t(:report_customers_csv)
|
||||
|
||||
.row
|
||||
= button t(:search)
|
||||
|
||||
= render partial: "customer_names_message"
|
||||
|
||||
= render "table", id: "listing_orders", msg_option: t(:search)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user