Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2018-01-09 17:08:00 +06:30
7 changed files with 54 additions and 24 deletions

View File

@@ -113,6 +113,9 @@ class HomeController < ApplicationController
@top_items = Sale.top_items(today) @top_items = Sale.top_items(today)
@total_foc_items = Sale.total_foc_items(today) @total_foc_items = Sale.total_foc_items(today)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
end end
def destroy def destroy

View File

@@ -37,6 +37,25 @@ class MenuCategory < ApplicationRecord
end end
end end
def valid_time
menu_category = MenuCategory.find(self.id)
menu = Menu.find(menu_category.menu_id)
from = menu.valid_time_from.strftime("%H:%m:%S")
to = menu.valid_time_to.strftime("%H:%m:%S")
current = Time.now.utc.getlocal.strftime("%H:%m:%S")
from = from.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
to = to.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
current = current.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
if current.between?(from, to)
return true
else
return nil
end
end
private private
# def generate_menu_category_code # def generate_menu_category_code

View File

@@ -654,7 +654,7 @@ def self.get_item_query()
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " + query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," + "SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
"i.remark as status_type,"+ "i.remark as status_type,"+
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" + " i.unit_price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
" menu_category_name,mc.id as menu_category_id ") " menu_category_name,mc.id as menu_category_id ")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +

View File

@@ -360,7 +360,7 @@ class CloseCashierPdf < Prawn::Document
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end end
end end
#end total amount by Account #end total amount by Account

View File

@@ -2,7 +2,18 @@
<div class="block-header"> <div class="block-header">
<h2><%= t :dashboard %></h2> <h2><%= t :dashboard %></h2>
</div> </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 --> <!-- Widgets -->
<div class="row clearfix"> <div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12"> <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
@@ -125,19 +136,19 @@
</tr> </tr>
<tr> <tr>
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td> <td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
<td align="right"><%= @summ_sale.total_amount %></td> <td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr> </tr>
<tr> <tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td> <td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
<td align="right"><%= @summ_sale.total_discount %></td> <td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr> </tr>
<tr> <tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td> <td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
<td align="right"><%= @summ_sale.total_tax %></td> <td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
</tr> </tr>
<tr> <tr>
<td><%= t("views.right_panel.detail.grand_total") %> : </td> <td><%= t("views.right_panel.detail.grand_total") %> : </td>
<td align="right"><%= @summ_sale.grand_total %></td> <td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
</tr> </tr>
</table> </table>
<table class="table"> <table class="table">

View File

@@ -8,6 +8,7 @@
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" > <ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %> <% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %> <% if menu.menu_category_id.nil? %>
<% if @table.get_current_checkout_booking.nil? %> <% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %> <% if !menu.code.include? "SPL" %>
@@ -28,21 +29,10 @@
</a> </a>
</li> </li>
<% end%> <% end%>
<% end%> <% end%>
<% end %>
<%end %> <%end %>
<!-- <li class="nav-item menu_category">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1 <b class="caret"></b></a>
<ul class="dropdown-menu multi-level">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
<li class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li> -->
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>"> <li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a> <a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li> </li>

View File

@@ -77,11 +77,14 @@
<% total_tax = 0 %> <% total_tax = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" <% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item total_qty += sale.total_item
end %> end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0 <% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1) total_item_foc += sale.grand_total*(-1)
end %> end %>
@@ -127,9 +130,13 @@
<% count = count + 1 %> <% count = count + 1 %>
<% sub_total += sale.grand_total %> <% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %> <% #sub_qty += sale.total_item %>
<% if sale.status_type != "Discount" && sale.status_type != "foc" <% if sale.status_type!="Discount" && sale.status_type!="foc"
sub_qty += sale.total_item sub_qty += sale.total_item
end %> end %>
<% if sale.status_type == "foc" && sale.price > 0
sub_qty += sale.total_item
end %>
<% if count == value %> <% if count == value %>
<tr> <tr>
<td colspan="3">&nbsp;</td> <td colspan="3">&nbsp;</td>