From ff4cdfa158300f79f7a5427faa850b9517309427 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 30 Apr 2018 15:16:07 +0630 Subject: [PATCH] update member discount and tax --- .../reports/order_reservation_controller.rb | 63 +++++ app/views/origami/home/show.html.erb | 2 +- app/views/origami/payments/show.html.erb | 3 +- .../_shift_sale_report_filter.html.erb | 128 +++++++++ .../reports/order_reservation/index.html.erb | 248 ++++++++++++++++++ .../reports/order_reservation/index.xls.erb | 106 ++++++++ config/routes.rb | 1 + 7 files changed, 548 insertions(+), 3 deletions(-) create mode 100644 app/controllers/reports/order_reservation_controller.rb create mode 100755 app/views/reports/order_reservation/_shift_sale_report_filter.html.erb create mode 100755 app/views/reports/order_reservation/index.html.erb create mode 100755 app/views/reports/order_reservation/index.xls.erb diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb new file mode 100644 index 00000000..fb9517e4 --- /dev/null +++ b/app/controllers/reports/order_reservation_controller.rb @@ -0,0 +1,63 @@ +class Reports::OrderReservationController < BaseReportController +# authorize_resource :class => false + def index + @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["Other Payment","card"]] + + from, to = get_date_range_from_params + + @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift = '' + if params[:shift_name].to_i != 0 + 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 + + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end + end + payment_type = params[:payment_type] + @sale_data = Sale.get_sales_by_order_reservation(@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(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/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 9e6cb2f9..cc5e0f2f 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -826,7 +826,7 @@ $.ajax({ type: "POST", url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card }, + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier' }, async: false, success:function(result){ } diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 100b1425..d1a9eef4 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -530,7 +530,6 @@ var customer_name = "<%= @customer.name %>"; } else{ $("#credit_payment").show(); } -console.log(jQuery.inArray("Master", payment_type)) if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 || parseInt(jQuery.inArray("VISA", payment_type)) != -1 || parseInt(jQuery.inArray("JCB", payment_type)) != -1 || @@ -1020,7 +1019,7 @@ console.log(jQuery.inArray("Master", payment_type)) $.ajax({ type: "POST", url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card }, + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':cashier_type }, async: false, success:function(result){ } diff --git a/app/views/reports/order_reservation/_shift_sale_report_filter.html.erb b/app/views/reports/order_reservation/_shift_sale_report_filter.html.erb new file mode 100755 index 00000000..a1db6824 --- /dev/null +++ b/app/views/reports/order_reservation/_shift_sale_report_filter.html.erb @@ -0,0 +1,128 @@ +
+ <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
+
+ + +
+ <% if defined? payments %> +
+ + <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> +
+ <% end %> +
+ + + +
+
+ + +
+
+ + +
+
+
+ +
+
+ <% end %> + + <% end %> +
+ + diff --git a/app/views/reports/order_reservation/index.html.erb b/app/views/reports/order_reservation/index.html.erb new file mode 100755 index 00000000..567b056b --- /dev/null +++ b/app/views/reports/order_reservation/index.html.erb @@ -0,0 +1,248 @@ + +
+
+ + + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_index_path} %> +
+ + + + + + + + +
+
+ + + + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + + + + <% 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 + + puts precision + puts "predelidm" + puts delimiter %> + + <% grand_total = 0 %> + <% old_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 %> + <%if @sale_data %> + <% @sale_data.each do |result| %> + + <% grand_total = grand_total.to_f + result.grand_total.to_f %> + <% old_grand_total = old_grand_total.to_f + result.old_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 %> + + + + + + + + <%if result.customer.customer_type == "Takeaway"%> + + <%end%> + <% result.sale_taxes.each do |tax| %> + + <%end%> + + + + + + + <% end %> + + + + + <% @sale_taxes.each do |tax| %> + + <% end %> + + + + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + <%end%> + +
<%= 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 '-'%>
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= 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.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %><%= result.rounding_adjustment.to_f rescue '-' %><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
 <%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= rounding_adj.to_f rescue '-' %><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %>
 <%= 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.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
+
+
+
+
+ + \ No newline at end of file diff --git a/app/views/reports/order_reservation/index.xls.erb b/app/views/reports/order_reservation/index.xls.erb new file mode 100755 index 00000000..c8521b0d --- /dev/null +++ b/app/views/reports/order_reservation/index.xls.erb @@ -0,0 +1,106 @@ + +
+
+
+
+ + + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + + + + <% grand_total = 0 %> + <% old_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 %> + <%if @sale_data %> + <% @sale_data.each do |result| %> + + <% grand_total = grand_total.to_f + result.grand_total.to_f %> + <% old_grand_total = old_grand_total.to_f + result.old_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 %> + + + + + + + + <%if result.customer.customer_type == "Takeaway"%> + + <%end%> + <% result.sale_taxes.each do |tax| %> + + <%end%> + + + + + + + <% end %> + + + + + <% @sale_taxes.each do |tax| %> + + <% end %> + + + + + + + + + + <% @tax_profiles.each do |tax| %> + + <% end %> + + + + + <%end%> + +
<%= 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 '-'%>
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= 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.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %>0.0<%= tax.tax_payable_amount rescue '-' %><%= result.grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%>
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= tax.st_amount.round(2) %><%= grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= grand_total.to_f.round + rounding_adj %>
 <%= 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.name %><%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.rnd_adj_sh") %><%= t("views.right_panel.detail.grand_total") %> +
+ <%= t("views.right_panel.detail.rnd_adj_sh") %> +
+
+
+
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 30b78fd9..760ee999 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -436,6 +436,7 @@ scope "(:locale)", locale: /en|mm/ do resources :stock_check, :only => [:index, :show] resources :payment_method resources :product_sale, :only => [:index, :show] + resources :order_reservation, :only => [:index, :show] get "saleitem/get_shift_by_date", to: "saleitem#show", as: "get_shift_by_sale_item" get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"