update sale item report qty sum

This commit is contained in:
Aung Myo
2018-01-09 12:04:56 +06:30
parent 674f6cd37d
commit 6aab87a89d
2 changed files with 11 additions and 4 deletions

View File

@@ -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" +

View File

@@ -77,11 +77,14 @@
<% total_tax = 0 %>
<% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% 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 %>
<!-- end all total qty -->
<% 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 %>
<tr>
<td colspan="3">&nbsp;</td>