precision

This commit is contained in:
Myat Zin Wai Maw
2019-09-05 18:12:17 +06:30
parent 1ced4a3d6d
commit 258aba669b
5 changed files with 58 additions and 12 deletions

View File

@@ -2,6 +2,20 @@
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<% if !@print_settings.nil? %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% end %>
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -72,7 +86,7 @@
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
</tr>
<!-- <tr>
<td class="charges-name"><strong>Food:</strong></td>
@@ -89,15 +103,15 @@
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
<td class="item-attr">(<strong id="order-discount"><%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong>)</td>
</tr>
<tr class="hidden">
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
</tr>
<tr class="hidden">
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
</tr>
</table>
</div>
@@ -712,7 +726,7 @@ function calculate_overall_discount(type, amount){
}
}
$("#order-discount").text(total_discount);
$("#order-discount").text(total_discount.toFixed(<%= precision.to_i %>));
}
/* Calculate Items Discount*/
@@ -860,7 +874,7 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// }
}
$("#order-sub-total").text(parseFloat(sub_total).toFixed(2));
$("#order-sub-total").text(parseFloat(sub_total).toFixed(<%= precision.to_i %>));
}else{
$("#discount-amountErr").html("Discount is greater than sub total!");
}