update payment
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -91,4 +91,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|||||||
|
|
||||||
gem 'httparty', '~> 0.15.5'
|
gem 'httparty', '~> 0.15.5'
|
||||||
|
|
||||||
gem 'bootstrap-datepicker-rails'
|
gem 'bootstrap-datepicker-rails'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, @user, cash)
|
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
|
||||||
|
|
||||||
def process_payment(invoice, action_by, cash_amount,payment_method)
|
def process_payment(invoice, action_by, cash_amount, payment_method)
|
||||||
|
|
||||||
self.sale = invoice
|
self.sale = invoice
|
||||||
self.received_amount = cash_amount
|
self.received_amount = cash_amount
|
||||||
@@ -75,7 +75,7 @@ class SalePayment < ApplicationRecord
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id)
|
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id,campaign_type_id)
|
||||||
@@ -93,9 +93,9 @@ class SalePayment < ApplicationRecord
|
|||||||
else
|
else
|
||||||
response =false;
|
response =false;
|
||||||
end
|
end
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -103,7 +103,7 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
self.payment_method = "cash"
|
self.payment_method = "cash"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
self.outstanding_amount = self.sale.grand_total - self.received_amount
|
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
|
|
||||||
@@ -195,11 +195,10 @@ class SalePayment < ApplicationRecord
|
|||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||||
sale_update_payment_status(self.received_amount.to_f)
|
sale_update_payment_status(self.received_amount.to_f)
|
||||||
|
|
||||||
else
|
else
|
||||||
sale_update_payment_status(0)
|
sale_update_payment_status(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return payment_status
|
return payment_status
|
||||||
|
|
||||||
@@ -207,9 +206,9 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
def sale_update_payment_status(paid_amount)
|
def sale_update_payment_status(paid_amount)
|
||||||
#update amount_outstanding
|
#update amount_outstanding
|
||||||
self.sale.amount_received = self.sale.amount_received + paid_amount
|
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||||
self.sale.amount_changed = paid_amount - self.sale.amount_received
|
self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received
|
||||||
if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0)
|
if (self.sale.grand_total <= self.sale.amount_received.to_f && self.sale.amount_changed.to_f > 0)
|
||||||
self.sale.payment_status = "paid"
|
self.sale.payment_status = "paid"
|
||||||
self.sale.sale_status = "completed"
|
self.sale.sale_status = "completed"
|
||||||
self.sale.save!
|
self.sale.save!
|
||||||
|
|||||||
@@ -165,14 +165,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
var original_value;
|
var original_value;
|
||||||
original_value = $('#cash').text();
|
original_value = $('#cash').text();
|
||||||
|
|
||||||
var input_type = $(this).attr("data-type");
|
var input_type = $(this).attr("data-type");
|
||||||
|
|
||||||
switch (input_type) {
|
switch (input_type) {
|
||||||
case 'num':
|
case 'num':
|
||||||
var input_value = $(this).attr("data-value");
|
var input_value = $(this).attr("data-value");
|
||||||
@@ -184,23 +182,26 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
update_balance();
|
update_balance();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add':
|
case 'add':
|
||||||
var input_value = $(this).attr("data-value");
|
var input_value = $(this).attr("data-value");
|
||||||
amount = parseInt(input_value) + parseInt(original_value);
|
amount = parseInt(input_value) + parseInt(original_value);
|
||||||
$('#cash').text(amount);
|
$('#cash').text(amount);
|
||||||
update_balance();
|
update_balance();
|
||||||
break;
|
break;
|
||||||
|
case 'del' :
|
||||||
|
var cash=$('#cash').text();
|
||||||
|
$('#cash').text(cash.substr(0,cash.length-1));
|
||||||
|
update_balance();
|
||||||
|
break;
|
||||||
case 'clr':
|
case 'clr':
|
||||||
$('#cash').text("0.0");
|
$('#cash').text("0.0");
|
||||||
update_balance();
|
update_balance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
event.handled = true;
|
event.handled = true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
@@ -221,19 +222,18 @@ $( document ).ready(function() {
|
|||||||
if($('#balance').text() > 0){
|
if($('#balance').text() > 0){
|
||||||
alert(" Insufficient Amount!")
|
alert(" Insufficient Amount!")
|
||||||
}else{
|
}else{
|
||||||
// payment
|
// payment
|
||||||
var cash = $('#cash').text();
|
var cash = $('#cash').text();
|
||||||
var credit = $('#credit').text();
|
var credit = $('#credit').text();
|
||||||
var card = $('#card').text();
|
var card = $('#card').text();
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_process_path %>",
|
url: "<%= origami_payment_process_path %>",
|
||||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
alert("THANK YOU")
|
alert("THANK YOU")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ Rails.application.config.assets.precompile += %w( origami.css )
|
|||||||
Rails.application.config.assets.precompile += %w( origami.js )
|
Rails.application.config.assets.precompile += %w( origami.js )
|
||||||
# -- Order Queue Station -----
|
# -- Order Queue Station -----
|
||||||
Rails.application.config.assets.precompile += %w( OQS.css )
|
Rails.application.config.assets.precompile += %w( OQS.css )
|
||||||
Rails.application.config.assets.precompile += %w( OQS.js )
|
Rails.application.config.assets.precompile += %w( OQS.js )
|
||||||
|
|
||||||
Rails.application.config.assets.precompile += %w( settings.css )
|
Rails.application.config.assets.precompile += %w( settings.css )
|
||||||
|
|||||||
Reference in New Issue
Block a user