diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1ee30bab..25fb0d70 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -113,6 +113,9 @@ class HomeController < ApplicationController @top_items = Sale.top_items(today) @total_foc_items = Sale.total_foc_items(today) + + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() end def destroy diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 9930d3cd..200c4469 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -37,6 +37,25 @@ class MenuCategory < ApplicationRecord 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 # def generate_menu_category_code diff --git a/app/models/sale.rb b/app/models/sale.rb index 69aa930a..0b68bf49 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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, " + "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.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 ") query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" + diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index d84b0366..35248b97 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -360,7 +360,7 @@ class CloseCashierPdf < Prawn::Document text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right end 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 total amount by Account diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 3ed5e068..eb1bdecd 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -2,7 +2,18 @@