update cloud and master

This commit is contained in:
Aung Myo
2018-01-15 15:08:52 +06:30
parent 4a5c5aff03
commit 9ab9f3b002
4 changed files with 78 additions and 28 deletions

View File

@@ -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;
}

View File

@@ -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"]

View File

@@ -396,9 +396,15 @@
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] != "cloud" %>
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<% end %>
<% else %>
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
<% 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";

View File

@@ -305,24 +305,28 @@
<script>
$(document).ready(function(){
/* start check first bill or not*/
var receipt_no = "";
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
console.log(payment_type)
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) > 0 || parseInt(jQuery.inArray("VISA", payment_type)) > 0 || parseInt(jQuery.inArray("JCB", payment_type)) > 0 || parseInt(jQuery.inArray("Master", payment_type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) > 0 || parseInt(jQuery.inArray("Redeem", payment_type)) > 0){
$("#card_payment").show();
} else{
$("#card_payment").hide();
if(parseInt(jQuery.inArray("MPU", payment_type)) > 0 || parseInt(jQuery.inArray("VISA", payment_type)) > 0 || parseInt(jQuery.inArray("JCB", payment_type)) > 0 || parseInt(jQuery.inArray("Master", payment_type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) > 0 || parseInt(jQuery.inArray("Redeem", payment_type)) > 0){
$("#card_payment").show();
} else{
$("#card_payment").hide();
}
}
}
/* end check first bill or not*/