add rounding adj for table invoices
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop::ShopDetail
|
||||
puts "table bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
@@ -9,7 +10,18 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
if sale.sale_status != "completed"
|
||||
@sale_array.push(sale)
|
||||
end
|
||||
@@ -19,12 +31,24 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop::ShopDetail
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
@sale_array.push(sale)
|
||||
end
|
||||
|
||||
@@ -75,8 +75,8 @@
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'>Back</button>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button>
|
||||
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block btn-lg bg-default" disabled>Pay</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
</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"><%= @sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-default btn-block" id='back'>Back</button>
|
||||
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
|
||||
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn bg-danger btn-block"> Void </button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user