change redeem payment process for dinga
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class Origami::DingaController < BaseOrigamiController
|
class Origami::DingaController < BaseOrigamiController
|
||||||
def index
|
def index
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
payment_method = params[:payment_method]
|
payment_method = params[:payment_method]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@@ -15,16 +15,16 @@ class Origami::DingaController < BaseOrigamiController
|
|||||||
# @rounding_adj = new_total-sale_data.grand_total
|
# @rounding_adj = new_total-sale_data.grand_total
|
||||||
@rounding_adj = sale_data.rounding_adjustment
|
@rounding_adj = sale_data.rounding_adjustment
|
||||||
|
|
||||||
@payparcount = 0
|
@dingacount = 0
|
||||||
others = 0
|
others = 0
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "paypar"
|
if sale_payment.payment_method == "dinga"
|
||||||
@payparcount = @payparcount + sale_payment.payment_amount
|
@dingacount = @dingacount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
others = others + sale_payment.payment_amount
|
others = others + sale_payment.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
@redeem_prices = sale_data.grand_total - @dingacount -others
|
||||||
|
|
||||||
|
|
||||||
if sale_data
|
if sale_data
|
||||||
@@ -33,15 +33,15 @@ class Origami::DingaController < BaseOrigamiController
|
|||||||
if customer_data
|
if customer_data
|
||||||
@membership_id = customer_data.membership_id
|
@membership_id = customer_data.membership_id
|
||||||
if !@membership_id.nil?
|
if !@membership_id.nil?
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type("dinga_url")
|
||||||
if membership_setting.gateway_url
|
if membership_setting.gateway_url
|
||||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||||
if member_actions.gateway_url
|
if member_actions.gateway_url
|
||||||
@campaign_type_id = nil
|
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
|
||||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||||
merchant_uid= member_actions.merchant_account_id
|
merchant_uid= member_actions.merchant_account_id
|
||||||
auth_token = member_actions.auth_token.to_s
|
auth_token = member_actions.auth_token.to_s
|
||||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
membership_data = SalePayment.get_dinga_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
@membership_rebate_balance=membership_data["balance"]
|
@membership_rebate_balance=membership_data["balance"]
|
||||||
@out = true, @membership_rebate_balance,@membership_id
|
@out = true, @membership_rebate_balance,@membership_id
|
||||||
@@ -67,36 +67,36 @@ class Origami::DingaController < BaseOrigamiController
|
|||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
|
||||||
cash = params[:payment_amount]
|
|
||||||
sale_id = params[:sale_id]
|
|
||||||
if(Sale.exists?(sale_id))
|
|
||||||
saleObj = Sale.find(sale_id)
|
|
||||||
shop_details = Shop::ShopDetail
|
|
||||||
|
|
||||||
# rounding adjustment
|
|
||||||
# if shop_details.is_rounding_adj
|
|
||||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
|
||||||
# rounding_adj = new_total-saleObj.grand_total
|
|
||||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# saleObj = Sale.find(sale_id)
|
def create
|
||||||
sale_payment = SalePayment.new
|
sale_id = params[:sale_id]
|
||||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga")
|
@cashier_type = params[:type]
|
||||||
if status == true
|
redeem_amount = params[:redeem_amount]
|
||||||
@out = true, "Success!"
|
membership_id = params[:membership_id]
|
||||||
else
|
payment_method = "dinga"
|
||||||
@out =false, "Please try again payment!"
|
if(Sale.exists?(sale_id))
|
||||||
end
|
saleObj = Sale.find(sale_id)
|
||||||
end
|
shop_details = Shop::ShopDetail
|
||||||
end
|
|
||||||
|
# rounding adjustment
|
||||||
#Shop Name in Navbor
|
if shop_details.is_rounding_adj
|
||||||
helper_method :shop_detail
|
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||||
def shop_detail
|
rounding_adj = new_total-saleObj.grand_total
|
||||||
@shop = Shop.first
|
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||||
|
end
|
||||||
|
|
||||||
|
sale_payment = SalePayment.new
|
||||||
|
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
|
||||||
|
if status == true
|
||||||
|
@out = true, "Success!"
|
||||||
|
else
|
||||||
|
@out =false, "Please try again payment!"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@out = false, "There has no sale record!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -410,10 +410,10 @@ class SalePayment < ApplicationRecord
|
|||||||
#Next time - validate if the vochure number is valid - within
|
#Next time - validate if the vochure number is valid - within
|
||||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
||||||
|
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "#{membership_data} Dinga Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||||
|
|
||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
@@ -429,8 +429,8 @@ class SalePayment < ApplicationRecord
|
|||||||
else
|
else
|
||||||
sale_update_payment_status(0)
|
sale_update_payment_status(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return payment_status
|
return payment_status
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
$("#qr_code").on('click', function(e){
|
$("#qr_code").on('sclick', function(e){
|
||||||
var code = "";
|
var code = "";
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
code=getQRCode();
|
code=getQRCode();
|
||||||
@@ -281,4 +281,8 @@ $(document).on('click',".customer_tr",function(){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#sxModal .btn_cancel").on('click',function(){
|
||||||
|
$("#sxModal").hide();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -360,9 +360,42 @@
|
|||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
$("#qr_code").on('click', function(e){
|
$("#qr_code").on('click', function(e){
|
||||||
var code = "";
|
var code = "";
|
||||||
|
var customer_id = '';
|
||||||
|
var customer_name = '';
|
||||||
|
var sale_id = $("#sale_id").val() || 0;
|
||||||
|
var customer_mamber_card_no = 0;
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
code=getQRCode();
|
code=getQRCode();
|
||||||
setQRCode(code);
|
setQRCode(code);
|
||||||
|
|
||||||
|
customer_mamber_card_no = $("#search").val();
|
||||||
|
|
||||||
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/"+sale_id+"/get_customer" ,
|
||||||
|
data: { filter : customer_mamber_card_no ,type :"card"},
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
if (data[0].customer_id == false) {
|
||||||
|
swal("Alert!", data[0].message, "error");
|
||||||
|
// $.alert({
|
||||||
|
// title: 'Alert!',
|
||||||
|
// content: data[0].message,
|
||||||
|
// type: 'red',
|
||||||
|
// typeAnimated: true,
|
||||||
|
// btnClass: 'btn-danger',
|
||||||
|
// });
|
||||||
|
}else{
|
||||||
|
customer_id = data[0].customer_id;
|
||||||
|
customer_name = data[0].name;
|
||||||
|
update_sale(customer_id, customer_name,sale_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},100);
|
},100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,41 +15,41 @@
|
|||||||
<div class="rebate-form">
|
<div class="rebate-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="">You can pay up to </label>
|
<label class="">You can redeem up to </label>
|
||||||
<%@payment_prices = @payment_prices +@rounding_adj%>
|
<%@redeem_prices = @redeem_prices +@rounding_adj%>
|
||||||
<input type="text" name="" id="paymentamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payment_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
<input type="text" name="" id="redeemamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @redeem_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% if @payparcount > 0 %>
|
<% if @dingacount > 0 %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="">Recent Payment Amount </label>
|
<label class="">Recent Redeem Amount </label>
|
||||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @payparcount %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @dingacount %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="">Available Balance </label>
|
<label class=""> Rebate Balance </label>
|
||||||
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@membership_rebate_balance%>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@membership_rebate_balance%>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||||
<label class="">Payment Balance</label>
|
<label class="">Redeem Amount</label>
|
||||||
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
<div id="used_amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <% if @payparcount > 0 %>
|
<!-- <% if @dingacount > 0 %>
|
||||||
<p class="">Last time rebate amount is <%= @payparcount %></p>
|
<p class="">Last time rebate amount is <%= @dingacount %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @payment_prices %></span></p> -->
|
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @redeem_prices %></span></p> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row bottom m-l-5">
|
<div class="row bottom m-l-5">
|
||||||
<div class="pay purple left" id="dinga_payment">Pay</div>
|
<div class="pay purple left" id="dinga">Pay</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -109,13 +109,12 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var cashier_type = "<%= @cashier_type %>";
|
var cashier_type = "<%= @cashier_type %>";
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
setHeaderBreadCrumb(_DINGA_);
|
setHeaderBreadCrumb(_REDEEM_PAYMENT_);
|
||||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
else {
|
else {
|
||||||
$('#paymentamt').attr("value",parseFloat("<%= @payment_prices %>") - parseFloat(localStorage.getItem("cash")));
|
$('#redeemamt').attr("value",parseFloat("<%= @redeem_prices %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -149,7 +148,7 @@
|
|||||||
$('#used_amount').text(cash.substr(0,cash.length-1));
|
$('#used_amount').text(cash.substr(0,cash.length-1));
|
||||||
break;
|
break;
|
||||||
case 'nett':
|
case 'nett':
|
||||||
var remain_amount = $('#paymentamt').val();
|
var remain_amount = $('#redeemamt').val();
|
||||||
$('#used_amount').text(remain_amount);
|
$('#used_amount').text(remain_amount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -160,22 +159,22 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#dinga_payment").click(function(){
|
$("#dinga").click(function(){
|
||||||
valid_amount = $("#valid_amount").val();
|
valid_amount = $("#valid_amount").val();
|
||||||
sale_id = $("#valid_amount").attr('data-value');
|
sale_id = $("#valid_amount").attr('data-value');
|
||||||
membership_id = $("#valid_amount").attr('data-member-value');
|
membership_id = $("#valid_amount").attr('data-member-value');
|
||||||
payment_amount = parseFloat($("#used_amount").text());
|
redeem_amount = parseFloat($("#used_amount").text());
|
||||||
if(payment_amount<=0 ){
|
if(redeem_amount<=0 ){
|
||||||
swal ( "Oops" , "Please type valid amount!" , "warning" );
|
swal ( "Oops" , "Please type valid amount!" , "warning" );
|
||||||
}else if(valid_amount< payment_amount){
|
}else if(valid_amount< redeem_amount){
|
||||||
swal ( "Oops" , "Insufficient Amount!" , "warning" );
|
swal ( "Oops" , "Insufficient Amount!" , "warning" );
|
||||||
}else{
|
}else{
|
||||||
if(payment_amount <= "<%= @payment_prices %>"){
|
if(redeem_amount <= "<%= @redeem_prices %>"){
|
||||||
$(this).off("click");
|
$(this).off("click");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<%=origami_payment_dinga_path%>",
|
url: "<%=origami_payment_dinga_path%>",
|
||||||
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id},
|
data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id},
|
||||||
success: function(result){
|
success: function(result){
|
||||||
if(result.status == true){
|
if(result.status == true){
|
||||||
swal({
|
swal({
|
||||||
@@ -195,7 +194,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else {
|
}else {
|
||||||
swal ( "Oops" , "Payment Amount is over!" , "warning" );
|
swal ( "Oops" , "Redeem Amount is over!" , "warning" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user