diff --git a/app/models/sale.rb b/app/models/sale.rb index 6dea5db3..2265a135 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1375,7 +1375,7 @@ end if payment_method == 'card' query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) else - query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and sales.receipt_date between ? and ?",from,to) end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else @@ -1384,7 +1384,7 @@ end if payment_method == 'card' query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) else - query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and sales.receipt_date between ? and ?",from,to) end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 85fe9630..91cce7e3 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -165,19 +165,19 @@
| <% @sale_data.each do |data| %> <% pay_mth = payment.payment_method %> - <%= data[""+pay_mth+""] %> + <%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> <% end %> | @@ -203,7 +203,7 @@|
| <%= t("views.right_panel.detail.card_sale") %> : | - <%= total_card["card"].to_f %> + <%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> |