# frozen_string_literal: true # helper for home module HomeHelper def change_ammount(ammount) HomeHelper.change_ammount(ammount) end def self.change_ammount(ammount) return '' if ammount.blank? ret = if ammount >= 1_000_000 amm = ammount / 1_000_000 rest = (ammount % 1_000_000) / 1_000 re1 = if rest.zero? amm else "#{amm}.#{rest}".to_f.to_s.tr('.', ',') end "#{re1} mln" else "#{ammount / 1_000} tys." end ret end def render_to_stringi(data, comp_sizes) action_view = ActionView::Base.new action_view.view_paths = ActionController::Base.view_paths action_view.class_eval do include ApplicationHelper end action_view.render template: 'home/show.pdf', layout: 'layouts/pdf.html', locals: { dotation: data, company_sizes: comp_sizes } end def render_to_pdf_all(data, comp_sizes) action_view = ActionView::Base.new action_view.view_paths = ActionController::Base.view_paths action_view.class_eval do include ApplicationHelper end action_view.render template: 'home/prepare_pdf.pdf', layout: 'layouts/pdf.html', locals: { dotations: data, company_sizes: comp_sizes } end def render_cover_header(data, comp_sizes) action_view = ActionView::Base.new action_view.view_paths = ActionController::Base.view_paths action_view.class_eval do include ApplicationHelper end action_view.render template: 'home/show.pdf', layout: 'layouts/pdf_header.html', locals: { dotation: data, company_sizes: comp_sizes } end def render_cover_footer(data, comp_sizes) action_view = ActionView::Base.new action_view.view_paths = ActionController::Base.view_paths action_view.class_eval do include ApplicationHelper end action_view.render template: 'home/show.pdf', layout: 'layouts/pdf_footer.html', locals: { dotation: data, company_sizes: comp_sizes } end end