From f354e32e319762024c807ca12931ad66fe4a5562 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 20 Mar 2018 15:55:00 +0630 Subject: [PATCH] SQA feedback --- app/controllers/origami/shifts_controller.rb | 2 +- app/models/sale.rb | 22 ++++++++++++++++++++ app/views/origami/shifts/show.html.erb | 10 ++++----- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index d0b73f99..acce6c65 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -3,7 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController end def show - @type = params[:type] + @cashier_type = params[:type] @shift = ShiftSale.current_open_shift(current_user.id) #for bank integration bank_integration = Lookup.collection_of('bank_integration') diff --git a/app/models/sale.rb b/app/models/sale.rb index 11ddd296..5e7042e5 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -371,6 +371,8 @@ class Sale < ApplicationRecord end #compute rounding adjustment # adjust_rounding + sale.rounding_adjustment = compute_adjust_rounding(sale.grand_total) + sale.save! end @@ -552,6 +554,26 @@ class Sale < ApplicationRecord end + def compute_adjust_rounding(grand_total) + shop_details = Shop::ShopDetail + # rounding adjustment + if shop_details.is_rounding_adj + a = grand_total % 25 # Modulus + b = 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(grand_total) + rounding_adjustment = new_total - grand_total + else + rounding_adjustment = 0.00 + end + else + rounding_adjustment = 0.00 + end + return rounding_adjustment + end + #Generate new Receipt No when it is not assigned def generate_receipt_no #shop_code and client_code diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 4e42f11b..006763eb 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -58,7 +58,7 @@