From 12f5e42d44418b0b4419bb05fef8ce76df8e17c3 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 21 Dec 2017 10:49:25 +0630 Subject: [PATCH] update comment for rounding adj --- app/controllers/origami/home_controller.rb | 1 + .../origami/payments_controller.rb | 21 ++++++++++++------- app/controllers/origami/rooms_controller.rb | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 50944b39..fdf00b29 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -25,6 +25,7 @@ class Origami::HomeController < BaseOrigamiController @shop = Shop::ShopDetail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index d307cc5d..2c0de0f7 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -30,9 +30,10 @@ class Origami::PaymentsController < BaseOrigamiController # rounding adjustment if shop_details.is_rounding_adj - a = sale_data.grand_total % 25 - b = sale_data.grand_total / 25 - + a = sale_data.grand_total % 25 # Modulus + b = sale_data.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_data.grand_total) rounding_adj = new_total-sale_data.grand_total @@ -73,8 +74,10 @@ class Origami::PaymentsController < BaseOrigamiController # rounding adjustment if shop_details.is_rounding_adj - a = saleObj.grand_total % 25 - b = saleObj.grand_total / 25 + a = saleObj.grand_total % 25 # Modulus + b = saleObj.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(saleObj.grand_total) rounding_adj = new_total-saleObj.grand_total @@ -296,9 +299,11 @@ class Origami::PaymentsController < BaseOrigamiController @shop = Shop.find_by_id(1) if @shop.is_rounding_adj - a = saleObj.grand_total % 25 # - b = saleObj.grand_total / 25 # - if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + a = saleObj.grand_total % 25 # Modulus + b = saleObj.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(saleObj.grand_total) rounding_adj = new_total-saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 4009666a..5e5b42cb 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -22,6 +22,7 @@ class Origami::RoomsController < BaseOrigamiController @shop = Shop::ShopDetail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all + @room.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new