fix api addorder and foc payment status
This commit is contained in:
@@ -402,7 +402,7 @@ class Order < ApplicationRecord
|
||||
end
|
||||
|
||||
#Process order items and send to order queue
|
||||
def self.process_order_queue(order_id,table_id,source)
|
||||
def self.process_order_queue(order_id, table_id, source)
|
||||
print_status = nil
|
||||
cup_status = nil
|
||||
|
||||
@@ -422,7 +422,7 @@ class Order < ApplicationRecord
|
||||
else
|
||||
if order
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.process_order(order, table_id, order_source)
|
||||
oqs.process_order(order, table_id, source)
|
||||
end
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||
|
||||
@@ -77,18 +77,26 @@ class SalePayment < ApplicationRecord
|
||||
if payment_for
|
||||
invoice_sale_payments = SalePayment.get_sale_payment_for_credit(invoice)
|
||||
amount_due = SalePayment.get_credit_amount_due_left(self.sale_id)[0] ? SalePayment.get_credit_amount_due_left(self.sale_id)[0].payment_amount.to_f : 0
|
||||
puts "amount_due => #{amount_due}"
|
||||
else
|
||||
invoice_sale_payments = invoice.sale_payments
|
||||
amount_due = invoice.grand_total
|
||||
puts "amount_due => #{amount_due}"
|
||||
end
|
||||
|
||||
puts "amount_due => #{amount_due}"
|
||||
|
||||
invoice_sale_payments.each do |payment|
|
||||
if (payment.payment_status == "paid" )
|
||||
amount_due = amount_due - payment.payment_amount
|
||||
end
|
||||
end
|
||||
puts "Cash Amount -> #{cash_amount}"
|
||||
|
||||
if (amount_due > 0)
|
||||
puts "payment_method -> #{payment_method}"
|
||||
|
||||
puts "Amount Due => #{amount_due}"
|
||||
if amount_due > 0
|
||||
payment_status = false
|
||||
membership_data = nil
|
||||
#route to payment type
|
||||
@@ -118,6 +126,7 @@ class SalePayment < ApplicationRecord
|
||||
when "paypar"
|
||||
payment_status = paypar_payment
|
||||
when "foc"
|
||||
puts ">>>>> FOC <<<<<"
|
||||
payment_status = foc_payment
|
||||
when "paymal"
|
||||
payment_status,membership_data = paymal_payment
|
||||
@@ -418,19 +427,19 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
def foc_payment
|
||||
payment_status = false
|
||||
|
||||
sale = self.sale
|
||||
# add to sale item with foc
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||
sale_items = sale.sale_items
|
||||
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
SaleItem.update_existing_item(item.qty, item, sale.sale_id, "foc", item.unit_price, item.price)
|
||||
end
|
||||
sale = Sale.find(self.sale.sale_id)
|
||||
|
||||
sale.compute_by_sale_items(sale.total_discount,'','','',"foc")
|
||||
|
||||
self.payment_method = "foc"
|
||||
self.payment_amount = self.received_amount
|
||||
# self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
|
||||
self.outstanding_amount = 0.00
|
||||
self.payment_status = "paid"
|
||||
payment_status = self.save!
|
||||
@@ -654,12 +663,12 @@ class SalePayment < ApplicationRecord
|
||||
is_foc = sale.sale_payments.any? { |x| x.payment_method == "foc" }
|
||||
|
||||
if (sale.grand_total <= all_received_amount)
|
||||
sale.payment_status = "paid"
|
||||
if is_credit
|
||||
sale.payment_status = "outstanding"
|
||||
elsif is_foc
|
||||
end
|
||||
if is_foc
|
||||
sale.payment_status = "foc"
|
||||
else
|
||||
sale.payment_status = "paid"
|
||||
end
|
||||
|
||||
sale.sale_status = "completed"
|
||||
|
||||
Reference in New Issue
Block a user