change redeem payment process for dinga
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Origami::DingaController < BaseOrigamiController
|
||||
def index
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@@ -15,16 +15,16 @@ class Origami::DingaController < BaseOrigamiController
|
||||
# @rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
@dingacount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "paypar"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
if sale_payment.payment_method == "dinga"
|
||||
@dingacount = @dingacount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
||||
@redeem_prices = sale_data.grand_total - @dingacount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
@@ -33,15 +33,15 @@ class Origami::DingaController < BaseOrigamiController
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
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
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
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
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
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
|
||||
@membership_rebate_balance=membership_data["balance"]
|
||||
@out = true, @membership_rebate_balance,@membership_id
|
||||
@@ -67,36 +67,36 @@ class Origami::DingaController < BaseOrigamiController
|
||||
@out = false, 0
|
||||
end
|
||||
@out = false, 0
|
||||
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
|
||||
end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga")
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
redeem_amount = params[:redeem_amount]
|
||||
membership_id = params[:membership_id]
|
||||
payment_method = "dinga"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -410,10 +410,10 @@ class SalePayment < ApplicationRecord
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
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
|
||||
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)
|
||||
|
||||
if membership_data["status"]==true
|
||||
@@ -429,8 +429,8 @@ class SalePayment < ApplicationRecord
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
|
||||
return payment_status
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
|
||||
@@ -142,7 +142,7 @@ $(function() {
|
||||
});
|
||||
|
||||
// QR Code Reader
|
||||
$("#qr_code").on('click', function(e){
|
||||
$("#qr_code").on('sclick', function(e){
|
||||
var code = "";
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
@@ -281,4 +281,8 @@ $(document).on('click',".customer_tr",function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sxModal .btn_cancel").on('click',function(){
|
||||
$("#sxModal").hide();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -360,9 +360,42 @@
|
||||
// QR Code Reader
|
||||
$("#qr_code").on('click', function(e){
|
||||
var code = "";
|
||||
var customer_id = '';
|
||||
var customer_name = '';
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_mamber_card_no = 0;
|
||||
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
setQRCode(code);
|
||||
code=getQRCode();
|
||||
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);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,41 +15,41 @@
|
||||
<div class="rebate-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">You can pay up to </label>
|
||||
<%@payment_prices = @payment_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 %>">
|
||||
<label class="">You can redeem up to </label>
|
||||
<%@redeem_prices = @redeem_prices +@rounding_adj%>
|
||||
<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>
|
||||
<hr>
|
||||
</div>
|
||||
<% if @payparcount > 0 %>
|
||||
<% if @dingacount > 0 %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label class="">Recent Payment 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 %>">
|
||||
<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="<%= @dingacount %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<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 %>">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<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>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <% if @payparcount > 0 %>
|
||||
<p class="">Last time rebate amount is <%= @payparcount %></p>
|
||||
<!-- <% if @dingacount > 0 %>
|
||||
<p class="">Last time rebate amount is <%= @dingacount %></p>
|
||||
<% 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 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>
|
||||
<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>
|
||||
|
||||
@@ -109,13 +109,12 @@
|
||||
<script type="text/javascript">
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function() {
|
||||
setHeaderBreadCrumb(_DINGA_);
|
||||
setHeaderBreadCrumb(_REDEEM_PAYMENT_);
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||
else {
|
||||
$('#paymentamt').attr("value",parseFloat("<%= @payment_prices %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
});
|
||||
|
||||
else {
|
||||
$('#redeemamt').attr("value",parseFloat("<%= @redeem_prices %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
});
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
@@ -149,7 +148,7 @@
|
||||
$('#used_amount').text(cash.substr(0,cash.length-1));
|
||||
break;
|
||||
case 'nett':
|
||||
var remain_amount = $('#paymentamt').val();
|
||||
var remain_amount = $('#redeemamt').val();
|
||||
$('#used_amount').text(remain_amount);
|
||||
break;
|
||||
|
||||
@@ -160,22 +159,22 @@
|
||||
}
|
||||
});
|
||||
|
||||
$("#dinga_payment").click(function(){
|
||||
$("#dinga").click(function(){
|
||||
valid_amount = $("#valid_amount").val();
|
||||
sale_id = $("#valid_amount").attr('data-value');
|
||||
membership_id = $("#valid_amount").attr('data-member-value');
|
||||
payment_amount = parseFloat($("#used_amount").text());
|
||||
if(payment_amount<=0 ){
|
||||
redeem_amount = parseFloat($("#used_amount").text());
|
||||
if(redeem_amount<=0 ){
|
||||
swal ( "Oops" , "Please type valid amount!" , "warning" );
|
||||
}else if(valid_amount< payment_amount){
|
||||
}else if(valid_amount< redeem_amount){
|
||||
swal ( "Oops" , "Insufficient Amount!" , "warning" );
|
||||
}else{
|
||||
if(payment_amount <= "<%= @payment_prices %>"){
|
||||
if(redeem_amount <= "<%= @redeem_prices %>"){
|
||||
$(this).off("click");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
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){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -195,7 +194,7 @@
|
||||
}
|
||||
})
|
||||
}else {
|
||||
swal ( "Oops" , "Payment Amount is over!" , "warning" );
|
||||
swal ( "Oops" , "Redeem Amount is over!" , "warning" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user