precision
This commit is contained in:
@@ -3,6 +3,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def index
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
|
||||
@@ -17,7 +17,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
# origami table detail
|
||||
def show
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
|
||||
@@ -452,6 +452,7 @@ class Sale < ApplicationRecord
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||
self.grand_total_round
|
||||
#compute rounding adjustment
|
||||
adjust_rounding
|
||||
|
||||
@@ -461,6 +462,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
|
||||
shop = Shop.first
|
||||
sale = Sale.find(sale_id)
|
||||
sales_items = sale_itemss
|
||||
|
||||
@@ -484,6 +486,7 @@ class Sale < ApplicationRecord
|
||||
sale.total_amount = subtotal_price
|
||||
sale.total_discount = total_discount
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
||||
sale.grand_total_round
|
||||
if discount_type == "member_discount"
|
||||
sale.discount_type = discount_type
|
||||
end
|
||||
@@ -519,6 +522,7 @@ class Sale < ApplicationRecord
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||
self.grand_total_round
|
||||
#compute rounding adjustment
|
||||
adjust_rounding
|
||||
|
||||
@@ -2948,6 +2952,17 @@ end
|
||||
|
||||
# End hourly sale item report
|
||||
|
||||
|
||||
#not to show decimal in grand total
|
||||
def grand_total_round
|
||||
shop =Shop.first
|
||||
print_settings = PrintSetting.get_precision_delimiter()
|
||||
if !print_settings.nil?
|
||||
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
||||
puts self.grand_total
|
||||
puts "Hello grand_total_round"
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
|
||||
@@ -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 clearfix">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
@@ -350,7 +364,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="sub-total"><%= sub_total %></strong></td>
|
||||
<td class="item-attr"><strong id="sub-total"><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
|
||||
@@ -359,7 +373,7 @@
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<%end%>
|
||||
|
||||
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount">(<%= number_with_precision(@obj_sale.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</strong></td>
|
||||
</tr>
|
||||
<% if @status_sale == "sale" %>
|
||||
<tr>
|
||||
@@ -382,15 +396,15 @@
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@obj_sale.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= number_with_precision(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= number_with_precision(@obj_sale.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr class="rebate_amount"></tr>
|
||||
|
||||
Reference in New Issue
Block a user