Rebate balance in receipt
This commit is contained in:
@@ -55,7 +55,7 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
var cashier="";
|
var cashier="";
|
||||||
var receipt_date="";
|
var receipt_date="";
|
||||||
var sub_total=0;
|
var sub_total=0.0;
|
||||||
var discount_amount=0;
|
var discount_amount=0;
|
||||||
var tax_amount=0;
|
var tax_amount=0;
|
||||||
var grand_total_amount=0;
|
var grand_total_amount=0;
|
||||||
@@ -83,34 +83,35 @@ $(document).ready(function(){
|
|||||||
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#receipt_no").text(receipt_no);
|
|
||||||
$("#cashier").text(cashier == null ? "" : cashier);
|
|
||||||
$("#receipt_date").text(show_date);
|
|
||||||
|
|
||||||
|
|
||||||
//Receipt Charges
|
//Receipt Charges
|
||||||
sub_total += (parse_data.qty*parse_data.price);
|
sub_total += parseFloat(parse_data.price);
|
||||||
|
|
||||||
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
||||||
tax_amount = parse_data.tax_amount;
|
tax_amount = parse_data.tax_amount;
|
||||||
grand_total_amount = parse_data.grand_total_amount;
|
grand_total_amount = parse_data.grand_total_amount;
|
||||||
|
|
||||||
$("#order-sub-total").text(sub_total);
|
|
||||||
// $("#order-food").text('');
|
|
||||||
// $("#order-beverage").text('');
|
|
||||||
$("#order-discount").text(discount_amount);
|
|
||||||
$("#order-Tax").text(tax_amount);
|
|
||||||
$("#order-grand-total").text(grand_total_amount);
|
|
||||||
|
|
||||||
// Ordered Items
|
// Ordered Items
|
||||||
var order_items_rows = "<tr>" +
|
var order_items_rows = "<tr>" +
|
||||||
"<td class='item-name'>" + parse_data.item_name + "</td>" +
|
"<td class='item-name'>" + parse_data.item_name + "</td>" +
|
||||||
"<td class='item-attr'>" + parse_data.qty + "</td>" +
|
"<td class='item-attr'>" + parse_data.qty + "</td>" +
|
||||||
"<td class='item-attr'>" + parse_data.qty*parse_data.price + "</td>" +
|
"<td class='item-attr'>" + parse_data.price + "</td>" +
|
||||||
"</tr>";
|
"</tr>";
|
||||||
|
|
||||||
$("#order-items-table").children("tbody").append(order_items_rows);
|
$("#order-items-table").children("tbody").append(order_items_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cashier Info
|
||||||
|
$("#receipt_no").text(receipt_no);
|
||||||
|
$("#cashier").text(cashier == null ? "" : cashier);
|
||||||
|
$("#receipt_date").text(show_date);
|
||||||
|
|
||||||
|
// Payment Info
|
||||||
|
$("#order-sub-total").text(sub_total);
|
||||||
|
// $("#order-food").text('');
|
||||||
|
// $("#order-beverage").text('');
|
||||||
|
$("#order-discount").text(discount_amount);
|
||||||
|
$("#order-Tax").text(tax_amount);
|
||||||
|
$("#order-grand-total").text(grand_total_amount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// End AJAX Call
|
// End AJAX Call
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ 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, "cash")
|
rebate_amount = sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||||
|
|
||||||
|
puts "resssssssssssssssssss"
|
||||||
|
puts rebate_amount.to_json
|
||||||
|
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
@@ -24,7 +27,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
|
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.where('customer_id=' + @sale_data.customer_id)
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
|
|
||||||
|
customer= Customer.find( @sale_data.customer_id)
|
||||||
|
# get member information
|
||||||
|
member_info = Customer.get_member_account(customer)
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
|
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
|
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info)
|
||||||
redirect_to origami_path(@sale_data.sale_id)
|
redirect_to origami_path(@sale_data.sale_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ class Order < ApplicationRecord
|
|||||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||||
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true)
|
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true)
|
||||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
|
.group("bookings.booking_id")
|
||||||
# For PG
|
# For PG
|
||||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
|
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
|
||||||
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
|
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
|
||||||
@@ -262,7 +262,7 @@ class Order < ApplicationRecord
|
|||||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||||
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true)
|
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true)
|
||||||
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id")
|
.group("bookings.booking_id")
|
||||||
# For PG
|
# For PG
|
||||||
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
|
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
|
||||||
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id
|
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
if oqs.id == oqpbz.order_queue_station_id
|
if oqs.id == oqpbz.order_queue_station_id
|
||||||
#Same Order_items can appear in two location.
|
#Same Order_items can appear in two location.
|
||||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
|
else
|
||||||
|
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil)
|
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info)
|
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount)
|
||||||
|
|
||||||
pdf.render_file "tmp/receipt_bill.pdf"
|
pdf.render_file "tmp/receipt_bill.pdf"
|
||||||
self.print("tmp/receipt_bill.pdf")
|
self.print("tmp/receipt_bill.pdf")
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class Sale < ApplicationRecord
|
|||||||
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
||||||
#get all order attached to this booking and combine into 1 invoice
|
#get all order attached to this booking and combine into 1 invoice
|
||||||
|
|
||||||
puts booking.booking_orders.length
|
|
||||||
booking.booking_orders.each do |order|
|
booking.booking_orders.each do |order|
|
||||||
if booking.sale_id
|
if booking.sale_id
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||||
@@ -98,6 +97,8 @@ class Sale < ApplicationRecord
|
|||||||
order.save
|
order.save
|
||||||
|
|
||||||
booking.sale_id = self.id
|
booking.sale_id = self.id
|
||||||
|
booking.checkout_at = Time.now.utc
|
||||||
|
booking.checkout_by = requested_by.name
|
||||||
booking.save
|
booking.save
|
||||||
|
|
||||||
return true, self.id
|
return true, self.id
|
||||||
@@ -198,9 +199,14 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# Tax Calculate
|
# Tax Calculate
|
||||||
def apply_tax(total_taxable)
|
def apply_tax(total_taxable)
|
||||||
|
#if tax is not apply create new record
|
||||||
|
# self.sale_taxes.each do |existing_tax|
|
||||||
|
# #delete existing and create new
|
||||||
|
# existing_tax.delete
|
||||||
|
# end
|
||||||
|
|
||||||
#if tax is not apply create new record
|
#if tax is not apply create new record
|
||||||
self.sale_taxes.each do |existing_tax|
|
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||||
#delete existing and create new
|
#delete existing and create new
|
||||||
existing_tax.delete
|
existing_tax.delete
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class SaleItem < ApplicationRecord
|
|||||||
food_prices = food_prices + food_price
|
food_prices = food_prices + food_price
|
||||||
beverage_prices = beverage_prices + beverage_price
|
beverage_prices = beverage_prices + beverage_price
|
||||||
end
|
end
|
||||||
|
puts food_prices
|
||||||
|
puts beverage_prices
|
||||||
return food_prices, beverage_prices
|
return food_prices, beverage_prices
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -61,6 +63,17 @@ class SaleItem < ApplicationRecord
|
|||||||
return food_price, beverage_price
|
return food_price, beverage_price
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_overall_discount(sale_id)
|
||||||
|
price = 0.0
|
||||||
|
item=SaleItem.where("product_code=?", sale_id)
|
||||||
|
|
||||||
|
item.each do|i|
|
||||||
|
price += i.price
|
||||||
|
end
|
||||||
|
|
||||||
|
return price
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ class SalePayment < ApplicationRecord
|
|||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
||||||
|
sObj = Sale.find(self.sale_id)
|
||||||
|
|
||||||
return true, self.sale
|
response = rebat(sObj)
|
||||||
|
return true, response
|
||||||
else
|
else
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||||
@@ -66,37 +68,52 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token)
|
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token)
|
||||||
|
# Control for Paypar Cloud
|
||||||
|
begin
|
||||||
response = HTTParty.get(url,
|
response = HTTParty.get(url,
|
||||||
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
}, :timeout => 10
|
||||||
)
|
)
|
||||||
return response;
|
rescue Net::OpenTimeout
|
||||||
|
response = { status: false }
|
||||||
|
end
|
||||||
|
return response;
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
|
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
|
||||||
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
|
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
|
||||||
|
|
||||||
if !membership_actions_data.nil?
|
if !membership_actions_data.nil?
|
||||||
|
|
||||||
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
|
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
|
||||||
merchant_uid = membership_actions_data.merchant_account_id
|
merchant_uid = membership_actions_data.merchant_account_id
|
||||||
auth_token = membership_actions_data.auth_token
|
auth_token = membership_actions_data.auth_token
|
||||||
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
|
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
sale_data = Sale.find_by_sale_id(sale_id)
|
||||||
if sale_data
|
|
||||||
response = HTTParty.post(url,
|
if sale_data
|
||||||
:body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
# Control for Paypar Cloud
|
||||||
:headers => {
|
begin
|
||||||
'Content-Type' => 'application/json',
|
response = HTTParty.post(url,
|
||||||
'Accept' => 'application/json'
|
:body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
}
|
:headers => {
|
||||||
)
|
'Content-Type' => 'application/json',
|
||||||
else
|
'Accept' => 'application/json'
|
||||||
response = false;
|
},
|
||||||
end
|
:timeout => 10
|
||||||
|
)
|
||||||
|
puts "vvvvvvvvv"
|
||||||
|
puts response.to_json
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
response = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
response = false;
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
response =false;
|
response =false;
|
||||||
@@ -119,7 +136,6 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def creditnote_payment(customer_id)
|
def creditnote_payment(customer_id)
|
||||||
|
|
||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
self.payment_method = "creditnote"
|
self.payment_method = "creditnote"
|
||||||
@@ -187,17 +203,20 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
#Next time - validate if the vochure number is valid - within
|
#Next time - validate if the vochure number is valid - within
|
||||||
self.payment_method = "paypar"
|
|
||||||
self.payment_amount = self.received_amount
|
|
||||||
self.payment_reference = self.voucher_no
|
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
|
||||||
self.payment_status = "pending"
|
|
||||||
payment_method = self.save!
|
|
||||||
|
|
||||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
membership_data = SalePayment.redeem(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)
|
||||||
|
puts 'membership_data["status"]'
|
||||||
|
puts membership_data.to_json
|
||||||
|
puts "amountttttttttttt"
|
||||||
|
puts self.received_amount
|
||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
|
self.payment_method = "paypar"
|
||||||
|
self.payment_amount = self.received_amount
|
||||||
|
self.payment_reference = self.voucher_no
|
||||||
|
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||||
|
self.payment_status = "pending"
|
||||||
|
payment_method = self.save!
|
||||||
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)
|
||||||
|
|
||||||
@@ -251,7 +270,12 @@ class SalePayment < ApplicationRecord
|
|||||||
payparcost = payparcost + pp.payment_amount
|
payparcost = payparcost + pp.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
total_amount = food_prices - payparcost
|
overall_dis = SaleItem.get_overall_discount(sObj.id)
|
||||||
|
total_amount = food_prices - payparcost + overall_dis
|
||||||
|
puts "total_amount"
|
||||||
|
puts food_prices
|
||||||
|
puts payparcost
|
||||||
|
puts total_amount
|
||||||
if total_amount > 0
|
if total_amount > 0
|
||||||
receipt_no = sObj.receipt_no
|
receipt_no = sObj.receipt_no
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
@@ -261,6 +285,7 @@ class SalePayment < ApplicationRecord
|
|||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
|
# Control for Paypar Cloud
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
|
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
|
||||||
receipt_no: receipt_no,auth_token:auth_token}.to_json,
|
receipt_no: receipt_no,auth_token:auth_token}.to_json,
|
||||||
@@ -271,8 +296,8 @@ class SalePayment < ApplicationRecord
|
|||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
end
|
end
|
||||||
|
return response
|
||||||
puts response.to_json
|
# puts response.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
class ReceiptBillPdf < Prawn::Document
|
class ReceiptBillPdf < Prawn::Document
|
||||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil)
|
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil)
|
||||||
self.page_width = 210
|
self.page_width = 210
|
||||||
self.page_height = 2500
|
self.page_height = 2500
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
self.price_width = 35
|
self.price_width = 40
|
||||||
self.qty_width = 20
|
self.qty_width = 20
|
||||||
self.total_width = 35
|
self.total_width = 40
|
||||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
self.item_height = 15
|
self.item_height = 15
|
||||||
self.item_description_width = (self.page_width-20) / 2
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
@@ -32,9 +32,13 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
line_items(sale_items, food_total, beverage_total)
|
line_items(sale_items, food_total, beverage_total)
|
||||||
all_total(sale_data)
|
all_total(sale_data)
|
||||||
|
|
||||||
|
|
||||||
if member_info != nil
|
if member_info != nil
|
||||||
member_info(member_info,customer_name)
|
member_info(member_info,customer_name,rebate_amount,sale_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
customer(customer_name)
|
||||||
|
|
||||||
footer
|
footer
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,11 +57,10 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
# move_down 2
|
# move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
text "Receipt No:", :size => self.item_font_size,:align => :left
|
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
bounding_box([self.label_width, y_position], :width =>self.item_width) do
|
text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
|
||||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
@@ -71,11 +74,28 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
# move_down 5
|
# move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
bounding_box([0, y_position], :width =>self.item_width) do
|
||||||
text "Date:", :size => self.item_font_size,:align => :left
|
text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.label_width,y_position], :width => self.item_width) do
|
move_down 5
|
||||||
text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_width, :height => self.item_height) do
|
||||||
|
text "Cashier: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
# bounding_box([self.label_width,y_position], :width =>self.item_width) do
|
||||||
|
# text "#{customer_name}" , :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
@@ -91,7 +111,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
text_box "Total", :at =>[(self.item_width+self.price_width),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,10 +138,10 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
pad_top(15) {
|
pad_top(15) {
|
||||||
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix
|
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
}
|
}
|
||||||
move_down 3
|
move_down 3
|
||||||
end
|
end
|
||||||
@@ -163,7 +183,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
if sale_data.sale_taxes.length > 1
|
if sale_data.sale_taxes.length > 0
|
||||||
sale_data.sale_taxes.each do |st|
|
sale_data.sale_taxes.each do |st|
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -193,28 +213,82 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down 5
|
move_down 5
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
text "Grand Total", :size => self.item_font_size,:align => :left
|
text "Grand Total", :size => self.header_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
|
text "#{sale_data.grand_total}" , :size => self.header_font_size,:align => :right
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
# stroke_horizontal_rule
|
|
||||||
|
sale_payment(sale_data)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def sale_payment(sale_data)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ payment.payment_amount }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
if sale_data.amount_received > 0
|
||||||
|
y_position = cursor
|
||||||
|
move_down 5
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{sale_data.amount_changed}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# show member information
|
# show member information
|
||||||
def member_info(member_info,customer_name)
|
def member_info(member_info,customer_name,rebate_amount,sale_data)
|
||||||
|
|
||||||
move_down 7
|
if rebate_amount != nil
|
||||||
y_position = cursor
|
stroke_horizontal_rule
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
if rebate_amount[1]["status"] == true
|
||||||
text "Customer", :size => self.item_font_size,:align => :left
|
total_redeem = 0.0
|
||||||
|
amount = 0.0
|
||||||
|
earm_amount = 0.0
|
||||||
|
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
|
||||||
|
if payment.payment_method == "paypar"
|
||||||
|
total_redeem = total_redeem + payment.payment_amount
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
end
|
||||||
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
|
earm_amount = earm_amount + rebate_amount[1]["rebate_earned"].to_f
|
||||||
end
|
amount = amount + total_redeem
|
||||||
move_down 5
|
amount = amount + earm_amount
|
||||||
|
old = rebate_amount[1]["total_rebate_amount"].to_f - amount
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{old}" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Earned Balance", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ rebate_amount[1]["rebate_earned"] }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if member_info["status"] == true
|
if member_info["status"] == true
|
||||||
member_info["data"].each do |res|
|
member_info["data"].each do |res|
|
||||||
|
|
||||||
@@ -233,6 +307,18 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def customer(customer_name)
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Customer", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def footer
|
def footer
|
||||||
|
|||||||
@@ -306,12 +306,12 @@
|
|||||||
sub_total = 0
|
sub_total = 0
|
||||||
if @selected_item_type == "Sale"
|
if @selected_item_type == "Sale"
|
||||||
@selected_item.sale_items.each do |sale_item|
|
@selected_item.sale_items.each do |sale_item|
|
||||||
sub_total += (sale_item.qty*sale_item.unit_price)
|
sub_total = sub_total + sale_item.price
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='item-name'><%= sale_item.product_name %></td>
|
<td class='item-name'><%= sale_item.product_name %></td>
|
||||||
<td class='item-attr'><%= sale_item.qty %></td>
|
<td class='item-attr'><%= sale_item.qty %></td>
|
||||||
<td class='item-attr'><%= sale_item.qty*sale_item.price %></td>
|
<td class='item-attr'><%= sale_item.price %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
# For Order Items
|
# For Order Items
|
||||||
if @selected_item_type == "Order"
|
if @selected_item_type == "Order"
|
||||||
@selected_item.order_items.each do |order_item|
|
@selected_item.order_items.each do |order_item|
|
||||||
sub_total += (order_item.qty*order_item.unit_price)
|
sub_total = sub_total + (order_item.qty*order_item.price)
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='item-name'><%= order_item.item_name %></td>
|
<td class='item-name'><%= order_item.item_name %></td>
|
||||||
|
|||||||
@@ -96,6 +96,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
|
else {
|
||||||
|
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
|
}
|
||||||
|
});
|
||||||
// number key pad
|
// number key pad
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -144,7 +150,7 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
$('#jcb_pay').on('click',function(){
|
$('#jcb_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= "<%= @can_jcb %>"){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_jcb_path %>",
|
url: "<%= origami_payment_jcb_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
@@ -96,6 +96,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
|
else {
|
||||||
|
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
|
}
|
||||||
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -138,7 +144,7 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
$('#master_pay').on('click',function(){
|
$('#master_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= "<%= @can_master %>"){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_master_path %>",
|
url: "<%= origami_payment_master_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
@@ -96,6 +96,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
|
else {
|
||||||
|
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
|
}
|
||||||
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -141,7 +147,7 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
$('#mpu_pay').on('click',function(){
|
$('#mpu_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= "<%= @can_mpu %>"){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_mpu_path %>",
|
url: "<%= origami_payment_mpu_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
@@ -96,6 +96,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||||
|
else {
|
||||||
|
$('#validamount').attr("value",parseFloat("<%= @can_visa %>") - parseFloat(localStorage.getItem("cash")));
|
||||||
|
}
|
||||||
|
});
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -141,7 +147,7 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
$('#visa_pay').on('click',function(){
|
$('#visa_pay').on('click',function(){
|
||||||
var amount = $('#amount').text();
|
var amount = $('#amount').text();
|
||||||
var sale_id = "<%= @sale_id %>";
|
var sale_id = "<%= @sale_id %>";
|
||||||
if(parseFloat(amount) <= "<%= @can_visa %>"){
|
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value"))){
|
||||||
$.ajax({type: "POST",
|
$.ajax({type: "POST",
|
||||||
url: "<%= origami_payment_visa_path %>",
|
url: "<%= origami_payment_visa_path %>",
|
||||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user