daily sale net sales & tax

This commit is contained in:
yarzar_code
2020-08-12 14:34:53 +06:30
parent 51bb2d0fcf
commit 7aef3d7bac
4 changed files with 83 additions and 55 deletions

View File

@@ -4,7 +4,7 @@ class Reports::DailysaleController < BaseReportController
def index def index
from, to = get_date_range_from_params from, to = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to) @sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to) @tax_profiles = TaxProfile.group(:name).order(:order_by).pluck(:name)
@from = from @from = from
@to = to @to = to
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method") @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")

View File

@@ -754,6 +754,8 @@ class Sale < ApplicationRecord
def self.daily_sales_list(from,to) def self.daily_sales_list(from,to)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method) payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
tax_profiles = TaxProfile.group(:name).order(:order_by).pluck(:name)
sales = select(Sale.column_names) sales = select(Sale.column_names)
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.push('').join(', ')} .select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.push('').join(', ')}
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
@@ -764,6 +766,15 @@ class Sale < ApplicationRecord
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to) .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql .group("sale_id").to_sql
sale_taxes = Sale.select('sales.sale_id, sale_taxes.tax_name')
.joins(:sale_taxes)
.where('(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ', 'completed', 'void', from, to)
.group('sale_id')
if tax_profiles.present?
sale_taxes = sale_taxes.select(tax_profiles.map { |name| "SUM(case when (sale_taxes.tax_name = '#{name}') then sale_taxes.tax_payable_amount else 0 end) as `#{name.parameterize}`"}.join(', '))
end
daily_total = connection.select_all("SELECT daily_total = connection.select_all("SELECT
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale, IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
@@ -772,8 +783,9 @@ class Sale < ApplicationRecord
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount, IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj, IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax, #{tax_profiles.map { |name| "SUM(`#{name.parameterize}`) as `#{name.parameterize}`"}.push('').join(', ') if tax_profiles.present?}
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale, IFNULL(SUM(case when (sale_status='completed') then total_tax else 0 end),0) as tax,
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) - (IFNULL(SUM(case when (sale_status='completed') then total_tax else 0 end),0)) as net_sale,
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale, (IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0)) + (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as gross_sale,
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
#{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(`#{pm}`) as `#{pm}`"}.push('').join(', ')} #{payment_methods.map { |method| pm = method == 'paypar' ? 'redeem' : method; "SUM(`#{pm}`) as `#{pm}`"}.push('').join(', ')}
@@ -783,6 +795,7 @@ class Sale < ApplicationRecord
FROM ( FROM (
#{sales} #{sales}
) as s ) as s
JOIN (#{sale_taxes.to_sql}) AS st ON s.sale_id = st.sale_id
GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys) GROUP BY DATE(CONVERT_TZ(receipt_date,'+00:00','+06:30'))").to_hash.map(&:symbolize_keys)
return daily_total return daily_total
end end

View File

@@ -24,7 +24,7 @@
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th> <th colspan="<%= column_count = @payment_methods.length + 11 + @tax_profiles.length %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr> </tr>
<% @count = 1 %> <% @count = 1 %>
<% @payment_methods.each_slice(10) do |slice| %> <% @payment_methods.each_slice(10) do |slice| %>
@@ -72,13 +72,11 @@
<th></th> <th></th>
<th></th> <th></th>
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th> <th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
<th colspan=4 style='text-align:center;'>Outgoing</th> <th colspan='4' style='text-align:center;'>Outgoing</th>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - Void"><i class="material-icons md-18">live_help</i></th> <th colspan='<%= @tax_profiles.size %>' style='text-align:center;'>Tax</th>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Net Sales = Income - Tax"><i class="material-icons md-18">live_help</i></th>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Gross Sales = Income + Discount"><i class="material-icons md-18">live_help</i></th>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th> <th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th>
<% if @tax.blank? %>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th>
<th style='text-align:center; cursor: help;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th>
<% end %>
</tr> </tr>
<tr> <tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
@@ -86,22 +84,21 @@
<% @payment_methods.each do |method| %> <% @payment_methods.each do |method| %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th> <th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
<% end %> <% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th> <th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> --> <!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<% if @tax_profiles.present? %>
<% @tax_profiles.each do |name| %>
<th style='text-align:center;'><%= t name %></th>
<% end %>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.gross_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.gross_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.total_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.total_sales") %></th>
<% if @tax.blank? %>
<th style='text-align:center;'><%= t("views.right_panel.detail.tax") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
<% end %>
</tr> </tr>
</thead> </thead>
<% unless @sale_data.blank? %> <% unless @sale_data.blank? %>
@@ -148,12 +145,16 @@
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> --> <!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
<td style='text-align:right;'><%= number_format(sale[:rounding_adj], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:rounding_adj], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax_profiles.present? %>
<% @tax_profiles.each do |name| %>
<td style='text-align:right;'><%= number_format(sale[name.parameterize.to_sym], precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
<% end %>
<% end %>
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax.blank? %>
<td style='text-align:right;'><%= number_format(sale[:tax], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
</tr> </tr>
<% count = count + 1 %> <% count = count + 1 %>
@@ -172,33 +173,37 @@
<td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(gross_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(total_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <% if @tax_profiles.present? %>
<% if @tax.blank? %> <% @tax_profiles.each do |name| %>
<td style='text-align:right;'><%= number_format(tax, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[name.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <% end %>
<% end %> <% end %>
<td style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(gross_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(total_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr> </tr>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="<%= column_count %>">&nbsp;</td> <td colspan="<%= column_count %>">&nbsp;</td>
</tr> </tr>
<% total_tax = 0 %> <% total_tax = 0 %>
<% net = 0 %> <% net = 0 %>
<% unless @tax.blank? %> <% if @tax_profiles.present? %>
<% @tax.each do |tax| <% @tax_profiles.each do |name| %>
total_tax += tax.tax_amount.to_f %> <tr style="font-weight:600;">
<tr style="font-weight:600;"> <td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t name rescue '-'%></td>
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td> <td colspan="5" style='text-align:right;'>
<td colspan="5" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[name.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
</tr> </td>
</tr>
<% end %> <% end %>
<% net = grand_total %> <% net = grand_total %>
<% net = net - rounding_adj%> <% net = net - rounding_adj%>
<% net = net - total_tax %> <% net = net - total_tax %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td> <td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
</tr> </tr>
<% else %> <% else %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">

View File

@@ -22,6 +22,7 @@
<th></th> <th></th>
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th> <th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
<th colspan=4 style='text-align:center;'>Outgoing</th> <th colspan=4 style='text-align:center;'>Outgoing</th>
<th colspan='<%= @tax_profiles.size %>' style='text-align:center;'>Tax</th>
</tr> </tr>
<tr> <tr>
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
@@ -38,13 +39,14 @@
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th> <th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> --> <!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
<% if @tax_profiles.present? %>
<% @tax_profiles.each do |name| %>
<th style='text-align:center;'><%= t name %></th>
<% end %>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.gross_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.gross_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.total_sales") %></th> <th style='text-align:center;'><%= t("views.right_panel.detail.total_sales") %></th>
<% if @tax.blank? %>
<th style='text-align:center;'><%= t("views.right_panel.detail.tax") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
<% end %>
</tr> </tr>
</thead> </thead>
<% unless @sale_data.blank? %> <% unless @sale_data.blank? %>
@@ -90,12 +92,16 @@
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> --> <!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax_profiles.present? %>
<% @tax_profiles.each do |name| %>
<td style='text-align:right;'><%= number_format(sale[name.parameterize.to_sym], precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
<% end %>
<% end %>
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax.blank? %>
<td style='text-align:right;'><%= number_format(sale[:tax], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
</tr> </tr>
<% count = count + 1 %> <% count = count + 1 %>
@@ -114,12 +120,15 @@
<td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax_profiles.present? %>
<% @tax_profiles.each do |name| %>
<td style='text-align:right;'><%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[name.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
<% end %>
<td style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(gross_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(gross_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(total_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td style='text-align:right;'><%= number_format(total_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% if @tax.blank? %>
<td style='text-align:right;'><%= number_format(tax, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<% end %>
</tr> </tr>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
@@ -127,20 +136,21 @@
</tr> </tr>
<% total_tax = 0 %> <% total_tax = 0 %>
<% net = 0 %> <% net = 0 %>
<% unless @tax.blank? %> <% if @tax_profiles.present? %>
<% @tax.each do |tax| <% @tax_profiles.each do |name| %>
total_tax += tax.tax_amount.to_f %> <tr style="font-weight:600;">
<tr style="font-weight:600;"> <td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t name rescue '-'%></td>
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td> <td colspan="4" style='text-align:right;'>
<td colspan="1" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <%= number_format(@sale_data.inject(0.0.to_d) { |sum, sale| sum + sale[name.parameterize.to_sym] }, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
</tr> </td>
</tr>
<% end %> <% end %>
<% net = grand_total %> <% net = grand_total %>
<% net = net - rounding_adj%> <% net = net - rounding_adj%>
<% net = net - total_tax %> <% net = net - total_tax %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td> <td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td colspan="1" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td colspan="4" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr> </tr>
<% else %> <% else %>
<tr style="font-weight:600;"> <tr style="font-weight:600;">