This commit is contained in:
Nweni
2017-06-11 17:49:06 +06:30
parent f6d14de461
commit fc3893f048
5 changed files with 13 additions and 13 deletions

View File

@@ -20,7 +20,7 @@ $(document).ready(function(){
$(".orders").on('click', function(){ $(".orders").on('click', function(){
var zone_name=$(this).find(".orders-table").text(); var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text(); var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id=$(this).find(".orders-id").text(); var unique_id = $(this).find(".orders-id").text();
var order_status=$(this).find(".orders-order-status").text().trim(); var order_status=$(this).find(".orders-order-status").text().trim();
// Enable/Disable Button // Enable/Disable Button

View File

@@ -106,7 +106,6 @@ class SalePayment < ApplicationRecord
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f 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!
sale_update_payment_status(self.received_amount) sale_update_payment_status(self.received_amount)
return payment_status return payment_status
@@ -205,30 +204,28 @@ class SalePayment < ApplicationRecord
end end
def sale_update_payment_status(paid_amount) def sale_update_payment_status(paid_amount)
puts "sale update"
#update amount_outstanding #update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f
all_received_amount = 0.0 all_received_amount = 0.0
sObj = self.sale sObj = Sale.find(self.sale_id)
sObj.sale_payments.each do |spay| sObj.sale_payments.each do |spay|
puts spay
puts spay.payment_amount
all_received_amount += spay.payment_amount.to_f all_received_amount += spay.payment_amount.to_f
end end
puts all_received_amount
puts self.sale.grand_total
if (self.sale.grand_total <= all_received_amount) if (self.sale.grand_total <= all_received_amount)
puts " sale update ......"
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!
rebat()
end end
end end
def rebat
end
private private
def generate_custom_id def generate_custom_id
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")

View File

@@ -11,12 +11,13 @@ Amount :
$('#mpu_pay').on('click',function(){ $('#mpu_pay').on('click',function(){
var amount = $('#amount').val(); var amount = $('#amount').val();
var sale_id = "<%= @sale_id %>"; var sale_id = "<%= @sale_id %>";
alert(amount);
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_create_mpu_payment_path %>", url: "<%= origami_create_mpu_payment_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id, data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){ success:function(result){
if(result){ if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment"; window.location.href = '/origami/sale/'+ sale_id + "/payment";
} }
} }

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -229,7 +229,8 @@ $( document ).ready(function() {
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")
window.location.href = '/origami';
} }
}); });
} }