Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01
This commit is contained in:
21
Dockerfile
21
Dockerfile
@@ -1,15 +1,20 @@
|
||||
FROM ruby:2.4.1
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
|
||||
FROM ruby:2.5
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmariadb-dev libcups2-dev libpq-dev nodejs tzdata
|
||||
RUN mkdir /sxrestaurant
|
||||
RUN mkdir -p /sxrestaurant/tmp/puma
|
||||
ENV RAILS_ENV staging
|
||||
ENV RACK_ENV staging
|
||||
ENV RAILS_ENV production
|
||||
ENV RACK_ENV production
|
||||
WORKDIR /sxrestaurant
|
||||
COPY Gemfile /sxrestaurant/Gemfile
|
||||
COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
RUN bundle install --without development test
|
||||
#RUN gem install bundler
|
||||
#COPY Gemfile /sxrestaurant/Gemfile
|
||||
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
#RUN bundle install --without development test
|
||||
RUN echo "Asia/Rangoon" > /etc/timezone
|
||||
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN date
|
||||
COPY . /sxrestaurant
|
||||
RUN gem install bundler
|
||||
#RUN bundle update --bundler
|
||||
RUN bundle install --without development test
|
||||
RUN bundle exec rake assets:precompile
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
|
||||
19
Dockerfile.backup
Normal file
19
Dockerfile.backup
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM ruby:2.5
|
||||
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
|
||||
RUN mkdir /sxrestaurant
|
||||
RUN mkdir -p /sxrestaurant/tmp/puma
|
||||
ENV RAILS_ENV production
|
||||
ENV RACK_ENV production
|
||||
WORKDIR /sxrestaurant
|
||||
#RUN gem install bundler
|
||||
#COPY Gemfile /sxrestaurant/Gemfile
|
||||
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock
|
||||
#RUN bundle install --without development test
|
||||
RUN echo "Asia/Rangoon" > /etc/timezone
|
||||
RUN dpkg-reconfigure -f noninteractive tzdata
|
||||
COPY . /sxrestaurant
|
||||
RUN gem install bundler
|
||||
#RUN bundle update --bundler
|
||||
RUN bundle install --without development test
|
||||
RUN bundle exec rake assets:precompile
|
||||
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
|
||||
4
Gemfile
4
Gemfile
@@ -1,5 +1,8 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
ruby '2.4.1'
|
||||
#ruby '2.5.7'
|
||||
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||
"https://github.com/#{repo_name}.git"
|
||||
@@ -45,6 +48,7 @@ gem 'jquery-fileupload-rails', '~> 0.4.7'
|
||||
|
||||
#Report and Printing gems
|
||||
#gem 'cups' #remove for cloud installation
|
||||
gem 'cups', '~>0.0.7'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
gem 'prawn-qrcode'
|
||||
|
||||
@@ -80,7 +80,7 @@ GEM
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
chartkick (3.2.1)
|
||||
chartkick (3.2.2)
|
||||
chronic (0.10.2)
|
||||
chunky_png (1.3.11)
|
||||
coffee-rails (4.2.2)
|
||||
@@ -93,6 +93,7 @@ GEM
|
||||
concurrent-ruby (1.1.5)
|
||||
connection_pool (2.2.2)
|
||||
crass (1.0.5)
|
||||
cups (0.0.7)
|
||||
database_cleaner (1.7.0)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.9.0)
|
||||
@@ -328,6 +329,7 @@ DEPENDENCIES
|
||||
carrierwave (~> 1.0)
|
||||
chartkick
|
||||
coffee-rails (~> 4.2)
|
||||
cups (~> 0.0.7)
|
||||
database_cleaner
|
||||
factory_girl_rails (~> 4.0)
|
||||
faker
|
||||
@@ -372,5 +374,10 @@ DEPENDENCIES
|
||||
web-console (>= 3.3.0)
|
||||
whenever
|
||||
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
|
||||
12
README.md
12
README.md
@@ -279,6 +279,15 @@ For Food Court Settings On/Off
|
||||
** '0' means can not use food court and '1' means can use food court **
|
||||
=> settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' }
|
||||
|
||||
For Number Formats
|
||||
Precision
|
||||
=> settings/lookups => { lookup_type: number_format, name: precision, value: {0..2} }
|
||||
Delimiter
|
||||
=> settings/lookups => { lookup_type: number_format, name: delimiter, value: { ',', '\u0020', '', ... }
|
||||
Strip insignificant zeros
|
||||
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
|
||||
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
|
||||
|
||||
/* Customer Types in lookups */
|
||||
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
|
||||
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
|
||||
@@ -299,6 +308,9 @@ settings/lookups => {type:display_type, name: Display Type, value: 2}
|
||||
For show total before tax in receipt bill
|
||||
settings/lookups => {type:show_total_before_tax, name:Show Total Before Tax, value: {0 or 1}}
|
||||
|
||||
For Using Staff Meal
|
||||
settings/lookups => { type:customer_type, name: Staff, value:Staff }
|
||||
|
||||
* ToDo list
|
||||
|
||||
1. Migration
|
||||
|
||||
@@ -629,7 +629,7 @@ $(function() {
|
||||
status = "selected-attribute";
|
||||
}
|
||||
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||
disabled = "disabled";
|
||||
// disabled = "disabled";
|
||||
}
|
||||
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
# include TokenVerification
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
@@ -23,25 +24,25 @@ class Api::ApiController < ActionController::API
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
# if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def website_connection(license)
|
||||
# def website_connection(license)
|
||||
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
# :username => license.dbusername, :password => license.dbpassword)
|
||||
# end
|
||||
@@ -55,8 +56,8 @@ class Api::ApiController < ActionController::API
|
||||
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
# end
|
||||
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
|
||||
# if (@license.detail_with_local_cache(lookup) == true)
|
||||
# return @license
|
||||
|
||||
@@ -40,7 +40,7 @@ class Api::AuthenticateController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "This employee is not active!"
|
||||
# render json: JSON.generate({:status => false, :error_message => "This employee is not active!"})
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "Bad Emp_ID or Password!"
|
||||
|
||||
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
require "net/http"
|
||||
class Api::LoaderService::LoadDataController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def get_sale_data_rage
|
||||
load_time_start = params[:load_time]
|
||||
load_time_end = params[:load_time_end]
|
||||
unless load_time_start.nil? || load_time_end.nil?
|
||||
@sale_data = Sale.get_load_sale_range(load_time_start.to_datetime,load_time_end.to_datetime)
|
||||
if !@sale_data.empty?
|
||||
@out = {general_status: true, data: @sale_data}
|
||||
else
|
||||
@out = {general_status: false, data: "Data is empty."}
|
||||
end
|
||||
else
|
||||
@out = {general_status: false, data: "load_time is missing."}
|
||||
end
|
||||
render :json => @out
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk Start
|
||||
|
||||
# Detail Sale
|
||||
def get_detail_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data[:transaction_date].to_s
|
||||
detail_sale_data = SaleItem.get_detail_sale_data(transaction_date)
|
||||
json = detail_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless detail_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => detail_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json {render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Tender sale
|
||||
def get_tender_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
tender_sale_data = Sale.get_tender_sale_data(transaction_date)
|
||||
json = tender_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless tender_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => tender_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Daily_Sale summary
|
||||
def get_daily_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
daily_sale_data = Sale.get_daily_sale_data(transaction_date)
|
||||
unless daily_sale_data.empty?
|
||||
out = { :status => "success", :data => daily_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Check Sale Data
|
||||
def get_check_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
check_sale_data = Sale.get_check_sale_data(transaction_date)
|
||||
json = check_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless check_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => check_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk End
|
||||
end
|
||||
@@ -8,7 +8,7 @@ class Api::VoidController < Api::ApiController
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
@@ -25,18 +25,17 @@ class Api::VoidController < Api::ApiController
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
sale.rounding_adjustment = 0.0
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_login_employee.name, current_login_employee.name,nil,"SALEVOID" )
|
||||
render json: JSON.generate({:status => true, :message => "Void successful."})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "There is no sale for '#{params[:sale_id]}'!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include LoginVerification
|
||||
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
@@ -17,7 +17,5 @@ class ApplicationController < ActionController::Base
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class BaseOrigamiController < ActionController::Base
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_token
|
||||
|
||||
@@ -15,16 +15,16 @@ class BaseOrigamiController < ActionController::Base
|
||||
redirect_to origami_dashboard_path
|
||||
end
|
||||
|
||||
def check_user
|
||||
if check_mobile
|
||||
def check_user
|
||||
if check_mobile
|
||||
if current_user.nil?
|
||||
return render status: 401, json: {
|
||||
message: "User using other device!"
|
||||
message: "User using other device!"
|
||||
}.to_json
|
||||
end
|
||||
else
|
||||
else
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -41,13 +41,13 @@ class BaseOrigamiController < ActionController::Base
|
||||
#check webview
|
||||
def check_mobile
|
||||
status = false
|
||||
authenticate_with_http_token do |token, options|
|
||||
authenticate_with_http_token do |token, options|
|
||||
if token
|
||||
session[:webview] = true
|
||||
session[:session_token] = token
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
|
||||
status = true
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -26,61 +26,51 @@ class BaseReportController < ActionController::Base
|
||||
}
|
||||
|
||||
def get_date_range_from_params
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
day_ref = Time.now.utc.getlocal
|
||||
period_type = params[:period_type]
|
||||
period = params[:period]
|
||||
|
||||
if from.present? && to.present?
|
||||
if params[:from].present? && params[:to].present?
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to])
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
from = Time.now
|
||||
to = Time.now
|
||||
when PERIOD["yesterday"]
|
||||
from = 1.day.ago
|
||||
to = 1.day.ago
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week
|
||||
to = Time.now
|
||||
when PERIOD["last_week"]
|
||||
from = 1.week.ago.beginning_of_week
|
||||
to = 1.week.ago.end_of_week
|
||||
when PERIOD["last_7"]
|
||||
from = 7.day.ago
|
||||
to = Time.now
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month
|
||||
to = Time.now
|
||||
when PERIOD["last_month"]
|
||||
from = 1.month.ago.beginning_of_month
|
||||
to = 1.month.ago.end_of_month
|
||||
when PERIOD["last_30"]
|
||||
from = 30.day.ago
|
||||
to = Time.now
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year
|
||||
to = Time.now
|
||||
when PERIOD["last_year"]
|
||||
from = 1.year.ago.beginning_of_year
|
||||
to = 1.year.ago.end_of_year
|
||||
end
|
||||
end
|
||||
|
||||
f_date = DateTime.parse(from)
|
||||
t_date = DateTime.parse(to)
|
||||
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
|
||||
|
||||
else
|
||||
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
|
||||
from = day_ref.beginning_of_day.utc
|
||||
to = day_ref.end_of_day.utc
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
from = (day_ref - 1.day).beginning_of_day.utc
|
||||
to = (day_ref - 1.day).end_of_day.utc
|
||||
|
||||
when PERIOD["this_week"]
|
||||
from = Time.now.beginning_of_week.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_week"]
|
||||
from = (day_ref - 7.day).beginning_of_week.utc
|
||||
to = (day_ref - 7.day).end_of_week.utc
|
||||
when PERIOD["last_7"]
|
||||
from = (day_ref - 7.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_month"]
|
||||
from = Time.now.beginning_of_month.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_month"]
|
||||
from = (day_ref - 1.month).beginning_of_month.utc
|
||||
to = (day_ref - 1.month).end_of_month.utc
|
||||
when PERIOD["last_30"]
|
||||
from = (day_ref - 30.day).utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["this_year"]
|
||||
from = Time.now.beginning_of_year.utc
|
||||
to = Time.now.utc
|
||||
when PERIOD["last_year"]
|
||||
from = (day_ref - 1.year).beginning_of_year.utc
|
||||
to = (day_ref - 1.year).end_of_year.utc
|
||||
end
|
||||
end
|
||||
|
||||
return from, to
|
||||
from = from.beginning_of_day
|
||||
to = to.end_of_day
|
||||
|
||||
return from, to
|
||||
end
|
||||
|
||||
def check_user
|
||||
|
||||
68
app/controllers/concerns/number_formattable.rb
Normal file
68
app/controllers/concerns/number_formattable.rb
Normal file
@@ -0,0 +1,68 @@
|
||||
module NumberFormattable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def precision
|
||||
return @precision if defined? @precision
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
|
||||
end
|
||||
if @precision.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
if @print_settings
|
||||
@precision = @print_settings.precision.to_i
|
||||
else
|
||||
@precision = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def delimiter
|
||||
return @delimiter if defined? @delimiter
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
|
||||
end
|
||||
if @delimiter.nil?
|
||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
||||
if @print_settings && @print_settings.delimiter
|
||||
@delimiter = ","
|
||||
else
|
||||
@delimiter = ","
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def strip_insignificant_zeros
|
||||
return @strip_insignificant_zeros if defined? @strip_insignificant_zeros
|
||||
@number_formats = Lookup.number_formats if !defined? @number_formats
|
||||
if @number_formats
|
||||
@strip_insignificant_zeros = @number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}.value.in? ['1', 't', 'true', 'on', 'y', 'yes'] rescue false
|
||||
end
|
||||
end
|
||||
|
||||
def number_format(number, options = {})
|
||||
options[:precision] = options[:precision] || precision
|
||||
# options[:delimiter] = options[:delimiter] || delimiter
|
||||
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
|
||||
|
||||
number = number.to_f.round(options[:precision])
|
||||
|
||||
if options[:precision] > 0
|
||||
if options[:strip_insignificant_zeros]
|
||||
formatted = "%.12g" % number
|
||||
else
|
||||
formatted = "%.#{options[:precision]}f" % number
|
||||
end
|
||||
else
|
||||
formatted = number.to_i.to_s
|
||||
end
|
||||
|
||||
if options[:delimiter] && !options[:delimiter].empty?
|
||||
formatted = formatted.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, "\\1#{options[:delimiter]}")
|
||||
end
|
||||
|
||||
return formatted
|
||||
end
|
||||
|
||||
end
|
||||
@@ -21,7 +21,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||
# search account no from paypar
|
||||
if type == "card"
|
||||
|
||||
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if !@crm_customers.present?
|
||||
if response["status"] == true
|
||||
@@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
else
|
||||
flash[:member_error]="Need to press sync button "
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -95,7 +95,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||
@create_flag = false
|
||||
end
|
||||
@@ -135,7 +135,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
params[:type] = nil
|
||||
params[:customer_id] = params[:id]
|
||||
@credit_sales = SalePayment.get_credit_sales(params)
|
||||
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
@response = Customer.get_membership_transactions(@customer)
|
||||
@@ -158,8 +158,9 @@ class Crm::CustomersController < BaseCrmController
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
|
||||
def sync
|
||||
@customer = Customer.find(params[:id])
|
||||
@customer = Customer.find(params[:id])
|
||||
respond_to do |format|
|
||||
name = @customer.name
|
||||
phone = @customer.contact_no
|
||||
@@ -169,31 +170,21 @@ class Crm::CustomersController < BaseCrmController
|
||||
nrc = @customer.nrc_no
|
||||
card_no = @customer.card_no
|
||||
paypar_account_no = @customer.paypar_account_no
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
if !id.present? && !member_group_id.nil?
|
||||
id = @customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
# if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
@@ -221,7 +212,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
Rails.logger.debug "--------Sync Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
@@ -247,14 +238,14 @@ class Crm::CustomersController < BaseCrmController
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@checked_contact = Customer.find_by_contact_no(customer_params[:contact_no])
|
||||
if @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
@@ -272,7 +263,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
nrc = customer_params[:nrc_no]
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if member_group_id.present?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -282,7 +273,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
@@ -333,7 +324,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
@@ -399,7 +390,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# PATCH/PUT /crm/customers/1
|
||||
# PATCH/PUT /crm/customers/1.json
|
||||
def update
|
||||
# Remove "" default first
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@checked_contact = nil
|
||||
@existed_contact = Customer.find_by_customer_id_and_contact_no(customer_params[:id], customer_params[:contact_no])
|
||||
@@ -409,7 +400,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
if !@existed_contact.nil? || @checked_contact.nil?
|
||||
respond_to do |format|
|
||||
if @crm_customer.update(customer_params)
|
||||
# update tax profile
|
||||
# update tax profile
|
||||
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
@@ -420,7 +411,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
card_no = customer_params[:card_no]
|
||||
paypar_account_no = customer_params[:paypar_account_no]
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = params[:member_group_id]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -430,7 +421,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
@@ -471,7 +462,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
Rails.logger.debug "--------Update Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
@@ -496,7 +487,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
@@ -601,7 +592,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
flash[:member_notice]='Membership was successfully updated'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -617,6 +608,5 @@ class Crm::CustomersController < BaseCrmController
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -89,37 +89,28 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
@from, @to = get_date_range_from_params
|
||||
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
|
||||
@sales = Sale.receipt_date_between(@from, @to).completed
|
||||
|
||||
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@orders = @orders.where(shift_sale_id: shift.id)
|
||||
@sales = @sales.where(shift_sale_id: shift.id)
|
||||
end
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top").sum('i.qty')
|
||||
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom").sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
|
||||
|
||||
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
|
||||
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
|
||||
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><'
|
||||
logger.debug @hourly_sales.to_json
|
||||
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
|
||||
logger.debug @hourly_sales.to_json
|
||||
employee_sales = Sale.employee_sales(current_user,@from,@to)
|
||||
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
|
||||
@employee_sales = []
|
||||
if !employee_sales.nil?
|
||||
@@ -132,44 +123,41 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)
|
||||
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
|
||||
|
||||
@total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||
@total_credit = Sale.credit_payment(current_user,@from,@to)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
|
||||
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_order = Sale.total_order(current_user,@from,@to)
|
||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today,current_user,@from,@to,@from_time,@to_time)
|
||||
if !acc.nil?
|
||||
acc = Sale.account_data(account.account_id,current_user,@from,@to)
|
||||
if !acc.nil? && acc.cnt_acc > 0
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@top_items = Sale.top_items(current_user,@from,@to)
|
||||
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@@ -231,23 +219,18 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
# f_date = DateTime.parse(from)
|
||||
# t_date = DateTime.parse(to)
|
||||
# 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
|
||||
|
||||
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
|
||||
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
|
||||
if params[:from].present? && params[:to].present?
|
||||
if params[:from_time].present? && params[:to_time].present?
|
||||
from = Time.parse("#{params[:from]} #{params[:from_time]}")
|
||||
to = Time.parse("#{params[:to]} #{params[:to_time]}")
|
||||
else
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to]).end_of_day
|
||||
end
|
||||
|
||||
return from, to, from_time, to_time
|
||||
else
|
||||
from = Time.now.beginning_of_day
|
||||
to = Time.now.end_of_day
|
||||
end
|
||||
return from, to
|
||||
end
|
||||
end
|
||||
|
||||
@@ -305,7 +305,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
|
||||
@@ -48,44 +48,44 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
def add_customer
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
@page = params[:dir_page]
|
||||
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
@dining_facility = nil
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||
@booking = Booking.find(@booking_order.booking_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
@dining_facility = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
filter = params[:filter]
|
||||
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id") #.page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
@crm_customers = Customer.search(filter)
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
|
||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
||||
.order("group_type ASC,order_by ASC")
|
||||
@@ -100,7 +100,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
lookup_customer = Lookup.collection_of('customer_settings')
|
||||
if !lookup_customer.empty?
|
||||
lookup_customer.each do |create_setting|
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[0].downcase == "create"
|
||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||
@create_flag = false
|
||||
end
|
||||
@@ -154,13 +154,13 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
end
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def send_account
|
||||
amount = params[:amount]
|
||||
account_no = params[:account_no]
|
||||
|
||||
@@ -2,46 +2,41 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user)
|
||||
@total_payment_methods = Sale.total_payment_methods(current_user)
|
||||
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale('card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@total_payment_methods.each do |payment|
|
||||
pay = Sale.payment_sale(payment.payment_method, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
else
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@summ_sale = Sale.summary_sale_receipt(current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user)
|
||||
@total_accounts = Sale.total_account(today,current_user)
|
||||
@total_order = Sale.total_order(current_user)
|
||||
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today,current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
|
||||
else
|
||||
@account_data = nil
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user)
|
||||
@top_items = Sale.top_items(current_user)
|
||||
@total_foc_items = Sale.total_foc_items(current_user)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@@ -104,12 +99,14 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
@menus = Menu.active.all
|
||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params)
|
||||
if !credit_sales.nil?
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
result = {:status=> false, :message=>"There is no record." }
|
||||
|
||||
@@ -7,9 +7,9 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
sale_id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -32,7 +32,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
overall_discount = params[:overall_discount]
|
||||
sub_total = params[:sub_total]
|
||||
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
@@ -44,26 +43,29 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
# sale.save
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
# sale.save
|
||||
if discount_items.length > 0
|
||||
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
|
||||
|
||||
sale_item = SaleItem.new
|
||||
|
||||
if !origin_sale_item.nil?
|
||||
menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
|
||||
if !menu_category.nil?
|
||||
sale_item.menu_category_code = menu_category.code
|
||||
sale_item.menu_category_name = menu_category.name
|
||||
end
|
||||
end
|
||||
# if !origin_sale_item.nil?
|
||||
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
|
||||
# if !menu_category.nil?
|
||||
# sale_item.menu_category_code = menu_category.code
|
||||
# sale_item.menu_category_name = menu_category.name
|
||||
# end
|
||||
# end
|
||||
|
||||
sale_item.menu_category_code = origin_sale_item.menu_category_code
|
||||
sale_item.menu_category_name = origin_sale_item.menu_category_name
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
@@ -73,7 +75,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_item.status = "Discount"
|
||||
|
||||
sale_item.qty = -1
|
||||
sale_item.unit_price = di["price"].to_f * (-1)
|
||||
sale_item.unit_price = di["price"].to_f * -1
|
||||
sale_item.taxable_price = di["price"]
|
||||
sale_item.is_taxable = 1
|
||||
sale_item.account_id = origin_sale_item.account_id
|
||||
@@ -83,11 +85,11 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
action_by = current_user.name
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
if overall_discount.to_f > 0
|
||||
@@ -97,24 +99,24 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
else
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
|
||||
end
|
||||
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
|
||||
if !table.nil?
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Success" }
|
||||
end
|
||||
else
|
||||
else
|
||||
if !table.nil?
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
@@ -131,45 +133,45 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
|
||||
action_by = current_user.name
|
||||
if table.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" )
|
||||
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
else
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
@@ -180,29 +182,29 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
order_source = params[:type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
|
||||
sale = Sale.find(sale_id)
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
table_type = table.type
|
||||
table_type = table.type
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
table_type = nil
|
||||
end
|
||||
end
|
||||
|
||||
discount_items = []
|
||||
discount_items = []
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.status == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
discount_items.push(si)
|
||||
sale.sale_items.each do |si|
|
||||
if si.status == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
discount_items.push(si)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# sale.total_discount = 0
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
|
||||
#destroy in sale.sale_items
|
||||
@@ -215,23 +217,23 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
else
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
@@ -251,7 +253,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
end
|
||||
# Check for Card Payment
|
||||
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
|
||||
|
||||
|
||||
# if is_card != "true"
|
||||
account_types = Account.where("discount=?",true)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
@@ -267,9 +269,9 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
str={type:pc[:name],amount:pc[:price]}
|
||||
acc_prices.push(str)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
generic_customer_id = sale.customer.membership_id
|
||||
generic_customer_id = sale.customer.membership_id
|
||||
receipt_no = sale.receipt_no
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("member_discount")
|
||||
@@ -282,7 +284,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# Check for items for Paypar Cloud
|
||||
if acc_prices.length > 0
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
response = HTTParty.post(url,
|
||||
:body => { account_no: account_no,
|
||||
generic_customer_id:generic_customer_id ,
|
||||
campaign_type_id: campaign_type_id,
|
||||
@@ -307,7 +309,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
rescue SocketError
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
end
|
||||
else
|
||||
else
|
||||
response = {"status": false, "message": "You have no selected discount item" }
|
||||
end
|
||||
Rails.logger.debug "-------------- Member Discount Osaka ---------"
|
||||
@@ -318,14 +320,14 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if response["discount_bonus_earned"]
|
||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source, tax_type)
|
||||
sale.compute_by_sale_items(discount_amount, 'member_discount', order_source, tax_type)
|
||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||
elsif response["status"] == "500"
|
||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
else
|
||||
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
end
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
|
||||
# end #end Is Card Payment
|
||||
@@ -376,5 +378,5 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# redirect_to origami_path(sale_id)
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -4,9 +4,9 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -15,11 +15,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||
sub_total = params[:sub_total]
|
||||
@@ -34,11 +34,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
# sale.save
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
# sale.save
|
||||
if other_charges_items.length > 0
|
||||
#save sale item for discount
|
||||
other_charges_items.each do |di|
|
||||
@@ -68,18 +68,18 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
else
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
end
|
||||
|
||||
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" )
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
|
||||
end
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, cashier_type)
|
||||
end
|
||||
if !table.nil?
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,15 +64,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
# rounding adjustment
|
||||
if shop_detail.is_rounding_adj
|
||||
a = sale_data.grand_total % 25 # Modulus
|
||||
b = sale_data.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = new_total-sale_data.grand_total
|
||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = new_total - sale_data.grand_total
|
||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
end
|
||||
#end rounding adjustment
|
||||
#record for sale audit
|
||||
@@ -151,15 +145,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
if shop_detail.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
end
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total - saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
@@ -655,7 +643,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
|
||||
saleObj.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
@@ -830,7 +818,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
order_source = params[:cashier_type]
|
||||
tax_type = params[:tax_type]
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount,nil,order_source,tax_type)
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
||||
|
||||
render json: JSON.generate({:status => true})
|
||||
end
|
||||
@@ -839,7 +827,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
|
||||
@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
else
|
||||
redirect_to "/origami/#{params[:type]}" and return
|
||||
end
|
||||
elsif id.start_with?("BKI")
|
||||
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
|
||||
@bookings = Booking.find(id)
|
||||
@order = @bookings.orders.where(status: "new").first
|
||||
@order_items = @bookings.order_items
|
||||
|
||||
@@ -59,7 +59,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
saleitemObj.status = 'foc'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.unit_price = saleitemObj.unit_price * 1
|
||||
@@ -95,7 +95,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
@@ -143,17 +143,17 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" )
|
||||
# saleitemObj.remark = 'edit'
|
||||
|
||||
unless saleitemObj.product_name.include? 'updated'
|
||||
unless saleitemObj.product_name.include? 'UPDATED'
|
||||
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
|
||||
end
|
||||
|
||||
saleitemObj.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
# saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
# order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
# order = Order.find(order_id)
|
||||
|
||||
# order.order_items.each do |o|
|
||||
# if saleitemObj.product_code == o.item_code
|
||||
@@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
# sale.compute_by_sale_items(saleObj.total_discount, nil, order_source) FOR WHAT????
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
end
|
||||
@@ -196,7 +196,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order_source)
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
@@ -214,9 +214,9 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
item.save
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
|
||||
saleObj.sale_items.reset
|
||||
# re-calc tax
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount,nil, order_source)
|
||||
end
|
||||
|
||||
def apply_void
|
||||
|
||||
@@ -10,7 +10,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
|
||||
@@ -15,7 +15,6 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
sale.sale_status = remark
|
||||
sale.save
|
||||
|
||||
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
# add to sale item with foc
|
||||
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Reports::ReceiptNoDetailController < BaseReportController
|
||||
class Reports::ReceiptNoDetailController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
@payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]]
|
||||
@@ -9,11 +9,10 @@ authorize_resource :class => false
|
||||
|
||||
@shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
if to.blank?
|
||||
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
|
||||
else
|
||||
if @shift_sale.shift_closed_at.blank?
|
||||
@@ -25,7 +24,7 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
@@ -62,10 +61,10 @@ authorize_resource :class => false
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
133
app/controllers/reports/staff_meal_controller.rb
Normal file
133
app/controllers/reports/staff_meal_controller.rb
Normal file
@@ -0,0 +1,133 @@
|
||||
class Reports::StaffMealController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
staff = Customer.where(customer_type: 'staff')
|
||||
customer_id = Array.new
|
||||
staff.each { |s|
|
||||
customer_id.push(s.customer_id)
|
||||
}
|
||||
|
||||
account_type = params[:account_type]
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
if shift.present?
|
||||
shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
def get_period_name(period)
|
||||
period_name = '-'
|
||||
unless period.nil? or period.blank?
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
period_name = "Today"
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
period_name = "Yesterday"
|
||||
|
||||
when PERIOD["this_week"]
|
||||
period_name = "This Week"
|
||||
|
||||
when PERIOD["last_week"]
|
||||
period_name = "Last Week"
|
||||
|
||||
when PERIOD["last_7"]
|
||||
period_name = "Last 7 days"
|
||||
|
||||
when PERIOD["this_month"]
|
||||
period_name = "This Month"
|
||||
|
||||
when PERIOD["last_month"]
|
||||
period_name = "Last Month"
|
||||
|
||||
when PERIOD["last_30"]
|
||||
period_name = "Last 30 Days"
|
||||
|
||||
when PERIOD["this_year"]
|
||||
period_name = "This Year"
|
||||
|
||||
when PERIOD["last_year"]
|
||||
period_name = "Last Year"
|
||||
|
||||
end
|
||||
end
|
||||
return period_name
|
||||
end
|
||||
|
||||
end
|
||||
@@ -6,7 +6,7 @@ class Transactions::SalesController < ApplicationController
|
||||
# GET /transactions/sales
|
||||
# GET /transactions/sales.json
|
||||
def index
|
||||
|
||||
|
||||
receipt_no = params[:receipt_no]
|
||||
# from = params[:from]
|
||||
# to = params[:to]
|
||||
@@ -19,18 +19,18 @@ class Transactions::SalesController < ApplicationController
|
||||
if receipt_no.nil? && from.nil? && to.nil?
|
||||
if @shift.blank?
|
||||
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
|
||||
else
|
||||
else
|
||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
||||
end
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search(receipt_no,from,to,@shift)
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
@receipt_no = receipt_no
|
||||
@from = from
|
||||
@@ -41,20 +41,20 @@ class Transactions::SalesController < ApplicationController
|
||||
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = @shift
|
||||
end
|
||||
|
||||
|
||||
# if receipt_no.nil? && search_date.nil?
|
||||
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
# else
|
||||
# if !search_date.blank? && receipt_no.blank?
|
||||
# if !search_date.blank? && receipt_no.blank?
|
||||
# sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||
# elsif !search_date.blank? && !receipt_no.blank?
|
||||
# elsif !search_date.blank? && !receipt_no.blank?
|
||||
# sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||
# else
|
||||
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
||||
# end
|
||||
# else
|
||||
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
||||
# end
|
||||
# if sale.count > 0
|
||||
# @sales = sale
|
||||
# @sales = sale
|
||||
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
# else
|
||||
# @sales = 0
|
||||
@@ -182,7 +182,7 @@ class Transactions::SalesController < ApplicationController
|
||||
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?
|
||||
@@ -191,8 +191,8 @@ class Transactions::SalesController < ApplicationController
|
||||
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
|
||||
else
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
else
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
from = day_ref.beginning_of_day.utc
|
||||
@@ -226,10 +226,10 @@ class Transactions::SalesController < ApplicationController
|
||||
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
|
||||
@@ -248,7 +248,7 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
sale.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
@@ -265,7 +265,7 @@ class Transactions::SalesController < ApplicationController
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
sale.rounding_adjustment = 0.0
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
@@ -308,16 +308,16 @@ class Transactions::SalesController < ApplicationController
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
if access_code != "null" && current_user.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
||||
|
||||
# For Print
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
@@ -325,7 +325,7 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
@@ -339,12 +339,12 @@ class Transactions::SalesController < ApplicationController
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find_by_id(1)
|
||||
# get member information
|
||||
@@ -363,31 +363,31 @@ class Transactions::SalesController < ApplicationController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
|
||||
#end print
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_sale
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module ApplicationHelper
|
||||
include NumberFormattable
|
||||
|
||||
def flash_class(level)
|
||||
case level
|
||||
when :notice then "alert alert-info fade-in"
|
||||
@@ -6,5 +8,6 @@ module ApplicationHelper
|
||||
when :error then "alert alert-error fade-in"
|
||||
when :alert then "alert alert-error fade-in"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,13 +32,12 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.check_balance(item, inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUT OF STOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||
StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
end
|
||||
|
||||
def self.modify_balance(item, stock, inventory_definition) #saleitemObj
|
||||
@@ -63,6 +62,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
elsif item.is_a? SaleItem
|
||||
trans_type = StockJournal::SALES_TRANS
|
||||
end
|
||||
# StockJournal.add_to_journal(instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
|
||||
StockJournal.add_to_journal(item.item_instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
|
||||
check_item.different = check_item.different - qty
|
||||
check_item.save
|
||||
|
||||
@@ -18,22 +18,22 @@ class License
|
||||
if (server != "")
|
||||
self.class.base_uri server
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# For Cloud
|
||||
def detail_with_local_cache(lookup)
|
||||
def detail_with_local_cache(lookup)
|
||||
aes = MyAesCrypt.new
|
||||
aes_key, aes_iv = aes.export_to_file(lookup)
|
||||
|
||||
aes_key, aes_iv = aes.export_to_file(lookup)
|
||||
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
cache_key = "#{lookup}:license:#{aes_key}:hostname"
|
||||
cache_key = "#{lookup}:license:#{aes_key}:hostname"
|
||||
|
||||
cache_license = nil
|
||||
|
||||
##Get redis connection from connection pool
|
||||
redis = Redis.new
|
||||
cache_license = redis.get(cache_key)
|
||||
|
||||
cache_license = redis.get(cache_key)
|
||||
|
||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
if cache_license.nil?
|
||||
##change the d/e key
|
||||
@@ -41,12 +41,13 @@ class License
|
||||
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} }
|
||||
response = self.class.get("/subdomain", @params)
|
||||
@license = response.parsed_response
|
||||
Rails.logger.info "License Response - " + response.parsed_response.to_s
|
||||
|
||||
if (@license["status"] == true)
|
||||
assign(aes_key, aes_iv)
|
||||
|
||||
# Rails.logger.info "License - " + response.parsed_response.to_s
|
||||
|
||||
#Rails.logger.info "License - " + response.parsed_response.to_s
|
||||
|
||||
redis = Redis.new
|
||||
redis.set(cache_key, Marshal.dump(@license))
|
||||
# redis.sadd("License:cache:keys", cache_key)
|
||||
@@ -59,36 +60,36 @@ class License
|
||||
|
||||
return true
|
||||
end
|
||||
else
|
||||
else
|
||||
@license = Marshal.load(cache_license)
|
||||
assign(aes_key, aes_iv)
|
||||
# Rails.logger.info 'API License'
|
||||
# Rails.logger.info 'API License'
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
# For Local System
|
||||
def detail_with_local_file()
|
||||
def detail_with_local_file()
|
||||
renewal_date_str = read_license("renewable_date")
|
||||
if check_expiring(renewal_date_str)
|
||||
# return for all ok
|
||||
if check_expiring(renewal_date_str)
|
||||
# return for all ok
|
||||
return 1
|
||||
else
|
||||
has_license = verify_license()
|
||||
if has_license
|
||||
# return for expiring
|
||||
# return for expiring
|
||||
return 2
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
# License Activation
|
||||
def license_activate (shop, license_key, db_host, db_schema, db_user, db_password)
|
||||
aes = MyAesCrypt.new
|
||||
aes_key, aes_iv = aes.export_key(license_key)
|
||||
aes = MyAesCrypt.new
|
||||
aes_key, aes_iv = aes.export_key(license_key)
|
||||
|
||||
@params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } }
|
||||
response = self.class.get("/activate", @params)
|
||||
@@ -96,21 +97,21 @@ class License
|
||||
|
||||
if (@activate["status"])
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
cache_key = "shop:#{@activate["shop_name"]}"
|
||||
cache_key = "shop:#{@activate["shop_name"]}"
|
||||
|
||||
cache_license = nil
|
||||
cache_license = nil
|
||||
|
||||
##Get redis connection from connection pool
|
||||
redis = Redis.new
|
||||
cache_license = redis.get(cache_key)
|
||||
cache_license = redis.get(cache_key)
|
||||
|
||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
|
||||
if cache_license.nil?
|
||||
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
|
||||
if cache_license.nil?
|
||||
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
|
||||
redis = Redis.new
|
||||
redis.set(cache_key, Marshal.dump(cache))
|
||||
end
|
||||
end
|
||||
|
||||
Rails.logger.info "License - " + response.parsed_response.to_s
|
||||
|
||||
@@ -120,21 +121,21 @@ class License
|
||||
sym_path = File.expand_path("~/symmetric/")
|
||||
|
||||
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
|
||||
|
||||
|
||||
if(response[:status])
|
||||
response = run_symmetric(sym_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
|
||||
end
|
||||
end
|
||||
return response
|
||||
end
|
||||
|
||||
def verify_license
|
||||
api_token = read_license_no_decrypt("api_token")
|
||||
def verify_license
|
||||
api_token = read_license_no_decrypt("api_token")
|
||||
@params = { query: {lookup_type: "application", api_token: api_token} }
|
||||
|
||||
|
||||
begin
|
||||
response = self.class.get("/verify", @params)
|
||||
@varified = response.parsed_response
|
||||
@@ -145,7 +146,7 @@ class License
|
||||
end
|
||||
else
|
||||
delete_license_file
|
||||
end
|
||||
end
|
||||
|
||||
rescue SocketError => e
|
||||
Rails.logger.debug "In SocketError No Internet connection ! "
|
||||
@@ -159,21 +160,21 @@ class License
|
||||
rescue OpenURI::HTTPError
|
||||
Rails.logger.debug "Can't connect server"
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
# Check Expired before 30 days
|
||||
def check_expiring(renewal_date_str)
|
||||
def check_expiring(renewal_date_str)
|
||||
if !renewal_date_str.empty?
|
||||
renewal_date = DateTime.parse(renewal_date_str)
|
||||
renewal_date = DateTime.parse(renewal_date_str)
|
||||
renewal_date > Date.today.advance(:days => 30)
|
||||
end
|
||||
end
|
||||
|
||||
# Check License expired date from PROVISION SERVER
|
||||
def check_expired(renewal_date_str)
|
||||
def check_expired(renewal_date_str)
|
||||
expired_date_str = read_license("renewable_date")
|
||||
renewal_date = DateTime.parse(renewal_date_str)
|
||||
if(renewal_date_str != expired_date_str)
|
||||
@@ -186,32 +187,32 @@ class License
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Check License File exists
|
||||
def self.check_license_file
|
||||
return File.exist?("config/license.yml")
|
||||
return File.exist?("config/license.yml")
|
||||
end
|
||||
|
||||
# read line by key for license file
|
||||
def read_license(key_name)
|
||||
decrypted_line = ""
|
||||
def read_license(key_name)
|
||||
decrypted_line = ""
|
||||
key, iv = get_redis_key()
|
||||
|
||||
if File.exist?("config/license.yml")
|
||||
if File.exist?("config/license.yml")
|
||||
File.open("config/license.yml").each do |line|
|
||||
if line.include? (key_name)
|
||||
decrypted_line_array = line.split(": ")
|
||||
if line.include? (key_name)
|
||||
decrypted_line_array = line.split(": ")
|
||||
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return decrypted_line
|
||||
end
|
||||
|
||||
# read line by key for license file without decrypt
|
||||
def read_license_no_decrypt(key)
|
||||
decrypted_line = ""
|
||||
if File.exist?("config/license.yml")
|
||||
if File.exist?("config/license.yml")
|
||||
File.open("config/license.yml").each do |line|
|
||||
if line.include? (key)
|
||||
decrypted_line_array = line.split(": ")
|
||||
@@ -226,18 +227,18 @@ class License
|
||||
def update_license(content, new_content)
|
||||
key, iv = get_redis_key()
|
||||
|
||||
if !new_content.include? "=="
|
||||
if !new_content.include? "=="
|
||||
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||
end
|
||||
|
||||
|
||||
content_str = read_license_no_decrypt(content)
|
||||
if File.exist?("config/license.yml")
|
||||
if File.exist?("config/license.yml")
|
||||
file_str = File.read("config/license.yml")
|
||||
new_file_str = file_str.gsub(content_str, encode_str(crypted_str))
|
||||
|
||||
# To write changes to the file, use:
|
||||
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
|
||||
|
||||
|
||||
# File.open("config/license.yml").each do |line|
|
||||
# new_file_str = line.gsub(content, crypted_str)
|
||||
# f.put
|
||||
@@ -247,33 +248,33 @@ class License
|
||||
|
||||
# Re-get keys
|
||||
def get_key
|
||||
api_token = read_license_no_decrypt("api_token")
|
||||
shop_name = read_license_no_decrypt("shop_name")
|
||||
api_token = read_license_no_decrypt("api_token")
|
||||
shop_name = read_license_no_decrypt("shop_name")
|
||||
@params = { query: {lookup_type: "application", api_token: api_token } }
|
||||
response = self.class.get("/get_key", @params)
|
||||
@data = response.parsed_response
|
||||
|
||||
|
||||
if (@data["status"])
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
cache_key = "shop:#{shop_name.chomp}"
|
||||
cache_key = "shop:#{shop_name.chomp}"
|
||||
|
||||
cache_license = nil
|
||||
cache_license = nil
|
||||
|
||||
##Get redis connection from connection pool
|
||||
redis = Redis.new
|
||||
cache_license = redis.get(cache_key)
|
||||
cache_license = redis.get(cache_key)
|
||||
|
||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
|
||||
if cache_license.nil?
|
||||
cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] }
|
||||
if cache_license.nil?
|
||||
cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] }
|
||||
redis = Redis.new
|
||||
redis.set(cache_key, Marshal.dump(cache))
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def get_redis_key
|
||||
@@ -281,18 +282,18 @@ class License
|
||||
key = ""
|
||||
shop = read_license_no_decrypt("shop_name")
|
||||
##Check from local redis - if available load local otherwise get from remote
|
||||
cache_key = "shop:#{shop.chomp}"
|
||||
cache_key = "shop:#{shop.chomp}"
|
||||
|
||||
cache_shop = nil
|
||||
cache_shop = nil
|
||||
|
||||
##Get redis connection from connection pool
|
||||
redis = Redis.new
|
||||
cache_shop = redis.get(cache_key)
|
||||
cache_shop = redis.get(cache_key)
|
||||
|
||||
if !cache_shop.nil?
|
||||
@shop = Marshal.load(cache_shop)
|
||||
key = @shop["key"]
|
||||
iv = @shop["iv"]
|
||||
if !cache_shop.nil?
|
||||
@shop = Marshal.load(cache_shop)
|
||||
key = @shop["key"]
|
||||
iv = @shop["iv"]
|
||||
end
|
||||
return key, iv
|
||||
end
|
||||
@@ -307,13 +308,13 @@ class License
|
||||
|
||||
# License File Creation
|
||||
def create_license_file(response_data)
|
||||
if File.exist?("config/license.yml")
|
||||
if File.exist?("config/license.yml")
|
||||
delete_license_file
|
||||
end
|
||||
|
||||
begin
|
||||
# Licese File Creation
|
||||
File.open("config/license.yml", "w") do |f|
|
||||
File.open("config/license.yml", "w") do |f|
|
||||
f.puts("iv_key: #{response_data['iv_key']}")
|
||||
f.puts("shop_name: #{response_data['shop_name']}")
|
||||
f.puts("email: #{response_data['email']}")
|
||||
@@ -325,11 +326,11 @@ class License
|
||||
f.puts("dbusername: #{response_data['dbusername']}")
|
||||
f.puts("dbpassword: #{response_data['dbpassword']}")
|
||||
f.puts("api_token: #{response_data['api_token']}")
|
||||
f.puts("app_token: #{response_data['app_token']}")
|
||||
f.puts("app_token: #{response_data['app_token']}")
|
||||
f.puts("plan_sku: #{response_data['plan_sku']}")
|
||||
f.puts("renewable_date: #{response_data['renewable_date']}")
|
||||
f.puts("plan_name: #{response_data['plan_name']}")
|
||||
end
|
||||
end
|
||||
rescue IOError
|
||||
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||
end
|
||||
@@ -352,15 +353,15 @@ class License
|
||||
f.write("group.id=sx\n")
|
||||
f.write("external.id=000\n")
|
||||
f.write("job.purge.period.time.ms=7200000\n")
|
||||
f.write("job.routing.period.time.ms=5000\n")
|
||||
f.write("job.push.period.time.ms=10000\n")
|
||||
f.write("job.pull.period.time.ms=10000\n")
|
||||
f.write("initial.load.create.first=true\n")
|
||||
f.write("job.routing.period.time.ms=5000\n")
|
||||
f.write("job.push.period.time.ms=10000\n")
|
||||
f.write("job.pull.period.time.ms=10000\n")
|
||||
f.write("initial.load.create.first=true\n")
|
||||
f.write("initial.load.use.extract.job.enabled=true\n")
|
||||
f.write("rest.api.enable=true\n")
|
||||
f.close
|
||||
f.close
|
||||
|
||||
# read from license file
|
||||
# read from license file
|
||||
# shop_name = read_license_no_decrypt("shop_name")
|
||||
shop_name = "cloud"
|
||||
dbhost = read_license("dbhost")
|
||||
@@ -378,12 +379,12 @@ class License
|
||||
f.write("registration.url=http://#{db_host}:31415/sync/sx\n")
|
||||
f.write("group.id=cloud\n")
|
||||
f.write("external.id=001\n")
|
||||
f.write("job.routing.period.time.ms=5000\n")
|
||||
f.write("job.push.period.time.ms=10000\n")
|
||||
f.write("job.routing.period.time.ms=5000\n")
|
||||
f.write("job.push.period.time.ms=10000\n")
|
||||
f.write("job.pull.period.time.ms=10000\n")
|
||||
f.write("rest.api.enable=true\n")
|
||||
# f.write("initial.load.create.first=true\n")
|
||||
# f.write("initial.load.use.extract.job.enabled=true\n")
|
||||
# f.write("initial.load.create.first=true\n")
|
||||
# f.write("initial.load.use.extract.job.enabled=true\n")
|
||||
f.close
|
||||
rescue IOError
|
||||
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||
@@ -392,12 +393,12 @@ class License
|
||||
end
|
||||
end
|
||||
|
||||
# Run Symmetric
|
||||
# Run Symmetric
|
||||
def run_symmetric(sym_path)
|
||||
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
||||
# check_sym_proc_str = check_sym_proc_str.split("\n")
|
||||
# sym_install_status = check_sym_proc_str[0].split(": ")
|
||||
|
||||
|
||||
check_sym_proc_str = `#{"sudo service SymmetricDS status"}`
|
||||
|
||||
# Check Sym Installed
|
||||
@@ -412,7 +413,7 @@ class License
|
||||
check_sym_table = system("sudo " + sym_path + "/bin/symadmin --engine sx create-sym-tables")
|
||||
if check_sym_table
|
||||
sym_sql = Rails.root + "db/sym_master.sql"
|
||||
|
||||
|
||||
if File.exist? (sym_sql)
|
||||
# Import Sym Sql to db and start sym
|
||||
run_sym_sql = system("sudo " + sym_path + "/bin/dbimport --engine sx " + sym_sql.to_s)
|
||||
@@ -427,7 +428,7 @@ class License
|
||||
else
|
||||
response = { "status": false, "message": "Activation is success but Cannot create Sym Tables. \n Please contact code2lab call center!"}
|
||||
end
|
||||
else
|
||||
else
|
||||
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
|
||||
end
|
||||
end
|
||||
@@ -435,7 +436,7 @@ class License
|
||||
# Check Symmetric Running
|
||||
def check_sym_running(status, sym_path)
|
||||
# Run Sym Service
|
||||
# if status.include? "Server is already running"
|
||||
# if status.include? "Server is already running"
|
||||
# return true
|
||||
# elsif status.include? "false"
|
||||
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
||||
@@ -443,9 +444,9 @@ class License
|
||||
# return true
|
||||
# else
|
||||
# check_sym_running(sym_start_status[0])
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# return true
|
||||
# return true
|
||||
# end
|
||||
|
||||
if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
|
||||
@@ -456,15 +457,15 @@ class License
|
||||
|
||||
# Delete License File
|
||||
def delete_license_file
|
||||
File.delete("config/license.yml") if File.exist?("config/license.yml")
|
||||
File.delete("config/license.yml") if File.exist?("config/license.yml")
|
||||
end
|
||||
|
||||
# Assign db info for Cloud
|
||||
def assign(aes_key, aes_iv)
|
||||
def assign(aes_key, aes_iv)
|
||||
key = Base64.decode64(aes_key)
|
||||
iv = Base64.decode64(aes_iv)
|
||||
|
||||
if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
|
||||
|
||||
if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
|
||||
host = Base64.decode64(@license["dbhost"])
|
||||
dbschema = Base64.decode64(@license["dbschema"])
|
||||
dbusername = Base64.decode64(@license["dbusername"])
|
||||
@@ -473,8 +474,8 @@ class License
|
||||
self.dbhost = AESCrypt.decrypt_data(host, key, iv, ENV['CIPHER_TYPE'])
|
||||
self.dbschema = AESCrypt.decrypt_data(dbschema, key, iv, ENV['CIPHER_TYPE'])
|
||||
self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE'])
|
||||
self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
|
||||
self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ class Lookup < ApplicationRecord
|
||||
|
||||
has_many :accounts
|
||||
|
||||
scope :number_formats, -> { where(lookup_type: 'number_format')}
|
||||
|
||||
def available_types
|
||||
{'Employee Roles' => 'employee_roles',
|
||||
'Dining Facilities Status' => 'dining_facilities_status',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class MenuCategory < ApplicationRecord
|
||||
class MenuCategory < ApplicationRecord
|
||||
# before_create :generate_menu_category_code
|
||||
|
||||
belongs_to :menu
|
||||
belongs_to :menu
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
has_many :menu_items
|
||||
@@ -38,9 +38,7 @@ class MenuCategory < ApplicationRecord
|
||||
end
|
||||
|
||||
def valid_time
|
||||
|
||||
menu_category = MenuCategory.find(self.id)
|
||||
menu = Menu.find(menu_category.menu_id)
|
||||
menu = self.menu
|
||||
|
||||
from_t = Time.parse(menu.valid_time_from.strftime("%H:%M:%S"))
|
||||
to_t = Time.parse(menu.valid_time_to.strftime("%H:%M:%S"))
|
||||
@@ -64,7 +62,7 @@ class MenuCategory < ApplicationRecord
|
||||
|
||||
c +=24
|
||||
current = c*3600 + current_t.min* 60 + current_t.sec
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
else # (after) noon
|
||||
@@ -77,8 +75,8 @@ class MenuCategory < ApplicationRecord
|
||||
|
||||
day = Date.today.wday
|
||||
dayresult = menu.valid_days.include?(day.to_s)
|
||||
|
||||
|
||||
|
||||
|
||||
if current.between?(from, to) && menu.valid_days.include?(day.to_s)
|
||||
return true
|
||||
else
|
||||
@@ -104,12 +102,12 @@ class MenuCategory < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
# def generate_menu_category_code
|
||||
# self.code = SeedGenerator.generate_code(self.class.name, "C")
|
||||
# def generate_menu_category_code
|
||||
# self.code = SeedGenerator.generate_code(self.class.name, "C")
|
||||
# end
|
||||
|
||||
def self.to_csv
|
||||
|
||||
|
||||
mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << mc_attributes
|
||||
@@ -123,7 +121,3 @@ class MenuCategory < ApplicationRecord
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ class MenuItem < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
has_many :menu_item_sets
|
||||
has_many :item_sets, through: :menu_item_sets
|
||||
has_and_belongs_to_many :item_sets, join_table: "menu_item_sets"
|
||||
|
||||
validates_presence_of :item_code, :name, :type, :min_qty,:account_id
|
||||
validates_uniqueness_of :item_code
|
||||
|
||||
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
|
||||
|
||||
@@ -125,32 +125,13 @@ class OrderItem < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
if self.qty != self.qty_before_last_save
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
InventoryDefinition.check_balance(self, inventory_definition)
|
||||
unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
|
||||
if self.qty != self.qty_before_last_save
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
InventoryDefinition.check_balance(self, inventory_definition)
|
||||
end
|
||||
end
|
||||
end
|
||||
# if self.qty > self.qty_was
|
||||
# credit = 0
|
||||
# debit = self.qty.to_i - self.qty_was.to_i
|
||||
# else
|
||||
# credit = self.qty_was.to_i - self.qty.to_i
|
||||
# debit = 0
|
||||
# end
|
||||
# if credit != debit
|
||||
# defination = InventoryDefinition.find_by_item_code(self.item_instance_code)
|
||||
# stock = StockJournal.where('item_code = ?', self.item_instance_code).order("id DESC").first
|
||||
# journal = StockJournal.create(
|
||||
# item_code: self.item_instance_code,
|
||||
# credit: credit,
|
||||
# debit: debit,
|
||||
# balance: stock.balance - debit + credit,
|
||||
# inventory_definition_id: defination.id,
|
||||
# remark: 'ok',
|
||||
# trans_ref: self.order.id,
|
||||
# trans_type: StockJournal::SALES_TRANS
|
||||
# )
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'cups'
|
||||
|
||||
class Printer::PrinterWorker
|
||||
attr_accessor :print_settings
|
||||
|
||||
|
||||
def initialize(print_settings)
|
||||
self.print_settings = print_settings
|
||||
end
|
||||
|
||||
@@ -227,8 +227,8 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
count = printer_settings.print_copies
|
||||
|
||||
# override print copies for print worker loop
|
||||
print_settings.print_copies = 1
|
||||
print_settings.save!
|
||||
# print_settings.print_copies = 1
|
||||
# print_settings.save!
|
||||
end
|
||||
directory_name = 'public/receipts'
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
@@ -11,37 +11,23 @@ class Promotion < ApplicationRecord
|
||||
PROMO_TYPE3 = "Net_price" # 1800 => 1000 => 1000
|
||||
PROMO_TYPE4 = "Percentage"
|
||||
|
||||
def is_promo_day
|
||||
promo_day.include? Date.today.wday.to_s
|
||||
end
|
||||
|
||||
def self.promo_activate(saleObj)
|
||||
array_same =[]
|
||||
current_day = Time.now.strftime("%Y-%m-%d")
|
||||
current_time = Time.now.strftime('%H:%M:%S')
|
||||
day = Date.today.wday
|
||||
promoList = is_between_promo_datetime(current_day,current_time)
|
||||
puts "promoList - " + promoList.size.to_s
|
||||
if promoList.size > 0
|
||||
itemList = combine_item(saleObj)
|
||||
itemList.each do|list|
|
||||
list.each do |l|
|
||||
array_same.push({
|
||||
item_instance_code: l.item_instance_code,
|
||||
order_id:l.order_id,
|
||||
qty:l.qty
|
||||
})
|
||||
|
||||
promoList.each do |promo|
|
||||
if promo.is_promo_day
|
||||
if item = saleObj.qty_of(promo.original_product)
|
||||
check_promo_type(promo, item, saleObj)
|
||||
end
|
||||
end
|
||||
end
|
||||
item_list =[]
|
||||
array_same.group_by do |same|
|
||||
same.values_at :item_instance_code
|
||||
end.map do |(item_instance_code), array_same|
|
||||
quantities = array_same.map { |p| p[:qty] }
|
||||
qty = quantities.all? ? quantities.reduce(:+) : nil
|
||||
item_list.push({ item_instance_code: item_instance_code, qty: qty })
|
||||
end
|
||||
Rails.logger.debug "-------promo_activate array_same-------"
|
||||
puts item_list.to_json
|
||||
is_promo_day(promoList,day, item_list, saleObj.sale_id)
|
||||
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
@@ -49,45 +35,7 @@ class Promotion < ApplicationRecord
|
||||
return promoList
|
||||
end
|
||||
|
||||
def self.combine_item(saleObj)
|
||||
# order_id = saleObj.sale_orders[0][0].order_id
|
||||
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
|
||||
# array_same =[]
|
||||
itemList = []
|
||||
saleObj.sale_orders.each do |so|
|
||||
# itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)
|
||||
itemList << OrderItem.where("order_id = ?",so.order_id).select(:item_instance_code,:order_id,:qty)
|
||||
end
|
||||
|
||||
return itemList
|
||||
end
|
||||
|
||||
def self.is_promo_day(promoList, day, orderitemList, sale_id)
|
||||
puts "Today date - " + day.to_s
|
||||
promoList.each do |promo|
|
||||
dayresult = promo.promo_day.include?(day.to_s)
|
||||
if dayresult
|
||||
orderitemList.each do |item|
|
||||
find_promo_item(promo, item, sale_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_promo_item(promo, orderitem, sale_id)
|
||||
item_code = OrderItem.find_by_item_instance_code(orderitem[:item_instance_code]).item_code
|
||||
# orderitem.each do |odr_item|
|
||||
if promo.original_product.downcase.to_s == orderitem[:item_instance_code]
|
||||
if promo.min_qty.to_i > orderitem[:qty].to_i
|
||||
return false
|
||||
else
|
||||
check_promo_type(promo,orderitem, sale_id)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
def self.check_promo_type(promo, orderitem, sale_id)
|
||||
def self.check_promo_type(promo, orderitem, saleObj)
|
||||
promo.promotion_products.each do |promo_product|
|
||||
if promo_product.item_code.downcase == orderitem[:item_instance_code]
|
||||
same = true
|
||||
@@ -97,20 +45,20 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
# same, promo_product = check_giveaway_product(promo, orderitem[0][0])
|
||||
if promo.promo_type == Promotion::PROMO_TYPE1
|
||||
if same
|
||||
give_promotion_same_product(orderitem[:qty], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code)
|
||||
else
|
||||
give_promotion_second_product(orderitem[:qty], promo.min_qty, promo_product.item_code, orderitem, sale_id)
|
||||
if same
|
||||
give_promotion_same_product(orderitem[:qty], promo.min_qty, promo_product.min_qty, orderitem, saleObj, promo_product.item_code)
|
||||
else
|
||||
give_promotion_second_product(orderitem[:qty], promo.min_qty, promo_product.item_code, orderitem, saleObj)
|
||||
end
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE2
|
||||
give_promotion_nett_off(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
give_promotion_nett_off(same,promo_product,promo.min_qty, orderitem, saleObj)
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE3
|
||||
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
give_promotion_nett_price(same,promo_product,promo.min_qty, orderitem, saleObj)
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE4
|
||||
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
|
||||
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, saleObj)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -128,106 +76,66 @@ class Promotion < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
|
||||
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id,promo_product)
|
||||
item =''
|
||||
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
|
||||
multiple = qty.to_i / promoqty.to_i # loop count
|
||||
charge_qty = 0
|
||||
foc_qty = 0
|
||||
if multiple > 0
|
||||
multiple.times.each do |key|
|
||||
if qty > promoqty
|
||||
charge_qty += promoqty
|
||||
different = qty - promoqty
|
||||
qty = different
|
||||
if different == 0
|
||||
foc_qty += foc_min_qty
|
||||
else
|
||||
foc_qty += foc_min_qty
|
||||
qty = qty - foc_min_qty
|
||||
end
|
||||
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, saleObj,promo_product)
|
||||
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
|
||||
multiple = qty.to_i / promoqty.to_i # loop count
|
||||
charge_qty = 0
|
||||
foc_qty = 0
|
||||
if multiple > 0
|
||||
multiple.times.each do |key|
|
||||
if qty > promoqty
|
||||
charge_qty += promoqty
|
||||
different = qty - promoqty
|
||||
qty = different
|
||||
if different == 0
|
||||
foc_qty += foc_min_qty
|
||||
else
|
||||
charge_qty += qty
|
||||
foc_qty += foc_min_qty
|
||||
qty = qty - foc_min_qty
|
||||
end
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
if multiple == foc_qty
|
||||
charge_qty += qty
|
||||
end
|
||||
else
|
||||
end
|
||||
if multiple == foc_qty
|
||||
charge_qty += qty
|
||||
end
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
price =0
|
||||
source =''
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if promo_product.downcase != item[:item_instance_code]
|
||||
price = 0
|
||||
source = saleObj.orders.first.source
|
||||
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
||||
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_code = ?",promo_product).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
end
|
||||
if !item.nil?
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion", item[:price],source)
|
||||
end
|
||||
if !item.nil?
|
||||
update_existing_item(foc_qty, item, saleObj, "promotion", item[:price], source)
|
||||
end
|
||||
end
|
||||
# AA - 10 # 3 # BB # orderList, #S34345
|
||||
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
|
||||
source =''
|
||||
item =''
|
||||
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, saleObj)
|
||||
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
|
||||
|
||||
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product)
|
||||
foc_qty = saleObj.qty_of(promo_product).qty rescue 0
|
||||
if (foc_qty < promotion_qty)
|
||||
promotion_qty = foc_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product)
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
price =0
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||
|
||||
price = 0
|
||||
source = saleObj.orders.first.source
|
||||
item = saleObj.order_items.where(item_instance_code: promo_product).first
|
||||
|
||||
if !item.nil?
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item[:price],source)
|
||||
update_existing_item(promotion_qty, item, saleObj, "promotion", item[:price],source)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.update_existing_item(qty, item, sale_id, type, item_price,source)
|
||||
if qty >0
|
||||
def self.update_existing_item(qty, item, saleObj, type, item_price,source)
|
||||
if qty > 0
|
||||
menu_category = MenuCategory.get_menu_category(item[:item_code]) #get menu category for menu items
|
||||
|
||||
|
||||
sale_item = SaleItem.new
|
||||
if !menu_category.nil?
|
||||
sale_item.menu_category_code = menu_category.code
|
||||
@@ -247,216 +155,85 @@ class Promotion < ApplicationRecord
|
||||
sale_item.price = qty * item_price * (-1)
|
||||
|
||||
sale_item.is_taxable = 1
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.sale = saleObj
|
||||
sale_item.save
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,nil,source)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
item =''
|
||||
source =''
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
if same
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
|
||||
|
||||
price =0
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
if !item.nil?
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
|
||||
else
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if !item.nil?
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
|
||||
saleObj.sale_items << sale_item
|
||||
saleObj.compute_by_sale_items(saleObj.total_discount, nil, source)
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
|
||||
def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, saleObj)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
source =''
|
||||
item =''
|
||||
if same
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0]) # need to specify with menu item instance
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if !item.nil?
|
||||
price = item[:price].to_i - promo_product.net_price.to_i
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
end
|
||||
|
||||
else
|
||||
order_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
|
||||
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
if !same
|
||||
order_qty = saleObj.qty_of(promo_product.item_code).qty rescue 0
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
|
||||
if foc_qty > order_qty
|
||||
foc_qty = order_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
end
|
||||
|
||||
if !item.nil?
|
||||
price = item[:price].to_i - promo_product.net_price.to_i
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
end
|
||||
|
||||
source = saleObj.orders.first.source
|
||||
item = saleObj.order_items.where(item_instance_code: promo_product.item_code).first
|
||||
|
||||
if !item.nil?
|
||||
update_existing_item(foc_qty, item, saleObj, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
end
|
||||
|
||||
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, saleObj)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
source =''
|
||||
item =''
|
||||
if same
|
||||
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
if !same
|
||||
order_qty = saleObj.qty_of(promo_product.item_code).qty rescue 0
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# total = orderitem[1].to_i * item.price
|
||||
if !item.nil?
|
||||
total = item[:price]
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||
end
|
||||
|
||||
else
|
||||
order_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# give total qty is 1
|
||||
#foc_qty = (foc_qty - foc_qty) + 1
|
||||
|
||||
if foc_qty > order_qty
|
||||
foc_qty = order_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# total = item.price * foc_qty
|
||||
if !item.nil?
|
||||
total = item[:price]
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||
end
|
||||
end
|
||||
|
||||
source = saleObj.orders.first.source
|
||||
item = saleObj.order_items.where(item_instance_code: promo_product.item_code).first
|
||||
|
||||
if !item.nil?
|
||||
price = item[:price].to_i - promo_product.net_price.to_i
|
||||
update_existing_item(foc_qty, item, saleObj, "promotion nett price", price,source)
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_second_item_qty(sale_id, promo_item)
|
||||
array_same =[]
|
||||
saleObj = Sale.find_by_sale_id(sale_id)
|
||||
itemList = combine_item(saleObj)
|
||||
itemList.each do|list|
|
||||
list.each do |l|
|
||||
array_same.push({
|
||||
item_instance_code: l.item_instance_code,
|
||||
order_id:l.order_id,
|
||||
qty:l.qty
|
||||
})
|
||||
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, saleObj)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
if !same
|
||||
order_qty = saleObj.qty_of(promo_product.item_code).qty rescue 0
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
|
||||
if foc_qty > order_qty
|
||||
foc_qty = order_qty
|
||||
end
|
||||
end
|
||||
item_list =[]
|
||||
array_same.group_by do |same|
|
||||
same.values_at :item_instance_code
|
||||
end.map do |(item_instance_code), array_same|
|
||||
quantities = array_same.map { |p| p[:qty] }
|
||||
qty = quantities.all? ? quantities.reduce(:+) : nil
|
||||
item_list.push({ item_instance_code: item_instance_code, qty: qty })
|
||||
end
|
||||
item_list.each do |item|
|
||||
if item[:item_instance_code] == promo_item.downcase
|
||||
return item[:qty].to_i
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def self.calculate_discount(total, percentage)
|
||||
return (total.to_i * percentage.to_i) / 100
|
||||
end
|
||||
source = saleObj.orders.first.source
|
||||
item = saleObj.order_items.where(item_instance_code: promo_product.item_code).first
|
||||
puts saleObj
|
||||
puts item
|
||||
# total = orderitem[1].to_i * item.price
|
||||
if item
|
||||
total = item[:price]
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, saleObj, "promotion discount", price,source)
|
||||
end
|
||||
end
|
||||
|
||||
def self.calculate_discount(total, percentage)
|
||||
return (total * percentage) / 100
|
||||
end
|
||||
end
|
||||
|
||||
2046
app/models/sale.rb
2046
app/models/sale.rb
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,8 @@ class SaleAudit < ApplicationRecord
|
||||
|
||||
belongs_to :sale
|
||||
|
||||
belongs_to :sale_payments_for_credit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment"
|
||||
|
||||
def self.sync_sale_audit_records(sale_audits)
|
||||
if !sale_audits.nil?
|
||||
sale_audits.each do |sa|
|
||||
@@ -163,7 +165,7 @@ class SaleAudit < ApplicationRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return card_balance_amount
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class SaleItem < ApplicationRecord
|
||||
include NumberFormattable
|
||||
self.primary_key = "sale_item_id"
|
||||
|
||||
#primary key - need to be unique generated for multiple shops
|
||||
@@ -11,7 +12,9 @@ class SaleItem < ApplicationRecord
|
||||
def compute_item
|
||||
end
|
||||
|
||||
before_validation :round_to_precision
|
||||
after_update :update_stock_journal
|
||||
after_save :update_stock_journal_set_item
|
||||
|
||||
# Add Sale Items
|
||||
def self.add_sale_items(sale_items)
|
||||
@@ -88,7 +91,7 @@ class SaleItem < ApplicationRecord
|
||||
# sale_item.save
|
||||
if type != "foc"
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale.total_discount)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -224,6 +227,59 @@ class SaleItem < ApplicationRecord
|
||||
return sale_items
|
||||
end
|
||||
|
||||
# Loader Service SFTP Start
|
||||
# Detail Sale Data
|
||||
def self.get_detail_sale_data(transaction_date)
|
||||
query = SaleItem.select("
|
||||
sale_items.sale_item_id as id,
|
||||
sale_items.sale_id as parent_id,
|
||||
s.receipt_no as check_num,
|
||||
s.receipt_date as business_date,
|
||||
s.receipt_date as transaction_date,
|
||||
'' as item_seq,
|
||||
sale_items.menu_category_code as category_code,
|
||||
sale_items.menu_category_name as category_name,
|
||||
'' as sub_category_code,
|
||||
'' as sub_category_name,
|
||||
'' as report_group_code,
|
||||
'' as report_group_name,
|
||||
sale_items.product_code as item_id,
|
||||
sale_items.product_name as item_name,
|
||||
sale_items.qty as qty,
|
||||
CASE
|
||||
WHEN s.sale_status = 'completed' OR s.sale_status = 'void' THEN 'Sales'
|
||||
WHEN s.sale_status = 'waste' THEN 'Waste'
|
||||
WHEN s.sale_status = 'spoile' THEN 'Spoil'
|
||||
END as transaction_type,
|
||||
sale_items.price as gross_sales,
|
||||
'' as discount_code,
|
||||
CASE
|
||||
WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0
|
||||
END as discount_amt,
|
||||
(sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) as sales,
|
||||
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21) as tax_amt,
|
||||
'' as service_charges,
|
||||
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) - ((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21)) as net_sales,
|
||||
'0' as is_set_item,
|
||||
'0' as is_staff_meal,
|
||||
'0' as is_raw_wastage,
|
||||
'0' as is_semi_wastage,
|
||||
CASE WHEN s.sale_status = 'waste' THEN 1 ELSE 0 END as is_wastage,
|
||||
CASE WHEN s.sale_status = 'spoile' THEN 1 ELSE 0 END as is_spoilage,
|
||||
'0' as is_sampling,
|
||||
'1' as tax_able,
|
||||
CASE
|
||||
WHEN s.sale_status = 'void' THEN 1 ELSE 0
|
||||
END as is_void
|
||||
")
|
||||
.joins("LEFT JOIN sales s ON s.sale_id = sale_items.sale_id")
|
||||
.joins("LEFT JOIN sale_items i ON sale_items.sale_id = i.sale_id AND sale_items.item_instance_code = i.item_instance_code AND i.status = 'Discount' AND sale_items.qty = abs(i.qty)")
|
||||
.where("DATE(s.receipt_date) = ? AND s.sale_status != 'void' AND (sale_items.status NOT IN('Discount', 'void','foc') OR sale_items.status IS NULL)", transaction_date)
|
||||
.order("s.receipt_no")
|
||||
end
|
||||
|
||||
# Loader Service SFTP End
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_item_id.nil?
|
||||
@@ -231,41 +287,59 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
is_void = self.status == "void" && self.status_before_last_save != "void"
|
||||
cancel_void = self.status_before_last_save == "void" && self.status.nil?
|
||||
is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
|
||||
is_foc = self.status == "foc" && self.status_before_last_save != "foc"
|
||||
cancel_foc = self.status_before_last_save == "foc"
|
||||
def round_to_precision
|
||||
unit_price_fraction = self.unit_price % 1
|
||||
price_fraction = self.unit_price % 1
|
||||
# is_dining_charge = self.menu_category_code == 'DingingCharge'
|
||||
|
||||
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
if is_void or cancel_void or is_edit
|
||||
if is_void
|
||||
qty = -self.qty
|
||||
remark = "void"
|
||||
elsif cancel_void
|
||||
qty = self.qty
|
||||
remark = "cancel void"
|
||||
elsif is_edit
|
||||
qty = self.qty - self.qty_before_last_save
|
||||
remark = "edit"
|
||||
end
|
||||
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different + qty
|
||||
check_item.save
|
||||
else is_foc or cancel_foc
|
||||
qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
|
||||
if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id
|
||||
if stock_journal = StockJournal.find_by_trans_ref(order_item_id)
|
||||
if is_foc
|
||||
stock_journal.update(remark: "foc")
|
||||
elsif cancel_foc
|
||||
stock_journal.update(remark: "cancel_foc")
|
||||
if self.unit_price != self.unit_price_was || self.price != self.price_was
|
||||
if unit_price_fraction > 0 || price_fraction > 0
|
||||
if ['Discount', 'promotion'].include?(self.status)
|
||||
self.unit_price = self.unit_price.round(precision)
|
||||
self.price = (self.unit_price * self.qty).round(precision)
|
||||
self.taxable_price = self.price
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
unless MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
|
||||
is_void = self.status == "void" && self.status_before_last_save != "void"
|
||||
cancel_void = self.status_before_last_save == "void" && self.status.nil?
|
||||
is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
|
||||
is_foc = self.status == "foc" && self.status_before_last_save != "foc"
|
||||
cancel_foc = self.status_before_last_save == "foc"
|
||||
|
||||
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
if is_void or cancel_void or is_edit
|
||||
if is_void
|
||||
qty = -self.qty
|
||||
remark = "void"
|
||||
elsif cancel_void
|
||||
qty = self.qty
|
||||
remark = "cancel void"
|
||||
elsif is_edit
|
||||
qty = self.qty - self.qty_before_last_save
|
||||
remark = "edit"
|
||||
end
|
||||
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different + qty
|
||||
check_item.save
|
||||
else is_foc or cancel_foc
|
||||
qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
|
||||
if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id
|
||||
if stock_journal = StockJournal.find_by_trans_ref(order_item_id)
|
||||
if is_foc
|
||||
stock_journal.update(remark: "foc")
|
||||
elsif cancel_foc
|
||||
stock_journal.update(remark: "cancel_foc")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -275,4 +349,78 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def update_stock_journal_set_item
|
||||
is_void = self.status == "void" && self.status_before_last_save != "void" && self.qty > 0
|
||||
cancel_void = self.status_before_last_save == "void" && self.status.nil?
|
||||
is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
|
||||
is_foc = self.status == "foc" && self.status_before_last_save != "foc"
|
||||
cancel_foc = self.status_before_last_save == "foc"
|
||||
is_waste = self.status == "waste"
|
||||
is_spoile = self.status == "spoile"
|
||||
|
||||
if MenuItemInstance.where("item_instance_name <> ''").pluck(:item_instance_code).include?(self.item_instance_code)
|
||||
if self.qty == 1 && self.qty != self.qty_before_last_save
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
if self.qty.to_i >= 0
|
||||
qty = self.qty - self.qty_was
|
||||
if stock.balance.to_i >= qty
|
||||
puts ">> stock is greater than order qty"
|
||||
remark = "ok"
|
||||
else
|
||||
puts " << stock is less than order qty"
|
||||
remark = "out of stock"
|
||||
end
|
||||
end
|
||||
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different - qty
|
||||
check_item.save
|
||||
else
|
||||
StockJournal.add_to_journal(self.item_instance_code, self.qty, 0, "out of stock", inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
end
|
||||
elsif is_void or cancel_void or is_edit
|
||||
if is_void
|
||||
qty = -self.qty
|
||||
remark = "void"
|
||||
elsif cancel_void
|
||||
qty = self.qty
|
||||
remark = "cancel void"
|
||||
elsif is_edit
|
||||
qty = self.qty - self.qty_before_last_save
|
||||
remark = "edit"
|
||||
end
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
|
||||
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different + qty
|
||||
check_item.save
|
||||
end
|
||||
end
|
||||
elsif is_foc or cancel_foc
|
||||
qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
|
||||
if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code).order(id: :desc).first
|
||||
if is_foc
|
||||
stock_journal.update(remark: "foc")
|
||||
elsif cancel_foc
|
||||
stock_journal.update(remark: "cancel_foc")
|
||||
end
|
||||
end
|
||||
elsif is_waste or is_spoile
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
if stock_journal = StockJournal.where(trans_ref: self.sale_item_id, item_code: self.item_instance_code)
|
||||
stock_journal.update(remark: self.status)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,8 +6,9 @@ class SaleOrder < ApplicationRecord
|
||||
|
||||
belongs_to :sale
|
||||
belongs_to :order
|
||||
has_many :order_items, foreign_key: "order_id", primary_key: "order_id"
|
||||
|
||||
def create_sale_order(sale_id, order_id)
|
||||
def create_sale_order(sale_id, order_id)
|
||||
# sale_order = SaleOrder.new
|
||||
self.sale_id = sale_id
|
||||
self.order_id = order_id
|
||||
@@ -37,6 +38,6 @@ class SaleOrder < ApplicationRecord
|
||||
if self.sale_order_id.nil?
|
||||
self.sale_order_id = SeedGenerator.generate_id(self.class.name, 'SOI')
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,8 +6,13 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
belongs_to :sale
|
||||
|
||||
has_one :sale_audit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id"
|
||||
|
||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
|
||||
|
||||
scope :credits, -> { where(payment_method: 'creditnote') }
|
||||
scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher']) }
|
||||
|
||||
def self.sync_sale_payment_records(sale_payments)
|
||||
if !sale_payments.nil?
|
||||
sale_payments.each do |sp|
|
||||
@@ -419,7 +424,7 @@ class SalePayment < ApplicationRecord
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
end
|
||||
sale = Sale.find(self.sale.sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,'','','',"foc")
|
||||
sale.compute_by_sale_items(sale.total_discount,'','','',"foc")
|
||||
|
||||
self.payment_method = "foc"
|
||||
self.payment_amount = self.received_amount
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
class SaleTax < ApplicationRecord
|
||||
include NumberFormattable
|
||||
self.primary_key = "sale_tax_id"
|
||||
|
||||
#primary key - need to be unique generated for multiple shops
|
||||
before_create :generate_custom_id
|
||||
belongs_to :sale
|
||||
|
||||
before_validation :round_to_precision
|
||||
|
||||
def self.sync_sale_tax_records(sale_taxes)
|
||||
if !sale_taxes.nil?
|
||||
sale_taxes.each do |t|
|
||||
@@ -38,4 +41,12 @@ class SaleTax < ApplicationRecord
|
||||
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
|
||||
end
|
||||
end
|
||||
|
||||
def round_to_precision
|
||||
if self.tax_payable_amount != self.tax_payable_amount_was
|
||||
if self.tax_payable_amount % 1 > 0
|
||||
self.tax_payable_amount = self.tax_payable_amount.round(precision)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
class ShiftSale < ApplicationRecord
|
||||
belongs_to :cashier_terminal
|
||||
belongs_to :employee, :foreign_key => 'employee_id'
|
||||
has_many :sales
|
||||
|
||||
def self.current_shift
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
@@ -25,7 +26,7 @@ class ShiftSale < ApplicationRecord
|
||||
def self.current_open_shift(current_user)
|
||||
#if current_user
|
||||
#find open shift where is open today and is not closed and login by current cashier
|
||||
#DATE(shift_started_at)=? and
|
||||
#DATE(shift_started_at)=? and
|
||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
||||
return shift
|
||||
@@ -43,7 +44,7 @@ class ShiftSale < ApplicationRecord
|
||||
# status = 'updated'
|
||||
if shift_sale.nil?
|
||||
shift_sale = ShiftSale.new
|
||||
# status = 'created'
|
||||
# status = 'created'
|
||||
end
|
||||
|
||||
shift_sale.id = ss['id']
|
||||
@@ -118,7 +119,7 @@ class ShiftSale < ApplicationRecord
|
||||
credit = saleobj.get_credit_amount
|
||||
other_sales = saleobj.get_other_amount
|
||||
tax = saleobj.get_commerical_tax
|
||||
|
||||
|
||||
if type == "void"
|
||||
self.total_revenue = self.total_revenue.to_f - saleobj.total_amount.to_f
|
||||
self.total_discounts = self.total_discounts - saleobj.total_discount
|
||||
@@ -137,7 +138,7 @@ class ShiftSale < ApplicationRecord
|
||||
self.takeaway_count = self.takeaway_count - 1
|
||||
end
|
||||
|
||||
|
||||
|
||||
self.save
|
||||
end
|
||||
end
|
||||
@@ -149,11 +150,11 @@ class ShiftSale < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_shift_other_payment(shift)
|
||||
|
||||
|
||||
other_payment = Sale.select("sale_payments.payment_method as name,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
|
||||
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
|
||||
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
|
||||
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
|
||||
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
|
||||
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
|
||||
SUM(case when (sale_payments.payment_method='unionpay') then (sale_payments.payment_amount) else 0 end) as unionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='alipay') then (sale_payments.payment_amount) else 0 end) as alipay_amount,
|
||||
@@ -161,19 +162,19 @@ class ShiftSale < ApplicationRecord
|
||||
SUM(case when (sale_payments.payment_method='dinga') then (sale_payments.payment_amount) else 0 end) as dinga_amount,
|
||||
SUM(case when (sale_payments.payment_method='giftvoucher') then (sale_payments.payment_amount) else 0 end) as giftvoucher_amount,
|
||||
SUM(case when (sale_payments.payment_method='JunctionPay') then (sale_payments.payment_amount) else 0 end) as junctionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
|
||||
SUM(case when (sale_payments.payment_method='paymal') then (sale_payments.payment_amount) else 0 end) as paymal_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
|
||||
SUM(case when (sale_payments.payment_method='paymal') then (sale_payments.payment_amount) else 0 end) as paymal_amount,
|
||||
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
|
||||
end
|
||||
|
||||
def self.calculate_total_price_by_accounts(shift,type)
|
||||
query = Sale.select("acc.title as account_name," +
|
||||
query = Sale.select("acc.title as account_name," +
|
||||
"SUM(case when (acc.id=i.account_id) then (i.price) else 0 end) as total_price")
|
||||
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id "+
|
||||
"JOIN accounts acc ON acc.id = i.account_id" +
|
||||
"JOIN accounts acc ON acc.id = i.account_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||
if type == 'discount'
|
||||
query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.remark = 'Discount'", shift.id)
|
||||
@@ -187,17 +188,17 @@ class ShiftSale < ApplicationRecord
|
||||
def self.get_total_member_discount(shift)
|
||||
query = Sale.select("SUM(sales.total_discount) as member_discount")
|
||||
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
|
||||
|
||||
end
|
||||
|
||||
def self.get_total_dinein(shift)
|
||||
end
|
||||
|
||||
def self.get_total_dinein(shift)
|
||||
query = Sale.select("sum(sales.grand_total) as total_dinein_amount")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Dinein" and c.membership_id is null',shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_total_takeway(shift)
|
||||
def self.get_total_takeway(shift)
|
||||
query = Sale.select("sum(sales.grand_total) as total_takeway_amount")
|
||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Takeaway" and c.membership_id is null',shift.id)
|
||||
@@ -211,12 +212,12 @@ class ShiftSale < ApplicationRecord
|
||||
# .where('s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null and s.receipt_date between ? and ?',from, to)
|
||||
# end
|
||||
|
||||
def self.get_total_other_charges(shift)
|
||||
def self.get_total_other_charges(shift)
|
||||
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
|
||||
.first()
|
||||
end
|
||||
end
|
||||
|
||||
def self.search(filter,from,to)
|
||||
if filter.blank?
|
||||
|
||||
@@ -4,6 +4,8 @@ class StockJournal < ApplicationRecord
|
||||
ORDER_TRANS = "order"
|
||||
STOCK_CHECK_TRANS = "stock_check"
|
||||
|
||||
scope :created_at_between, -> (from, to) { where(created_at: from..to)}
|
||||
|
||||
def self.add_to_journal(item_instance_code, qty, old_balance, stock_message, inventory_definition, trans_ref, trans_type) # item => saleObj | balance => Stock journal
|
||||
|
||||
balance = calculate_balance(old_balance, qty)
|
||||
@@ -52,23 +54,13 @@ class StockJournal < ApplicationRecord
|
||||
journal.save
|
||||
end
|
||||
|
||||
def self.inventory_balances(today,from,to,from_time,to_time)
|
||||
def self.inventory_balances(from,to)
|
||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||
.group("mii.item_instance_name")
|
||||
.order("mii.item_instance_name ASC")
|
||||
if !from.nil? && !to.nil?
|
||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'")
|
||||
else
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'")
|
||||
end
|
||||
query = query.group("mii.item_instance_name")
|
||||
.order("mii.item_instance_name ASC")
|
||||
else
|
||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||
.where("DATE_FORMAT(stock_journals.created_at,'%Y-%m-%d') = '#{today}'")
|
||||
.group("mii.item_instance_name")
|
||||
.order("mii.item_instance_name ASC")
|
||||
query = query.created_at_between(from, to)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CheckInOutPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size, :item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,booking, table)
|
||||
self.page_width = print_settings.page_width
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CloseCashierCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
|
||||
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
@@ -39,22 +39,11 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
end
|
||||
|
||||
def header (shop_details)
|
||||
@@ -103,13 +92,13 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -117,8 +106,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
end
|
||||
|
||||
|
||||
@@ -135,7 +124,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
@@ -144,7 +133,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash In :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -152,7 +141,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash Out :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
move_down -5
|
||||
@@ -165,7 +154,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
#start total FOC amount
|
||||
@total_foc = 0
|
||||
@@ -173,7 +162,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
end
|
||||
|
||||
#end total FOC amount
|
||||
#end total FOC amount
|
||||
total_grand_total = shift_sale.grand_total + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f
|
||||
# @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void
|
||||
y_position = cursor
|
||||
@@ -181,21 +170,21 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Grand Total :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_discount_by_account.each do |amount|
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -205,8 +194,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
@total_foc = 0
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -218,7 +207,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
move_down 7
|
||||
|
||||
@total_foc = 0
|
||||
y_position = cursor
|
||||
@@ -226,7 +215,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -234,9 +223,9 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
#start other payment details
|
||||
#start other payment details
|
||||
if shift_sale.other_sales > 0
|
||||
other_payment.each do |other|
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
@@ -246,7 +235,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -256,7 +245,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "VISA Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -266,7 +255,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Master Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -276,7 +265,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -286,7 +275,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -296,7 +285,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Alipay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -306,7 +295,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -316,7 +305,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Dinga Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -326,7 +315,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Redeem Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -336,7 +325,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Paymal Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -346,7 +335,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -356,7 +345,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Other Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -365,8 +354,8 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -374,14 +363,14 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
# end other payment details
|
||||
# end other payment details
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
|
||||
|
||||
# start Dinein and Takeaway
|
||||
|
||||
y_position = cursor
|
||||
@@ -392,7 +381,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
total_dinein = 0
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -401,11 +390,11 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
end
|
||||
if total_takeway.nil?
|
||||
total_takeway = 0
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_format(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
|
||||
# stop Dinein and Takeaway
|
||||
move_down -5
|
||||
@@ -419,7 +408,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -428,7 +417,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -436,7 +425,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
if total_credit_payments && total_credit_payments.to_f > 0
|
||||
@@ -445,7 +434,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end for service charges and commercial tax
|
||||
@@ -463,16 +452,16 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
move_down 7
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
# total_discount_by_account.each do |amount|
|
||||
|
||||
|
||||
# y_position = cursor
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
# text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
# text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
# end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
# y_position = cursor
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -481,19 +470,19 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
|
||||
|
||||
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_amount_by_account.each do |amount|
|
||||
total_amount_by_account.each do |amount|
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
#start total other charges amount
|
||||
if total_other_charges.present?
|
||||
@@ -502,9 +491,9 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Other Charges :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
#end total other charges amount
|
||||
|
||||
move_down -5
|
||||
@@ -513,32 +502,32 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
|
||||
#start total over all discount
|
||||
if total_member_discount[0].member_discount.present?
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = shift_sale.total_discounts - @member_discount
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
end
|
||||
|
||||
|
||||
if @overall > 0
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "-#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
end
|
||||
end
|
||||
#end total over all discount
|
||||
|
||||
if total_waste.to_f > 0
|
||||
@@ -547,7 +536,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Waste :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -557,7 +546,7 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
text "Total Spoile :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -591,4 +580,3 @@ class CloseCashierCustomisePdf < Prawn::Document
|
||||
move_down 5
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CloseCashierPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
|
||||
def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
@@ -39,25 +39,14 @@ class CloseCashierPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||
|
||||
if !sale_items.nil? or !sale_items.blank?
|
||||
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
|
||||
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,13 +96,13 @@ class CloseCashierPdf < Prawn::Document
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -121,8 +110,8 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
end
|
||||
|
||||
|
||||
@@ -139,7 +128,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
@@ -148,7 +137,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash In:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -156,7 +145,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash Out:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
move_down -5
|
||||
@@ -169,7 +158,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -177,10 +166,10 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
#start other payment details
|
||||
#start other payment details
|
||||
if shift_sale.other_sales > 0
|
||||
other_payment.each do |other|
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
@@ -190,7 +179,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -200,7 +189,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "VISA Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,7 +199,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Master Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -220,7 +209,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -230,7 +219,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -240,7 +229,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Alipay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -250,7 +239,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "KBZ Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -260,7 +249,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -270,7 +259,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Dinga Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -280,7 +269,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Redeem Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -290,7 +279,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Paymal Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -300,7 +289,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -310,7 +299,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Other Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -319,7 +308,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -327,10 +316,10 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
# end other payment details
|
||||
# end other payment details
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
@@ -342,7 +331,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -351,7 +340,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -359,7 +348,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
if total_credit_payments && total_credit_payments.to_f > 0
|
||||
@@ -368,7 +357,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end for service charges and commercial tax
|
||||
@@ -386,30 +375,30 @@ class CloseCashierPdf < Prawn::Document
|
||||
move_down 7
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_discount_by_account.each do |amount|
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
if total_member_discount[0].member_discount.present?
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = shift_sale.total_discounts - @member_discount
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -417,18 +406,18 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total FOC :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Void :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
@@ -441,7 +430,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Waste :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -449,7 +438,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Spoile :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
# y_position = cursor
|
||||
@@ -459,19 +448,19 @@ class CloseCashierPdf < Prawn::Document
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
|
||||
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_amount_by_account.each do |amount|
|
||||
total_amount_by_account.each do |amount|
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -482,7 +471,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -532,7 +521,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
sale_items.each do |item|
|
||||
|
||||
if !arr.include?(item['menu_category_id'])
|
||||
|
||||
|
||||
if flag == true
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
@@ -567,7 +556,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
# text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
# }
|
||||
add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i)
|
||||
|
||||
|
||||
if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void'
|
||||
total_qty += item['total_item'].to_i
|
||||
total_items += item['total_item'].to_i
|
||||
@@ -657,4 +646,4 @@ class CloseCashierPdf < Prawn::Document
|
||||
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class CloseCashierPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
|
||||
def initialize(printer_settings, shift_sale, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
@@ -39,22 +39,11 @@ class CloseCashierPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
|
||||
|
||||
end
|
||||
|
||||
@@ -104,13 +93,13 @@ class CloseCashierPdf < Prawn::Document
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
text "#{ number_format(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -118,8 +107,8 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
text "#{ number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||
# text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||
end
|
||||
|
||||
|
||||
@@ -136,7 +125,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
|
||||
end
|
||||
|
||||
@@ -145,7 +134,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash In:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -153,7 +142,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash Out:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
move_down -5
|
||||
@@ -166,7 +155,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -174,10 +163,10 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
#start other payment details
|
||||
#start other payment details
|
||||
if shift_sale.other_sales > 0
|
||||
other_payment.each do |other|
|
||||
@total_foc = other.foc_amount.round(2)
|
||||
@@ -187,7 +176,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -197,7 +186,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "VISA Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -207,7 +196,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Master Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -217,7 +206,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -227,7 +216,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -237,7 +226,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Alipay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -247,7 +236,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -257,7 +246,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Dinga Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -267,7 +256,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Redeem Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -277,7 +266,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Paymal Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -287,7 +276,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -297,7 +286,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Other Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -306,7 +295,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -314,10 +303,10 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
text "#{ number_format(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
# end other payment details
|
||||
# end other payment details
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
@@ -329,7 +318,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -338,7 +327,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -346,7 +335,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
text "#{number_format(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||
end
|
||||
|
||||
if total_credit_payments && total_credit_payments.to_f > 0
|
||||
@@ -355,7 +344,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end for service charges and commercial tax
|
||||
@@ -373,30 +362,30 @@ class CloseCashierPdf < Prawn::Document
|
||||
move_down 7
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_discount_by_account.each do |amount|
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
if total_member_discount[0].member_discount.present?
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||
@overall = shift_sale.total_discounts - @member_discount
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
text "#{ number_format(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
else
|
||||
@overall = shift_sale.total_discounts
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -404,18 +393,18 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "#{ number_format(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total FOC :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
text "(#{ number_format(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total Void :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
@@ -428,7 +417,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Waste :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
@@ -436,7 +425,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
text "Total Spoile :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
text "(#{ number_format(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
|
||||
# y_position = cursor
|
||||
@@ -446,19 +435,19 @@ class CloseCashierPdf < Prawn::Document
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||
# end
|
||||
|
||||
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
move_down 7
|
||||
|
||||
#start total amount by Account Like Food / Beverage /..
|
||||
total_amount_by_account.each do |amount|
|
||||
total_amount_by_account.each do |amount|
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
text "#{number_format(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -469,7 +458,7 @@ class CloseCashierPdf < Prawn::Document
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
|
||||
end
|
||||
#end total amount by Account
|
||||
#end total amount by Account
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||
@@ -502,4 +491,4 @@ class CloseCashierPdf < Prawn::Document
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class MoveTablePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||
self.page_width = printer_settings.page_width
|
||||
@@ -39,7 +39,7 @@ class MoveTablePdf < Prawn::Document
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
add_lining_item(order_items, printer_settings.precision)
|
||||
add_lining_item(order_items, precision)
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
@@ -98,7 +98,7 @@ class MoveTablePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class MoveTableStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
|
||||
self.page_width = printer_settings.page_width
|
||||
@@ -38,7 +38,7 @@ class MoveTableStarPdf < Prawn::Document
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
add_lining_item(order_items, printer_settings.precision)
|
||||
add_lining_item(order_items, precision)
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
@@ -97,7 +97,7 @@ class MoveTableStarPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderItemCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -47,7 +47,7 @@ class OrderItemCustomisePdf < Prawn::Document
|
||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items(order_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
@@ -107,7 +107,7 @@ class OrderItemCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -129,7 +129,7 @@ class OrderItemCustomisePdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -146,7 +146,7 @@ class OrderItemCustomisePdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.page_width) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderItemPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||
@@ -48,7 +48,7 @@ class OrderItemPdf < Prawn::Document
|
||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items(order_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
@@ -108,7 +108,7 @@ class OrderItemPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -130,7 +130,7 @@ class OrderItemPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -147,7 +147,7 @@ class OrderItemPdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :item_slim_font_size
|
||||
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,9 +11,9 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
self.item_slim_font_size=8
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
@@ -29,17 +29,17 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
if !order_item_slim.dining.nil?
|
||||
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
@@ -47,35 +47,35 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
|
||||
|
||||
# order items slim
|
||||
order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -88,7 +88,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
#Add Order Item
|
||||
add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
@@ -108,7 +108,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -146,7 +146,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.page_width) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class OrderItemSlimPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
|
||||
|
||||
def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
self.page_height = print_settings.page_height
|
||||
@@ -12,9 +12,9 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
@@ -29,17 +29,17 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
if !order_item_slim.dining.nil?
|
||||
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
@@ -47,35 +47,35 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
|
||||
|
||||
# order items slim
|
||||
order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -87,7 +87,7 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
#Add Order Item
|
||||
add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||
puts options
|
||||
puts '............PDF OPTIONS...............'
|
||||
@@ -108,7 +108,7 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -130,7 +130,7 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -146,7 +146,7 @@ class OrderItemSlimPdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderItemStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
|
||||
@@ -48,7 +48,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_items(order_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
@@ -108,7 +108,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -130,7 +130,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -147,7 +147,7 @@ class OrderItemStarPdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSetItemCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -12,9 +12,9 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
@@ -29,11 +29,11 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
if !order_set_item.dining.nil?
|
||||
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
else
|
||||
@@ -46,35 +46,35 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at)
|
||||
|
||||
# order items
|
||||
order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -86,7 +86,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
#Add Order Item
|
||||
add_order_set_items(order_set_item, options, alt_name, precision)
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
@@ -106,7 +106,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -144,7 +144,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -161,7 +161,7 @@ class OrderSetItemCustomisePdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.page_width) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSetItemPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,9 +11,9 @@ class OrderSetItemPdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
@@ -28,11 +28,11 @@ class OrderSetItemPdf < Prawn::Document
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
if !order_set_item.dining.nil?
|
||||
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
else
|
||||
@@ -45,35 +45,35 @@ class OrderSetItemPdf < Prawn::Document
|
||||
order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at)
|
||||
|
||||
# order items
|
||||
order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty)
|
||||
order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -85,7 +85,7 @@ class OrderSetItemPdf < Prawn::Document
|
||||
def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
#Add Order Item
|
||||
add_order_set_items(order_set_item, options, alt_name, precision)
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
@@ -105,7 +105,7 @@ class OrderSetItemPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(order_set_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
@@ -143,7 +143,7 @@ class OrderSetItemPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
@@ -160,7 +160,7 @@ class OrderSetItemPdf < Prawn::Document
|
||||
# add option
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "* Change quantity [#{number_format(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_format(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummaryCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -48,9 +48,9 @@ class OrderSummaryCustomisePdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -113,7 +113,7 @@ class OrderSummaryCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 10,y_position], :width => self.qty_width) do
|
||||
text " [#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text " [#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummaryPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,9 +11,9 @@ class OrderSummaryPdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
@@ -27,18 +27,18 @@ class OrderSummaryPdf < Prawn::Document
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
end
|
||||
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
|
||||
if !order[0].dining.nil?
|
||||
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
@@ -47,38 +47,38 @@ class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -103,7 +103,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
@@ -113,7 +113,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
@@ -123,14 +123,14 @@ class OrderSummaryPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 4
|
||||
@@ -138,15 +138,15 @@ class OrderSummaryPdf < Prawn::Document
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
|
||||
if options != ""
|
||||
move_down 5
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
@@ -161,7 +161,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 5
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_booking_id(order_no)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -12,9 +12,9 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
@@ -38,7 +38,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
@@ -47,38 +47,38 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.order_no_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -92,7 +92,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
@@ -102,7 +102,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
@@ -112,14 +112,14 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 4
|
||||
@@ -127,7 +127,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
#add set menu items
|
||||
@@ -148,10 +148,10 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
|
||||
if options != ""
|
||||
move_down 5
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
@@ -166,7 +166,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 5
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_booking_id(order_no)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummarySetPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,9 +11,9 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
@@ -37,7 +37,7 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
@@ -46,38 +46,38 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -102,7 +102,7 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
@@ -112,7 +112,7 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
@@ -122,14 +122,14 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 4
|
||||
@@ -137,7 +137,7 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
#add set menu items
|
||||
@@ -158,10 +158,10 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
|
||||
if options != ""
|
||||
move_down 5
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
@@ -176,7 +176,7 @@ class OrderSummarySetPdf < Prawn::Document
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 5
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_booking_id(order_no)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:item_slim_font_size
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,10 +11,10 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.item_slim_font_size=8
|
||||
self.label_width=90
|
||||
self.item_slim_font_size=8
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
@@ -38,7 +38,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
@@ -47,38 +47,38 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_slim_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -95,7 +95,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
@@ -105,7 +105,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
move_down 1
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
@@ -115,14 +115,14 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 5,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
text "[#{number_format(odi.qty, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 1
|
||||
@@ -134,7 +134,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
|
||||
if options != ""
|
||||
move_down 1
|
||||
|
||||
@@ -152,7 +152,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 1
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_booking_id(order_no)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class OrderSummarySlimPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty)
|
||||
self.page_width = print_settings.page_width
|
||||
@@ -11,9 +11,9 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=90
|
||||
self.label_width=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
@@ -37,7 +37,7 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
else
|
||||
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
end
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
@@ -46,38 +46,38 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
order_items(order, alt_name, precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
order_items(order_items, alt_name, precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
def order_info(order_no, order_by, order_at)
|
||||
#booking ID
|
||||
booking_id = get_booking_id(order_no)
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -102,7 +102,7 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
@@ -112,7 +112,7 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
move_down 1
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
@@ -122,14 +122,14 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
text "#{number_format(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 1
|
||||
@@ -141,7 +141,7 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
|
||||
if options != ""
|
||||
move_down 1
|
||||
|
||||
@@ -159,7 +159,7 @@ class OrderSummarySlimPdf < Prawn::Document
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 1
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_booking_id(order_no)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ReceiptBillA5Pdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
|
||||
@@ -26,11 +26,6 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
|
||||
# db font setup
|
||||
if printer_settings.font != ""
|
||||
font_families.update("#{printer_settings.font}" => {
|
||||
@@ -46,23 +41,17 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header(shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name, latest_order_no)
|
||||
line_items(sale_items,printer_settings.precision,delimiter)
|
||||
all_total(sale_data,printer_settings.precision,delimiter)
|
||||
line_items(sale_items,precision,delimiter)
|
||||
all_total(sale_data,precision,delimiter)
|
||||
|
||||
|
||||
if member_info != nil
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||
end
|
||||
|
||||
customer(customer_name)
|
||||
@@ -77,21 +66,21 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
card_balance_data(card_balance_amount)
|
||||
end
|
||||
#end card blanace amount
|
||||
|
||||
|
||||
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
|
||||
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||
discount_account(discount_price_by_accounts,precision,delimiter)
|
||||
end
|
||||
|
||||
if shop_details.show_account_info
|
||||
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
|
||||
items_account(item_price_by_accounts,precision,delimiter)
|
||||
if other_charges_amount
|
||||
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
|
||||
show_other_charges_amount(other_charges_amount,precision,delimiter)
|
||||
end
|
||||
end
|
||||
|
||||
#start for individual payment
|
||||
if !sale_data.equal_persons.nil?
|
||||
individual_payment(sale_data, printer_settings.precision, delimiter)
|
||||
individual_payment(sale_data, precision, delimiter)
|
||||
end
|
||||
#end for individual payment
|
||||
|
||||
@@ -100,7 +89,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
if shop_details.note && !shop_details.note.nil?
|
||||
shop_note(printed_status)
|
||||
end
|
||||
|
||||
|
||||
footer(printed_status)
|
||||
end
|
||||
|
||||
@@ -130,7 +119,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
@@ -154,7 +143,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -172,7 +161,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
|
||||
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
|
||||
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
|
||||
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
|
||||
# :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
@@ -209,7 +198,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items,precision,delimiter)
|
||||
|
||||
|
||||
if precision.to_i > 0
|
||||
item_name_width = (self.item_width+self.price_width)
|
||||
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||
@@ -229,17 +218,17 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
sub_total = 0.0
|
||||
total_qty = 0.0
|
||||
sale_items.each do |item|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
|
||||
show_price = Lookup.find_by_lookup_type("show_price")
|
||||
|
||||
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
|
||||
if item.status != 'Discount' && item.qty > 0
|
||||
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
else
|
||||
if item.price != 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -265,14 +254,14 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# bounding_box([self.item_width + self.price_width + 11,y_position], :width =>self.qty_width, :height => self.item_height) do
|
||||
# text "#{number_with_precision(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
||||
# text "#{number_format(total_qty, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :center
|
||||
# end
|
||||
# bounding_box([self.item_width + self.price_width + 8,y_position], :width =>self.total_width, :height => self.item_height) do
|
||||
# text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
# text "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
end
|
||||
|
||||
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -297,10 +286,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -328,7 +317,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{ dis_type }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if sale_data.sale_taxes.length > 0
|
||||
@@ -344,7 +333,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -370,7 +359,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
@@ -380,15 +369,15 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
|
||||
sale_payment(sale_data,precision,delimiter)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
stroke_horizontal_rule
|
||||
# move_down 10
|
||||
sql = "SELECT SUM(payment_amount)
|
||||
@@ -419,28 +408,28 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
if sale_data.amount_received > 0
|
||||
if sale_data.amount_received > 0
|
||||
y_position = cursor
|
||||
move_down line_move
|
||||
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
|
||||
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
#move_down line_move
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# show member information
|
||||
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||
if rebate_amount != nil
|
||||
if rebate_amount != nil
|
||||
if rebate_amount["status"] == true
|
||||
stroke_horizontal_rule
|
||||
total = 0
|
||||
@@ -467,10 +456,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Rebate Earn", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
# Total Rebate Amount if birthday
|
||||
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
|
||||
rebate_balance = rebate_balance + res["deposit"]
|
||||
@@ -480,9 +469,9 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
#end Total rebate if birthday
|
||||
end
|
||||
|
||||
@@ -492,7 +481,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if current_balance != nil
|
||||
@@ -502,10 +491,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -515,7 +504,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
total_balance = total_balance + res["balance"]
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
move_down line_move
|
||||
@@ -524,10 +513,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Total Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def customer(customer_name)
|
||||
@@ -554,8 +543,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.description_width,y_position], :width =>self.label_width) do
|
||||
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
end
|
||||
@@ -570,8 +559,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
end
|
||||
@@ -582,9 +571,9 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
text "Other Charges", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
move_down line_move
|
||||
end
|
||||
|
||||
#individual payment per person
|
||||
@@ -604,7 +593,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
move_down 15
|
||||
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -623,17 +612,17 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
JOIN sale_audits sa
|
||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
||||
if payment.payment_method == "creditnote"
|
||||
|
||||
y_position = cursor
|
||||
stroke_horizontal_rule
|
||||
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 70
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 73
|
||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||
@@ -650,8 +639,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
move_down 70
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
if sale_data.payment_status == "foc"
|
||||
|
||||
if sale_data.payment_status == "foc"
|
||||
bounding_box([self.label_width,y_position], :width =>self.description_width) do
|
||||
move_down 73
|
||||
text "Acknowledged By" , :size => self.item_font_size,:align => :center
|
||||
@@ -661,10 +650,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
move_down 73
|
||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def shop_note(shop)
|
||||
@@ -674,8 +663,8 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
move_down line_move
|
||||
y_position = cursor
|
||||
|
||||
text "#{shop.note}", :size => self.item_font_size,:align => :left
|
||||
|
||||
text "#{shop.note}", :size => self.item_font_size,:align => :left
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -688,10 +677,10 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width) do
|
||||
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -729,7 +718,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -753,4 +742,4 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
end
|
||||
return status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ReceiptBillOrderPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
|
||||
@@ -27,11 +27,6 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
|
||||
# db font setup
|
||||
if printer_settings.font != ""
|
||||
font_families.update("#{printer_settings.font}" => {
|
||||
@@ -47,19 +42,13 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header(shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
|
||||
line_items(sale_items,printer_settings.precision,delimiter,order_reservation)
|
||||
all_total(sale_data,printer_settings.precision,delimiter,order_reservation)
|
||||
line_items(sale_items,precision,delimiter,order_reservation)
|
||||
all_total(sale_data,precision,delimiter,order_reservation)
|
||||
|
||||
footer(printed_status)
|
||||
end
|
||||
@@ -78,13 +67,13 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
|
||||
def cashier_info(sale_data, customer_name, latest_order_no,order_reservation)
|
||||
move_down line_move
|
||||
|
||||
|
||||
# move_down 2
|
||||
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Order Date " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.created_at.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -92,7 +81,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Requested Date Time " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.requested_time.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -100,7 +89,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "Payment Type" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{order_reservation.payment_type}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -108,7 +97,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do
|
||||
text "#{customer_name} " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "Online Order", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
@@ -167,14 +156,14 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
total_qty = 0.0
|
||||
show_price = Lookup.find_by_lookup_type("show_price")
|
||||
sale_items.each do |item|
|
||||
# check for item not to show
|
||||
# check for item not to show
|
||||
|
||||
if item.status != 'Discount' && item.qty > 0
|
||||
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
else
|
||||
if item.price != 0
|
||||
total_qty += item.qty
|
||||
total_qty += item.qty
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -191,7 +180,7 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
qty = item.qty
|
||||
total_price = item.price #item.qty*item.unit_price - comment for room charges
|
||||
price = item.unit_price
|
||||
|
||||
|
||||
# end
|
||||
if !show_price.nil? && show_price.value.to_i>0
|
||||
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -209,8 +198,8 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(order_reservation.total_amount, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if !order_reservation.delivery_type.nil? && order_reservation.delivery_fee.to_f > 0
|
||||
y_position = cursor
|
||||
@@ -219,27 +208,27 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.description_width - 48,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
text "#{number_format(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
if order_reservation.total_tax > 0
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||
text "Tax " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
text "#{number_format(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do
|
||||
text "Convenience Charges " , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if order_reservation.discount_amount > 0
|
||||
@@ -249,9 +238,9 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
text "#{number_format(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Change items rows
|
||||
@@ -277,10 +266,10 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -309,11 +298,11 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
text "#{number_format(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
# sale_payment(sale_data,precision,delimiter)
|
||||
# sale_payment(sale_data,precision,delimiter)
|
||||
end
|
||||
|
||||
#Change Footer
|
||||
@@ -326,10 +315,10 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
bounding_box([0, y_position], :width =>self.label_width) do
|
||||
text "#{printed_status}",:style => :bold, :size => header_font_size - 1,:align => :left
|
||||
end
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size - 1,:align => :left
|
||||
end
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
end
|
||||
@@ -351,4 +340,4 @@ class ReceiptBillOrderPdf < Prawn::Document
|
||||
end
|
||||
return status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# require 'prawn/qrcode'
|
||||
require 'prawn/measurement_extensions'
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
|
||||
@@ -29,11 +29,6 @@ class ReceiptBillPdf < Prawn::Document
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
|
||||
# db font setup
|
||||
if printer_settings.font != ""
|
||||
font_families.update("#{printer_settings.font}" => {
|
||||
@@ -49,23 +44,17 @@ class ReceiptBillPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header(shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name, latest_order_no)
|
||||
line_items(sale_items,printer_settings.precision,delimiter)
|
||||
all_total(sale_data,printer_settings.precision,delimiter)
|
||||
line_items(sale_items,precision,delimiter)
|
||||
all_total(sale_data,precision,delimiter)
|
||||
|
||||
|
||||
if member_info != nil
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||
end
|
||||
|
||||
customer(customer_name)
|
||||
@@ -82,19 +71,19 @@ class ReceiptBillPdf < Prawn::Document
|
||||
#end card blanace amount
|
||||
|
||||
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
|
||||
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||
discount_account(discount_price_by_accounts,precision,delimiter)
|
||||
end
|
||||
|
||||
if shop_details.show_account_info
|
||||
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
|
||||
items_account(item_price_by_accounts,precision,delimiter)
|
||||
if other_charges_amount
|
||||
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
|
||||
show_other_charges_amount(other_charges_amount,precision,delimiter)
|
||||
end
|
||||
end
|
||||
|
||||
#start for individual payment
|
||||
if !sale_data.equal_persons.nil?
|
||||
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
|
||||
individual_payment(sale_data,sale_data.equal_persons, precision, delimiter)
|
||||
end
|
||||
#end for individual payment
|
||||
|
||||
@@ -273,8 +262,8 @@ class ReceiptBillPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
end
|
||||
|
||||
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -298,9 +287,9 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -330,7 +319,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ dis_type }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
service_tax_desc = ""
|
||||
@@ -355,14 +344,14 @@ class ReceiptBillPdf < Prawn::Document
|
||||
sale_data.sale_taxes.each do |st|
|
||||
if (st.tax_name.include? "Service")
|
||||
service_tax_desc = st.tax_name
|
||||
service_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
|
||||
service_tax_amount = st.tax_payable_amount
|
||||
if incl_tax
|
||||
service_tax_rate = st.tax_rate.to_i
|
||||
end
|
||||
end
|
||||
if (st.tax_name.include? "Commercial")
|
||||
com_tax_desc = st.tax_name
|
||||
com_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)
|
||||
com_tax_amount = st.tax_payable_amount
|
||||
if incl_tax
|
||||
com_tax_rate = st.tax_rate.to_i
|
||||
end
|
||||
@@ -374,7 +363,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
y_position = cursor
|
||||
@@ -391,7 +380,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
else
|
||||
sale_data.sale_taxes.each do |st|
|
||||
@@ -402,7 +391,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -439,7 +428,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
@@ -480,7 +469,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -491,7 +480,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
# move_down line_move
|
||||
end
|
||||
@@ -526,7 +515,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Rebate Earn", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
end
|
||||
@@ -539,7 +528,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
#end Total rebate if birthday
|
||||
@@ -551,7 +540,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if current_balance != nil
|
||||
@@ -561,7 +550,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -583,7 +572,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Total Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -615,7 +604,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -631,7 +620,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -643,7 +632,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Other Charges", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -666,7 +655,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
move_down 15
|
||||
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ReceiptBillStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
|
||||
|
||||
@@ -28,11 +28,6 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
#setting page margin and width
|
||||
super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
|
||||
# db font setup
|
||||
if printer_settings.font != ""
|
||||
font_families.update("#{printer_settings.font}" => {
|
||||
@@ -48,23 +43,17 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header(shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name, latest_order_no)
|
||||
line_items(sale_items,printer_settings.precision,delimiter)
|
||||
all_total(sale_data,printer_settings.precision,delimiter)
|
||||
line_items(sale_items,precision,delimiter)
|
||||
all_total(sale_data,precision,delimiter)
|
||||
|
||||
|
||||
if member_info != nil
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||
end
|
||||
|
||||
customer(customer_name)
|
||||
@@ -81,19 +70,19 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
#end card blanace amount
|
||||
|
||||
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
|
||||
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||
discount_account(discount_price_by_accounts,precision,delimiter)
|
||||
end
|
||||
|
||||
if shop_details.show_account_info
|
||||
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
|
||||
items_account(item_price_by_accounts,precision,delimiter)
|
||||
if other_charges_amount
|
||||
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
|
||||
show_other_charges_amount(other_charges_amount,precision,delimiter)
|
||||
end
|
||||
end
|
||||
|
||||
#start for individual payment
|
||||
if !sale_data.equal_persons.nil?
|
||||
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
|
||||
individual_payment(sale_data,sale_data.equal_persons, precision, delimiter)
|
||||
end
|
||||
#end for individual payment
|
||||
|
||||
@@ -268,8 +257,8 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
end
|
||||
|
||||
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
|
||||
@@ -293,9 +282,9 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "#{product_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{number_format(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
|
||||
if show_alt_name
|
||||
if !(item.product_alt_name).empty?
|
||||
@@ -325,7 +314,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "#{ dis_type }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
text "( #{number_format(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if sale_data.sale_taxes.length > 0
|
||||
@@ -342,7 +331,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -378,7 +367,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
text "#{number_format(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
|
||||
@@ -419,7 +408,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
end
|
||||
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -430,7 +419,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
# move_down line_move
|
||||
end
|
||||
@@ -465,7 +454,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Rebate Earn", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
end
|
||||
@@ -478,7 +467,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
#end Total rebate if birthday
|
||||
@@ -490,7 +479,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if current_balance != nil
|
||||
@@ -500,7 +489,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -522,7 +511,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Total Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -554,7 +543,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
text "(" + "#{ number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -570,7 +559,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -582,7 +571,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
text "Other Charges", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down line_move
|
||||
end
|
||||
@@ -605,7 +594,7 @@ class ReceiptBillStarPdf < Prawn::Document
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
move_down 15
|
||||
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
text "#{number_format(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SaleItemsPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
|
||||
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
|
||||
@@ -41,17 +41,6 @@ class SaleItemsPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SaleItemsStarPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include NumberFormattable
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||
|
||||
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
|
||||
@@ -41,17 +41,6 @@ class SaleItemsStarPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
printer_settings.precision = 2
|
||||
end
|
||||
#check delimiter
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
@@ -3,18 +3,6 @@
|
||||
<!-- <h2><%= t :dashboard %></h2> -->
|
||||
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
|
||||
</div>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<!-- Widgets -->
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 col-mbl-view">
|
||||
@@ -79,24 +67,16 @@
|
||||
<div class="row clearfix">
|
||||
<%
|
||||
if !@from.nil? && @from != ""
|
||||
from_date = DateTime.parse(@from).utc.getlocal.strftime("%d-%m-%Y")
|
||||
from_date = @from.strftime("%d-%m-%Y")
|
||||
from_time = @from.strftime("%H:%M") if @from.strftime("%H:%M") != "00:00"
|
||||
else
|
||||
from_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
|
||||
from_date = Time.now.strftime('%d-%m-%Y')
|
||||
end
|
||||
if !@to.nil? && @to != ""
|
||||
to_date = DateTime.parse(@to).utc.getlocal.strftime("%d-%m-%Y")
|
||||
to_date = @to.strftime("%d-%m-%Y")
|
||||
to_time = @to.strftime("%H:%M") if @to.strftime("%H:%M") != "23:59"
|
||||
else
|
||||
to_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
|
||||
end
|
||||
if !@from_time.nil?
|
||||
from_time = @from_time
|
||||
else
|
||||
from_time = ''
|
||||
end
|
||||
if !@to_time.nil?
|
||||
to_time = @to_time
|
||||
else
|
||||
to_time = ''
|
||||
to_date = Time.now.strftime('%d-%m-%Y')
|
||||
end
|
||||
%>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-mbl-view mbl-style">
|
||||
@@ -211,49 +191,44 @@
|
||||
<tr>
|
||||
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
|
||||
<td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td>
|
||||
<td align="right"><%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td align="right"><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td align="right"><%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td align="right"><%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total_sale") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
<td align="right"><%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table">
|
||||
<% if !(@total_payment_methods.nil?) %>
|
||||
<% @total_payment_methods.each do |payment| %>
|
||||
<% if !@sale_data[0].empty? %>
|
||||
<% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' && payment.payment_method != 'unionpay' %>
|
||||
<tr>
|
||||
<% if payment.payment_method == 'paypar' %>
|
||||
<td>Redeem Sale : </td>
|
||||
<% else %>
|
||||
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
|
||||
<% end %>
|
||||
<td align="right">
|
||||
<% @sale_data.each do |data| %>
|
||||
<% pay_mth = payment.payment_method %>
|
||||
<%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if payment.payment_method != 'card' %>
|
||||
<tr>
|
||||
<% if payment.payment_method == 'paypar' %>
|
||||
<td>Redeem Sale : </td>
|
||||
<% else %>
|
||||
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
|
||||
<% end %>
|
||||
<td align="right">
|
||||
<%= number_format(@sale_data.find {|x| x.key?(payment.payment_method) }[payment.payment_method], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %>
|
||||
<% total_card = @sale_data.find {|x| x.key?("card") } %>
|
||||
<% if !total_card.nil? %>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
|
||||
<td align="right">
|
||||
<%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
<%= number_format(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_format(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -138,6 +138,9 @@
|
||||
<li>
|
||||
<a href="<%= reports_induty_index_path %>">Induty</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_staff_meal_index_path %>">Staff Meal</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
|
||||
</li>
|
||||
@@ -324,6 +327,9 @@
|
||||
<li>
|
||||
<a href="<%= reports_induty_index_path %>">Induty</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_staff_meal_index_path %>">Staff Meal</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
|
||||
</li>
|
||||
|
||||
@@ -1,53 +1,20 @@
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item.item_attributes.each do|attr_id|
|
||||
menu_attr = MenuItemAttribute.find(attr_id)
|
||||
if attr_format.count == 0
|
||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||
next
|
||||
end
|
||||
|
||||
attr_format.each do |af|
|
||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||
if menu_attr.attribute_type == af[:type]
|
||||
af[:values].push(menu_attr.name)
|
||||
end
|
||||
else
|
||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||
attr_format.push(new_attr)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item_attributes = MenuItemAttribute.where(id: item.item_attributes)
|
||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||
next
|
||||
end
|
||||
|
||||
opt_format.each do |of|
|
||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||
if menu_opt.option_type == of[:type]
|
||||
of[:values].push(menu_opt.name)
|
||||
end
|
||||
else
|
||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||
opt_format.push(new_opt)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item_options = MenuItemOption.where(id: item.item_options)
|
||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
||||
end
|
||||
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.code item.item_code
|
||||
@@ -63,17 +30,15 @@ json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
|
||||
# Item Sets of Menu Item
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets do |its|
|
||||
json.id its.id
|
||||
json.name its.name
|
||||
json.alt_name its.alt_name
|
||||
json.min_selectable_qty its.min_selectable_qty
|
||||
json.max_selectable_qty its.max_selectable_qty
|
||||
json.instances its.menu_item_instances do |i|
|
||||
json.id i.id
|
||||
end
|
||||
end
|
||||
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||
end
|
||||
|
||||
json.attributes attr_format
|
||||
json.options opt_format
|
||||
@@ -92,22 +57,17 @@ json.options opt_format
|
||||
json.instances item.menu_item_instances do |is|
|
||||
if is.is_available
|
||||
# Convert id to name for attributes
|
||||
instance_attr = []
|
||||
is.item_attributes.each do |ia|
|
||||
mItemAttr = MenuItemAttribute.find(ia).name
|
||||
instance_attr.push(mItemAttr)
|
||||
end
|
||||
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
json.is_available is.is_available
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.values instance_attr
|
||||
# json.item_sets is.item_sets
|
||||
instance_attr = MenuItemAttribute.where(id: item.item_attributes).pluck(:name)
|
||||
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
json.is_available is.is_available
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.values instance_attr
|
||||
end
|
||||
end
|
||||
|
||||
@@ -116,4 +76,4 @@ end
|
||||
# json.set_items item.children.each do |item|
|
||||
# json.partial! 'api/restaurant/menu/menu_item', item: item
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
@@ -8,22 +8,17 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
||||
if (menu.menu_categories)
|
||||
order_by = Lookup.find_by_lookup_type("order_by")
|
||||
# if !order_by.nil? && order_by.value == "name"
|
||||
# categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
|
||||
# categories = MenuCategory.unscope(:order).where("menu_id ='#{menu.id}'").order("name asc")
|
||||
# else
|
||||
# categories = menu.menu_categories
|
||||
# end
|
||||
categories = menu.menu_categories
|
||||
categories = menu.menu_categories
|
||||
json.categories categories do |category|
|
||||
if category.is_available
|
||||
menu_category = MenuCategory.find_by_menu_category_id(category.id)
|
||||
if !menu_category.nil?
|
||||
json.sub_category "true"
|
||||
else
|
||||
json.sub_category "false"
|
||||
end
|
||||
json.sub_category category.children.present?
|
||||
|
||||
valid_time = category.valid_time
|
||||
json.valid_time valid_time
|
||||
|
||||
json.id category.id
|
||||
json.code category.code
|
||||
json.order_by category.order_by
|
||||
@@ -34,7 +29,7 @@ if (menu.menu_categories)
|
||||
json.is_available category.is_available
|
||||
|
||||
if !order_by.nil? && order_by.value == "name"
|
||||
menu_items = MenuItem.unscoped.where("menu_category_id = ?",category.id).order("name asc")
|
||||
menu_items = category.menu_items.sort_by(&:name)
|
||||
else
|
||||
menu_items = category.menu_items
|
||||
end
|
||||
@@ -42,7 +37,68 @@ if (menu.menu_categories)
|
||||
if category.menu_items
|
||||
json.items menu_items do |item|
|
||||
if item.is_available
|
||||
json.partial! 'origami/addorders/menu_item', item: item
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item_attributes = item.item_attributes.map(&:to_s)
|
||||
attr_format = @item_attributes.select { |x| item_attributes.include?(x.id.to_s) }.group_by {|att| att.attribute_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item_options = item.item_options.map(&:to_s)
|
||||
opt_format = @item_options.select { |x| item_options.include?(x.id.to_s) }.group_by {|opt| opt.option_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||
end
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.image item.image_path.url
|
||||
json.description item.description
|
||||
json.information item.information
|
||||
json.type item.type
|
||||
json.account_id item.account_id
|
||||
json.min_qty item.min_qty
|
||||
json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets do |its|
|
||||
json.id its.id
|
||||
json.name its.name
|
||||
json.alt_name its.alt_name
|
||||
json.min_selectable_qty its.min_selectable_qty
|
||||
json.max_selectable_qty its.max_selectable_qty
|
||||
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||
end
|
||||
|
||||
json.attributes attr_format
|
||||
json.options opt_format
|
||||
|
||||
json.instances item.menu_item_instances do |is|
|
||||
if is.is_available
|
||||
# Convert id to name for attributes
|
||||
item_attributes = is.item_attributes.map(&:to_s)
|
||||
instance_attr = @item_attributes.select{ |x| item_attributes.include?(x.id.to_s) }.pluck(:name)
|
||||
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
json.is_available is.is_available
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.values instance_attr
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,18 +6,6 @@
|
||||
<!-- <h2><%= t :dashboard %></h2> -->
|
||||
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
|
||||
</div>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
|
||||
<!-- Widgets -->
|
||||
<div class="row clearfix">
|
||||
@@ -91,19 +79,19 @@
|
||||
<tr>
|
||||
<% revenue = @summ_sale.total_amount - @summ_sale.total_discount%>
|
||||
<td><%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : </td>
|
||||
<td align="right"><%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td align="right"><%= number_format( revenue, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td align="right"><%= number_format( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
<td align="right"><%= number_format( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
||||
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
<td align="right"><%= number_format( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table">
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<% if !@print_settings.nil? %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
@@ -34,7 +20,7 @@
|
||||
<span class="hidden" id ="table_id" value="<%=@table%>"><%=@table%></span>
|
||||
<span class="hidden" id="table_type" value="<%=@table%>"><%=@table%></span>
|
||||
<%end%>
|
||||
|
||||
|
||||
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||
<p class="m-l-10">Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
|
||||
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
|
||||
@@ -44,24 +30,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="order-detail-slimscroll" data-height="160">
|
||||
<div class="card-text dining">
|
||||
<span id="discount_itemsErr" style="color:red;"></span>
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<div class="card-text dining">
|
||||
<span id="discount_itemsErr" style="color:red;"></span>
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</th>
|
||||
<th class="item-attr">Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% sub_total = 0 %>
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<%
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
|
||||
%>
|
||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||
<% sub_total += sale_item.qty * sale_item.unit_price %>
|
||||
<% if sale_item.price > 0 && sale_item.status.blank? %>
|
||||
<tr class="item-row item" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
|
||||
@@ -74,19 +58,31 @@
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif sale_item.price < 0 && sale_item.status == "Discount" %>
|
||||
<tr class="item-row discount" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-account-qty" class="hidden"><%=sale_item.qty%></span>
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=sale_item.qty.abs%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
@@ -103,15 +99,15 @@
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
|
||||
<td class="item-attr">(<strong id="order-discount"><%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong>)</td>
|
||||
<td class="item-attr">(<strong id="order-discount"><%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong>)</td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -130,18 +126,18 @@
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="form-horizontal">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<input type="text" id="discount-amount" name="discount-amount" value="0" class="form-control" />
|
||||
<span id="discount-amountErr" style="color:red;"></span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<% @accounts.each do |acc| %>
|
||||
<button id="account-<%= acc.id %>" class="accounts-type btn bg-default"><%= acc.title %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -217,11 +213,11 @@
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<button id="net" class="btn bg-info fluid action-btn">Nett</button>
|
||||
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
|
||||
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
|
||||
<button id="remove-item" class="btn bg-default fluid action-btn">Clear Discount</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -235,7 +231,7 @@
|
||||
<div class="form-horizontal">
|
||||
<div class="p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-md-8 form-group">
|
||||
<div class="col-md-8 form-group">
|
||||
<div class="form-group">
|
||||
<input type="text" id="promo-code" name="promo-code" value="" class="form-control" /></span>
|
||||
</div>
|
||||
@@ -243,11 +239,11 @@
|
||||
<div class="col-md-4">
|
||||
<button id="" class="btn bg-primary btn-block action-btn">Promo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<!-- Column Three -->
|
||||
@@ -259,7 +255,7 @@
|
||||
<button id="remove-all" class="btn bg-primary btn-block action-btn">Remove All</button>
|
||||
<button id="pay-discount" class="btn bg-primary btn-block action-btn">Enter</button>
|
||||
<% if @member_discount%>
|
||||
<!-- <hr />
|
||||
<!-- <hr />
|
||||
<button id="member-discount" class="btn btn-success btn-block action-btn
|
||||
<%= @sale_data.customer.membership_id ? " " : "disabled"%>">Member Discount</button> -->
|
||||
<%end %>
|
||||
@@ -270,6 +266,11 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
var totalAmount = <%= sub_total %>;
|
||||
var totalDiscount = <%= @sale_data.total_discount %>
|
||||
var precision = <%= precision %>;
|
||||
var originalAmount = totalAmount;
|
||||
var originalDiscount = totalDiscount;
|
||||
$(document).ready(function(){
|
||||
setHeaderBreadCrumb(_DISCOUNTS_);
|
||||
/* check webview loaded*/
|
||||
@@ -293,17 +294,17 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value=0;
|
||||
var original_value = 0;
|
||||
original_value = $('#discount-amount').val();
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('#discount-amount').val(input_value);
|
||||
if (parseFloat(original_value) == 0){
|
||||
$('#discount-amount').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('#discount-amount').val(original_value + '' + input_value);
|
||||
$('#discount-amount').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
@@ -313,10 +314,10 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
break;
|
||||
case 'del' :
|
||||
var discount_text=$('#discount-amount').val();
|
||||
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
|
||||
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
case 'clr':
|
||||
$('#discount-amount').val("0.0");
|
||||
$('#discount-amount').val("0");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
@@ -326,28 +327,12 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
});
|
||||
|
||||
// Select Sale Item
|
||||
$('.item-row').on('click',function(){
|
||||
$('#order-items-table').on('click', '.item-row', function(){
|
||||
if($(this).hasClass('selected-item') == true){
|
||||
$(this).removeClass('selected-item');
|
||||
}
|
||||
else {
|
||||
if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){
|
||||
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Select discount-item
|
||||
$('#order-items-table tbody').on('click', '.discount-item-row',function(){
|
||||
if($(this).hasClass('selected-item') == true){
|
||||
$(this).removeClass('selected-item');
|
||||
}
|
||||
else {
|
||||
if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){
|
||||
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -374,7 +359,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate Net Discount for Payment
|
||||
@@ -382,9 +367,9 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_value = $('#discount-amount').val();
|
||||
var sub_total = parseFloat($('#order-sub-total').text());
|
||||
var sub_total = totalAmount;
|
||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||
|
||||
|
||||
if(discount_value!=""){
|
||||
if(discount_value > 0){
|
||||
if(parseFloat(discount_value) > sub_total){
|
||||
@@ -393,7 +378,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
}else{
|
||||
$("#discount-amountErr").html("");
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
var sale_items = get_selected_sale_items();
|
||||
|
||||
// Selected Account
|
||||
var account_types = get_selected_account_types();
|
||||
@@ -401,9 +386,9 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
if(sale_items.length == 0 && account_types.length == 0){
|
||||
calculate_overall_discount(0, discount_value);
|
||||
}
|
||||
else {
|
||||
calculate_item_discount(0, discount_value, sale_items, account_types);
|
||||
}
|
||||
else if(sale_items.length > 0){
|
||||
calculate_item_discount(0, discount_value, sale_items, account_types);
|
||||
}
|
||||
|
||||
// Remove Selection
|
||||
selection_remove();
|
||||
@@ -414,7 +399,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
}else{
|
||||
$("#discount-amountErr").html("can't be blank");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Calculate Percentage Discount for Payment
|
||||
@@ -424,34 +409,43 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
var discount_value = $('#discount-amount').val();
|
||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
// Selected Account
|
||||
var account_types = get_selected_account_types();
|
||||
|
||||
if(sale_items.length == 0 && account_types.length == 0){
|
||||
calculate_overall_discount(1, discount_value);
|
||||
}
|
||||
else {
|
||||
calculate_item_discount(1, discount_value, sale_items, account_types);
|
||||
if(discount_value!=""){
|
||||
if(discount_value > 0){
|
||||
$("#discount-amountErr").val("");
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
// Selected Account
|
||||
var account_types = get_selected_account_types();
|
||||
|
||||
if(sale_items.length == 0 && account_types.length == 0){
|
||||
calculate_overall_discount(1, discount_value);
|
||||
} else if(sale_items.length > 0){
|
||||
calculate_item_discount(1, discount_value, sale_items, account_types);
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("Discount must be greater than 0!");
|
||||
}
|
||||
}else{
|
||||
$("#discount-amountErr").html("can't be blank");
|
||||
}
|
||||
|
||||
// Remove Selection
|
||||
selection_remove();
|
||||
selection_remove();
|
||||
});
|
||||
|
||||
// Remove selected discount items
|
||||
$("#remove-item").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
var total = 0;
|
||||
// var total = 0;
|
||||
|
||||
$('.discount-item-row.selected-item').each(function(i){
|
||||
var amount = parseFloat($(this).find('#item-total-price').text());
|
||||
total = total + Math.abs(amount);
|
||||
$('.item-row.new-discount').each(function(i){
|
||||
// total = total + Math.abs(amount);
|
||||
$(this).remove();
|
||||
});
|
||||
$("#order-sub-total").text(origin_sub_total + total);
|
||||
|
||||
$("#order-sub-total").text(originalAmount.toFixed(<%= precision.to_i %>));
|
||||
$("#order-discount").text(originalDiscount.toFixed(<%= precision.to_i %>));
|
||||
});
|
||||
|
||||
// Pay Discount for Payment
|
||||
@@ -462,10 +456,10 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
}
|
||||
$("#loading_wrapper").show();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = JSON.stringify(get_discount_item_rows());
|
||||
var overall_discount = $("#order-discount").text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||
var discount_items = JSON.stringify(get_new_discount_item_rows());
|
||||
var overall_discount = totalDiscount;
|
||||
var sub_total = totalAmount;
|
||||
var ajax_url = "/origami/" + sale_id + "/discount";
|
||||
|
||||
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
|
||||
|
||||
@@ -473,8 +467,8 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
$("#loading_wrapper").hide();
|
||||
success:function(result){
|
||||
$("#loading_wrapper").hide();
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: result.status,
|
||||
@@ -489,7 +483,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -500,13 +494,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = [];
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
if(sale_items.length == 0){
|
||||
//swal("Information!", "You have no selected item!");
|
||||
swal ( "Oops" , "You have no selected item!" , "error" );
|
||||
return;
|
||||
}
|
||||
var sale_items = get_selected_discount_items();
|
||||
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(sale_items[i].price < 0){
|
||||
@@ -514,7 +502,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
}
|
||||
else {
|
||||
swal ("Oops" , "You have no selected item!" , "error" );
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +527,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -566,7 +554,7 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -575,8 +563,8 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
$("#member-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var ajax_url = "/origami/" + sale_id + "/member_discount";
|
||||
var sub_total = totalAmount;
|
||||
var ajax_url = "/origami/" + sale_id + "/member_discount";
|
||||
|
||||
// Selected Account
|
||||
//var account_types = JSON.stringify(get_selected_account_types());
|
||||
@@ -618,96 +606,93 @@ var cashier_type = "<%= @cashier_type %>";
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});//end member discount
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
function selection_remove(){
|
||||
$(".item-row").removeClass("selected-item");
|
||||
$(".discount_item_row").removeClass("selected-item");
|
||||
$(".accounts-type").removeClass("selected-account");
|
||||
}
|
||||
|
||||
/* Get Item rows but not discount*/
|
||||
function get_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.item-row').not('.discount-item-row').each(function(i){
|
||||
var sale_items = [];
|
||||
$('.item-row.item').not('.discount').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id').substr(0,16);
|
||||
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
|
||||
sale_item.account_id = $(this).find('#item-account-type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
function get_discount_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.discount-item-row').each(function(i){
|
||||
function get_new_discount_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.item-row.new-discount').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.account_id = $(this).find('#item_account_type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
// function get_selected_discount_items(){
|
||||
// var sale_items = [];
|
||||
// $('.discount-item-row').hasClass('.selected-item').each(function(i){
|
||||
// var sale_item = {};
|
||||
// sale_item.id = $(this).attr('id');
|
||||
// sale_item.name = $(this).find('#item-name-price').text();
|
||||
// sale_item.account_id = $(this).find('#item_account_type').text();
|
||||
// sale_item.price = $(this).find('#item-total-price').text();
|
||||
// sale_items.push(sale_item);
|
||||
// });
|
||||
// return sale_items;
|
||||
// }
|
||||
function get_selected_discount_items(){
|
||||
var sale_items = [];
|
||||
$('.item-row.discount.selected-item').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.account_id = $(this).find('#item_account_type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get Selected Sale Item's ID and Price */
|
||||
function get_selected_sale_items(){
|
||||
var sale_items = [];
|
||||
$('.item-row.selected-item').each(function(i){
|
||||
var sale_items = [];
|
||||
$('.item-row.item.selected-item').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id').substr(0,16);
|
||||
sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
|
||||
sale_item.account_id = $(this).find('#item-account-type').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
/* Get Selected Accounts ID and Price */
|
||||
function get_selected_account_types(){
|
||||
function get_selected_account_types(){
|
||||
var account_types = [];
|
||||
|
||||
$('.selected-account').each(function(i){
|
||||
var account= {};
|
||||
account.id = $(this).attr('id').substr(8);
|
||||
account.name = $(this).text();
|
||||
account.name = $(this).text();
|
||||
account_types.push(account);
|
||||
});
|
||||
});
|
||||
return account_types;
|
||||
}
|
||||
|
||||
/* Calculate Overall Discount*/
|
||||
function calculate_overall_discount(type, amount){
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
var dis_amount = 0;
|
||||
var sub_total = 0;
|
||||
var sub_total = totalAmount;
|
||||
var total_discount = 0;
|
||||
|
||||
// For Net Pay
|
||||
if(type == 0){
|
||||
total_discount = amount;
|
||||
total_discount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
|
||||
// For Percentage Pay
|
||||
@@ -719,57 +704,45 @@ function calculate_overall_discount(type, amount){
|
||||
type: "error",
|
||||
confirmButtonText: 'OK',
|
||||
confirmButtonColor:"red"
|
||||
});
|
||||
});
|
||||
}
|
||||
else{
|
||||
total_discount = (origin_sub_total * amount)/100;
|
||||
total_discount = Math.round(sub_total * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
}
|
||||
|
||||
totalDiscount = total_discount
|
||||
$("#order-discount").text(parseFloat(total_discount).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
|
||||
/* Calculate Items Discount*/
|
||||
function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
var origin_sub_total = parseFloat($("#order-sub-total").text());
|
||||
var origin_sub_total = totalAmount;
|
||||
var dis_amount = 0;
|
||||
var sub_total = 0;
|
||||
var total_discount = 0;
|
||||
var arrItemName = "";
|
||||
|
||||
$("#discount_itemsErr").html("");
|
||||
$("#discount-amountErr").html("");
|
||||
// For Net Pay
|
||||
if(origin_sub_total > 0){
|
||||
if(type == 0){
|
||||
dis_amount = (0 - amount);
|
||||
dis_amount = -Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
|
||||
arrItemName += ", " + sale_items[i].name;
|
||||
}else{
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
total_discount = parseFloat(total_discount) + parseFloat(amount);
|
||||
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
|
||||
arrItemName += ", " + sale_items[i].name;
|
||||
}else{
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
total_discount = parseFloat(total_discount) + parseFloat(amount);
|
||||
|
||||
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
}else{
|
||||
total_discount = parseFloat(total_discount) - parseFloat(amount);
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
}else{
|
||||
total_discount = parseFloat(total_discount) - parseFloat(amount);
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -782,30 +755,12 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
}else{
|
||||
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// No Needs For Auto Selected
|
||||
// if(account_types.length > 0){
|
||||
// var item_rows=get_item_rows();
|
||||
// if(item_rows.length > 0){
|
||||
// for(var k=0; k < item_rows.length; k++){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(item_rows[k].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// alert("No Items!");
|
||||
// }
|
||||
// }
|
||||
|
||||
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
|
||||
totalAmount = sub_total
|
||||
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
|
||||
// For Percentage Pay
|
||||
@@ -817,27 +772,15 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
type: "error",
|
||||
confirmButtonText: 'OK',
|
||||
confirmButtonColor:"red"
|
||||
});
|
||||
});
|
||||
}
|
||||
else{
|
||||
// Check sale items exists
|
||||
if(sale_items.length > 0){
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
// if(account_types.length > 0){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(sale_items[i].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + dis_amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
dis_amount = 0 - ((sale_items[i].price * amount)/100);
|
||||
dis_amount = -Math.round(sale_items[i].price * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
|
||||
|
||||
|
||||
total_discount = total_discount + dis_amount;
|
||||
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
|
||||
$("#order-items-table tbody").append(discount_item_row);
|
||||
@@ -845,40 +788,18 @@ function calculate_item_discount(type, amount, sale_items, account_types){
|
||||
total_discount = total_discount - dis_amount;
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
// }
|
||||
}
|
||||
sub_total = parseFloat(origin_sub_total) + parseFloat(total_discount);
|
||||
totalAmount = sub_total
|
||||
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
|
||||
}
|
||||
}
|
||||
// No Needs For Auto Selected
|
||||
// Check account types exists
|
||||
// if(account_types.length > 0){
|
||||
// var item_rows=get_item_rows();
|
||||
// console.log(account_types);
|
||||
// if(item_rows.length > 0){
|
||||
// for(var k=0; k < item_rows.length; k++){
|
||||
// for(var j=0; j < account_types.length; j++){
|
||||
// if(item_rows[k].account_id == account_types[j].id){
|
||||
// // Discount Items
|
||||
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
|
||||
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
|
||||
// $("#order-items-table tbody").append(discount_item_row);
|
||||
// total_discount = total_discount + dis_amount;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// alert("No Items!");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
|
||||
|
||||
}else{
|
||||
$("#discount-amountErr").html("Discount is greater than sub total!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function item_row_template(type, item, discount_amount, amount){
|
||||
@@ -886,25 +807,25 @@ function item_row_template(type, item, discount_amount, amount){
|
||||
if(type == 1){
|
||||
dis_str = dis_str + "(" + amount + "%)"
|
||||
}
|
||||
var discount_item_row = "<tr class='discount-item-row' id='" + item.id + "'>" +
|
||||
"<td style='width: 60%; text-align: left;'>" +
|
||||
"<span id='item_account_type' class='hidden'>" +
|
||||
var discount_item_row = "<tr class='item-row new-discount' id='" + item.id + "'>" +
|
||||
"<td style='width: 60%; text-align: left;'>" +
|
||||
"<span id='item_account_type' class='hidden'>" +
|
||||
item.account_id +
|
||||
"</span>" +
|
||||
"<span id='item-name-price'>" +
|
||||
"</span>" +
|
||||
"<span id='item-name-price'>" +
|
||||
item.name + dis_str +
|
||||
"</span>" +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-qty'>1</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-total-price'>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-total-price'>" +
|
||||
discount_amount +
|
||||
"</span>" +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
return discount_item_row;
|
||||
return discount_item_row;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<% if !@print_settings.nil? %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% end %>
|
||||
<div class="row clearfix">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
@@ -57,14 +43,14 @@
|
||||
<!--- Panel 1 - Table Orders -->
|
||||
<div class="tab-pane dining active " id="tables" role="tabpanel">
|
||||
<div class="card-columns">
|
||||
<% @tables.each do |table| %>
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
<% if table.get_booking.nil? %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
@@ -72,12 +58,12 @@
|
||||
<div style="font-size:12px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% else %>
|
||||
<% if table.get_checkout_booking.nil? %>
|
||||
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% else %>
|
||||
<% else %>
|
||||
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= table.name %> <br>
|
||||
<%= table.zone.name %>
|
||||
@@ -111,7 +97,7 @@
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -123,7 +109,7 @@
|
||||
<% end %>
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %>"> new</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -132,8 +118,8 @@
|
||||
<div class="card rooms green text-white table_<%= room.id %>" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %> <br>
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %> hide">
|
||||
<%= room.zone.name %>
|
||||
<span class="float-right font-12 new_text_<%= room.id %> hide">
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -160,8 +146,8 @@
|
||||
<% else %>
|
||||
<% order_status = order.status %>
|
||||
<% end %>
|
||||
<%= order.order_id %>
|
||||
<% if !order_status.empty? %>| <%= order_status %>
|
||||
<%= order.order_id %>
|
||||
<% if !order_status.empty? %>| <%= order_status %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -193,7 +179,7 @@
|
||||
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
||||
</thead>
|
||||
<tbody class="tbd_credit_lists"></tbody>
|
||||
@@ -245,7 +231,7 @@
|
||||
<% else %>
|
||||
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="row p-l-5 p-r-5">
|
||||
@@ -335,8 +321,8 @@
|
||||
<% end %>
|
||||
|
||||
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
|
||||
<br>
|
||||
<span class="font-13">
|
||||
<%= item_instance["item_instance_name"] %>
|
||||
@@ -345,17 +331,17 @@
|
||||
<br><span class="font-13"> <%= set_item_option %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end
|
||||
</span>
|
||||
<% end
|
||||
sub_total += set_item_prices
|
||||
end %>
|
||||
</td>
|
||||
<td class='item-attr'><%= order_item.qty %></td>
|
||||
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -364,7 +350,7 @@
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="sub-total"><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
<td class="item-attr"><strong id="sub-total"><%= number_format(sub_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
|
||||
@@ -373,7 +359,7 @@
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
|
||||
<td class="item-attr"><strong id="order-discount">(<%= number_with_precision(@obj_sale.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= number_format(@obj_sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</strong></td>
|
||||
</tr>
|
||||
<% if @status_sale == "sale" %>
|
||||
<tr>
|
||||
@@ -396,15 +382,15 @@
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@obj_sale.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_format(@obj_sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= number_with_precision(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= number_format(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_with_precision(@obj_sale.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_format(@obj_sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="rebate_amount"></tr>
|
||||
@@ -431,10 +417,10 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if !order_item.set_menu_items.nil?
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
<% if !order_item.set_menu_items.nil?
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
|
||||
%>
|
||||
%>
|
||||
<br><span class="font-13">
|
||||
<%= item_instance["item_instance_name"] %>
|
||||
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
|
||||
@@ -444,8 +430,8 @@
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end
|
||||
</span>
|
||||
<% end
|
||||
sub_total += set_item_prices
|
||||
end %>
|
||||
</td>
|
||||
@@ -456,7 +442,7 @@
|
||||
end
|
||||
%>
|
||||
</table> -->
|
||||
|
||||
|
||||
<!-- <button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button> -->
|
||||
<% end %>
|
||||
<% if @sale_array.size > 1 %>
|
||||
@@ -496,7 +482,7 @@
|
||||
<!-- <a href="<%=origami_second_display_index_path%>" target="_blank" id="second_view" class="btn action-btn bg-blue waves-effect" style="height: 45px">Customer View</a> -->
|
||||
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
|
||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
||||
<% if @dining.status != "available" %>
|
||||
<% if @dining.status != "available" %>
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<%if !@order_items.empty? %>
|
||||
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
|
||||
@@ -526,7 +512,7 @@
|
||||
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button> -->
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
|
||||
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<% else %>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
|
||||
@@ -535,9 +521,9 @@
|
||||
<% end %>
|
||||
<% if current_login_employee.role != "waiter" %>
|
||||
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
|
||||
|
||||
|
||||
<% if !@split_bill.nil? %>
|
||||
<% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %>
|
||||
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
|
||||
@@ -545,19 +531,19 @@
|
||||
<% end %>
|
||||
<% if current_login_employee.role != "waiter" %>
|
||||
<!-- first bill not used in cloud -->
|
||||
|
||||
|
||||
<%if @membership.discount && @obj_sale.customer.membership_id %>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal" data-order="<%= existing_order %>">First Bill</button>
|
||||
<%else%>
|
||||
<button type="button" id="first_bill" data-order="<%= existing_order %>" class="btn btn-block bg-blue waves-effect">First Bill</button>
|
||||
<%end%>
|
||||
|
||||
<%end%>
|
||||
|
||||
<button type="button" id="pay" data-order="<%= existing_order %>" class="btn btn-block bg-blue waves-effect">Pay</button>
|
||||
|
||||
<!-- <button type="button" id="kbz_query" data-order="<%= existing_order %>" class="btn btn-block bg-blue waves-effect">KBZ Query</button> -->
|
||||
|
||||
<!--<% if current_login_employee.role != "waiter" %>
|
||||
<button type="button" class="btn action-btn bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
|
||||
<button type="button" class="btn action-btn bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
|
||||
<% end %>-->
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -583,7 +569,7 @@
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<button class='btn btn-md waves-effect btn-link payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
|
||||
</div>
|
||||
|
||||
|
||||
<% @payment_methods.each_with_index do |pay, pay_index| %>
|
||||
<%if (pay_index+1)%3 == 0 %>
|
||||
<div class="row clearfix"></div>
|
||||
@@ -625,7 +611,7 @@
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -638,7 +624,7 @@
|
||||
<h4 class="modal-title" id="AccessCodeModalLabel">Enter Access Code</h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
|
||||
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
|
||||
<input type="password" id="access_code" class="access_code form-control col-md-12 ">
|
||||
<div class="row bottom p-l-15 p-r-15 m-t-10">
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="1" data-type="num">1</div>
|
||||
@@ -657,7 +643,7 @@
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 access_number border-top border-left orange" data-type="clr">Clr</div>
|
||||
<div class="col-md-3 access_number ok border-top border-left blue" data-type="ok" data-action="">OK</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -690,7 +676,7 @@
|
||||
count += 1 %>
|
||||
|
||||
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
|
||||
<td><%= count %></td>
|
||||
<td><%= count %></td>
|
||||
<td class='item-name'>
|
||||
<%= order_item.item_name %>
|
||||
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
|
||||
@@ -701,10 +687,10 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if !order_item.set_menu_items.nil?
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
<% if !order_item.set_menu_items.nil?
|
||||
JSON.parse(order_item.set_menu_items).each do |item_instance|
|
||||
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
|
||||
%>
|
||||
%>
|
||||
<br><span class="font-13">
|
||||
<%= item_instance["item_instance_name"] %>
|
||||
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
|
||||
@@ -714,8 +700,8 @@
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end
|
||||
</span>
|
||||
<% end
|
||||
sub_total += set_item_prices
|
||||
end %>
|
||||
</td>
|
||||
@@ -823,7 +809,7 @@
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
|
||||
|
||||
discount="<%= @membership.discount%>"
|
||||
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
if (discount) {
|
||||
@@ -887,7 +873,7 @@
|
||||
} else {
|
||||
var sale_id = "<%= @dining.id %>";
|
||||
}
|
||||
//var table_id = $('.tables').attr("data-id");
|
||||
//var table_id = $('.tables').attr("data-id");
|
||||
window.location.href = '/origami/' + sale_id +"/"+cashier_type+ "/surveys"
|
||||
});
|
||||
|
||||
@@ -989,22 +975,22 @@
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.payment_btn', function(event){
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.payment_btn', function(event){
|
||||
active = $(this).hasClass('selected-payment');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
payments = $(".payment_btn");
|
||||
|
||||
if (active) {
|
||||
if (active) {
|
||||
$(this).removeClass('selected-payment');
|
||||
}else{
|
||||
}else{
|
||||
$(this).addClass('selected-payment');
|
||||
}
|
||||
}); //End selecct attribute buttom
|
||||
@@ -1026,7 +1012,7 @@
|
||||
if(!location.pathname.includes("credit_payment")){
|
||||
calculate_member_discount(sale_id,"Cash",tax_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
|
||||
$.ajax({
|
||||
@@ -1045,7 +1031,7 @@
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function calculate_member_discount(sale_id,type,tax_type) {
|
||||
@@ -1060,10 +1046,10 @@
|
||||
url: "/origami/" + sale_id + "/member_discount",
|
||||
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
|
||||
async: false,
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
$('#pay').on('click', function () {
|
||||
@@ -1137,11 +1123,11 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
swal("Opps","There is no orders!","warning");
|
||||
}
|
||||
@@ -1151,7 +1137,7 @@
|
||||
$('#split_bills').click(function(){
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
window.location.href = '/origami/table/' + dining_id + "/" + cashier_type +"/split_bills";
|
||||
});
|
||||
});
|
||||
|
||||
$('#move').on('click', function () {
|
||||
if($('#move').is(":visible")) {
|
||||
@@ -1236,7 +1222,7 @@
|
||||
}else{
|
||||
swal("Opps","You are not authorized for void","warning")
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#commissions').on('click', function () {
|
||||
@@ -1285,7 +1271,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
swal("Opps","You are not authorized for void","warning")
|
||||
}
|
||||
@@ -1303,7 +1289,7 @@
|
||||
window.location.href = '/origami/addorders/' + dining_id;
|
||||
});
|
||||
|
||||
/* check in process */
|
||||
/* check in process */
|
||||
$('#check_in').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
|
||||
@@ -1394,7 +1380,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function check_emp_access_code(access_code,type) {
|
||||
@@ -1460,11 +1446,11 @@
|
||||
type: "POST",
|
||||
url: "/origami/payment/"+cashier_type+"/change_tax",
|
||||
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type},
|
||||
success:function(data){
|
||||
success:function(data){
|
||||
if(data.status){
|
||||
localStorage.setItem("tax_type", tax_type);
|
||||
window.location.href = '/origami/table/'+dining_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
@@ -2,20 +2,6 @@
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<% if !@print_settings.nil? %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% end %>
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||
@@ -78,9 +64,9 @@
|
||||
<% sub_total += sale_item.price%>
|
||||
<tr>
|
||||
<td><%= count %></td>
|
||||
<td class="item-name"><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%></td>
|
||||
<td class="item-name"><%=sale_item.product_name%>@<%=number_format( sale_item.unit_price, precision: precision.to_i )%></td>
|
||||
<td class="item-attr"><%=sale_item.qty%></td>
|
||||
<td class="item-attr"><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%></td>
|
||||
<td class="item-attr"><%=(number_format(sale_item.price, precision: precision.to_i ))%></td>
|
||||
</tr>
|
||||
<%end %>
|
||||
</tbody>
|
||||
@@ -93,7 +79,7 @@
|
||||
<tfooter>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total</strong></td>
|
||||
<td class="item-attr"><strong><span id="sub-total"><%=number_with_precision(sub_total, precision: precision.to_i)%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="sub-total"><%=number_format(sub_total, precision: precision.to_i)%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale_data.discount_type == 'member_discount'%>
|
||||
@@ -101,7 +87,7 @@
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>(Discount)</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
<td class="item-attr"><strong><span>(<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name">
|
||||
@@ -122,20 +108,20 @@
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong><%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||
<td class="item-attr"><strong><%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total</strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<%if @balance > 0%>
|
||||
<tr>
|
||||
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
|
||||
<td class="item-attr"><strong><span><%=number_with_precision(@balance, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span><%=number_format(@balance, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@individual_total[0].nil? %>
|
||||
@@ -149,7 +135,7 @@
|
||||
<td class="charges-name">
|
||||
<strong>Amount Due (per person)</strong>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span><%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tfooter>
|
||||
@@ -171,16 +157,16 @@
|
||||
<strong>
|
||||
<span id="grand_total" class="hidden">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% else %>
|
||||
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
</span>
|
||||
<span id="amount_due">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
<% else %>
|
||||
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
</span>
|
||||
</strong>
|
||||
@@ -190,13 +176,13 @@
|
||||
<div class="row payment cash-color p-l-5 p-r-5">
|
||||
<div class="col-md-8">Cash</div>
|
||||
<div class="col-md-4" id="cash" >
|
||||
<%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
|
||||
<%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
|
||||
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
|
||||
<div class="col-md-8">Credit</div>
|
||||
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="credit"><%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="col-md-4 hidden" id="credit">0</div>
|
||||
@@ -205,21 +191,21 @@
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments (KBZ Pay)</div>
|
||||
<div class="col-md-4" id="others">
|
||||
<%= number_with_precision(@kbz_pay_amount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
|
||||
<%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="others">
|
||||
<%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
|
||||
<%= number_format(@other, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="other_payment_amount">
|
||||
<%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
|
||||
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -231,9 +217,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MPU</div>
|
||||
<% if @other != 0.0 %>
|
||||
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 mpu is_card" id="others"><%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="others"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -242,9 +228,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<% if @ppamount != 0.0 %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -253,9 +239,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">VISA</div>
|
||||
<% if @visacount != 0.0 %>
|
||||
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 visa is_card" id="visacount"><%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="visacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -264,9 +250,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JCB</div>
|
||||
<% if @jcbcount != 0.0 %>
|
||||
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="jcbcount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -275,9 +261,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MASTER</div>
|
||||
<% if @mastercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="mastercount"><%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="mastercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
@@ -287,9 +273,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">UNIONPAY</div>
|
||||
<% if @unionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="unionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -298,9 +284,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Alipay</div>
|
||||
<% if @alipaycount != 0.0 %>
|
||||
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="alipaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="alipaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -309,9 +295,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">PAYMAL</div>
|
||||
<% if @paymalcount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="paymalcount"><%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="paymalcount"><%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="paymalcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="paymalcount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- DINGA -->
|
||||
@@ -319,9 +305,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">DINGA</div>
|
||||
<% if @dingacount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="dingacount"><%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="dingacount"><%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="dingacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="dingacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -330,9 +316,9 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JUNCTION PAY</div>
|
||||
<% if @junctionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="junctionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="junctionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -341,15 +327,15 @@
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">GIFT VOUCHER</div>
|
||||
<% if @giftvouchercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="giftvouchercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<div class="col-md-4" id="giftvouchercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong class='amount_balance'>Balance</strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<% if !@print_settings.nil? %>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% end %>
|
||||
|
||||
<div class="col-lg-4 col-md-6 col-sm-6">
|
||||
<!-- <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> -->
|
||||
@@ -89,7 +75,7 @@
|
||||
<td><%= count %></td>
|
||||
<td class='item-name'><%= sale_item.product_name %></td>
|
||||
<td class='item-attr'><%= sale_item.qty %></td>
|
||||
<td class='item-attr'><%= number_with_precision(sale_item.price, precision: precision.to_i ) %></td>
|
||||
<td class='item-attr'><%= number_format(sale_item.price, precision: precision.to_i ) %></td>
|
||||
</tr>
|
||||
<%
|
||||
# end
|
||||
@@ -108,7 +94,7 @@
|
||||
<td><%= count %></td>
|
||||
<td class='item-name'><%= order_item.item_name %></td>
|
||||
<td class='item-attr'><%= order_item.qty %></td>
|
||||
<td class='item-attr'><%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %></td>
|
||||
<td class='item-attr'><%= number_format(order_item.qty*order_item.price, precision: precision.to_i ) %></td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
@@ -124,7 +110,7 @@
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><span id="sub_total"><%= number_with_precision(sub_total, precision: precision.to_i ) %></span></strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><span id="sub_total"><%= number_format(sub_total, precision: precision.to_i ) %></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale.discount_type == 'member_discount'%>
|
||||
@@ -132,19 +118,19 @@
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= number_with_precision(@sale.total_discount, precision: precision.to_i ) rescue 0%>)</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= number_format(@sale.total_discount, precision: precision.to_i ) rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale.total_tax, precision: precision.to_i ) rescue 0%></strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_format(@sale.total_tax, precision: precision.to_i ) rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= number_with_precision(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%></strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= number_format(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><span id="grand_total"><%= number_with_precision(@sale.grand_total, precision: precision.to_i ) rescue 0%></span></strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><span id="grand_total"><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue 0%></span></strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
</table>
|
||||
@@ -163,7 +149,7 @@
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
|
||||
<%else%>
|
||||
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<% end %>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
|
||||
|
||||
@@ -173,7 +159,7 @@
|
||||
<% else %>
|
||||
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
|
||||
<button type="button" data-toggle="modal" data-target="#voidModal" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -197,8 +183,8 @@
|
||||
<%= pay.payment_method %>
|
||||
</option>
|
||||
<%end %>
|
||||
|
||||
</select>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
@@ -228,7 +214,7 @@
|
||||
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -252,7 +238,7 @@
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -266,7 +252,7 @@
|
||||
<h4 class="modal-title" id="AccessCodeModalLabel">Enter Access Code</h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
|
||||
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
|
||||
<input type="password" id="access_code" class="access_code form-control col-md-12 ">
|
||||
<div class="row bottom p-l-15 p-r-15 m-t-10">
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="1" data-type="num">1</div>
|
||||
@@ -285,7 +271,7 @@
|
||||
<div class="col-md-3 access_number border-top border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-3 access_number border-top border-left orange" data-type="clr">Clr</div>
|
||||
<div class="col-md-3 access_number ok border-top border-left blue" data-type="ok" data-action="">OK</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -298,7 +284,7 @@ $(document).ready(function(){
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
|
||||
|
||||
discount="<%= @membership.discount%>"
|
||||
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
if (discount) {
|
||||
@@ -339,7 +325,7 @@ $(document).ready(function(){
|
||||
// }
|
||||
// location.reload();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// Print for first bill
|
||||
@@ -376,9 +362,9 @@ $(document).ready(function(){
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
@@ -389,10 +375,10 @@ $(document).ready(function(){
|
||||
if(parseInt(jQuery.inArray("Credit", type)) == -1){
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
|
||||
calculate_member_discount(sale_id,"Card");
|
||||
|
||||
|
||||
}else{
|
||||
calculate_member_discount(sale_id,"Cash");
|
||||
}
|
||||
}
|
||||
}
|
||||
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
|
||||
$.ajax({
|
||||
@@ -411,7 +397,7 @@ $(document).ready(function(){
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function calculate_member_discount(sale_id,type) {
|
||||
@@ -426,7 +412,7 @@ $(document).ready(function(){
|
||||
url: "/origami/" + sale_id + "/member_discount",
|
||||
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
|
||||
async: false,
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -439,7 +425,7 @@ $('#pay').on('click',function() {
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: url,
|
||||
// success:function(result){
|
||||
// success:function(result){
|
||||
// // console.log(result);
|
||||
// }
|
||||
// });
|
||||
@@ -453,7 +439,7 @@ $('#back').on('click',function(){
|
||||
}else{
|
||||
window.location.href = '/origami/table/<%= @table.id %>';
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
@@ -487,7 +473,7 @@ $('#void').on('click',function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
swal("Opps","You are not authorized for void","warning");
|
||||
}
|
||||
@@ -505,12 +491,12 @@ $('#foc').click(function() {
|
||||
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total,'remark':remark,'type':'cashier','access_code':access_code };
|
||||
// console.log(sale_id);
|
||||
if(sale_id != ''){
|
||||
if ($(this).attr('active')=== "true") {
|
||||
if ($(this).attr('active')=== "true") {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/payment/cashier/foc",
|
||||
data: params,
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
if (cash >= 0) {
|
||||
swal({
|
||||
title: "Information!",
|
||||
@@ -549,7 +535,7 @@ $(document).on('click', '.access_modal', function(event){
|
||||
if (result.status == true) {
|
||||
createAccessCode(code);
|
||||
if (type == "edit") {
|
||||
|
||||
|
||||
}else if(type == "void"){
|
||||
$('#AccessCodeModal').modal('hide');
|
||||
$('#voidModal').modal('show');
|
||||
|
||||
@@ -43,18 +43,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
@@ -65,9 +53,9 @@
|
||||
<td><%= result.sale_item_id rescue '-' %></td>
|
||||
<td><%= result.commissioner.name rescue '-' %></td>
|
||||
<td><%= result.porduct_name rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.qty.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.price.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.amount.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.qty.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.price.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.amount.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
|
||||
</tr>
|
||||
<% total_qty += result.qty.to_f %>
|
||||
@@ -77,9 +65,9 @@
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="4"></td>
|
||||
<td><b><%= number_with_precision(total_qty, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_with_precision(total_price, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_with_precision(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(total_qty, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(total_price, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-'%></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -92,5 +80,3 @@
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -17,24 +17,12 @@
|
||||
<!-- <div class="row"> -->
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_credit_payment_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card ">
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.blank? %>
|
||||
|
||||
<table class="table table-striped" border="0">
|
||||
@@ -43,7 +31,7 @@
|
||||
<tr>
|
||||
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
@@ -61,10 +49,10 @@
|
||||
<tbody>
|
||||
<% total_credit_amount = 0
|
||||
total_credit_payment = 0 %>
|
||||
<% @sale_data.each do |credit| %>
|
||||
<% @sale_data.each do |credit| %>
|
||||
<% total_credit_amount += credit.payment_amount %>
|
||||
<% total_credit_payment += credit.credit_payment %>
|
||||
<tr>
|
||||
<tr>
|
||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||
<% else %>
|
||||
@@ -78,11 +66,11 @@
|
||||
Quick Service
|
||||
<% else %>
|
||||
Online Order
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= credit.cashier_name rescue '-' %></td>
|
||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
||||
<td><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= credit.customer_name rescue '-' %></td>
|
||||
<td><%= number_format(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td>
|
||||
<%if credit.credit_payment_shift_name == '-' %>
|
||||
<%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%>
|
||||
@@ -92,13 +80,16 @@
|
||||
</td>
|
||||
<td><%= credit.credit_payment_receipt_date rescue '-' %></td>
|
||||
<td><%= credit.credit_payment_cashier_name rescue '-' %></td>
|
||||
<td><%= number_with_precision(credit.credit_payment, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(credit.credit_payment, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"><b>Total</b></td>
|
||||
<td colspan="4"><b><%= number_with_precision(total_credit_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(total_credit_payment, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(total_credit_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b><%= number_format(total_credit_payment, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -112,20 +103,20 @@
|
||||
var check_arr = [];
|
||||
search_by_period();
|
||||
$('#sel_period').change(function(){
|
||||
|
||||
|
||||
search_by_period();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
@@ -140,32 +131,32 @@
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
|
||||
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
to = $("#to").val();
|
||||
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
|
||||
check_arr.push(to);
|
||||
|
||||
|
||||
console.log(check_arr.length)
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function show_shift_name(period,period_type,from,to,shift_item){
|
||||
var shift = $('#shift_name');
|
||||
if (from == '' && to == '') {
|
||||
@@ -173,18 +164,18 @@
|
||||
to = $("#to").val();
|
||||
}
|
||||
shift.empty();
|
||||
|
||||
|
||||
var str = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '<%= params[:shift_name] rescue '-'%>';
|
||||
|
||||
url = '<%= reports_get_shift_by_date_path %>';
|
||||
|
||||
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
var shift_id = data.message[index].shift_id ;
|
||||
@@ -193,18 +184,18 @@
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
}else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<tr>
|
||||
<th colspan="7"><%= t("views.right_panel.detail.from_date") %> : <%= params[:from] rescue '-'%> , <%= t("views.right_panel.detail.to_date") %> : <%= params[:to] rescue '-'%></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||
<th> <%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
@@ -33,10 +33,10 @@
|
||||
<tbody>
|
||||
<% total_credit_amount = 0
|
||||
total_credit_payment = 0 %>
|
||||
<% @sale_data.each do |credit| %>
|
||||
<% @sale_data.each do |credit| %>
|
||||
<% total_credit_amount += credit.payment_amount
|
||||
total_credit_payment += credit.credit_payment %>
|
||||
<tr>
|
||||
<tr>
|
||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||
<% else %>
|
||||
@@ -50,10 +50,10 @@
|
||||
Quick Service
|
||||
<% else %>
|
||||
Online Order
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= credit.cashier_name rescue '-' %></td>
|
||||
<td><%= credit.sale.customer.name rescue '-' %></td>
|
||||
<td><%= credit.customer_name rescue '-' %></td>
|
||||
<td><%= credit.payment_amount rescue '-' %></td>
|
||||
<td>
|
||||
<%if credit.credit_payment_shift_name == '-' %>
|
||||
@@ -69,7 +69,10 @@
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"><b>Total</b></td>
|
||||
<td colspan="4"><b><%= total_credit_amount rescue '-' %></b></td>
|
||||
<td><b><%= total_credit_amount rescue '-' %></b></td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b><%= total_credit_payment rescue '-' %></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -78,4 +81,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -24,14 +24,15 @@
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="18"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
<th colspan="<%= column_count = @payment_methods.length + 8 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
</tr>
|
||||
<% @count = 1 %>
|
||||
<% @payment_methods.each_slice(10) do |slice| %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% alph = "A" %>
|
||||
<% @count = 1 %>
|
||||
|
||||
<% slice.each do |payment_method| %>
|
||||
<th style="text-align:center;">
|
||||
<%= alph %>
|
||||
@@ -45,7 +46,6 @@
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||
@@ -126,20 +126,7 @@
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.empty? %>
|
||||
|
||||
<% unless @sale_data.blank? %>
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
<% mpu = 0 %>
|
||||
@@ -188,50 +175,50 @@
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_precision(sale[:void_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='color:red;text-align:right;'><%= number_format(sale[:void_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:foc_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
<td style='text-align:right;'>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(sale[:grand_total], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
</tr>
|
||||
<% count = count + 1 %>
|
||||
@@ -243,92 +230,93 @@
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end%>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<% if !request.user_agent.include? "Mobile" %>
|
||||
<% colspan += 1 %>
|
||||
<% end %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_precision(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_precision(void, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='color:red;text-align:right;'><%= number_format(void, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_format(grand_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
</tr>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= column_count %>"> </td>
|
||||
</tr>
|
||||
<% total_tax = 0 %>
|
||||
<% net = 0 %>
|
||||
<% unless @tax.empty? %>
|
||||
<% unless @tax.blank? %>
|
||||
<% @tax.each do |tax|
|
||||
total_tax += tax.tax_amount.to_f %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
<td colspan="2" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -338,8 +326,7 @@
|
||||
<% net = net - total_tax %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td style='text-align:right;'><%= number_with_precision(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
<td colspan="2" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% end %>
|
||||
|
||||
@@ -10,14 +10,13 @@
|
||||
<div class="card" style="width:129%;">
|
||||
<div class="body table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="15"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
<th colspan="<%= column_count = @payment_methods.length + 8 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<th style='text-align:center;' class='mobile'><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||
<% end %>
|
||||
@@ -53,30 +52,19 @@
|
||||
<% end %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
||||
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.empty? %>
|
||||
<% unless @sale_data.blank? %>
|
||||
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
@@ -97,8 +85,8 @@
|
||||
<% discount = 0 %>
|
||||
<% kbzpay = 0 %>
|
||||
<% total = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
<% count = 1 %> <% rounding_adj = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% void += sale[:void_amount] %>
|
||||
@@ -114,18 +102,17 @@
|
||||
<% giftvoucher += sale[:giftvoucher_amount] %>
|
||||
<% paypar += sale[:paypar_amount] %>
|
||||
<% cash += sale[:cash_amount]-sale[:total_change_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% kbzpay += sale[:kbzpay_amount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||
<tr>
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), delimiter => ',') rescue '-'%></td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<% end %>
|
||||
@@ -145,7 +132,7 @@
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_with_precision(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]),delimiter => ',') rescue '-'%></td>
|
||||
@@ -161,87 +148,90 @@
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), delimiter: delimiter) rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]),delimiter => ',') rescue '-'%></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), delimiter => ',') rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(sale[:grand_total].to_f + sale[:rounding_adj].to_f ,delimiter => ',') rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f),delimiter => ',') rescue '-'%></td>
|
||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(sale[:grand_total].to_f + sale[:rounding_adj].to_f ,delimiter => ',') rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]),delimiter => ',') rescue '-'%></td>
|
||||
|
||||
</tr>
|
||||
<% count = count + 1 %>
|
||||
<% end %>
|
||||
<% colspan = 7 %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="3" style='text-align:center;'>Total</td>
|
||||
<td colspan="2" style='text-align:center;'><b>Total</b></td>
|
||||
<% if @payment_methods.include? ("MPU") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",mpu),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Master") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",master),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("VISA") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa), delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",visa), delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JCB") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",jcb),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",unionpay),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",unionpay),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Alipay") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",alipay),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",alipay),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("KBZPay") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",kbzpay),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",kbzpay),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("PAYMAL") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paymal),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",paymal),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("DINGA") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",dinga),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",dinga),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("JunctionPay") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",junctionpay),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",junctionpay),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<% if @payment_methods.include? ("Redeem") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",paypar),delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), delimiter => ',') rescue '-'%></td>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",giftvoucher), delimiter => ',') rescue '-'%></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(discount,delimiter => ',') rescue '-'%>)</td>
|
||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(total,delimiter => ',') rescue '-'%></td> -->
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",cash),delimiter => ',') rescue '-'%></b></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",credit),delimiter => ',') rescue '-'%></b></td>
|
||||
<td style='color:red;text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",void),delimiter => ',') rescue '-'%></b></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",foc), delimiter => ',') rescue '-'%></b></td>
|
||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||
<% colspan += 1 %>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",giftvoucher), delimiter => ',') rescue '-'%></b></td>
|
||||
<% end %>
|
||||
<td style='text-align:right;'><b>(<%= number_with_delimiter(discount,delimiter => ',') rescue '-'%>)</b></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></b></td>
|
||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",grand_total),delimiter => ',') rescue '-'%></b></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="<%= column_count %>"> </td>
|
||||
</tr>
|
||||
<% total_tax = 0 %>
|
||||
<% net = 0 %>
|
||||
<% unless @tax.empty? %>
|
||||
<% @tax.each do |tax|
|
||||
<% unless @tax.blank? %>
|
||||
<% @tax.each do |tax|
|
||||
total_tax += tax.tax_amount.to_f %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount),delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><b><%= tax.tax_name rescue '-'%></b></td>
|
||||
<td colspan="2" style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount),delimiter => ',') rescue '-'%></b></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -250,9 +240,8 @@
|
||||
<% net = net - rounding_adj%>
|
||||
<% net = net - total_tax %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net),delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
<td colspan="<%= colspan %>" style='text-align:right;'><b><%= t("views.right_panel.detail.net_amount") %></b></td>
|
||||
<td colspan="2" style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",net),delimiter => ',') rescue '-'%></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% end %>
|
||||
@@ -264,4 +253,4 @@
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
<select class="form-control select" name="shift_name" id="shift_name" >
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 mbl-right-btn">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20 mbl-right-btn" style="margin-top: 4px;">
|
||||
<br>
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary float_right'>
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
<%= render :partial=>'hourly_saleitem_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_hourly_saleitem_index_path} %>
|
||||
<hr />
|
||||
<div class="text-right">
|
||||
@@ -60,18 +60,6 @@
|
||||
<% sale_item_count =sale_item_count +1 %>
|
||||
<% end %>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<!-- all total qty sum -->
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
@@ -113,8 +101,8 @@
|
||||
<td><%= sale.item_code %></td>
|
||||
<td><%= sale.product_name %></td>
|
||||
<td><%= sale.total_item.to_i %></td>
|
||||
<td><%= number_with_precision(sale.unit_price.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_with_precision(sale.grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(sale.unit_price.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(sale.grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<!-- <td><%= sale.date_format %></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -133,7 +121,7 @@
|
||||
<td style="text-align:right"> <strong>Grand Total: </strong></td>
|
||||
<td >
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= number_with_precision(grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></strong>
|
||||
<strong><%= number_format(grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></strong>
|
||||
<% grand_total = 0 %>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
@@ -5,142 +5,127 @@
|
||||
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<table class="table table-striped" border="0">
|
||||
<% time_arr = Array.new %>
|
||||
<% acc_arr = Array.new %>
|
||||
<% sale_item_count =0 %>
|
||||
<% menu_cat_arr = Array.new %>
|
||||
<% footer_arr = Array.new %>
|
||||
<% count = 0 %>
|
||||
<% waste_and_spoil_item_count = 0%>
|
||||
<% total_qty = 0 %>
|
||||
<% time_count = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if !time_arr.include?(sale.date_format) %>
|
||||
<% sale_item_count =1 %>
|
||||
<% time_count = time_count + 1 %>
|
||||
<thead>
|
||||
<td> </td>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Time :<%= sale.date_format %></strong>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3" style="text-align:right"><strong></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Menu Category</strong></td>
|
||||
<td><strong>Item Code</strong></td>
|
||||
<td><strong>Item Name</strong></td>
|
||||
<td><strong>Qty</strong></td>
|
||||
<td><strong>Price</strong></td>
|
||||
<td><strong>Total Price</strong></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<% time_arr.push(sale.date_format) %>
|
||||
<% menu_cat_arr.clear %>
|
||||
<% count = 0 %>
|
||||
<% else %>
|
||||
<% sale_item_count =sale_item_count +1 %>
|
||||
<% end %>
|
||||
<tbody>
|
||||
<!-- all total qty sum -->
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<% if sale.status_type == "foc" && sale.price > 0
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<% if sale.status_type == "Discount"
|
||||
total_qty += sale.total_item*(-1)
|
||||
end %>
|
||||
<% if sale.status_type =="promotion" && @type == "promotion"
|
||||
total_qty += sale.total_item*(-1)
|
||||
end %>
|
||||
|
||||
<table class="table table-striped" border="0">
|
||||
<% time_arr = Array.new %>
|
||||
<% acc_arr = Array.new %>
|
||||
<% sale_item_count =0 %>
|
||||
<% menu_cat_arr = Array.new %>
|
||||
<% footer_arr = Array.new %>
|
||||
<% count = 0 %>
|
||||
<% waste_and_spoil_item_count = 0%>
|
||||
<% total_qty = 0 %>
|
||||
<% time_count = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if !time_arr.include?(sale.date_format) %>
|
||||
<% sale_item_count =1 %>
|
||||
<% time_count = time_count + 1 %>
|
||||
<thead>
|
||||
<td> </td>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Time :<%= sale.date_format %></strong>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td colspan="3" style="text-align:right"><strong></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Menu Category</strong></td>
|
||||
<td><strong>Item Code</strong></td>
|
||||
<td><strong>Item Name</strong></td>
|
||||
<td><strong>Qty</strong></td>
|
||||
<td><strong>Price</strong></td>
|
||||
<td><strong>Total Price</strong></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<% time_arr.push(sale.date_format) %>
|
||||
<% menu_cat_arr.clear %>
|
||||
<% count = 0 %>
|
||||
<!-- end all total qty -->
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "promotion" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% grand_total += sale.grand_total %>
|
||||
|
||||
<% if !sale.item_code.nil?%>
|
||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||
<tr>
|
||||
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% menu_cat_arr.push(sale.menu_category_name) %>
|
||||
<% else %>
|
||||
<td> </td>
|
||||
<% end %>
|
||||
<td><%= sale.item_code %></td>
|
||||
<td><%= sale.product_name %></td>
|
||||
<td><%= sale.total_item.to_i %></td>
|
||||
<td><%= number_format(sale.unit_price.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(sale.grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<!-- <td><%= sale.date_format %></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- new tr -->
|
||||
<% count = count + 1 %>
|
||||
<% @hourly_total_qty.each do |hr| %>
|
||||
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
|
||||
<td>
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= total_qty.to_i %></strong>
|
||||
<% total_qty = 0%>
|
||||
</span></td>
|
||||
<td style="text-align:right"> <strong>Grand Total: </strong></td>
|
||||
<td >
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= number_format(grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></strong>
|
||||
<% grand_total = 0 %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% footer_arr.push(sale.sale_id) %>
|
||||
<% else %>
|
||||
<% sale_item_count =sale_item_count +1 %>
|
||||
<% end %>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<!-- all total qty sum -->
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<% if sale.status_type == "foc" && sale.price > 0
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<% if sale.status_type == "Discount"
|
||||
total_qty += sale.total_item*(-1)
|
||||
end %>
|
||||
<% if sale.status_type =="promotion" && @type == "promotion"
|
||||
total_qty += sale.total_item*(-1)
|
||||
end %>
|
||||
|
||||
<!-- end all total qty -->
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "promotion" && sale.grand_total < 0
|
||||
grand_total += sale.grand_total*(-1)
|
||||
end %>
|
||||
|
||||
<% grand_total += sale.grand_total %>
|
||||
|
||||
<% if !sale.item_code.nil?%>
|
||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||
<tr>
|
||||
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% menu_cat_arr.push(sale.menu_category_name) %>
|
||||
<% else %>
|
||||
<td> </td>
|
||||
<% end %>
|
||||
<td><%= sale.item_code %></td>
|
||||
<td><%= sale.product_name %></td>
|
||||
<td><%= sale.total_item.to_i %></td>
|
||||
<td><%= sale.unit_price.to_i %></td>
|
||||
<td><%= sale.grand_total.to_i %></td>
|
||||
<td><%= sale.date_format %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- new tr -->
|
||||
<% count = count + 1 %>
|
||||
<% @hourly_total_qty.each do |hr| %>
|
||||
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
|
||||
<td>
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= total_qty.to_i %></strong>
|
||||
<% total_qty = 0%>
|
||||
</span></td>
|
||||
<td style="text-align:right"> <strong>Grand Total: </strong></td>
|
||||
<td >
|
||||
<span class="underline" style="text-align:right">
|
||||
<strong><%= grand_total.to_i %></strong>
|
||||
<% grand_total = 0 %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% footer_arr.push(sale.sale_id) %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
<!-- <div class="row"> -->
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_order_reservation_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
@@ -33,12 +33,12 @@
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="15"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
||||
@@ -62,17 +62,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
<%
|
||||
discount_amount = 0.0
|
||||
delivery_fee = 0.0
|
||||
@@ -94,8 +83,8 @@
|
||||
%>
|
||||
<% unless @order_reservation_data.blank? %>
|
||||
<% @order_reservation_data.each do |order_reservation| %>
|
||||
<%
|
||||
provider = ""
|
||||
<%
|
||||
provider = ""
|
||||
discount_amount = order_reservation.discount_amount
|
||||
delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0
|
||||
convenience_charge = order_reservation.convenience_charge
|
||||
@@ -119,9 +108,9 @@
|
||||
total_tax += order_reservation.total_tax.to_f
|
||||
total_amount += order_reservation.total_amount.to_f
|
||||
grand_total += order_reservation.grand_total.to_f
|
||||
|
||||
total_transaction_fee += order_reservation.transaction_fee.to_f
|
||||
|
||||
|
||||
total_transaction_fee += order_reservation.transaction_fee.to_f
|
||||
|
||||
if order_reservation.provider == 'pick_up'
|
||||
provider = "Pick-Up"
|
||||
elsif order_reservation.provider == 'direct_delivery'
|
||||
@@ -147,32 +136,32 @@
|
||||
<td><%= provider%></td>
|
||||
<td><%= payment_type%></td>
|
||||
<td><%= order_reservation.payment_status%></td>
|
||||
<td><%= number_with_precision(order_reservation.total_amount, precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(discount_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(delivery_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(convenience_charge , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<!-- <td><%= number_with_precision(delivery_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(convenience_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(commercial_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td> -->
|
||||
<td><%= number_with_precision(order_reservation.total_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_with_precision(order_reservation.grand_total , precision:precision.to_i, delimiter:delimiter) rescue '0.0' %></td>
|
||||
<td><%= number_with_precision(order_reservation.transaction_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0' %></td>
|
||||
<td><%= number_format(order_reservation.total_amount, precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(discount_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(delivery_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(convenience_charge , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<!-- <td><%= number_format(delivery_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(convenience_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(commercial_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td> -->
|
||||
<td><%= number_format(order_reservation.total_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></td>
|
||||
<td><%= number_format(order_reservation.grand_total , precision:precision.to_i, delimiter:delimiter) rescue '0.0' %></td>
|
||||
<td><%= number_format(order_reservation.transaction_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0' %></td>
|
||||
</tr>
|
||||
<% end
|
||||
<% end
|
||||
end %>
|
||||
|
||||
<tr>
|
||||
<td colspan="7"><b>Total</b></td>
|
||||
<td><b><%= number_with_precision(total_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_discount_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_delivery_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_convenience_charge , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<!-- <td><b><%= number_with_precision(total_delivery_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_convenience_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_commercial_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>-->
|
||||
<td><b><%= number_with_precision(total_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(grand_total , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_with_precision(total_transaction_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_discount_amount , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_delivery_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_convenience_charge , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<!-- <td><b><%= number_format(total_delivery_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_convenience_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_commercial_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>-->
|
||||
<td><b><%= number_format(total_tax , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(grand_total , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
<td><b><%= number_format(total_transaction_fee , precision:precision.to_i, delimiter:delimiter) rescue '0.0'%></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -189,16 +178,16 @@
|
||||
$('#sel_period').change(function(){
|
||||
search_by_period();
|
||||
});
|
||||
|
||||
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
@@ -213,50 +202,50 @@
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
|
||||
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
|
||||
check_arr.push(to);
|
||||
|
||||
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function show_shift_name(period,period_type,from,to,shift_item){
|
||||
var shift = $('#shift_name');
|
||||
|
||||
|
||||
shift.empty();
|
||||
|
||||
|
||||
var str = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '<%= params[:shift_name] rescue '-'%>';
|
||||
if (from == '' && to == '') {
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
}
|
||||
url = '<%= reports_get_shift_by_order_reservation_path %>';
|
||||
|
||||
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
var shift_id = data.message[index].shift_id ;
|
||||
@@ -265,18 +254,18 @@
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
}else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -57,37 +57,25 @@
|
||||
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.empty? %>
|
||||
<tbody>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_with_precision(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -135,11 +123,11 @@
|
||||
<td><%= payment.payment_method rescue '-' %></td>
|
||||
<td><%= payment.sale.customer.name rescue '-' %></td>
|
||||
<% if payment.payment_method === 'cash' %>
|
||||
<td><%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<td><%= number_format(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<%else%>
|
||||
<td><%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<td><%= number_format(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<%end%>
|
||||
<td><%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
|
||||
</tr>
|
||||
|
||||
@@ -147,7 +135,7 @@
|
||||
<%if total>0%>
|
||||
<tr>
|
||||
<td colspan="5" style="text-align: right;"><strong >Total </strong></td>
|
||||
<td colspan="2"><strong><%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
|
||||
<td colspan="2"><strong><%=number_format(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</tbody>
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="9">
|
||||
<th colspan="9">
|
||||
<strong>
|
||||
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
|
||||
</strong>
|
||||
@@ -18,9 +18,9 @@
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="9">
|
||||
<strong><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</strong>
|
||||
</th>
|
||||
@@ -44,40 +44,28 @@
|
||||
<th><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.empty? %>
|
||||
<tbody>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_with_precision(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td> -->
|
||||
<td><%= number_format(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(sale[:giftvoucher_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -92,7 +80,7 @@
|
||||
<td colspan="7"><strong>All Payment Details</strong></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
|
||||
|
||||
<tr>
|
||||
<th> <%= t("views.right_panel.detail.shift_name") %> </th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
@@ -109,9 +97,9 @@
|
||||
<% if payment.payment_method === 'cash'
|
||||
total += payment.payment_amount - payment.change_amount
|
||||
else
|
||||
total += payment.payment_amount
|
||||
end%>
|
||||
<tr>
|
||||
total += payment.payment_amount
|
||||
end%>
|
||||
<tr>
|
||||
<% if @shift_from.nil? && @shift_to.nil? %>
|
||||
<td><%= payment.sale_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-'%></td>
|
||||
<% else %>
|
||||
@@ -122,19 +110,19 @@
|
||||
<td><%= payment.payment_method rescue '-' %></td>
|
||||
<td><%= payment.sale.customer.name rescue '-' %></td>
|
||||
<% if payment.payment_method === 'cash' %>
|
||||
<td><%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<td><%= number_format(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<%else%>
|
||||
<td><%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<td><%= number_format(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> </td>
|
||||
<%end%>
|
||||
<td><%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
|
||||
<td><%= number_format(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
<% end %>
|
||||
<%if total>0%>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: right;"><strong >Total </strong></td>
|
||||
<td colspan="2"><strong><%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
|
||||
<td colspan="2"><strong><%=number_format(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %></strong></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</tbody>
|
||||
@@ -142,4 +130,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
@@ -25,18 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -47,7 +36,7 @@
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||
<!-- <th><%= t("views.right_panel.detail.unit_price") %></th> -->
|
||||
<th><%= t("views.right_panel.detail.total") %></th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbd_data">
|
||||
<% unless @sale_data.blank? %>
|
||||
@@ -57,7 +46,7 @@
|
||||
<% total_qty = 0 %>
|
||||
<% total_item = {} %>
|
||||
<% total_data = {} %>
|
||||
<% @sale_data.each do |sale|
|
||||
<% @sale_data.each do |sale|
|
||||
if !total_item.has_key?(sale.item_code)
|
||||
grand_total += sale.grand_total
|
||||
total_item[sale.item_code] = sale.total_item
|
||||
@@ -66,25 +55,25 @@
|
||||
if sale.status_type == "void"
|
||||
total_item[sale.item_code] += sale.total_item
|
||||
end
|
||||
if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc"
|
||||
if sale.status_type == "void" || sale.status_type == "Discount" || sale.status_type == "foc"
|
||||
total_data[sale.item_code] += sale.grand_total
|
||||
grand_total += sale.grand_total
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end %>
|
||||
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<% if sale.status_type == "foc" && sale.price > 0
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
|
||||
|
||||
<% if sale.status_type != "Discount" && sale.price.to_f >= 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% cate_arr.push(sale.menu_category_id) %>
|
||||
<% else %>
|
||||
@@ -96,8 +85,8 @@
|
||||
<td><%= sale.item_code rescue '-' %></td>
|
||||
<td><%= sale.product_name rescue '-' %></td>
|
||||
<td><%= total_item[sale.item_code] rescue '-' %></td>
|
||||
<!-- <td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td><%= number_with_precision(total_data[sale.item_code] , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||
<!-- <td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||
<td><%= number_format(total_data[sale.item_code] , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
<!-- end sub total -->
|
||||
@@ -107,9 +96,9 @@
|
||||
<td colspan="3"></td>
|
||||
<td><strong>Total</strong></td>
|
||||
<td><strong><%= total_qty %></strong></td>
|
||||
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||
<td><strong><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -123,9 +112,9 @@
|
||||
$(function(){
|
||||
$('#order_by').val('<%= @order_by %>');
|
||||
});
|
||||
|
||||
|
||||
$('#order_by').on('change', function(){
|
||||
var order_by = $("#order_by").val();
|
||||
window.location.href = "?order_by=" + order_by;
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -60,18 +60,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
<% after_rounding = 0 %>
|
||||
@@ -81,40 +69,21 @@
|
||||
<% discount_amt = 0 %>
|
||||
<% other_amt = 0 %>
|
||||
<% total_nett = 0 %>
|
||||
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
|
||||
<% tax_profile_count = @tax_profiles.length %>
|
||||
<% rounding_adj = 0%>
|
||||
<% gov_tax = 0 %>
|
||||
<% service_charge = 0 %>
|
||||
|
||||
<%
|
||||
ttax_count = tax_profile_count - @sale_taxes.length
|
||||
ttax_flag = true
|
||||
@sale_taxes.each do |tax|
|
||||
if tax.tax_name.downcase.include?("service")
|
||||
ttax_flag = false
|
||||
end
|
||||
end
|
||||
%>
|
||||
<% if !@sale_data.nil? %>
|
||||
|
||||
|
||||
<%if !@sale_data.nil? %>
|
||||
<% @sale_data.each do |result| %>
|
||||
|
||||
<% grand_total +=result.grand_total.to_f %>
|
||||
<% old_grand_total += result.grand_total_after_rounding() %>
|
||||
<% grand_total += result.grand_total.to_f %>
|
||||
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
|
||||
<% total_tax += result.total_tax.to_f %>
|
||||
<% total_sum += result.total_amount.to_f %>
|
||||
<% discount_amt += result.total_discount.to_f %>
|
||||
<% rounding_adj += result.rounding_adjustment.to_f %>
|
||||
<% sale_tax_count = result.sale_taxes.length %>
|
||||
<% tax_count = tax_profile_count - sale_tax_count %>
|
||||
<% tax_flag = true %>
|
||||
<% result.sale_taxes.each do |tax|
|
||||
if tax.tax_name.downcase.include?("service")
|
||||
tax_flag = false
|
||||
end
|
||||
end %>
|
||||
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<%if result.type %>
|
||||
<%= result.type %> - <%= result.name %>
|
||||
@@ -124,50 +93,18 @@
|
||||
</td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
|
||||
</td>
|
||||
<!-- <%if result.customer.customer_type == "Takeaway"%>
|
||||
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<%end%> -->
|
||||
<% if !result.sale_taxes.empty? %>
|
||||
<% num = 1
|
||||
if tax_flag && tax_count > 0 %>
|
||||
<% while num <= tax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% result.sale_taxes.each do |tax| %>
|
||||
<td>
|
||||
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
|
||||
</td>
|
||||
<%end%>
|
||||
<% num = 1
|
||||
if tax_flag==false && tax_count > 0 %>
|
||||
<% while num <= tax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<%end%>
|
||||
|
||||
<% if result.old_grand_total.nil? %>
|
||||
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<%else%>
|
||||
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<%end%>
|
||||
|
||||
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td><%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) %></td>
|
||||
<td><%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '0' %></td>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<% if sale_tax = result.sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
|
||||
<td><%= number_format(sale_tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
|
||||
<% else %>
|
||||
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<td><%= number_format(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% if @lookup.value.to_i == 1 %>
|
||||
<td>
|
||||
<!-- ############### Need to Check SyncStatus ############# -->
|
||||
@@ -185,54 +122,18 @@
|
||||
<% end %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td colspan="3"> </td>
|
||||
<td><b><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<!-- <% if !@sale_taxes.empty?
|
||||
@sale_taxes.each do |tax| %>
|
||||
<td>
|
||||
<b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b>
|
||||
</td>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<td><b>0</b></td>
|
||||
<% end %>
|
||||
<% end %> -->
|
||||
|
||||
<% if !@sale_taxes.empty? %>
|
||||
<% num = 1
|
||||
if ttax_flag && ttax_count > 0 %>
|
||||
<% while num <= ttax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<td>
|
||||
<%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
|
||||
</td>
|
||||
<%end%>
|
||||
<% num = 1
|
||||
if ttax_flag==false && ttax_count > 0 %>
|
||||
<% while num <= ttax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<%end%>
|
||||
|
||||
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
|
||||
|
||||
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(total_sum, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(discount_amt, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<% if sale_tax = @sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
|
||||
<td><%= number_format(sale_tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
|
||||
<% else %>
|
||||
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<td><b><%= number_format(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %></b></td>
|
||||
<td><b><%= number_format(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
|
||||
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<th><%= tax.name %></th>
|
||||
<th><%= tax.name %></th>
|
||||
<% end %>
|
||||
<!-- <th>Other Amount</th> -->
|
||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
@@ -40,17 +40,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end %>
|
||||
|
||||
<% grand_total = 0 %>
|
||||
<% old_grand_total = 0 %>
|
||||
@@ -61,129 +50,58 @@
|
||||
<% discount_amt = 0 %>
|
||||
<% other_amt = 0 %>
|
||||
<% total_nett = 0 %>
|
||||
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
|
||||
<% tax_profile_count = @tax_profiles.length %>
|
||||
<% rounding_adj = 0%>
|
||||
<% gov_tax = 0 %>
|
||||
<% service_charge = 0 %>
|
||||
|
||||
<%
|
||||
ttax_count = tax_profile_count - @sale_taxes.length
|
||||
ttax_flag = true
|
||||
@sale_taxes.each do |tax|
|
||||
if tax.tax_name.downcase.include?("service")
|
||||
ttax_flag = false
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
<%if !@sale_data.nil? %>
|
||||
<% if @sale_data %>
|
||||
<% @sale_data.each do |result| %>
|
||||
|
||||
<% grand_total +=result.grand_total.to_f %>
|
||||
<% old_grand_total += result.grand_total_after_rounding() %>
|
||||
<% grand_total += result.grand_total.to_f %>
|
||||
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
|
||||
<% total_tax += result.total_tax.to_f %>
|
||||
<% total_sum += result.total_amount.to_f %>
|
||||
<% discount_amt += result.total_discount.to_f %>
|
||||
<% rounding_adj += result.rounding_adjustment.to_f %>
|
||||
<% sale_tax_count = result.sale_taxes.length %>
|
||||
<% tax_count = tax_profile_count - sale_tax_count %>
|
||||
<% tax_flag = true %>
|
||||
<% result.sale_taxes.each do |tax|
|
||||
if tax.tax_name.downcase.include?("service")
|
||||
tax_flag = false
|
||||
end
|
||||
end %>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<%if result.type %>
|
||||
<%= result.type %> - <%= result.name %>
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
|
||||
</td>
|
||||
<% if !result.sale_taxes.empty? %>
|
||||
<% num = 1
|
||||
if tax_flag && tax_count > 0 %>
|
||||
<% while num <= tax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<tr>
|
||||
<td>
|
||||
<%if result.type %>
|
||||
<%= result.type %> - <%= result.name %>
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
<% result.sale_taxes.each do |tax| %>
|
||||
<td>
|
||||
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
|
||||
</td>
|
||||
<%end%>
|
||||
<% num = 1
|
||||
if tax_flag==false && tax_count > 0 %>
|
||||
<% while num <= tax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<%end%>
|
||||
|
||||
<% if result.old_grand_total.nil? %>
|
||||
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<%else%>
|
||||
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<%end%>
|
||||
|
||||
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||
</tr>
|
||||
</td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<% if sale_tax = result.sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
|
||||
<td><%= number_format(sale_tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
|
||||
<% else %>
|
||||
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<td><%= number_format(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<td><%= number_format(result.grand_total, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td colspan="3"> </td>
|
||||
<td><b><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<% if !@sale_taxes.empty? %>
|
||||
<% num = 1
|
||||
if ttax_flag && ttax_count > 0 %>
|
||||
<% while num <= ttax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<td>
|
||||
<%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
|
||||
</td>
|
||||
<%end%>
|
||||
<% num = 1
|
||||
if ttax_flag==false && ttax_count > 0 %>
|
||||
<% while num <= ttax_count %>
|
||||
<td>
|
||||
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||
</td>
|
||||
<% num += 1
|
||||
end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<%end%>
|
||||
|
||||
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
|
||||
|
||||
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
|
||||
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
<td><b><%= number_format(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
|
||||
<% @tax_profiles.each do |tax| %>
|
||||
<% if sale_tax = @sale_taxes.find { |sale_tax| sale_tax.tax_name == tax.name } %>
|
||||
<td><%= number_format(sale_tax.st_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> </td>
|
||||
<% else %>
|
||||
<td><%= number_format(0, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<td><b><%= number_format(old_grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '0' %></b></td>
|
||||
<td><b><%= number_format(rounding_adj.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
<td><b><%= number_format(grand_total.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
@@ -209,4 +127,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -34,43 +34,30 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.table") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.shift_name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.table") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.receipt_no") %></b></th>
|
||||
<th><b><%= t :cashier %> <%= t("views.right_panel.detail.name") %></b></th>
|
||||
<th><b><%= t("views.right_panel.detail.revenue") %></b></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% grand_total = 0 %>
|
||||
<% @sale_data.each do |result| %>
|
||||
<% table_name=nil
|
||||
table_type =nil
|
||||
if result.table_id.to_i>0
|
||||
table = DiningFacility.find(result.table_id)
|
||||
if table = result.bookings[0].dining_facility
|
||||
table_type = table.type
|
||||
table_name = table.name
|
||||
end %>
|
||||
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
|
||||
<% grand_total = grand_total + result.grand_total %>
|
||||
<tr style="border-top:4px double #666;">
|
||||
<td><%= @shift_from %> - <%= @shift_to %></td>
|
||||
<td><%= table_type %> - <%= table_name %></td>
|
||||
<td><%= result.receipt_no rescue '-' %> </td>
|
||||
<td><%= result.cashier_name rescue '-' %></td>
|
||||
<td><%= number_with_precision(result.grand_total, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(result.grand_total, precision: precision, delimiter: delimiter) %></td>
|
||||
<!-- <td> </td> -->
|
||||
</tr>
|
||||
|
||||
@@ -85,8 +72,8 @@
|
||||
<% result.sale_items.each do |item|%>
|
||||
<tr>
|
||||
<td>
|
||||
<% if item.price.to_i < 0.to_i %>
|
||||
<% if item.qty.to_i < 0.to_i%>
|
||||
<% if item.price < 0 %>
|
||||
<% if item.qty < 0 %>
|
||||
[PROMO QTY]<%= item.product_name rescue '-' %>
|
||||
<% else %>
|
||||
[PROMO PRICE]<%= item.product_name rescue '-' %>
|
||||
@@ -96,15 +83,15 @@
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= item.qty rescue '-' %></td>
|
||||
<td><%= number_with_precision(item.unit_price, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||
<td><%= number_with_precision(item.price, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||
<td><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> </td>
|
||||
<td><%= number_format(item.unit_price, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) rescue '-' %></td>
|
||||
<td><%= number_format(item.price, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) rescue '-' %></td>
|
||||
<td><%=l item.created_at.getlocal, :format => :short rescue '-' %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr><td colspan="5"> </td></tr>
|
||||
|
||||
<%survey = Survey.find_by_receipt_no(result.receipt_no)%>
|
||||
<%survey = result.survey%>
|
||||
<% if !survey.nil?%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
@@ -120,19 +107,19 @@
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= number_with_precision(result.total_amount, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(result.total_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if result.total_discount.to_f > 0 %>
|
||||
<% if result.total_discount > 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.total") %>
|
||||
<%= t("views.right_panel.detail.discount") %>
|
||||
<%= t("views.right_panel.detail.amount") %></td>
|
||||
<td> - <%= number_with_precision(result.total_discount, precision:precision.to_i,delimiter:delimiter) %> </td>
|
||||
<td> - <%= number_format(result.total_discount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -142,39 +129,38 @@
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Tax Amount </td>
|
||||
<td><%= number_with_precision(result.total_tax, precision:precision.to_i,delimiter:delimiter) %> </td>
|
||||
<td><%= number_format(result.total_tax, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% sale_payments = SalePayment.get_sale_payments(result) %>
|
||||
<% sale_payments = result.sale_payments %>
|
||||
<% if sale_payments.length > 0%>
|
||||
<% sale_payments.each do |rec| %>
|
||||
<%if rec.payment_amount.to_f > 0 %>
|
||||
<% next if rec.payment_method == 'credit_note' && result.payments_for_credits_amount < rec.payment_amount %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= number_format(rec.payment_amount, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %> ( <%= rec.payment_status %> )</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||
<td><%= number_with_precision(rec.payment_amount, precision:precision.to_i,delimiter:delimiter) %> ( <%= rec.payment_status %> )</td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<% if !rec.payment_reference.nil? %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>Payment Ref.</td>
|
||||
<td><%= rec.payment_reference %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if result.amount_changed != 0 && !result.amount_changed.nil? %>
|
||||
<% if result.amount_changed != 0 %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><%= number_with_precision(result.amount_changed, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(result.amount_changed, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -196,7 +182,7 @@
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td><b>Total Nett</b> - <b><%= number_with_precision(grand_total, precision:precision.to_i,delimiter:delimiter) %></b></td>
|
||||
<td><b>Total Nett</b> - <b><%= number_format(grand_total, precision: precision, delimiter: delimiter, strip_insignificant_zeros: strip_insignificant_zeros) %></b></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -46,18 +46,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% acc_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
<% p_qty = 0 %>
|
||||
@@ -111,7 +99,7 @@
|
||||
<td>
|
||||
<% @totalByAccount.each do |account, total| %>
|
||||
<% if sale.account_id == account %>
|
||||
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||
<b><%= number_format(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||
<% grand_total += total %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -135,8 +123,8 @@
|
||||
<td><%= sale.total_item*(-1) rescue '-' %></td>
|
||||
<% end %>
|
||||
|
||||
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
@@ -161,7 +149,7 @@
|
||||
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
||||
<td><b><%= sub_qty %></b></td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||
<td ><span class="underline"><%= number_format(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||
</tr>
|
||||
<% sub_total = 0.0%>
|
||||
<% sub_qty = 0 %>
|
||||
@@ -191,8 +179,8 @@
|
||||
<td><%= product.product_code rescue '-' %></td>
|
||||
<td><%= product.product_name rescue '-' %></td>
|
||||
<td><%= product.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
@@ -205,7 +193,7 @@
|
||||
<td><b><%= p_qty %></b></td>
|
||||
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Product Sale -->
|
||||
@@ -229,8 +217,8 @@
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
@@ -240,7 +228,7 @@
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Other Charges -->
|
||||
@@ -249,18 +237,18 @@
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||
<td><span><%= total_qty%></span></td>
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td><span><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<% if @type =="" || @type =="all" || @type.nil? %>
|
||||
<tr class="foc_payment">
|
||||
<td colspan="5"> </td>
|
||||
<td>Total FOC Amount</td>
|
||||
<td><span><%= number_with_precision(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td><span><%= number_format(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<tr class="foc_payment" style="border-top:2px solid grey;border-bottom:2px solid grey;">
|
||||
<td colspan="5"> </td>
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -282,8 +270,8 @@
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
@@ -293,7 +281,7 @@
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</tbody>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -17,9 +17,9 @@
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -31,23 +31,11 @@
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||
<th><%= t("views.right_panel.detail.revenue") %></th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% acc_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
<% p_qty = 0 %>
|
||||
<% sub_qty = 0 %>
|
||||
<% sub_total = 0 %>
|
||||
@@ -67,7 +55,7 @@
|
||||
<% unless @sale_data.blank? %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<!-- all total qty sum -->
|
||||
|
||||
|
||||
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
@@ -81,20 +69,20 @@
|
||||
total_qty += sale.total_item
|
||||
end %>
|
||||
<!-- end all total qty -->
|
||||
|
||||
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
total_item_foc += sale.grand_total*(-1)
|
||||
end %>
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
total_item_dis += sale.grand_total*(-1)
|
||||
end %>
|
||||
<% if !acc_arr.include?(sale.account_id) %>
|
||||
|
||||
|
||||
<% @totalByAccount.each do |account, total| %>
|
||||
<% if sale.account_id == account %>
|
||||
|
||||
<% grand_total += total %>
|
||||
|
||||
<% grand_total += total %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% acc_arr.push(sale.account_id) %>
|
||||
@@ -109,15 +97,15 @@
|
||||
<%else%>
|
||||
<td><%= sale.total_item*(-1) rescue '-' %></td>
|
||||
<% end %>
|
||||
|
||||
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
<td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
<% @menu_cate_count.each do |key,value| %>
|
||||
<% if sale.account_id == key %>
|
||||
<% count = count + 1 %>
|
||||
<% count = count + 1 %>
|
||||
<% sub_total += sale.grand_total %>
|
||||
<% #sub_qty += sale.total_item %>
|
||||
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
|
||||
@@ -130,7 +118,7 @@
|
||||
<% if sale.remark == "promotion"
|
||||
sub_qty += sale.total_item
|
||||
end %>
|
||||
<% if count == value %>
|
||||
<% if count == value %>
|
||||
<% sub_total = 0.0%>
|
||||
<% sub_qty = 0 %>
|
||||
<% count = 0%>
|
||||
@@ -141,7 +129,7 @@
|
||||
<% end %>
|
||||
<!--Product Sale -->
|
||||
<% if @product.present?%>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><b>Product</b></td>
|
||||
<td colspan="4"> </td>
|
||||
@@ -159,13 +147,13 @@
|
||||
<td><%= product.product_code rescue '-' %></td>
|
||||
<td><%= product.product_name rescue '-' %></td>
|
||||
<td><%= product.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
|
||||
<% product_sub_total += product.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
@@ -173,14 +161,14 @@
|
||||
<td><b><%= p_qty %></b></td>
|
||||
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Product Sale -->
|
||||
|
||||
<!--Other Charges -->
|
||||
<% if @type == "other" || @other_charges.present?%>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><b>Other Charges</b></td>
|
||||
<td colspan="4"> </td>
|
||||
@@ -197,18 +185,18 @@
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
|
||||
<% other_sub_total += other.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Other Charges -->
|
||||
@@ -217,23 +205,23 @@
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||
<td><span><%= total_qty%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<% if @type =="" || @type =="all" %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td>Total FOC Amount</td>
|
||||
<td><span><%= number_with_precision(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td><span><%= number_format(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<tr style="border-top:2px solid grey;border-bottom:2px solid grey;">
|
||||
<td colspan="5"> </td>
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @type == "other"%>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><b>Other Charges</b></td>
|
||||
<td colspan="4"> </td>
|
||||
@@ -250,18 +238,18 @@
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
|
||||
<% other_sub_total += other.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</tbody>
|
||||
@@ -285,4 +273,4 @@
|
||||
$('.foc_payment').hide();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_saleitem_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="margin-top-20">
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -28,9 +28,9 @@
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
@@ -42,24 +42,12 @@
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||
<th><%= t("views.right_panel.detail.revenue") %></th>
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% unless @sale_data.blank? %>
|
||||
<% acc_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
|
||||
<% sub_qty = 0 %>
|
||||
<% sub_total = 0 %>
|
||||
@@ -87,7 +75,7 @@
|
||||
<!-- end all total qty -->
|
||||
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||
total_item_foc += sale.grand_total*(-1)
|
||||
end %>
|
||||
end %>
|
||||
|
||||
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||
total_item_dis += sale.grand_total*(-1)
|
||||
@@ -101,8 +89,8 @@
|
||||
<td>
|
||||
<% @totalByAccount.each do |account, total| %>
|
||||
<% if sale.account_id == account %>
|
||||
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||
<% grand_total += total %>
|
||||
<b><%= number_format(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||
<% grand_total += total %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
@@ -111,7 +99,7 @@
|
||||
<% end %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% cate_arr.push(sale.menu_category_id) %>
|
||||
<% else %>
|
||||
@@ -120,27 +108,27 @@
|
||||
<td><%= sale.item_code rescue '-' %></td>
|
||||
<td><%= sale.product_name rescue '-' %></td>
|
||||
<td><%= sale.total_item rescue '-' %></td>
|
||||
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
<% @menu_cate_count.each do |key,value| %>
|
||||
<% if sale.account_id == key %>
|
||||
<% count = count + 1 %>
|
||||
<% count = count + 1 %>
|
||||
<% sub_total += sale.grand_total %>
|
||||
<% #sub_qty += sale.total_item %>
|
||||
<% if sale.status_type!="Discount" && (!sale.product_name.include? "FOC")
|
||||
sub_qty += sale.total_item
|
||||
end %>
|
||||
|
||||
<% if count == value %>
|
||||
<% if count == value %>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
||||
<td><b><%= sub_qty %></b></td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||
<td ><span class="underline"><%= number_format(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||
</tr>
|
||||
<% sub_total = 0.0%>
|
||||
<% sub_qty = 0 %>
|
||||
@@ -168,18 +156,18 @@
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
|
||||
<% other_sub_total += other.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Other Charges -->
|
||||
@@ -188,25 +176,25 @@
|
||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||
<td><span><%= total_qty%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td><span><%= number_with_precision(total_item_foc , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||
<td><span><%= number_format(total_item_foc , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||
<td style="border-bottom:2px solid grey;"><span><%= number_format(total_item_dis , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.foc_sales") %></td>
|
||||
<td>
|
||||
<span><%= number_with_precision(@foc_data, precision:precision.to_i, delimiter:delimiter) %></span>
|
||||
<span><%= number_format(@foc_data, precision:precision.to_i, delimiter:delimiter) %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -214,11 +202,11 @@
|
||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||
<td style="border-bottom:2px solid grey;">
|
||||
<span>
|
||||
<%= number_with_precision(@discount_data , precision: precision.to_i,delimiter: delimiter) %>
|
||||
<%= number_format(@discount_data , precision: precision.to_i,delimiter: delimiter) %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tr>
|
||||
|
||||
<% @sale_taxes.each do |tax| %>
|
||||
<!-- <tr>
|
||||
<td colspan="5"> </td>
|
||||
@@ -232,13 +220,13 @@
|
||||
<td colspan="5"> </td>
|
||||
<td style="border-top:2px solid grey;">Net Amount</td>
|
||||
<!-- <td><span class="double_underline"><%= grand_total.to_f - @discount_data.to_f%></span></td> -->
|
||||
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision.to_i,delimiter:delimiter)%></td>
|
||||
<td style="border-top:2px solid grey;"><%= number_format(grand_total.to_f - @discount_data.to_f , precision:precision.to_i,delimiter:delimiter)%></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td colspan="5"> </td>
|
||||
<td>Grand Total</td>
|
||||
|
||||
<td><span class="double_underline"><%= @grand_total - @change_amount%></span></td>
|
||||
|
||||
<td><span class="double_underline"><%= @grand_total - @change_amount%></span></td>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -259,14 +247,14 @@
|
||||
if(search){
|
||||
|
||||
if(parseInt(search) == 0){
|
||||
search_by_period();
|
||||
search_by_period();
|
||||
}
|
||||
else{
|
||||
search_by_date();
|
||||
search_by_date();
|
||||
}
|
||||
}else{
|
||||
search_by_period();
|
||||
}
|
||||
search_by_period();
|
||||
}
|
||||
|
||||
$('#sel_period').change(function(){
|
||||
search_by_period();
|
||||
@@ -278,8 +266,8 @@
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
@@ -295,13 +283,13 @@
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
@@ -310,7 +298,7 @@
|
||||
|
||||
console.log(check_arr.length)
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
@@ -329,13 +317,13 @@
|
||||
var selected = '';
|
||||
var str = '';
|
||||
var param_shift = '<%= params[:shift_name]%>';
|
||||
|
||||
|
||||
url = '<%= reports_get_shift_by_date_path %>';
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
console.log(data)
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
@@ -346,21 +334,21 @@
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
|
||||
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -69,18 +69,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if @print_settings.precision.to_i > 0
|
||||
precision = @print_settings.precision
|
||||
else
|
||||
precision = 0
|
||||
end
|
||||
#check delimiter
|
||||
if @print_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% void = 0%>
|
||||
<% cash = 0%>
|
||||
<% credit = 0%>
|
||||
@@ -104,16 +92,16 @@
|
||||
<%= result[:shift_closed_at] ? result[:shift_closed_at].strftime("%e %b %I:%M%p") : '-' %>
|
||||
</td>
|
||||
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
|
||||
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(result[:cash_sales].to_f, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||
<td><%= number_format(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<td class="d-none d-sm-table-cell"><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td class="d-none d-sm-table-cell"><%= number_format(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td class="d-none d-sm-table-cell">
|
||||
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
||||
<%= number_format(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
||||
</td>
|
||||
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= number_format(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td>
|
||||
<%= link_to "Print", reports_get_shift_id_path(result[:shift_id].to_i), class:"btn btn-info wave-effects" %>
|
||||
</td>
|
||||
@@ -134,15 +122,15 @@
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="3"></td>
|
||||
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
|
||||
<td><b><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
|
||||
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
|
||||
<td class="d-none d-sm-table-cell"><b><%= number_with_precision(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td class="d-none d-sm-table-cell"><b><%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td class="d-none d-sm-table-cell"><b><%= number_format(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td class="d-none d-sm-table-cell"><b><%= number_format(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
|
||||
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
||||
<td><b><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_format(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user