From 89853935355d1a35d7e40df3a403842c8861b60f Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 8 Jul 2017 10:25:22 +0630 Subject: [PATCH] update receipt repoert --- .../reports/dailysale_controller.rb | 3 + .../reports/receipt_no_controller.rb | 262 ++++++++++++++++- app/models/sale.rb | 42 ++- app/pdf/receipt_bill_pdf.rb | 18 +- app/views/origami/payments/show.html.erb | 2 +- .../_shift_sale_report_filter.html.erb | 12 +- app/views/reports/dailysale/index.html.erb | 4 +- .../_shift_sale_report_filter.html.erb | 57 ++-- app/views/reports/receipt_no/index.html.erb | 269 ++++++++++++------ app/views/reports/receipt_no/index.xls.erb | 128 ++++++--- .../reports/receipt_no/indexback.html.erb | 115 ++++++++ .../reports/receipt_no/indexback.xls.erb | 43 +++ config/routes.rb | 4 +- 13 files changed, 751 insertions(+), 208 deletions(-) create mode 100644 app/views/reports/receipt_no/indexback.html.erb create mode 100644 app/views/reports/receipt_no/indexback.xls.erb diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index 27e812ab..14013a1b 100644 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -5,6 +5,9 @@ class Reports::DailysaleController < BaseReportController from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) @tax = SaleTax.get_tax(from,to) + puts from + puts to + puts "sssssssss" respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index e4157c4e..8e92ebb6 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,13 +1,34 @@ class Reports::ReceiptNoController < BaseReportController authorize_resource :class => false def index - from, to = get_date_range_from_params - puts "from..." - puts from - puts "to..." - puts to - @sale_data = Sale.get_receipt_no_list(from,to) - @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) + from, to, report_type = get_date_range_from_params + # if to.blank? + # @shift = ShiftSale.where('shift_started_at <= ? and shift_closed_at is NULL',from).take + # else + # @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take + # end + puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z" + puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC" +puts params[:shift_name] +puts from.utc +puts to.utc + + if params[:shift_name].to_i != 0 + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at =?',from,to).take + puts @shift.to_json + @sale_data = Sale.where('shift_sale_id = ? ',@shift.id) + @sale_taxes = Sale.get_separate_tax(from,to) + else + @sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc) + @sale_taxes = Sale.get_separate_tax(from.utc,to.utc) + end + + + if @shift.present? + @shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") + end + respond_to do |format| format.html format.xls @@ -15,6 +36,231 @@ authorize_resource :class => false end def show - + from, to, report_type = get_date_range_from_params + + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) +puts "hhhhhhhhhhhhhhhhhhhhh" +puts @sale_data.to_json +puts from +puts to +puts report_type +puts params[:shift_name] + + 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 + str = { :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 + + + def get_date_range_from_params + + period_type = params[:period_type] + period = params[:period] + + branch = params[:branch] + report_type = params[:report_type] + + shift_name = params[:shift_name] + unless shift_name.nil? + shift_arr = shift_name.split(' - ') + shift_from = shift_arr[0] + shift_to = shift_arr[1] + end + + day_ref = day_ref = Time.now.utc.getlocal + + if period_type.to_i == 1 + + ### =>search by from and to + unless shift_name.nil? + if shift_name.to_s == '0' + ### => all shift + f_date = DateTime.parse(params[:from]) + t_date = DateTime.parse(params[: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 + unless shift_from == '-' + f_date = DateTime.parse(shift_from) + from = f_date + else + from = '' + end + + unless shift_to == '-' + t_date = DateTime.parse(shift_to) + to = t_date + else + to = '' + end + end + else + f_date = DateTime.parse(params[:from]) + t_date = DateTime.parse(params[: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 + end + else + ### => search by Today or yesterday + + unless shift_name.nil? + if shift_name.to_s == '0' + ### => all shift + 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 + + else + unless shift_from == '-' + f_date = DateTime.parse(shift_from) + #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) + from = f_date.utc + else + from = '' + end + + unless shift_to == '-' + t_date = DateTime.parse(shift_to) + #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) + to = t_date.utc + else + to = '' + end + end + else + if params[:report_type].to_i != 0 + r_type = params[:report_type].to_s + + if r_type == 'shift_item' + + 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 + else + ### => report not shift + 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 + end + + end + + return from, to,report_type + end + + end \ No newline at end of file diff --git a/app/models/sale.rb b/app/models/sale.rb index 0e767ea0..266644be 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -445,6 +445,7 @@ class Sale < ApplicationRecord total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total, IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount, + IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount, IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj") .where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date) @@ -454,6 +455,7 @@ class Sale < ApplicationRecord old_grand_total = sale.old_grand_total total_discount = sale.total_discount void_amount = sale.void_amount + total_change_amount = sale.total_change_amount total = {:sale_date => pay.sale_date, :mpu_amount => pay.mpu_amount, :master_amount => pay.master_amount, @@ -464,6 +466,7 @@ class Sale < ApplicationRecord :credit_amount => pay.credit_amount, :foc_amount => pay.foc_amount, :total_discount => total_discount, + :total_change_amount => total_change_amount, :grand_total => grand_total, :old_grand_total => old_grand_total, :void_amount => void_amount, @@ -514,7 +517,7 @@ def self.get_by_shiftsales(from,to) return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) end -# def self.get_by_shiftsales(employee,from,to) +# def self.get_by_shiftsales(from,to) # shift_sales = ShiftSale.select('shift_sales.id, cs.name as cashier_station_name, shift_sales.shift_started_at as opening_date, shift_sales.shift_closeed_at as closing_date') # .joins(" INNER JOIN cashier_terminals cs ON cs.id = shift_sales.cashier_terminal_id") # .where("shift_sales.employee_id = ? and (shift_sales.shift_started_at between ? and ? OR shift_sales.shift_closeed_at between ? and ? )", employee, from, to, from, to) @@ -529,23 +532,23 @@ end # void = Sale.select("SUM(sales.grand_total) AS grand_total") # .joins("join shift_sales sh on sh.id = sales.shift_sale_id") -# .where('sales.sales_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id) +# .where('sales.sale_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id) # .sum(:grand_total) # cash = all_total.select('sr.payment_type') # .where('sr.payment_type = "cash"') # .sum(:amount) -# credit = all_total.where('sr.payment_type = "credit"') +# credit = all_total.where('sr.payment_type = "creditnote"') # .sum(:amount) # accept_credit = all_total.select('ci.amout') # .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id") -# .where('sr.payment_type = "credit"') +# .where('sr.payment_type = "creditnote"') # .sum(:amout) -# foc = all_total.where('sales.payment_type = "foc" and sales.sales_status = "completed"') +# foc = all_total.where('sales.payment_type = "foc" and sales.sale_status = "completed"') # .sum(:grand_total) # card = all_total.select('payment_type') @@ -571,6 +574,31 @@ end # return sale_arr # end +# def self.get_receipt_no_list(from,to) +# sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to) +# end + +def self.get_by_shift_sale(from,to,status) + query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,shift_closed_at As closing_date," + + " grand_total AS grand_total, cash_sales AS cash," + + "total_taxes AS total_tax,total_discounts As total_discount") + .order("shift_sales.id DESC") + return query = query.where("shift_sales.shift_started_at between ? and ?" + " or shift_sales.shift_closed_at between ? and ?",from,to ,from,to ) +end + +def self.get_separate_tax(from,to,payment_type=nil) + + query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name") + .joins("INNER JOIN sales ON sales.id = sale_taxes.sale_id") + .group("sale_taxes.tax_name") + + return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to) +end + +def grand_total_after_rounding + return self.grand_total.to_f + self.rounding_adjustment.to_f +end + def get_cash_amount cash = 0.0 self.sale_payments.each do |pay| @@ -616,8 +644,4 @@ end def generate_custom_id self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") end - - def self.get_receipt_no_list(from,to) - sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to) - end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index bd65ed20..b6c5416b 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -317,16 +317,16 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end - # old = balance + redeem + old = balance + redeem - # move_down 5 - # y_position = cursor - # bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - # 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(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - # end + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + 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(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end end end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 9b04e38e..505050eb 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -119,7 +119,7 @@
<%= @other %>
<% else %> -
+
Other Payments
<% end %> diff --git a/app/views/reports/dailysale/_shift_sale_report_filter.html.erb b/app/views/reports/dailysale/_shift_sale_report_filter.html.erb index 9b89858a..28706731 100644 --- a/app/views/reports/dailysale/_shift_sale_report_filter.html.erb +++ b/app/views/reports/dailysale/_shift_sale_report_filter.html.erb @@ -19,17 +19,7 @@
- +
diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index 64565fb5..d01463b7 100644 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -70,7 +70,7 @@ <% visa += sale[:visa_amount] %> <% jcb += sale[:jcb_amount] %> <% paypar += sale[:paypar_amount] %> - <% cash += sale[:cash_amount] %> + <% cash += sale[:cash_amount]-sale[:total_change_amount] %> <% credit += sale[:credit_amount] %> <% foc += sale[:foc_amount] %> <% discount += sale[:total_discount] %> @@ -86,7 +86,7 @@ <%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%> - <%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%> + <%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%> (<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>) 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 1b4082f5..d8e91393 100644 --- a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -18,6 +18,7 @@
+
-
+
-
+
-
+
+ + +
+
@@ -70,11 +75,7 @@ <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> <% end %> - <% if defined? shift_name %> - - <% end %> + <% if defined? cashiers %> <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> @@ -116,22 +117,6 @@
- \ No newline at end of file + diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index dc7d05ee..d87fcccf 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -1,13 +1,13 @@
- <%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %> + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_receipt_no_index_path} %>
@@ -21,95 +21,182 @@
- - - - - - - - - - <% TaxProfile.all.each do |r|%> - - <% end %> - - - +
DateReceipt NoCashier NameGross SalesDiscountTotal Sales<%=r.name%>Nett Sales
+ + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift.employee %> + <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> + <% end %> + + + <% end %> - - <% total_sales = 0 %> - <% net_sales = 0 %> - <% @sale_data.each do |sale| %> - <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> - <% net_sales = total_sales.to_f + sale.total_tax.to_f%> - - - - - - - - <% sale.sale_taxes.each do |sale|%> - - <% end %> - - - - <% end %> - -
From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
<%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %><%=sale.receipt_no.to_s rescue ''%><%=Employee.find(sale.cashier_id).name rescue ''%><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
-
+ + Recipt No + Cashier Name + Total Amount + Discount Amount + Tax Amount + + Grand Total + Rounding Adj. + Grand Total +
+ Rounding Adj. + + + + + <% grand_total = 0 %> + <% total_tax = 0 %> + <% guest_count = 0 %> + <% total_sum = 0 %> + <% discount_amt = 0 %> + <% other_amt = 0 %> + <% total_nett = 0 %> + <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + + <% @sale_data.each do |result| %> + + <% grand_total = grand_total.to_f + result.grand_total.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 %> + + + + <%= result.receipt_no rescue '-' %> + <%= result.cashier_name rescue '-' %> + <%= result.total_amount rescue '-' %> + <%= result.total_discount rescue '-' %> + <%= sprintf "%.2f",result.total_tax rescue '-' %> + + + <%= result.grand_total %> + <%= result.rounding_adjustment.to_f rescue '-' %> + <%= result.grand_total_after_rounding() rescue '-'%> + + + <% end %> + +   + <%= total_sum rescue '-'%> + <%= discount_amt rescue '-'%> + <%= sprintf "%.2f",total_tax rescue '-'%> + + <%= grand_total.to_f.round(2) rescue '-'%> + <%= rounding_adj rescue '-'%> + <%= grand_total.to_f.round + rounding_adj %> + + +   + Total Amount + Discount Amount + Tax Amount + Grand Total + Rounding Adj. + Grand Total +
+ Rounding Adj. + + + + +
-<%= paginate @sale_data %> - \ No newline at end of file diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index 5befb18a..b55a40c4 100644 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -1,43 +1,91 @@ -
-
+
+
+ + + <% if !params[:from].blank?%> + + + + <% end %> + <% if @shift_from %> + + <% if @shift.employee %> + <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %> + <% end %> + + + <% end %> -
From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
- - - - - - - - - <% TaxProfile.all.each do |r|%> - - <% end %> - - - + + + + + + + + + + + + + + <% grand_total = 0 %> + <% total_tax = 0 %> + <% guest_count = 0 %> + <% total_sum = 0 %> + <% discount_amt = 0 %> + <% other_amt = 0 %> + <% total_nett = 0 %> + <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> - - <% total_sales = 0 %> - <% net_sales = 0 %> - <% @sale_data.each do |sale| %> - <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> - <% net_sales = total_sales.to_f + sale.total_tax.to_f%> - - - - - - - - <% sale.sale_taxes.each do |sale|%> - - <% end %> - - - - <% end %> - -
DateReceipt NoCashier NameGross SalesDiscountTotal Sales<%=r.name%>Nett Sales
Recipt NoCashier NameTotal AmountDiscount Amount Tax AmountGrand TotalRounding Adj.Grand Total +
+ Rounding Adj. +
<%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %><%=sale.receipt_no.to_s rescue ''%><%=Employee.find(sale.cashier_id).name rescue ''%><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
-
+ <% @sale_data.each do |result| %> + + <% grand_total = grand_total.to_f + result.grand_total.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 %> + + + + <%= result.receipt_no rescue '-' %> + <%= result.cashier_name rescue '-' %> + <%= result.total_amount rescue '-' %> + <%= result.total_discount rescue '-' %> + <%= sprintf "%.2f",result.total_tax rescue '-' %> + + + <%= result.grand_total %> + <%= result.rounding_adjustment.to_f rescue '-' %> + <%= result.grand_total_after_rounding() rescue '-'%> + + + <% end %> + +   + <%= total_sum rescue '-'%> + <%= discount_amt rescue '-'%> + <%= sprintf "%.2f",total_tax rescue '-'%> + + <%= grand_total.to_f.round(2) rescue '-'%> + <%= rounding_adj rescue '-'%> + <%= grand_total.to_f.round + rounding_adj %> + + +   + Total Amount + Discount Amount + Tax Amount + Grand Total + Rounding Adj. + Grand Total +
+ Rounding Adj. + + + +
+
\ No newline at end of file diff --git a/app/views/reports/receipt_no/indexback.html.erb b/app/views/reports/receipt_no/indexback.html.erb new file mode 100644 index 00000000..dc7d05ee --- /dev/null +++ b/app/views/reports/receipt_no/indexback.html.erb @@ -0,0 +1,115 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %> +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + <% TaxProfile.all.each do |r|%> + + <% end %> + + + + + + <% total_sales = 0 %> + <% net_sales = 0 %> + <% @sale_data.each do |sale| %> + <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> + <% net_sales = total_sales.to_f + sale.total_tax.to_f%> + + + + + + + + <% sale.sale_taxes.each do |sale|%> + + <% end %> + + + + <% end %> + +
DateReceipt NoCashier NameGross SalesDiscountTotal Sales<%=r.name%>Nett Sales
<%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %><%=sale.receipt_no.to_s rescue ''%><%=Employee.find(sale.cashier_id).name rescue ''%><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
+
+
+ +<%= paginate @sale_data %> + + \ No newline at end of file diff --git a/app/views/reports/receipt_no/indexback.xls.erb b/app/views/reports/receipt_no/indexback.xls.erb new file mode 100644 index 00000000..5befb18a --- /dev/null +++ b/app/views/reports/receipt_no/indexback.xls.erb @@ -0,0 +1,43 @@ +
+
+ + + + + + + + + + + <% TaxProfile.all.each do |r|%> + + <% end %> + + + + + + <% total_sales = 0 %> + <% net_sales = 0 %> + <% @sale_data.each do |sale| %> + <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> + <% net_sales = total_sales.to_f + sale.total_tax.to_f%> + + + + + + + + <% sale.sale_taxes.each do |sale|%> + + <% end %> + + + + <% end %> + +
DateReceipt NoCashier NameGross SalesDiscountTotal Sales<%=r.name%>Nett Sales
<%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %><%=sale.receipt_no.to_s rescue ''%><%=Employee.find(sale.cashier_id).name rescue ''%><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
+
+
diff --git a/config/routes.rb b/config/routes.rb index 2b7db5eb..98943507 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -268,10 +268,12 @@ Rails.application.routes.draw do #--------- Reports Controller Sections ------------# namespace :reports do - resources :receipt_no, :only => [:index, :show] + resources :receipt_no resources :dailysale, :only => [:index, :show] resources :saleitem, :only => [:index, :show] resources :shiftsale, :only => [:index, :show] + + get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show]