From e0d97470cc0489a6ad85b3a307f6bfa6d9350654 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 21 Dec 2017 10:35:09 +0630 Subject: [PATCH] update membership discount firstbill --- app/controllers/origami/home_controller.rb | 3 +- .../origami/payments_controller.rb | 4 +- app/controllers/origami/rooms_controller.rb | 3 + app/models/membership_setting.rb | 1 + app/views/origami/rooms/show.html.erb | 75 ++++++++++++++++++- 5 files changed, 80 insertions(+), 6 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index d3c1db70..50944b39 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -23,9 +23,8 @@ class Origami::HomeController < BaseOrigamiController @sale_array = Array.new @shop = Shop::ShopDetail - @membership = MembershipSetting.find_by_discount(1) + @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 b01ff09a..d307cc5d 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -296,8 +296,8 @@ 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 + a = saleObj.grand_total % 25 # + b = saleObj.grand_total / 25 # 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 diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 6c0b98c8..4009666a 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -19,6 +19,9 @@ class Origami::RoomsController < BaseOrigamiController @status_sale = "" @sale_array = Array.new + @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 diff --git a/app/models/membership_setting.rb b/app/models/membership_setting.rb index 89f9eb14..3b60c781 100755 --- a/app/models/membership_setting.rb +++ b/app/models/membership_setting.rb @@ -1,2 +1,3 @@ class MembershipSetting < ApplicationRecord + MembershipSetting = MembershipSetting.find_by_id(1) end diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 759a171c..d4869a6a 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -1,4 +1,7 @@
+
@@ -260,7 +263,7 @@ - + <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> @@ -369,10 +372,43 @@ - + <%if @membership.discount && @obj_sale.customer.membership_id %> + + <%else%> + + <%end%> <% end %> + + + + + @@ -538,6 +574,41 @@ $("#first_bill").on('click', function(){ }); }); +$(".choose_payment").on('click', function () { + $( "#loading_wrapper").show(); + var sale_id = $('#sale_id').val(); + type = $('.payment_method').val(); + + calculate_member_discount(sale_id,type); + + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + $( "#loading_wrapper" ).hide(); + location.reload(); + } + }); +}); +function calculate_member_discount(sale_id,type) { + var sub_total = $('#sub-total').text(); + if (type == "Cash") { + is_card = false + }else{ + is_card = true +} +$.ajax({ + type: "POST", + url: "/origami/" + sale_id + "/member_discount", + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card }, + async: false, + success:function(result){ + } +}); + +} + $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
Sub Total:<%= sub_total %><%= sub_total %>