diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 74cc9ba9..d8592664 100755
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -91,7 +91,7 @@ class HomeController < ApplicationController
end
end
@summ_sale = Sale.summary_sale_receipt(today)
-
+ p @summ_sale
@total_customer = Sale.total_customer(today)
@total_dinein = Sale.total_dinein(today)
@total_takeaway = Sale.total_takeaway(today)
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 696e0598..ef00fb6a 100755
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -954,7 +954,7 @@ end
end
def self.summary_sale_receipt(today)
- query = Sale.select('count(sale_id) as total_receipt, sum(total_amount) as total_amount, sum(grand_total) as grand_total, sum(total_discount) as total_discount, sum(total_tax) as total_tax')
+ query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.first()
end
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index fa0c9c72..2de6f67d 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -103,9 +103,9 @@
+ <% if !@summ_sale.nil? %>
- <% if !@summ_sale.nil? %>
- <% end %>
+ <% end %>
@@ -168,44 +168,34 @@
Customer
<% if !@total_customer.nil? %>
- <% if @total_customer.total_cus > 0 %>
-
- | Total Customer : |
- <%= @total_customer.total_cus %> |
-
- <% end %>
+
+ | Total Customer : |
+ <%= @total_customer.total_cus %> |
+
<% end %>
<% if !@total_dinein.nil? %>
- <% if @total_dinein.total_dinein_cus > 0 %>
-
- | Dine in : |
- <%= @total_dinein.total_dinein_cus %> |
-
- <% end %>
+
+ | Dine in : |
+ <%= @total_dinein.total_dinein_cus %> |
+
<% end %>
<% if !@total_takeaway.nil? %>
- <% if @total_takeaway.total_take_cus > 0 %>
-
- | Takeaway : |
- <%= @total_takeaway.total_take_cus %> |
-
- <% end %>
+
+ | Takeaway : |
+ <%= @total_takeaway.total_take_cus %> |
+
<% end %>
<% if !@total_other_customer.nil? %>
- <% if @total_other_customer.total_cus > 0 %>
-
- | Customer : |
- <%= @total_other_customer.total_cus %> |
-
- <% end %>
+
+ | Customer : |
+ <%= @total_other_customer.total_cus %> |
+
<% end %>
<% if !@total_membership.nil? %>
- <% if @total_membership.total_memb_cus > 0 %>
-
- | Membership : |
- <%= @total_membership.total_memb_cus %> |
-
- <% end %>
+
+ | Membership : |
+ <%= @total_membership.total_memb_cus %> |
+
<% end %>
@@ -220,12 +210,10 @@
Order
<% if !@total_order.nil? %>
- <% if @total_order.total_order > 0 %>
-
- | Total Order : |
- <%= @total_order.total_order %> |
-
- <% end %>
+
+ | Total Order : |
+ <%= @total_order.total_order %> |
+
<% end %>
<% if !(@total_accounts.nil?) %>
@@ -249,12 +237,10 @@
<% end %>
<% if !@total_foc_items.nil? %>
- <% if @total_foc_items > 0 %>
-
- | Total FOC Item : |
- <%= @total_foc_items %> |
-
- <% end %>
+
+ | Total FOC Item : |
+ <%= @total_foc_items %> |
+
<% end %>