From da55eb6d2764308eecf7ccf0c0f6a4d9f8485282 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 7 Sep 2016 11:13:05 +1000 Subject: [PATCH] Form for changing enterprise type specifies trial length --- app/helpers/admin/business_model_configuration_helper.rb | 4 ++++ app/views/admin/enterprises/_change_type_form.html.haml | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/admin/business_model_configuration_helper.rb b/app/helpers/admin/business_model_configuration_helper.rb index b1a2f1ac12..de17761924 100644 --- a/app/helpers/admin/business_model_configuration_helper.rb +++ b/app/helpers/admin/business_model_configuration_helper.rb @@ -16,6 +16,10 @@ module Admin private + def free_use? + Spree::Config[:account_invoices_monthly_fixed] == 0 && Spree::Config[:account_invoices_monthly_rate] == 0 + end + def fixed_description fixed_amount = Spree::Money.new(Spree::Config[:account_invoices_monthly_fixed], {currency: Spree::Config[:currency]} ).rounded monthly_bill_includes_fixed? ? "#{fixed_amount}" : "" diff --git a/app/views/admin/enterprises/_change_type_form.html.haml b/app/views/admin/enterprises/_change_type_form.html.haml index 6474af1344..dd86311a9b 100644 --- a/app/views/admin/enterprises/_change_type_form.html.haml +++ b/app/views/admin/enterprises/_change_type_form.html.haml @@ -76,8 +76,12 @@ %span.error{ ng: { show: "(change_type.sells.$error.required || change_type.sells.$error.pattern) && submitted" } } Please choose one of the options above. - if @enterprise.sells == 'unspecified' && @enterprise.shop_trial_start_date.nil? - %input.button.big{ type: 'submit', value: 'Start 30 Day Trial', ng: { click: "submit(change_type)", show: "sells=='own' || sells=='any'" } } - %input.button.big{ type: 'submit', value: 'Select and continue', ng: { click: "submit(change_type)", hide: "sells=='own' || sells=='any'" } } + -if free_use? + %input.button.big{ type: 'submit', value: 'Select and continue', ng: { click: "submit(change_type)" } } + - else + - trial_length = Spree::Config[:shop_trial_length_days] + %input.button.big{ type: 'submit', value: "Start #{trial_length}-Day Shop Trial", ng: { click: "submit(change_type)", show: "sells=='own' || sells=='any'" } } + %input.button.big{ type: 'submit', value: 'Select and continue', ng: { click: "submit(change_type)", hide: "sells=='own' || sells=='any'" } } - elsif @enterprise.sells == 'unspecified' %input.button.big{ type: 'submit', value: 'Select and continue', ng: { click: "submit(change_type)" } } - else