diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb
new file mode 100755
index 00000000..d7b018d7
--- /dev/null
+++ b/app/controllers/reports/receipt_no_detail_controller.rb
@@ -0,0 +1,71 @@
+class Reports::ReceiptNoDetailController < BaseReportController
+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
+
+ @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
+
+ payment_type = params[:payment_type]
+ @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
+
+ @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 = 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
+
+ out = {:status => 'ok', :message => date_arr}
+
+ respond_to do |format|
+ format.json { render json: out }
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 574d303c..b25ee229 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1061,6 +1061,37 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
return query
end
+def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type)
+ ## => left join -> show all sales although no orders
+ if payment_type.blank?
+ payment_type = ''
+ else
+ payment_type = " and sale_payments.payment_method = '#{payment_type}'"
+ end
+
+ query = Sale.select("sales.*,dining_facilities.name as table_name,dining_facilities.type as table_type")
+ if shift.present?
+ query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .joins("join bookings on bookings.sale_id = sales.sale_id")
+ .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
+ .group("sales.sale_id")
+ elsif shift_sale_range.present?
+ query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .joins("join bookings on bookings.sale_id = sales.sale_id")
+ .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
+ .group("sales.sale_id")
+ else
+ query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .joins("join bookings on bookings.sale_id = sales.sale_id")
+ .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
+ .group("sales.sale_id")
+ end
+ return query
+end
+
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")
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
new file mode 100755
index 00000000..1d7c2a94
--- /dev/null
+++ b/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb
@@ -0,0 +1,140 @@
+
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
+ <% if period_type != false %>
+
+
+
+
+
+ <% if defined? payments %>
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% end %>
+
+ <% end %>
+
+
+
diff --git a/app/views/reports/receipt_no_detail/index.html.erb b/app/views/reports/receipt_no_detail/index.html.erb
new file mode 100755
index 00000000..d2f7f11f
--- /dev/null
+++ b/app/views/reports/receipt_no_detail/index.html.erb
@@ -0,0 +1,289 @@
+
+
+
+
+ <%= render :partial=>'shift_sale_report_filter',
+ :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_detail_index_path} %>
+
+
+
+
+
+
+
+
+ | <%= 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 '-'%>
+ |
+
+ <% if @shift_from %>
+
+ <% if @shift_data.employee %>
+ <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
+ <% end %>
+ | <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> ) |
+
+ <% end %>
+
+ | <%= t("views.right_panel.detail.shift_name") %> |
+ <%= t("views.right_panel.detail.table") %> |
+ <%= t("views.right_panel.detail.receipt_no") %> |
+ <%= t :cashier %> <%= t("views.right_panel.detail.name") %> |
+ <%= t("views.right_panel.detail.revenue") %> |
+ |
+
+
+
+ <% grand_total = 0 %>
+ <% @sale_data.each do |result| %>
+ <% grand_total = grand_total.to_f + result.grand_total.to_f%>
+
+ | <%= @shift_from %> - <%= @shift_to %> |
+ <%= result.table_type %> - <%= result.table_name %> |
+ <%= result.receipt_no rescue '-' %> |
+ <%= result.cashier_name rescue '-' %> |
+ <%=result.grand_total%> |
+
+
+
+
+ | <%= t("views.right_panel.detail.product") %> |
+ <%= t("views.right_panel.detail.qty") %> |
+ <%= t("views.right_panel.detail.unit_price") %> |
+ <%= t("views.right_panel.detail.total_price") %> |
+ <%= t("views.right_panel.detail.created_at") %> |
+
+
+ <% result.sale_items.each do |item|%>
+
+ |
+ <% if item.price.to_i < 0.to_i %>
+ <% if item.qty.to_i < 0.to_i%>
+ [PROMO QTY]<%= item.product_name rescue '-' %>
+ <% else %>
+ [PROMO PRICE]<%= item.product_name rescue '-' %>
+ <% end %>
+ <% else %>
+ <%= item.product_name rescue '-' %>
+ <% end %>
+ |
+ <%= item.qty rescue '-' %> |
+ <%= item.unit_price rescue '-' %> |
+ <%= item.price rescue '-' %> |
+ <%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> |
+
+ <% end %>
+
+ | |
+
+ <%survey = Survey.find_by_receipt_no(result.receipt_no)%>
+ <% if !survey.nil?%>
+
+ | |
+ |
+ No. of Guest |
+ <%= survey.total_customer rescue '-' %> |
+ |
+
+ <% end %>
+
+ <% if !result.total_amount.nil?%>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> |
+ <%= result.total_amount %> |
+ |
+
+ <% end %>
+
+ <% if result.total_discount.to_f > 0 %>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.total") %>
+ <%= t("views.right_panel.detail.discount") %>
+ <%= t("views.right_panel.detail.amount") %> |
+ - <%= result.total_discount %> |
+ |
+
+ <% end %>
+
+ <% if !result.total_tax.nil? %>
+
+ | |
+ |
+ Tax Amount |
+ <%= result.total_tax %> |
+ |
+
+ <% end %>
+
+ <% if result.sale_payments.count > 0%>
+ <% result.sale_payments.each do |rec| %>
+
+ | |
+ |
+ Payment <%= rec.payment_method.upcase %> |
+ <%= rec.payment_amount %> ( <%= result.payment_status %> ) |
+ |
+
+
+ <% if !rec.payment_reference.nil? %>
+
+ | |
+ |
+ Payment Ref. |
+ <%= rec.payment_reference %> |
+ |
+
+ <% end %>
+ <% end %>
+ <% if result.amount_changed != 0 && !result.amount_changed.nil? %>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %> |
+ <%= result.amount_changed %> |
+ |
+
+ <% end %>
+ <% if !result.customer_id.nil?%>
+
+ | |
+ |
+ Customer |
+ <%= result.customer.name.contact_first_name rescue '-'%>
+ (<%= result.customer.company rescue '-' %>)
+ |
+ |
+
+ <% end %>
+ <% end %>
+
+ <% end %>
+
+ | |
+ |
+ |
+ Total Nett - <%= grand_total %> |
+ |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/reports/receipt_no_detail/index.xls.erb b/app/views/reports/receipt_no_detail/index.xls.erb
new file mode 100755
index 00000000..a4f5ed20
--- /dev/null
+++ b/app/views/reports/receipt_no_detail/index.xls.erb
@@ -0,0 +1,182 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | <%= 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 '-'%>
+ |
+
+ <% if @shift_from %>
+
+ <% if @shift_data.employee %>
+ <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
+ <% end %>
+ | <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> ) |
+
+ <% end %>
+
+ | <%= t("views.right_panel.detail.shift_name") %> |
+ <%= t("views.right_panel.detail.table") %> |
+ <%= t("views.right_panel.detail.receipt_no") %> |
+ <%= t :cashier %> <%= t("views.right_panel.detail.name") %> |
+ <%= t("views.right_panel.detail.revenue") %> |
+ |
+
+
+
+ <% grand_total = 0 %>
+ <% @sale_data.each do |result| %>
+ <% grand_total = grand_total.to_f + result.grand_total.to_f%>
+
+ | <%= @shift_from %> - <%= @shift_to %> |
+ <%= result.table_type %> - <%= result.table_name %> |
+ <%= result.receipt_no rescue '-' %> |
+ <%= result.cashier_name rescue '-' %> |
+ <%=result.grand_total%> |
+
+
+
+
+ | <%= t("views.right_panel.detail.product") %> |
+ <%= t("views.right_panel.detail.qty") %> |
+ <%= t("views.right_panel.detail.unit_price") %> |
+ <%= t("views.right_panel.detail.total_price") %> |
+ <%= t("views.right_panel.detail.created_at") %> |
+
+
+ <% result.sale_items.each do |item|%>
+
+ |
+ <% if item.price.to_i < 0.to_i %>
+ <% if item.qty.to_i < 0.to_i%>
+ [PROMO QTY]<%= item.product_name rescue '-' %>
+ <% else %>
+ [PROMO PRICE]<%= item.product_name rescue '-' %>
+ <% end %>
+ <% else %>
+ <%= item.product_name rescue '-' %>
+ <% end %>
+ |
+ <%= item.qty rescue '-' %> |
+ <%= item.unit_price rescue '-' %> |
+ <%= item.price rescue '-' %> |
+ <%=l item.created_at.utc.getlocal, :format => :short rescue '-' %> |
+
+ <% end %>
+
+ | |
+
+ <%survey = Survey.find_by_receipt_no(result.receipt_no)%>
+ <% if !survey.nil?%>
+
+ | |
+ |
+ No. of Guest |
+ <%= survey.total_customer rescue '-' %> |
+ |
+
+ <% end %>
+
+ <% if !result.total_amount.nil?%>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %> |
+ <%= result.total_amount %> |
+ |
+
+ <% end %>
+
+ <% if result.total_discount.to_f > 0 %>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.total") %>
+ <%= t("views.right_panel.detail.discount") %>
+ <%= t("views.right_panel.detail.amount") %> |
+ - <%= result.total_discount %> |
+ |
+
+ <% end %>
+
+ <% if !result.total_tax.nil? %>
+
+ | |
+ |
+ Tax Amount |
+ <%= result.total_tax %> |
+ |
+
+ <% end %>
+
+ <% if result.sale_payments.count > 0%>
+ <% result.sale_payments.each do |rec| %>
+
+ | |
+ |
+ Payment <%= rec.payment_method.upcase %> |
+ <%= rec.payment_amount %> ( <%= result.payment_status %> ) |
+ |
+
+
+ <% if !rec.payment_reference.nil? %>
+
+ | |
+ |
+ Payment Ref. |
+ <%= rec.payment_reference %> |
+ |
+
+ <% end %>
+ <% end %>
+ <% if result.amount_changed != 0 && !result.amount_changed.nil? %>
+
+ | |
+ |
+ <%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %> |
+ <%= result.amount_changed %> |
+ |
+
+ <% end %>
+ <% if !result.customer_id.nil?%>
+
+ | |
+ |
+ Customer |
+ <%= result.customer.name.contact_first_name rescue '-'%>
+ (<%= result.customer.company rescue '-' %>)
+ |
+ |
+
+ <% end %>
+ <% end %>
+
+ <% end %>
+
+ | |
+ |
+ |
+ Total Nett - <%= grand_total %> |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 1b7f3682..99c008ae 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -443,6 +443,7 @@ scope "(:locale)", locale: /en|mm/ do
#--------- Reports Controller Sections ------------#
namespace :reports do
resources :receipt_no
+ resources :receipt_no_detail
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]