Class: OnboardController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OnboardController
- Defined in:
- app/controllers/onboard_controller.rb
Instance Method Summary collapse
- #accept_agreement ⇒ Object
- #agreement_form ⇒ Object
- #company_details_form ⇒ Object
- #create ⇒ Object
- #steps ⇒ Object
Methods included from AuthentificationHelper
#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token
Instance Method Details
#accept_agreement ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/onboard_controller.rb', line 71 def accept_agreement raise I18n.t('messages.registration_disabled') unless @app_mode.can_register? current_company.agree_to_agreement( app_mode: @app_mode, erp_user_id: current_user.erp_user_id, ip_address: request.remote_ip ) redirect_to_onboarding_or_home_path rescue ActiveRecord::RecordInvalid => e render json: { errors: e.record.errors, redirect_to: '/onboard' }, status: :bad_request end |
#agreement_form ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/onboard_controller.rb', line 59 def agreement_form onboarding_path = current_company.onboarding_path(app_mode: @app_mode) company_details_path = @app_mode.agreement_path redirect_to_onboarding_path if onboarding_path != company_details_path render json: { data: { agreement_path: @app_mode.agreement_file_path } } end |
#company_details_form ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/onboard_controller.rb', line 29 def company_details_form onboarding_path = current_company.onboarding_path(app_mode: @app_mode) company_details_path = @app_mode.company_details_path redirect_to_onboarding_path if onboarding_path != company_details_path render json: { payroll_frequencies: TypesMaster.payroll_frequencies.as_json( methods: %i[type_description] ), default_values: { bill_to_email: current_company.email, bill_to_phone_no: current_company.phone_no, bill_to_fax_no: current_company.fax_no, bill_to_address_line1: current_company.address_line1, bill_to_address_line2: current_company.address_line2, bill_to_city: current_company.city, bill_to_province: current_company.province, bill_to_postal_code: current_company.postal_code, employer_cnsst_percentage: current_company.employer_cnsst_percentage || 0, employer_cnt_percentage: current_company.employer_cnt_percentage || 0, first_payroll_period_start_date: Date.current, payroll_year: Date.current.year, country: Country.canad_option, tenant_name: current_company.company_name_e || current_user.name_from_email, # default_language: Language::FRENCH, # let the default language be the one of the session payroll_frequency_option: TypesMaster.by_weekly_payroll_frequency } } end |
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/onboard_controller.rb', line 8 def create OnboardingService.new( current_user: current_user, current_company: current_company, current_tenant: current_tenant, tenant_params: tenant_params, company_params: company_params, ship_name: ship_name, payroll_periods_params: payroll_periods_params, app_mode: @app_mode ).call redirect_to_onboarding_or_home_path rescue ActiveRecord::RecordInvalid => e render json: { errors: e.record.errors, redirect_to: @app_mode.company_details_path, message: e.record.errors..join(', ') }, status: :bad_request end |
#steps ⇒ Object
88 89 90 91 92 |
# File 'app/controllers/onboard_controller.rb', line 88 def steps render json: { data: current_company.onboarding_steps } end |