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/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/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 @@

<%= t :dashboard %>

- + <% 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 + %>
@@ -125,19 +136,19 @@ <%= t("views.right_panel.detail.total") %> <%= t :sale %> : - <%= @summ_sale.total_amount %> + <%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : - <%= @summ_sale.total_discount %> + <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : - <%= @summ_sale.total_tax %> + <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%> <%= t("views.right_panel.detail.grand_total") %> : - <%= @summ_sale.grand_total %> + <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%> diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index 4ad30d82..a96b80f8 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -77,11 +77,14 @@ <% total_tax = 0 %> <% @sale_data.each do |sale| %> - + <% if sale.status_type != "Discount" && sale.status_type != "foc" total_qty += sale.total_item end %> - + <% if sale.status_type == "foc" && sale.price > 0 + total_qty += sale.total_item + end %> + <% if sale.status_type == "foc" && sale.grand_total < 0 total_item_foc += sale.grand_total*(-1) end %> @@ -127,9 +130,13 @@ <% count = count + 1 %> <% sub_total += sale.grand_total %> <% #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 end %> + <% if sale.status_type == "foc" && sale.price > 0 + sub_qty += sale.total_item + end %> + <% if count == value %>