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) { if (payment) {
return status; //json_data[0]["payment"]; return json_data[0]["payment"];
}else{ }else{
return status; return status;
} }

View File

@@ -225,6 +225,8 @@ class Origami::DiscountsController < BaseOrigamiController
end end
Rails.logger.debug "-------------- Member Discount Osaka ---------" Rails.logger.debug "-------------- Member Discount Osaka ---------"
Rails.logger.debug response.to_json Rails.logger.debug response.to_json
puts "-------------- Member Discount Osaka ---------"
puts response.to_json
# Re-calc All Amount in Sale # Re-calc All Amount in Sale
if response["status"] == true if response["status"] == true
discount_amount = response["discount_earned"] 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="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> <button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- first bill not used in cloud --> <!-- 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> <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="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> <button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
<% end %> <% end %>
@@ -584,22 +590,60 @@
type: "GET", type: "GET",
url: ajax_url, url: ajax_url,
success: function (result) { 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 () { $(".choose_payment").on('click', function () {
// var sale_id = $('#sale_id').val(); $( "#loading_wrapper").show();
// var url = '/origami/sale/' + sale_id + "/rounding_adj";
// $.ajax({ var sale_id = $('#sale_id').val();
// type: "POST", type = $('.payment_method').val();
// url: '/origami/sale/' + sale_id + "/rounding_adj", if(parseInt(jQuery.inArray("Credit", type)) == -1){
// success: function (result) { 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) {
// window.location.href = '/origami/sale/' + sale_id + "/payment"; 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 () { $('#pay').on('click', function () {
var sale_id = $('#sale_id').val(); var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/' + sale_id + "/payment"; window.location.href = '/origami/sale/' + sale_id + "/payment";

View File

@@ -305,24 +305,28 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
/* start check first bill or not*/ /* 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()!="")){ if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim(); 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 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){ 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){
$("#credit_payment").hide(); $("#card_payment").show();
} else{ } else{
$("#credit_payment").show(); $("#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*/ /* end check first bill or not*/