update dinga and paymal
This commit is contained in:
@@ -169,6 +169,8 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
end
|
||||
@out = membership_data
|
||||
|
||||
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,32 +4,32 @@ class Origami::DingaController < BaseOrigamiController
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = sale_data.receipt_no
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = @sale_data.receipt_no
|
||||
@shop = Shop.first
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
# new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
# else
|
||||
# new_total = sale_data.grand_total
|
||||
# new_total = @sale_data.grand_total
|
||||
# end
|
||||
# @rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = sale_data.rounding_adjustment
|
||||
# @rounding_adj = new_total-@sale_data.grand_total
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
@sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "dinga"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
||||
@payment_prices = @sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
if sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if @sale_data
|
||||
if @sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(@sale_data.customer_id)
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
@@ -73,6 +73,7 @@ def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
@@ -85,7 +86,7 @@ def create
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga",transaction_ref)
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga",account_no)
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
|
||||
@@ -73,6 +73,7 @@ def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
@@ -86,7 +87,7 @@ def create
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal",transaction_ref)
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal",account_no)
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
|
||||
@@ -214,7 +214,7 @@ class SalePayment < ApplicationRecord
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { membership_id:membership_id,
|
||||
:body => { account_no:membership_id,
|
||||
amount:received_amount,
|
||||
receipt_no:sale_data.receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
@@ -242,7 +242,7 @@ class SalePayment < ApplicationRecord
|
||||
response =false;
|
||||
end
|
||||
|
||||
Rails.logger.debug "Payment response"
|
||||
Rails.logger.debug "Create Payment response"
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
return response;
|
||||
@@ -391,8 +391,13 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
|
||||
account_no = self.payment_reference
|
||||
if account_no == 0
|
||||
account_no = customer_data.customer_id
|
||||
end
|
||||
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.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||
@@ -433,9 +438,17 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
|
||||
account_no = self.payment_reference
|
||||
if account_no == 0
|
||||
account_no = customer_data.customer_id
|
||||
end
|
||||
|
||||
|
||||
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.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,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} "
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hidden" name="sale_id" id="sale_id" ><%=@sale_id %></p>
|
||||
<p class="hidden" name="receipt_no" id="receipt_no" ><%=@sale_data.receipt_no %></p>
|
||||
<!-- <% if @payparcount > 0 %>
|
||||
<p class="">Last time rebate amount is <%= @payparcount %></p>
|
||||
<% end %>
|
||||
@@ -116,7 +118,7 @@
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
|
||||
<input type="hidden" name="paypar_account_no" id="paypar_account_no" value="1011002923682533" />
|
||||
<input type="hidden" name="qr_code" id="qr_code" />
|
||||
<div class="row text-center m-t-20">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||
@@ -239,15 +241,15 @@
|
||||
var membership_id = '';
|
||||
var membership_type = '';
|
||||
var sale_id = $("#sale_id").text() || 0;
|
||||
var receipt_no = $("#receipt_no").text() || 0;
|
||||
var customer_mamber_card_no = 0;
|
||||
|
||||
$("#is_paymemberModal").hide();
|
||||
$("#sxModal").show();
|
||||
setTimeout(function(){
|
||||
getCardNo();
|
||||
$("#sxModal").hide();
|
||||
// $("#is_paymemberModal").hide();
|
||||
// $("#sxModal").show();
|
||||
// setTimeout(function(){
|
||||
// getCardNo();
|
||||
// $("#sxModal").hide();
|
||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
||||
|
||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -255,6 +257,7 @@
|
||||
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log(data)
|
||||
if (data.status == true) {
|
||||
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
|
||||
$("#valid_amount").val(parseFloat(valid_amount));
|
||||
@@ -262,8 +265,9 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_dinga_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no :customer_mamber_card_no},
|
||||
success: function(result){
|
||||
console.log(result)
|
||||
if(result.status == true){
|
||||
swal({
|
||||
title: "Information!",
|
||||
@@ -273,7 +277,7 @@
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
|
||||
});
|
||||
|
||||
}else{
|
||||
@@ -291,14 +295,14 @@
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
},100);
|
||||
// },100);
|
||||
});
|
||||
|
||||
// Read NFC card no from java
|
||||
@@ -316,13 +320,13 @@
|
||||
// QR Code Reader
|
||||
$(".btn_qr_code").on('click', function(e){
|
||||
$("#is_memberModal").hide();
|
||||
var code = "";
|
||||
var code = "1011002923682533";
|
||||
var customer_id = '';
|
||||
var customer_name = '';
|
||||
var membership_id = '';
|
||||
var membership_type = '';
|
||||
setTimeout(function(){
|
||||
code=getQRCode();
|
||||
// setTimeout(function(){
|
||||
// code=getQRCode();
|
||||
if(sale_id != 0 && code != ""){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -337,7 +341,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=origami_payment_paymal_path%>",
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref},
|
||||
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no : code},
|
||||
success: function(result){
|
||||
if(result.status == true){
|
||||
swal({
|
||||
@@ -372,7 +376,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
},100);
|
||||
// },100);
|
||||
});
|
||||
|
||||
// Read qrcode from java
|
||||
|
||||
@@ -290,7 +290,7 @@
|
||||
</div>
|
||||
<p id="ref_no" class="hidden"></p>
|
||||
<p id="callback_url" class="hidden"></p>
|
||||
<p id="order_id"></p>
|
||||
<p id="order_id" class="hidden"></p>
|
||||
<p id="status" class="hidden"></p>
|
||||
<script type="text/javascript">
|
||||
jQuery(function(){
|
||||
|
||||
@@ -168,15 +168,15 @@
|
||||
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
</div>
|
||||
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
||||
</div>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id=""><%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
||||
</div>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id=""><%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
@@ -269,12 +269,11 @@
|
||||
<div class="col-md-4" id="paymalcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- DINGA -->
|
||||
<div class="row <%= @dingacount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">DINGA</div>
|
||||
<% if @paymalcount != 0.0 %>
|
||||
<% if @dingacount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="dingacount"><%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="dingacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||
|
||||
Reference in New Issue
Block a user