diff --git a/app/serializers/api/admin/enterprise_serializer.rb b/app/serializers/api/admin/enterprise_serializer.rb index 7c29b41e70..eef391286f 100644 --- a/app/serializers/api/admin/enterprise_serializer.rb +++ b/app/serializers/api/admin/enterprise_serializer.rb @@ -9,6 +9,7 @@ module Api :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_producer_order, :preferred_shopfront_order_cycle_order, :show_customer_names_to_suppliers, + :show_customer_contacts_to_suppliers, :preferred_shopfront_product_sorting_method, :owner, :contact, :users, :tag_groups, :default_tag_group, :require_login, :allow_guest_orders, :allow_order_changes, :logo, :promo_image, :terms_and_conditions, diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 1dd5b5a838..c25c82a585 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -33,7 +33,8 @@ module PermittedAttributes :preferred_product_selection_from_inventory_only, :preferred_shopfront_message, :preferred_shopfront_closed_message, :preferred_shopfront_taxon_order, :preferred_shopfront_producer_order, :preferred_shopfront_order_cycle_order, - :show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, + :show_customer_names_to_suppliers, :show_customer_contacts_to_suppliers, + :preferred_shopfront_product_sorting_method, :preferred_invoice_order_by_supplier, :preferred_product_low_stock_display, :hide_ofn_navigation, :white_label_logo, :white_label_logo_link, diff --git a/app/views/admin/enterprises/form/_shop_preferences.html.haml b/app/views/admin/enterprises/form/_shop_preferences.html.haml index 7a650382cb..33f4a5f792 100644 --- a/app/views/admin/enterprises/form/_shop_preferences.html.haml +++ b/app/views/admin/enterprises/form/_shop_preferences.html.haml @@ -111,3 +111,15 @@ .five.columns.omega = f.radio_button :show_customer_names_to_suppliers, false = f.label :show_customer_names_to_suppliers, t('.customer_names_false'), value: :false + +.row + .three.columns.alpha + %label= t '.customer_contacts_in_reports' + %div{'ofn-with-tip' => t('.customer_contacts_tip')} + %a= t 'admin.whats_this' + .three.columns + = f.radio_button :show_customer_contacts_to_suppliers, true + = f.label :show_customer_contacts_to_suppliers, t('.customer_contacts_true'), value: :true + .five.columns.omega + = f.radio_button :show_customer_contacts_to_suppliers, false + = f.label :show_customer_contacts_to_suppliers, t('.customer_contacts_false'), value: :false diff --git a/config/locales/en.yml b/config/locales/en.yml index bc312c91ba..ee18a4014e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1350,6 +1350,10 @@ en: customer_names_tip: "Enable your suppliers to see your customers names in reports" customer_names_false: "Disabled" customer_names_true: "Enabled" + customer_contacts_in_reports: "Customer contact details in reports" + customer_contacts_tip: "Enable your suppliers to see your customer email and phone numbers in reports" + customer_contacts_false: "Disabled" + customer_contacts_true: "Enabled" shopfront_message: "Shopfront Message" shopfront_message_placeholder: > An optional message to welcome customers and explain how to shop with you. If text is entered here it will be displayed in a home tab when customers first arrive at your shopfront. diff --git a/db/migrate/20250304234657_add_show_customer_contacts_to_suppliers_to_enterprises.rb b/db/migrate/20250304234657_add_show_customer_contacts_to_suppliers_to_enterprises.rb new file mode 100644 index 0000000000..d0d6e5931b --- /dev/null +++ b/db/migrate/20250304234657_add_show_customer_contacts_to_suppliers_to_enterprises.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddShowCustomerContactsToSuppliersToEnterprises < ActiveRecord::Migration[7.0] + def change + add_column :enterprises, :show_customer_contacts_to_suppliers, :boolean, default: false, + null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index a20327a48a..69728aa208 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2025_01_28_031518) do +ActiveRecord::Schema[7.0].define(version: 2025_03_04_234657) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -230,6 +230,8 @@ ActiveRecord::Schema[7.0].define(version: 2025_01_28_031518) do t.text "white_label_logo_link" t.boolean "hide_groups_tab", default: false t.string "external_billing_id", limit: 128 + t.boolean "enable_producers_to_edit_orders", default: false, null: false + t.boolean "show_customer_contacts_to_suppliers", default: false, null: false t.index ["address_id"], name: "index_enterprises_on_address_id" t.index ["is_primary_producer", "sells"], name: "index_enterprises_on_is_primary_producer_and_sells" t.index ["name"], name: "index_enterprises_on_name", unique: true diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 86d007a46b..acaf29ecd4 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -100,6 +100,10 @@ RSpec.describe ' expect(page).not_to have_checked_field "enterprise_require_login_false" # expect(page).to have_checked_field "enterprise_enable_subscriptions_false" + choose('enterprise[show_customer_contacts_to_suppliers]', option: true) + + # See also "setting ordering preferences" tested separately. + scroll_to(:bottom) accept_alert do scroll_to(:bottom) @@ -216,6 +220,7 @@ RSpec.describe ' "enterprise_preferred_product_selection_from_inventory_only_false" ) + # Save changes click_button 'Update' expect(flash_message).to eq('Enterprise "Eaterprises" has been successfully updated!') @@ -246,6 +251,7 @@ RSpec.describe ' ) expect(page).to have_checked_field "enterprise_require_login_true" expect(page).to have_checked_field "enterprise_enable_subscriptions_true" + expect(page).to have_checked_field 'enterprise[show_customer_contacts_to_suppliers]', with: true # Back navigation loads the tab content page.execute_script('window.history.back()')