From a96ed5ed09ea6dbadd50380d4d7e1546a2140915 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 8 Aug 2018 14:28:36 +0630 Subject: [PATCH] check tax amount > 0 in receipt report --- app/views/reports/receipt_no/index.html.erb | 53 +++++++++++++++++++-- app/views/reports/receipt_no/index.xls.erb | 45 +++++++++++++++-- 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 1d23b782..689db837 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -79,7 +79,20 @@ <% discount_amt = 0 %> <% other_amt = 0 %> <% total_nett = 0 %> - <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <% tax_profile_count = @tax_profiles.length %> + + <% + ttax_count = tax_profile_count - @sale_taxes.length + ttax_flag = true + @sale_taxes.each do |tax| + if tax.tax_name.downcase.include?("service") + ttax_flag = false + end + end + %> + + <%if @sale_data %> <% @sale_data.each do |result| %> @@ -89,8 +102,6 @@ <% total_sum += result.total_amount.to_f %> <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> - - <% tax_profile_count = @tax_profiles.length %> <% sale_tax_count = result.sale_taxes.length %> <% tax_count = tax_profile_count - sale_tax_count %> <% tax_flag = true %> @@ -99,6 +110,7 @@ tax_flag = false end end %> + <%= result.receipt_no rescue '-' %> @@ -148,7 +160,7 @@   <%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> - <% if !@sale_taxes.empty? + + + <% if !@sale_taxes.empty? %> + <% num = 1 + if ttax_flag && ttax_count > 0 %> + <% while num <= ttax_count %> + + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + + <% num += 1 + end %> + <% end %> + <% @sale_taxes.each do |tax| %> + + <%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + + <%end%> + <% num = 1 + if ttax_flag==false && ttax_count > 0 %> + <% while num <= ttax_count %> + + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %> + + <% num += 1 + end %> + <% end %> + <% else %> + <% @tax_profiles.each do |tax| %> + <%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <% end %> + <%end%> + <%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %> <%= rounding_adj.to_f rescue '-' %> diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb index b6ac51b0..038798ee 100755 --- a/app/views/reports/receipt_no/index.xls.erb +++ b/app/views/reports/receipt_no/index.xls.erb @@ -48,7 +48,19 @@ <% discount_amt = 0 %> <% other_amt = 0 %> <% total_nett = 0 %> - <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> + <% tax_profile_count = @tax_profiles.length %> + + <% + ttax_count = tax_profile_count - @sale_taxes.length + ttax_flag = true + @sale_taxes.each do |tax| + if tax.tax_name.downcase.include?("service") + ttax_flag = false + end + end + %> + <%if @sale_data %> <% @sale_data.each do |result| %> @@ -58,8 +70,6 @@ <% total_sum += result.total_amount.to_f %> <% discount_amt += result.total_discount.to_f %> <% rounding_adj += result.rounding_adjustment.to_f %> - - <% tax_profile_count = @tax_profiles.length %> <% sale_tax_count = result.sale_taxes.length %> <% tax_count = tax_profile_count - sale_tax_count %> <% tax_flag = true %> @@ -113,9 +123,34 @@   <%= total_sum rescue '-'%> <%= discount_amt rescue '-'%> - <% @sale_taxes.each do |tax| %> + + <% if !@sale_taxes.empty? %> + <% num = 1 + if ttax_flag && ttax_count > 0 %> + <% while num <= ttax_count %> + 0.00 + <% num += 1 + end %> + <% end %> + <% @sale_taxes.each do |tax| %> + + <%= tax.st_amount.to_f.round(2) %> + + <%end%> + <% num = 1 + if ttax_flag==false && ttax_count > 0 %> + <% while num <= ttax_count %> + 0.00 + <% num += 1 + end %> + <% end %> + <% else %> + <% @tax_profiles.each do |tax| %> + 0.00 + <% end %> + <%end%> <%= grand_total.to_f.round(2) rescue '-'%> <%= rounding_adj rescue '-'%> <%= grand_total.to_f.round + rounding_adj %>