rounding decimal to print_settings precision

This commit is contained in:
Thein Lin Kyaw
2019-11-06 17:34:42 +06:30
parent 33670b450e
commit 155cb0a9eb
11 changed files with 467 additions and 802 deletions

View File

@@ -34,7 +34,7 @@
<span class="hidden" id ="table_id" value="<%=@table%>"><%=@table%></span>
<span class="hidden" id="table_type" value="<%=@table%>"><%=@table%></span>
<%end%>
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
<p class="m-l-10">Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
@@ -57,8 +57,8 @@
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
<%
sub_total += sale_item.qty*sale_item.unit_price
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
@@ -76,7 +76,7 @@
</tr>
<%
end
end
end
%>
</tbody>
</table>
@@ -130,18 +130,18 @@
<div class="card-block">
<div class="card-title">
<div class="form-horizontal">
<div class="col-md-12">
<div class="form-group">
<div class="col-md-12">
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
<span id="discount-amountErr" style="color:red;"></span>
</div>
<br>
<div class="form-group">
<div class="form-group">
<% @accounts.each do |acc| %>
<button id="account-<%= acc.id %>" class="accounts-type btn bg-default"><%= acc.title %></button>
<% end %>
</div>
</div>
</div>
</div>
</div>
@@ -217,11 +217,11 @@
<div class="col-md-4">
<div class="form-group">
<button id="net" class="btn bg-info fluid action-btn">Nett</button>
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
<button id="percentage" class="btn bg-primary fluid action-btn" style="font-size: 12.4px">Percentage</button>
<button id="remove-item" class="btn bg-default fluid action-btn">Clear Discount</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -235,7 +235,7 @@
<div class="form-horizontal">
<div class="p-l-20">
<div class="row">
<div class="col-md-8 form-group">
<div class="col-md-8 form-group">
<div class="form-group">
<input type="text" id="promo-code" name="promo-code" value="" class="form-control" /></span>
</div>
@@ -243,11 +243,11 @@
<div class="col-md-4">
<button id="" class="btn bg-primary btn-block action-btn">Promo</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
</div>
<!-- Column Three -->
@@ -259,7 +259,7 @@
<button id="remove-all" class="btn bg-primary btn-block action-btn">Remove All</button>
<button id="pay-discount" class="btn bg-primary btn-block action-btn">Enter</button>
<% if @member_discount%>
<!-- <hr />
<!-- <hr />
<button id="member-discount" class="btn btn-success btn-block action-btn
<%= @sale_data.customer.membership_id ? " " : "disabled"%>">Member Discount</button> -->
<%end %>
@@ -300,10 +300,10 @@ var cashier_type = "<%= @cashier_type %>";
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
$('#discount-amount').val(original_value + '' + input_value);
}
break;
case 'add':
@@ -313,10 +313,10 @@ var cashier_type = "<%= @cashier_type %>";
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#discount-amount').val("0.0");
$('#discount-amount').val("0.0");
break;
}
event.handled = true;
@@ -374,7 +374,7 @@ var cashier_type = "<%= @cashier_type %>";
}
}
});
}
}
});
// Calculate Net Discount for Payment
@@ -384,7 +384,7 @@ var cashier_type = "<%= @cashier_type %>";
var discount_value = $('#discount-amount').val();
var sub_total = parseFloat($('#order-sub-total').text());
var ajax_url = "/origami/" + sale_id + "/discount";
if(discount_value!=""){
if(discount_value > 0){
if(parseFloat(discount_value) > sub_total){
@@ -393,7 +393,7 @@ var cashier_type = "<%= @cashier_type %>";
}else{
$("#discount-amountErr").html("");
// Selected Items
var sale_items = get_selected_sale_items();
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
@@ -402,8 +402,8 @@ var cashier_type = "<%= @cashier_type %>";
calculate_overall_discount(0, discount_value);
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
calculate_item_discount(0, discount_value, sale_items, account_types);
}
// Remove Selection
selection_remove();
@@ -414,7 +414,7 @@ var cashier_type = "<%= @cashier_type %>";
}else{
$("#discount-amountErr").html("can't be blank");
}
});
// Calculate Percentage Discount for Payment
@@ -425,19 +425,19 @@ var cashier_type = "<%= @cashier_type %>";
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
var sale_items = get_selected_sale_items();
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(1, discount_value);
}
else {
calculate_item_discount(1, discount_value, sale_items, account_types);
calculate_item_discount(1, discount_value, sale_items, account_types);
}
// Remove Selection
selection_remove();
selection_remove();
});
// Remove selected discount items
@@ -447,8 +447,8 @@ var cashier_type = "<%= @cashier_type %>";
var total = 0;
$('.discount-item-row.selected-item').each(function(i){
var amount = parseFloat($(this).find('#item-total-price').text());
total = total + Math.abs(amount);
var amount = parseFloat($(this).find('#item-total-price').text());
total = total + Math.abs(amount);
$(this).remove();
});
$("#order-sub-total").text(origin_sub_total + total);
@@ -464,8 +464,8 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#sale-id').text();
var discount_items = JSON.stringify(get_discount_item_rows());
var overall_discount = $("#order-discount").text();
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
@@ -473,8 +473,8 @@ var cashier_type = "<%= @cashier_type %>";
type: "POST",
url: ajax_url,
data: params,
success:function(result){
$("#loading_wrapper").hide();
success:function(result){
$("#loading_wrapper").hide();
swal({
title: "Information!",
text: result.status,
@@ -489,7 +489,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -500,12 +500,12 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#sale-id').text();
var discount_items = [];
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Items
var sale_items = get_selected_sale_items();
if(sale_items.length == 0){
//swal("Information!", "You have no selected item!");
swal ( "Oops" , "You have no selected item!" , "error" );
return;
swal ( "Oops" , "You have no selected item!" , "error" );
return;
}
for(var i=0;i < sale_items.length;i++){
@@ -514,7 +514,7 @@ var cashier_type = "<%= @cashier_type %>";
}
else {
swal ("Oops" , "You have no selected item!" , "error" );
return;
return;
}
}
@@ -539,7 +539,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -566,7 +566,7 @@ var cashier_type = "<%= @cashier_type %>";
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
}
});
});
@@ -575,8 +575,8 @@ var cashier_type = "<%= @cashier_type %>";
$("#member-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/member_discount";
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/member_discount";
// Selected Account
//var account_types = JSON.stringify(get_selected_account_types());
@@ -618,7 +618,7 @@ var cashier_type = "<%= @cashier_type %>";
});
}
});
});//end member discount
});
@@ -631,7 +631,7 @@ var cashier_type = "<%= @cashier_type %>";
/* Get Item rows but not discount*/
function get_item_rows(){
var sale_items = [];
var sale_items = [];
$('.item-row').not('.discount-item-row').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id').substr(0,16);
@@ -639,13 +639,13 @@ var cashier_type = "<%= @cashier_type %>";
sale_item.account_id = $(this).find('#item-account-type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get discount Item rows */
function get_discount_item_rows(){
var sale_items = [];
var sale_items = [];
$('.discount-item-row').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id');
@@ -653,13 +653,13 @@ var cashier_type = "<%= @cashier_type %>";
sale_item.account_id = $(this).find('#item_account_type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get discount Item rows */
// function get_selected_discount_items(){
// var sale_items = [];
// var sale_items = [];
// $('.discount-item-row').hasClass('.selected-item').each(function(i){
// var sale_item = {};
// sale_item.id = $(this).attr('id');
@@ -667,13 +667,13 @@ var cashier_type = "<%= @cashier_type %>";
// sale_item.account_id = $(this).find('#item_account_type').text();
// sale_item.price = $(this).find('#item-total-price').text();
// sale_items.push(sale_item);
// });
// });
// return sale_items;
// }
/* Get Selected Sale Item's ID and Price */
function get_selected_sale_items(){
var sale_items = [];
var sale_items = [];
$('.item-row.selected-item').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id').substr(0,16);
@@ -681,33 +681,33 @@ function get_selected_sale_items(){
sale_item.account_id = $(this).find('#item-account-type').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
});
return sale_items;
}
/* Get Selected Accounts ID and Price */
function get_selected_account_types(){
function get_selected_account_types(){
var account_types = [];
$('.selected-account').each(function(i){
var account= {};
account.id = $(this).attr('id').substr(8);
account.name = $(this).text();
account.name = $(this).text();
account_types.push(account);
});
});
return account_types;
}
/* Calculate Overall Discount*/
function calculate_overall_discount(type, amount){
var origin_sub_total = parseFloat($("#order-sub-total").text());
var origin_sub_total = parseFloat($("#order-sub-total").text());
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
// For Net Pay
if(type == 0){
total_discount = amount;
total_discount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
}
// For Percentage Pay
@@ -719,10 +719,10 @@ function calculate_overall_discount(type, amount){
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
});
}
else{
total_discount = (origin_sub_total * amount)/100;
total_discount = Math.round(origin_sub_total * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
}
}
@@ -731,22 +731,23 @@ function calculate_overall_discount(type, amount){
/* Calculate Items Discount*/
function calculate_item_discount(type, amount, sale_items, account_types){
var origin_sub_total = parseFloat($("#order-sub-total").text());
var origin_sub_total = parseFloat($("#order-sub-total").text());
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
var arrItemName = "";
var precision = <%= precision %>;
$("#discount_itemsErr").html("");
$("#discount-amountErr").html("");
// For Net Pay
if(origin_sub_total > 0){
if(type == 0){
dis_amount = (0 - amount);
dis_amount = -Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
@@ -768,7 +769,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
// }
}
}
@@ -782,11 +783,11 @@ function calculate_item_discount(type, amount, sale_items, account_types){
}else{
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
@@ -802,7 +803,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// else {
// alert("No Items!");
// }
// }
// }
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
@@ -817,7 +818,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
});
}
else{
// Check sale items exists
@@ -825,7 +826,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
@@ -835,9 +836,9 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
dis_amount = -Math.round(sale_items[i].price * amount / 100 * Math.pow(10, precision)) / Math.pow(10, precision);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = total_discount + dis_amount;
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
@@ -852,14 +853,14 @@ function calculate_item_discount(type, amount, sale_items, account_types){
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
@@ -870,15 +871,15 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
// else {
// alert("No Items!");
// }
// }
// }
// }
}
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
}else{
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
function item_row_template(type, item, discount_amount, amount){
@@ -887,24 +888,24 @@ function item_row_template(type, item, discount_amount, amount){
dis_str = dis_str + "(" + amount + "%)"
}
var discount_item_row = "<tr class='discount-item-row' id='" + item.id + "'>" +
"<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" +
"<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" +
item.account_id +
"</span>" +
"<span id='item-name-price'>" +
"</span>" +
"<span id='item-name-price'>" +
item.name + dis_str +
"</span>" +
"</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-qty'>1</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-total-price'>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-total-price'>" +
discount_amount +
"</span>" +
"</span>" +
"</td>" +
"</tr>";
return discount_item_row;
return discount_item_row;
}
</script>

View File

@@ -98,8 +98,8 @@
<%if !@sale_data.nil? %>
<% @sale_data.each do |result| %>
<% grand_total +=result.grand_total.to_f %>
<% old_grand_total += result.grand_total_after_rounding() %>
<% grand_total += result.grand_total.to_f %>
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
@@ -127,47 +127,35 @@
<td><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue '0' %>
</td>
<!-- <%if result.customer.customer_type == "Takeaway"%>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<% num = 1 %>
<% if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>0</td>
<% num += 1 %>
<% end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i, delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1 %>
<% if !tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>0</td>
<% num += 1 %>
<% end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td>0</td>
<% end %>
<%end%>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.grand_total - result.rounding_adjustment, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i, delimiter: delimiter) rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i, delimiter: delimiter) %></td>
<% if @lookup.value.to_i == 1 %>
<td>
<!-- ############### Need to Check SyncStatus ############# -->

View File

@@ -16,21 +16,21 @@
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<% end %>
<th colspan="9"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<% end %>
<tr>
<th><%= t("views.right_panel.detail.dining") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
<% @tax_profiles.each do |tax| %>
<th><%= tax.name %></th>
<th><%= tax.name %></th>
<% end %>
<!-- <th>Other Amount</th> -->
<th><%= t("views.right_panel.detail.grand_total") %></th>
@@ -45,36 +45,36 @@
<% old_grand_total = 0 %>
<% total_tax = 0 %>
<% guest_count = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% other_amt = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<% total_nett = 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|
@sale_taxes.each do |tax|
if tax.tax_name.downcase.include?("service")
ttax_flag = false
end
end
end
%>
<%if @sale_data %>
<%if @sale_data %>
<% @sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f %>
<% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %>
<% grand_total += result.grand_total.to_f %>
<% old_grand_total += result.grand_total.to_f - result.rounding_adjustment.to_f %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
<% rounding_adj += result.rounding_adjustment.to_f %>
<% sale_tax_count = result.sale_taxes.length %>
<% tax_count = tax_profile_count - sale_tax_count %>
<% tax_flag = true %>
<% result.sale_taxes.each do |tax|
<% result.sale_taxes.each do |tax|
if tax.tax_name.downcase.include?("service")
tax_flag = false
end
@@ -82,7 +82,7 @@
<tr>
<td>
<%if result.type %>
<%= result.type %> - <%= result.name %>
<%= result.type %> - <%= result.name %>
<% else %>
-
<% end %>
@@ -91,15 +91,13 @@
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<!-- <%if result.customer.customer_type == "Takeaway"%>
<td>0.0</td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>0</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
@@ -107,11 +105,11 @@
<%= tax.tax_payable_amount rescue '-' %>
</td>
<%end%>
<% num = 1
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>0</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% else %>
@@ -120,9 +118,9 @@
<% end %>
<%end%>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
<td><%= result.grand_total - result.rounding_adjustment %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total rescue '-'%></td>
</tr>
<% end %>
@@ -134,11 +132,11 @@
<td><b><%= tax.st_amount.round(2) %></b></td>
<% end %> -->
<% if !@sale_taxes.empty? %>
<% num = 1
<% num = 1
if ttax_flag && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>0.00</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% @sale_taxes.each do |tax| %>
@@ -146,11 +144,11 @@
<%= tax.st_amount.to_f.round(2) %>
</td>
<%end%>
<% num = 1
<% num = 1
if ttax_flag==false && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>0.00</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% else %>
@@ -158,15 +156,15 @@
<td>0.00</td>
<% end %>
<%end%>
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<% @tax_profiles.each do |tax| %>
<td><%= tax.name %></td>
<% end %>
@@ -184,4 +182,4 @@
</div>
</div>
</body>
</html>
</html>