mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-28 06:15:17 +00:00
Adding configurable Shop Trial Length in business model
This commit is contained in:
@@ -18,8 +18,9 @@ class Admin::BusinessModelConfigurationController < Spree::Admin::BaseController
|
||||
|
||||
def load_settings
|
||||
@settings = OpenFoodNetwork::BusinessModelConfigurationValidator.new(params[:settings] || {
|
||||
shop_trial_length_days: Spree::Config[:shop_trial_length_days],
|
||||
account_invoices_monthly_fixed: Spree::Config[:account_invoices_monthly_fixed],
|
||||
account_invoices_monthly_rate: Spree::Config[:account_invoices_monthly_rate],
|
||||
account_invoiceaccount_invoices_monthly_rates_monthly_rate: Spree::Config[:account_invoices_monthly_rate],
|
||||
account_invoices_monthly_cap: Spree::Config[:account_invoices_monthly_cap],
|
||||
account_invoices_tax_rate: Spree::Config[:account_invoices_tax_rate]
|
||||
})
|
||||
|
||||
@@ -52,17 +52,17 @@ module EnterprisesHelper
|
||||
|
||||
def shop_trial_in_progress?(enterprise)
|
||||
!!enterprise.shop_trial_start_date &&
|
||||
(enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days > Time.zone.now) &&
|
||||
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days > Time.zone.now) &&
|
||||
%w(own any).include?(enterprise.sells)
|
||||
end
|
||||
|
||||
def shop_trial_expired?(enterprise)
|
||||
!!enterprise.shop_trial_start_date &&
|
||||
(enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days <= Time.zone.now) &&
|
||||
(enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days <= Time.zone.now) &&
|
||||
%w(own any).include?(enterprise.sells)
|
||||
end
|
||||
|
||||
def remaining_trial_days(enterprise)
|
||||
distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Enterprise::SHOP_TRIAL_LENGTH.days)
|
||||
distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class Enterprise < ActiveRecord::Base
|
||||
SELLS = %w(unspecified none own any)
|
||||
SHOP_TRIAL_LENGTH = 30
|
||||
ENTERPRISE_SEARCH_RADIUS = 100
|
||||
|
||||
preference :shopfront_message, :text, default: ""
|
||||
@@ -338,7 +337,7 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def shop_trial_expiry
|
||||
shop_trial_start_date.andand + Enterprise::SHOP_TRIAL_LENGTH.days
|
||||
shop_trial_start_date.andand + Spree::Config[:shop_trial_length_days].days
|
||||
end
|
||||
|
||||
def can_invoice?
|
||||
|
||||
@@ -20,7 +20,9 @@ Spree::AppConfiguration.class_eval do
|
||||
preference :account_invoices_monthly_rate, :decimal, default: 0
|
||||
preference :account_invoices_monthly_cap, :decimal, default: 0
|
||||
preference :account_invoices_tax_rate, :decimal, default: 0
|
||||
preference :shop_trial_length_days, :integer, default: 30
|
||||
|
||||
# Monitoring
|
||||
preference :last_job_queue_heartbeat_at, :string, default: nil
|
||||
|
||||
end
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
Adjust the amount that enterprises will be billed each month for use of the OFN.
|
||||
%br
|
||||
= form_for @settings, as: :settings, url: main_app.admin_business_model_configuration_path, :method => :put do |f|
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :shop_trial_length_days, t(:shop_trial_length)
|
||||
%span.icon-question-sign{'ofn-with-tip' => "The length of time (in days) that enterprises who are set up as shops can run as a trial period."}
|
||||
.two.columns.omega
|
||||
= f.number_field :shop_trial_length_days, min: 0.0, step: 1.0, class: "fullwidth", 'watch-value-as' => 'fixed'
|
||||
.row
|
||||
.three.columns.alpha
|
||||
= f.label :account_invoices_monthly_fixed, t(:fixed_monthly_charge)
|
||||
|
||||
Reference in New Issue
Block a user