diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 18c86d92..2e213323 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -18,7 +18,7 @@ class Reports::SaleitemController < BaseReportController @sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) -puts @sale_taxes.to_json +puts @sale_data.to_json @account_cate_count = Hash.new {|hash, key| hash[key] = 0} diff --git a/app/models/sale.rb b/app/models/sale.rb index 457278c0..4b60cc94 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -646,7 +646,7 @@ end 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," + + "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" + " menu_category_name,mc.id as menu_category_id ") diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index 2999a0cf..86dc85b4 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -65,10 +65,18 @@ <% @sale_data.each do |sale| %> - <% if sale.total_item > 0 && sale.status_type != "Discount" && sale.status_type != "foc" + <% if sale.status_type != "Discount" && sale.status_type != "foc" total_qty += sale.total_item end %> + <% if sale.status_type == "foc" && sale.grand_total < 0 + total_item_foc += sale.grand_total*(-1) + end %> + + <% if sale.status_type == "Discount" && sale.grand_total < 0 + total_item_dis += sale.grand_total*(-1) + end %> + <% if !acc_arr.include?(sale.account_id) %> <%= sale.account_name %> @@ -111,13 +119,6 @@ <%= t("views.right_panel.detail.sub_total") %> <%= sub_total %> - <% if sale.status_type === "foc" - total_item_foc += sale.grand_total - end %> - - <% if sale.status_type === "Discount" - total_item_dis += sale.grand_total - end %> <% sub_total = 0.0%> <% count = 0%> <% end %>