From ced6a0909527235bdbda128c79d97c96685c808c Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Sun, 19 Jul 2020 19:31:14 +0630 Subject: [PATCH] customer name filter --- .../reports/credit_payment_controller.rb | 13 +-- .../reports/receipt_no_controller.rb | 85 +++++++++--------- .../reports/receipt_no_detail_controller.rb | 4 +- app/models/sale.rb | 90 ++++++++++++++++--- app/models/sale_payment.rb | 2 +- .../_shift_sale_report_filter.html.erb | 39 ++++---- .../_shift_sale_report_filter.html.erb | 76 ++++++++-------- app/views/reports/receipt_no/index.html.erb | 8 +- app/views/reports/receipt_no/index.xls.erb | 4 +- .../_shift_sale_report_filter.html.erb | 10 ++- .../reports/receipt_no_detail/index.html.erb | 18 ++-- .../reports/receipt_no_detail/index.xls.erb | 16 ++-- 12 files changed, 224 insertions(+), 141 deletions(-) diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index 7a83474d..be22e569 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -1,16 +1,17 @@ -class Reports::CreditPaymentController < BaseReportController +class Reports::CreditPaymentController < BaseReportController authorize_resource :class => false def index @filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']] @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] from, to = get_date_range_from_params + customer_filter = params[:customer] @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift = '' if params[:shift_name].to_i != 0 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 @@ -20,8 +21,8 @@ authorize_resource :class => false @filter = params[:filter_check] @order_source = params[:order_source] - @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source) - + @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,customer_filter,@order_source) + @from = from @to = to @@ -58,10 +59,10 @@ authorize_resource :class => false end out = {:status => 'ok', :message => date_arr} - + respond_to do |format| format.json { render json: out } end end -end \ No newline at end of file +end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 1136bc31..1f478103 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -3,59 +3,60 @@ authorize_resource :class => false def index @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_method = PaymentMethodSetting.all - from, to = get_date_range_from_params + from, to = get_date_range_from_params + customer_filter = params[:customer] @shift_sale_range = '' - @shift = '' - if params[:shift_name].to_i != 0 + @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_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 + @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 - @lookup = Lookup.find_by_lookup_type('reprint_receipt') - if @lookup.nil? - @lookup = Lookup.create_reprint_receipt_lookup - end + @lookup = Lookup.find_by_lookup_type('reprint_receipt') + if @lookup.nil? + @lookup = Lookup.create_reprint_receipt_lookup + end - payment_type = params[:payment_type] - @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) - @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) - @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) + payment_type = params[:payment_type] + @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range, @shift, from, to, payment_type, customer_filter) + @sale_taxes = Sale.get_separate_tax(@shift_sale_range, @shift, from, to, payment_type) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) - @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 + @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 + format.html + format.xls + end end def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| @@ -68,11 +69,11 @@ authorize_resource :class => false date_arr.push(str) end - out = {:status => 'ok', :message => date_arr} + out = {:status => 'ok', :message => date_arr} - respond_to do |format| - format.json { render json: out } - end + respond_to do |format| + format.json { render json: out } + end end def sync_data diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index eba6c3e6..11f35252 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -5,6 +5,8 @@ authorize_resource :class => false from, to = get_date_range_from_params + customer_filter = params[:customer] + @shift_sale_range = '' @shift = '' @@ -24,7 +26,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, customer_filter) @from = from @to = to diff --git a/app/models/sale.rb b/app/models/sale.rb index 69398753..4076b4fe 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -26,7 +26,7 @@ class Sale < ApplicationRecord has_one :booking has_many :product_commissions - before_validation :round_to_precision + before_save :member_discount, :round_to_precision after_update :update_stock_journal scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } @@ -1167,7 +1167,7 @@ def self.get_menu_item_query(order_by) end #product sale report query -def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type) +def self.get_shift_sales_by_receipt_no(shift_sale_range, shift, from, to, payment_type, customer_filter) ## => left join -> show all sales although no orders if payment_type.blank? payment_type = '' @@ -1175,29 +1175,40 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty payment_type = " and sale_payments.payment_method = '#{payment_type}'" end - query = Sale.includes(:sale_items).select("sales.*,sale_payments.*,df.name,df.type") + query = Sale.includes(:sale_items).select("sales.*, sale_payments.*") + .select("customers.customer_id, customers.name as customer_name, df.name, df.type") .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") .joins("join bookings on bookings.sale_id = sales.sale_id") .joins("left join dining_facilities df on df.id = bookings.dining_facility_id") .group("sales.sale_id") + + if customer_filter.present? + query = query.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales.customer_id AND " + + "customers.name LIKE :filter", filter: "%#{customer_filter}%"])) + else + query = query.joins(:customer) + end + if shift.present? query = query.where("sales.shift_sale_id in (?)", shift.to_a) elsif shift_sale_range.present? - query = query.where("sales.shift_sale_id in (?)",shift_sale_range.to_a) + query = query.where("sales.shift_sale_id in (?)", shift_sale_range.to_a) else - query = query.where("sales.receipt_date between ? and ?",from,to) + query = query.where("sales.receipt_date between ? and ?", from, to) end + return query end -def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type) +def self.get_shift_sales_by_receipt_no_detail(shift_sale_range, shift, from, to, payment_type, customer_filter) ## => left join -> show all sales although no orders - query = Sale.includes([:customer, :survey, :sale_payments]) - .includes(:bookings => :dining_facility) + query = Sale.includes([:survey, :sale_payments]) .select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount") - .joins(:bookings) + .select("dining_facilities.type AS table_type, dining_facilities.name AS table_name") + .select("customers.customer_id, customers.name AS customer_name, customers.company AS customer_company") + .joins(:booking => :dining_facility) .joins("INNER JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .left_joins(:payments_for_credits) .completed @@ -1205,6 +1216,13 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay .group(:sale_id) .order(:receipt_date) + if customer_filter.present? + query = query.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales.customer_id AND " + + "customers.name LIKE :filter", filter: "%#{customer_filter}%"])) + else + query = query.joins(:customer) + end + if payment_type.present? if payment_type == 'card' query = query.where(sanitize_sql_array(["sp.payment_method IN (?)", SalePayment::CARD])) @@ -1226,7 +1244,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay return query end -def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source) +def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,customer_filter,order_source) payments_for_credits = SalePayment.select(" sales.sale_id, DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') as credit_payment_receipt_date, @@ -1253,11 +1271,17 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter, IFNULL(payments_for_credits.credit_payment_cashier_name, '-') as credit_payment_cashier_name, IFNULL(payments_for_credits.credit_payment_shift_name, '-') as credit_payment_shift_name") .joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sales_sale_payments.sale_id") - .joins(:sale => :customer) .joins(:sale => :orders) .credits .where("sales_sale_payments.sale_status = ?", 'completed') + if customer_filter.present? + credits = credits.joins(sanitize_sql_array(["INNER JOIN customers ON customers.customer_id = sales_sale_payments.customer_id AND " + + "customers.name LIKE :filter", filter: "%#{customer_filter}%"])) + else + credits = credits.joins(:sale => :customer) + end + if order_source.present? if order_source == "cashier" credits = credits.where("orders.source IN (?)", ['cashier', 'emenu']) @@ -2297,6 +2321,50 @@ private end end + def member_discount + return unless will_save_change_to_customer_id? || will_save_change_to_total_amount? + + if self.customer && self.customer.membership_id.present? + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("get_member_campaign") + merchant_uid = memberaction.merchant_account_id.to_s + campaign_type_id = memberaction.additional_parameter["campaign_type_id"] + auth_token = memberaction.auth_token + url = "#{membership.gateway_url}#{memberaction.gateway_url}" + + begin + response = HTTParty.get(url, + :body => { + member_group_id: sObj.customer.membership_type, + merchant_uid: merchant_uid, + campaign_type_id: campaign_type_id, + auth_token: auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, :timeout => 10) + rescue Net::OpenTimeout + response = { "status": false , "message": " Connection timeout" } + rescue OpenURI::HTTPError + response = { "status": false, "message": "Can't connect server"} + rescue SocketError + response = { "status": false, "message": "Can't connect server"} + end + + return unless response['status'] && response['membership_campaign_data'].present? + + Account.where(discount: true).inject(0) do |dis, acc| + rule = response['membership_campaign_data'].find { |c| c['rules_type'].downcase.strip == acc.title.downcase.strip } + dis += acc.sale_items.inject(0) { |i| i.account_id == acc.id ? i.price : 0 } * rule["change_unit"].to_i / rule["base_unit"].to_i + end + + + else + + end + end + def round_to_precision if (self.total_amount % 1 > 0 || self.total_discount % 1 > 0 || self.total_tax % 1 > 0) self.total_amount = self.total_amount.round(precision) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 94506351..59bea463 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -684,7 +684,7 @@ class SalePayment < ApplicationRecord end end sale.save! - + if sale.sale_status == 'completed' table_update_status(sale) update_shift diff --git a/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb b/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb index 4f960e96..241e69df 100755 --- a/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb +++ b/app/views/reports/credit_payment/_shift_sale_report_filter.html.erb @@ -2,9 +2,9 @@ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> <% if period_type != false %>
-
- - @@ -18,34 +18,37 @@
+ +
+ + +
+ <% if defined? filter_for_credit %>
- <%= select_tag "filter_check", options_for_select(@filter_for_credit, :selected => params[:filter_check]), :class => "form-control", :style => "height: 37px;" %> + <%= select_tag "filter_check", options_for_select(@filter_for_credit, :selected => params[:filter_check]), :class => "form-control m-t-3", :style => "height: 32px;" %>
<% end %>
- <%= select_tag "order_source", options_for_select(@sources, :selected => params[:order_source]), :class => "form-control" %> + <%= select_tag "order_source", options_for_select(@sources, :selected => params[:order_source]), :class => "form-control m-t-3", :style => "height: 32px;" %>
-
+
- - + +
-
- - +
+ +
-
- -
-
-
-
-
+
diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb index b2aeb16f..96a6d4b8 100755 --- a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -4,7 +4,7 @@
- <%= t("views.right_panel.detail.select_period") %> @@ -18,12 +18,17 @@
- <% if not defined? payments %> +
+ + +
+ + <% if defined? @payments %>
- <% @payments.each do |pm| %> <%end %> @@ -33,6 +38,7 @@
<% end %> +
@@ -44,11 +50,10 @@
-
-
@@ -104,37 +109,38 @@ $(".<%=params[:payment_type]%>").attr('selected','selected') - // shift = $(".shift-id").text() - // if (shift.length>0) { - // $('.shift_name > option[value="'+shift+'"]').attr('selected','selected'); - // } + // shift = $(".shift-id").text() + // if (shift.length>0) { + // $('.shift_name > option[value="'+shift+'"]').attr('selected','selected'); + // } - <% if params[:period_type] == 1 || params[:period_type] == "1" %> - $("#rd_period_type_1").attr("checked","checked"); - <% else %> - $("#rd_period_type_0").attr("checked","checked"); - <% end %> - $(".btn-group button").removeClass("active"); - <% report_type = params[:report_type].blank? ? "0" : params[:report_type] %> - $("#btn_report_type_<%= report_type %>").addClass("active"); + <% if params[:period_type] == 1 || params[:period_type] == "1" %> + $("#rd_period_type_1").attr("checked","checked"); + <% else %> + $("#rd_period_type_0").attr("checked","checked"); + <% end %> + $(".btn-group button").removeClass("active"); + <% report_type = params[:report_type].blank? ? "0" : params[:report_type] %> + $("#btn_report_type_<%= report_type %>").addClass("active"); - $('#item').change(function(){ - var item = $('#item').val(); - var payment_type = $('#payment_type'); + $('#item').change(function(){ + var item = $('#item').val(); + var payment_type = $('#payment_type'); + + if(item == 'sale'){ + $('#waiter').hide(); + $('#cashier').show(); + if(payment_type){ + $('#payment_type').show(); + } + } + else{ + $('#cashier').hide(); + $('#waiter').show(); + if(payment_type){ + $('#payment_type').hide(); + } + } + }); - if(item == 'sale'){ - $('#waiter').hide(); - $('#cashier').show(); - if(payment_type){ - $('#payment_type').show(); - } - } - else{ - $('#cashier').hide(); - $('#waiter').show(); - if(payment_type){ - $('#payment_type').hide(); - } - } - }); diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 264ee13a..7c3f3668 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -44,7 +44,8 @@ <%= t("views.right_panel.detail.dining") %> <%= t("views.right_panel.detail.receipt_no") %> - <%= t :cashier %> <%= t("views.right_panel.detail.name") %> + <%= t :customer %> + <%= t :cashier %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <% @tax_profiles.each do |tax| %> @@ -92,6 +93,7 @@ <% end %> <%= result.receipt_no rescue '-' %> + <%= result.customer_name rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) %> <%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '0' %> @@ -253,8 +255,8 @@ } str += ''; - // console.log(sh_date) - }) + // console.log(sh_date) + }) shift.append(str); }); } diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index ce7f8f8a..c88c57a9 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -25,7 +25,8 @@ <%= t("views.right_panel.detail.dining") %> <%= t("views.right_panel.detail.receipt_no") %> - <%= t :cashier %> <%= t("views.right_panel.detail.name") %> + <%= t :customer %> + <%= t :cashier %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> <% @tax_profiles.each do |tax| %> @@ -73,6 +74,7 @@ <% end %> <%= result.receipt_no rescue '-' %> + <%= result.customer_name rescue '-' %> <%= result.cashier_name rescue '-' %> <%= number_format(result.total_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> <%= number_format(result.total_discount, precision: precision.to_i, delimiter: delimiter) rescue '-' %> diff --git a/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb index ad834e00..f2370451 100755 --- a/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb +++ b/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb @@ -18,9 +18,9 @@
+ <% if defined? @payment_methods %> - -
+
<% end %> + +
+ + +
+
diff --git a/app/views/reports/receipt_no_detail/index.html.erb b/app/views/reports/receipt_no_detail/index.html.erb index 72ba9c0a..aa2de25a 100755 --- a/app/views/reports/receipt_no_detail/index.html.erb +++ b/app/views/reports/receipt_no_detail/index.html.erb @@ -46,19 +46,13 @@ <% grand_total = 0 %> <% @sale_data.each do |result| %> - <% table_name=nil - table_type =nil - if table = result.bookings[0].dining_facility - table_type = table.type - table_name = table.name - end %> - <% grand_total = grand_total + result.grand_total %> + <% grand_total = grand_total + result.grand_total %> <%= result.receipt_no rescue '-' %> <%=l result.receipt_date.getlocal, :format => :short rescue '-' %> <%= @shift_from %> - <%= @shift_to %> <%= result.cashier_name rescue '-' %> - <%= table_type %> - <%= table_name %> + <%= result.table_type %> - <%= result.table_name %> <%= number_format(result.grand_total, precision: precision, delimiter: delimiter) %> @@ -179,9 +173,11 @@     Customer - <%= result.customer.name rescue '-'%> - (<%= result.customer.company rescue '-' %>) - + <%= result.customer_name rescue '-'%> + <% if result.customer_company.present? %> + (<%= result.customer_company rescue '-' %>) + <% end %> +   <% end %> diff --git a/app/views/reports/receipt_no_detail/index.xls.erb b/app/views/reports/receipt_no_detail/index.xls.erb index 6fe33086..6d64ff9c 100755 --- a/app/views/reports/receipt_no_detail/index.xls.erb +++ b/app/views/reports/receipt_no_detail/index.xls.erb @@ -38,18 +38,12 @@ <% grand_total = 0 %> <% @sale_data.each do |result| %> <% grand_total = grand_total.to_f + result.grand_total.to_f%> - <% table_name=nil - table_type =nil - if table = result.bookings[0].dining_facility - table_type = table.type - table_name = table.name - end %> <%= result.receipt_no rescue '-' %> <%=l result.receipt_date.getlocal, :format => :short rescue '-' %> <%= @shift_from %> - <%= @shift_to %> <%= result.cashier_name rescue '-' %> - <%= table_type %> - <%= table_name %> + <%= result.table_type %> - <%= result.table_name %> <%= number_format(result.grand_total, precision: precision, delimiter: delimiter) %> @@ -171,9 +165,11 @@     Customer - <%= result.customer.name rescue '-'%> - (<%= result.customer.company rescue '-' %>) - + <%= result.customer_name rescue '-'%> + <% if result.customer_company.present? %> + (<%= result.customer_company rescue '-' %>) + <% end %> +   <% end %>