improve receipt/details reports and implement number formatting

1) eager load reports for receipt/details
2) introduce number_format lookups to replace print_settings for number formatting
3) implement NumberFormattable concern, reference number_format lookups or print_settings if not exist, to get number format settings and number formatting
4) replace rails NumberHelper.number_with_precision with NumberFormattable.number_format hopefully to reduce overhead, formatting numbers for huge lists of data
This commit is contained in:
Thein Lin Kyaw
2019-11-25 23:17:53 +06:30
parent a36e170d94
commit 3c1cc737b5
71 changed files with 1338 additions and 1898 deletions

View File

@@ -1,11 +1,11 @@
class BaseReportController < ActionController::Base
include LoginVerification
layout "application"
layout "application"
before_action :check_user
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
#before_action :check_installation
protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
@@ -29,7 +29,7 @@ class BaseReportController < ActionController::Base
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
to = params[:to]
day_ref = Time.now.utc.getlocal
if from.present? && to.present?
@@ -39,10 +39,10 @@ class BaseReportController < ActionController::Base
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else
else
case period.to_i
when PERIOD["today"]
@@ -77,10 +77,10 @@ class BaseReportController < ActionController::Base
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
end
return from, to
return from, to
end
def check_user