diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 18368f25..712ce8f7 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -163,7 +163,7 @@ function checkReceiptNoInFirstBillData(receipt_no,payment) { } } if (payment) { - return status; //json_data[0]["payment"]; + return json_data[0]["payment"]; }else{ return status; } diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 1166a705..8ff155cd 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -225,6 +225,8 @@ class Origami::DiscountsController < BaseOrigamiController end Rails.logger.debug "-------------- Member Discount Osaka ---------" Rails.logger.debug response.to_json + puts "-------------- Member Discount Osaka ---------" + puts response.to_json # Re-calc All Amount in Sale if response["status"] == true discount_amount = response["discount_earned"] diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index db9dbbb6..9a941df3 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -396,9 +396,15 @@ - <% if ENV["SERVER_MODE"] != "cloud" %> + <% if ENV["SERVER_MODE"] == "cloud" %> - <% end %> + <% else %> + <%if @membership.discount && @obj_sale.customer.membership_id %> + + <%else%> + + <%end%> + <% end %> <% end %> @@ -584,22 +590,60 @@ type: "GET", url: ajax_url, success: function (result) { - location.reload(); + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no,""); + + location.reload(); } - }); + }); }); - // $('#pay').on('click', function () { - // var sale_id = $('#sale_id').val(); - // var url = '/origami/sale/' + sale_id + "/rounding_adj"; - // $.ajax({ - // type: "POST", - // url: '/origami/sale/' + sale_id + "/rounding_adj", - // success: function (result) { - // window.location.href = '/origami/sale/' + sale_id + "/payment"; - // } - // }); - // }); + $(".choose_payment").on('click', function () { + $( "#loading_wrapper").show(); + + var sale_id = $('#sale_id').val(); + type = $('.payment_method').val(); + if(parseInt(jQuery.inArray("Credit", type)) == -1){ + if (parseInt(jQuery.inArray("MPU", type)) > 0 || parseInt(jQuery.inArray("VISA", type)) > 0 || parseInt(jQuery.inArray("JCB", type)) > 0 || parseInt(jQuery.inArray("Master", type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", type)) > 0 || parseInt(jQuery.inArray("Redeem", type)) > 0) { + calculate_member_discount(sale_id,"Card"); + + }else{ + calculate_member_discount(sale_id,"Cash"); + } + } + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + $( "#loading_wrapper" ).hide(); + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no,type); + 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(); window.location.href = '/origami/sale/' + sale_id + "/payment"; diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 84fea75f..78660997 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -305,24 +305,28 @@