other payments
This commit is contained in:
@@ -326,8 +326,8 @@ function setCommPorts(comPortLists) {
|
||||
/** pay with CB bank **/
|
||||
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) {
|
||||
$("#loading_wrapper").show();
|
||||
var com_port = $("#com_port_name").val();
|
||||
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
|
||||
var com_port = $("#com_port_name").val();
|
||||
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
|
||||
}
|
||||
|
||||
//add req data to card_sale_trans table
|
||||
|
||||
@@ -39,7 +39,92 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
# end
|
||||
end
|
||||
|
||||
def new
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
payment_methods = PaymentMethodSetting.pluck(:payment_method)
|
||||
if @payment_method = payment_methods.find { |m| m.parameterize == params[:method] }
|
||||
path = request.fullpath
|
||||
# limit master_amount
|
||||
if path.include? ("credit_payment")
|
||||
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
|
||||
else
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
end
|
||||
total = 0
|
||||
@shop = Shop.current_shop
|
||||
@paid_amount = 0
|
||||
@can_paid = 0
|
||||
@rounding_adj = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
|
||||
else
|
||||
sale_payment_data = sale_data.sale_payments
|
||||
end
|
||||
|
||||
sale_payment_data.each do |sale_payment|
|
||||
if sale_payment.payment_method == @payment_method.parameterize
|
||||
@paid_amount = @paid_amount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_paid = total - @paid_amount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
else
|
||||
if path.include? ("credit_payment")
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/payment/others_payment"
|
||||
else
|
||||
redirect_to "sale/#{@sale_id}/#{@cashier_type}/credit_payment/others_payment"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
payment_method = params[:method]
|
||||
if PaymentMethodSetting.pluck(:payment_method).map(&:parameterize).include? payment_method
|
||||
if saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.current_shop
|
||||
|
||||
path = request.fullpath
|
||||
payment_for = false
|
||||
if path.include? ("credit_payment")
|
||||
payment_for = true
|
||||
end
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, payment_method, ref_no, payment_for)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -51,7 +51,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
|
||||
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
@@ -232,15 +233,29 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
def show
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@shop = Shop.current_shop
|
||||
@customer = @sale.customer
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
if dining_facility = @sale.booking.dining_facility
|
||||
@table_no = dining_facility.type + ' ' + dining_facility.name
|
||||
@checkin_time = @sale.booking.checkin_at
|
||||
@dining = dining_facility
|
||||
end
|
||||
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
end
|
||||
|
||||
path = request.fullpath
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
@trans_flag = true
|
||||
|
||||
if params[:type] == "transaction"
|
||||
@trans_flag = false
|
||||
@cashier_type = "cashier"
|
||||
@@ -248,201 +263,111 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||
if path.include? 'credit_payment'
|
||||
@sale_payment = false
|
||||
@amount_due = @sale.sale_payments.where(payment_method: 'creditnote').pluck('SUM(payment_amount)').first
|
||||
payments = @sale.sale_payments.joins(:sale_audit).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
||||
else
|
||||
@sale_payment = true
|
||||
@amount_due = @sale.grand_total
|
||||
payments = @sale.sale_payments.left_joins(:sale_audit).where(sale_audits: {sale_audit_id: nil}).group_by(&:payment_method).map { |method, payments| [method, payments.sum { |payment| payment.payment_amount }] }
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@membership_rebate_balance=0
|
||||
@payment_methods = PaymentMethodSetting.where(is_active: true).pluck(:payment_method)
|
||||
@cash = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'cash' }
|
||||
@credit = payments.inject(0) { |sum, payment| sum + payment[1] if payment[0] == 'creditnote' }
|
||||
@other_payments = payments.select { |payment| !['cash', 'creditnote'].include? payment[0] }.map { |method, amount| [ @payment_methods.find { |payment_method| payment_method.parameterize == method }, amount ] }
|
||||
@other_payment = @other_payments.sum { |payment| payment[1] }
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@dingacount = 0.0
|
||||
@giftvouchercount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !@sale.equal_persons.nil?
|
||||
per_person_amount = @sale.grand_total / @sale.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => @sale.equal_persons.to_i, 'per_person_amount' => per_person_amount })
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
if !lookup_changable_tax.empty?
|
||||
lookup_changable_tax.each do |changable_tax|
|
||||
if changable_tax[0].downcase == "change"
|
||||
if changable_tax[1] == '0'
|
||||
@changable_tax = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@shop = shop_detail #show shop info
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
@pdf_view = nil
|
||||
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
|
||||
if !@lookup_pdf.nil?
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
# @kbz_pay_amount += amount.to_f
|
||||
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
# @sale_data.grand_total = new_total
|
||||
# @sale_data.old_grand_total = saleObj.grand_total
|
||||
# @sale_data.rounding_adjustment = @rounding_adj
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
|
||||
sale_taxes = @sale.sale_taxes
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.grand_total / 25 # Division
|
||||
# #not calculate rounding if modulus is 0 and division is even
|
||||
# #calculate rounding if modulus is zero or not zero and division are not even
|
||||
# if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
@rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj)
|
||||
@sale_data.grand_total = new_total
|
||||
@sale_data.old_grand_total = saleObj.grand_total
|
||||
@sale_data.rounding_adjustment = @rounding_adj
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
@tax_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc.id)
|
||||
# @account_arr.push(account)
|
||||
@tax_arr.push(account.name)
|
||||
end
|
||||
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
|
||||
if !sale_taxes.empty?
|
||||
sale_taxes.each do |sale_tax|
|
||||
@account_arr.push(sale_tax)
|
||||
end
|
||||
end
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
# get member information
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#end customer amount
|
||||
|
||||
#paymal payment
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
if path.include? ("credit_payment")
|
||||
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
|
||||
else
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
end
|
||||
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "dinga"
|
||||
@dingacount += spay.payment_amount
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
#end customer amount
|
||||
end
|
||||
|
||||
def reprint
|
||||
|
||||
@@ -36,7 +36,8 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
def self.get_kbz_pay_amount(sale_id, current_user)
|
||||
amount = 0
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
|
||||
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
|
||||
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
|
||||
if !sale_payment.nil? and !kbz_pay_method.nil?
|
||||
if sale_payment.payment_status == 'pending'
|
||||
@@ -81,7 +82,7 @@ class SalePayment < ApplicationRecord
|
||||
amount_due = invoice.sale_payments
|
||||
.map(&:payment_amount).reduce(invoice.grand_total, :-)
|
||||
end
|
||||
|
||||
|
||||
if amount_due > 0
|
||||
payment_status = false
|
||||
membership_data = nil
|
||||
@@ -121,10 +122,8 @@ class SalePayment < ApplicationRecord
|
||||
payment_status,membership_data = dinga_payment
|
||||
when "GiftVoucher"
|
||||
payment_status = giftvoucher_payment
|
||||
when KbzPay::KBZ_PAY
|
||||
payment_status = kbz_payment
|
||||
else
|
||||
puts "it was something else"
|
||||
else
|
||||
payment_status = external_terminal_card_payment(payment_method, payment_for)
|
||||
end
|
||||
|
||||
if payment_status
|
||||
@@ -623,17 +622,6 @@ class SalePayment < ApplicationRecord
|
||||
return payment_status
|
||||
end
|
||||
|
||||
def kbz_payment
|
||||
payment_status = false
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_status = self.save!
|
||||
# sale_update_payment_status(self.received_amount)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount, check_foc = false)
|
||||
#update amount_outstanding
|
||||
if ['completed'].include? sale.sale_status
|
||||
|
||||
5
app/views/origami/others_payments/create.json.jbuilder
Normal file
5
app/views/origami/others_payments/create.json.jbuilder
Normal file
@@ -0,0 +1,5 @@
|
||||
if(@status)
|
||||
json.status @status
|
||||
else
|
||||
json.status false
|
||||
end
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="row clearfix"></div>
|
||||
<% end %>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
|
||||
<div class="purple others-payment text-center m-l-10 m-b-10 <%= payment_method.payment_method %>" data-type="<%= payment_method.payment_method.parameterize %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -45,7 +45,7 @@
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
|
||||
if(payment_type) {
|
||||
$(".others-payment").hide();
|
||||
$(payment_type).each(function(i){
|
||||
$(payment_type).each(function(i){
|
||||
$("."+payment_type[i]).show();
|
||||
});
|
||||
}
|
||||
|
||||
279
app/views/origami/others_payments/new.html.erb
Normal file
279
app/views/origami/others_payments/new.html.erb
Normal file
@@ -0,0 +1,279 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<!-- <div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
|
||||
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.btn.mpu") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
|
||||
</span>
|
||||
</ol>
|
||||
</div> -->
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<span class="hidden" id="membership_id"><%= @membership_id%></span>
|
||||
<span class="hidden" id="member_discount"><%= @member_discount%></span>
|
||||
<span class="hidden" id="sub-total"><%= @sub_total%></span>
|
||||
<div class="card" style="margin-top:10px;padding:20px;">
|
||||
<div class="card-block">
|
||||
<div class="rebate-form">
|
||||
<% if @bank_integration == '1' %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label for="com_port_name">Select Device</label>
|
||||
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>You can pay up to </label>
|
||||
<%@can_paid = @can_paid + @rounding_adj%>
|
||||
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @can_paid %>" data-member-value="">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% if @paid_amount != 0 %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label><%= "Recent #{@payment_method} paid amount" %></label>
|
||||
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@paid_amount %>" data-member-value="">
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>Reference Number</label>
|
||||
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
|
||||
<br><span id="reference_no_Err" style="color:red;"></span>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 col-md-12 col-sm-12">
|
||||
<label>Amount</label>
|
||||
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:;">
|
||||
<div class=" m-t-10 p-l-20">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-left green" data-type="nett" >Nett</div>
|
||||
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
|
||||
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
|
||||
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="row bottom m-l-5">
|
||||
<div class="pay purple left" id="pay">Pay</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1 col-lg-1 col-sm-1">
|
||||
<button type="button" class="btn bg-default btn-block" id="back"><i class="material-icons m-t--5">reply</i> Back </button>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="sale_id" value="<%= @sale_id %>">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$(document).ready(function() {
|
||||
setHeaderBreadCrumb('/ <%= "#{@payment_method} PAYMENT" %>');
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
var bank_integration = "<%= @bank_integration %>";
|
||||
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
|
||||
else {
|
||||
$('#validamount').attr("value",parseFloat("<%= @can_paid %>") - parseFloat(localStorage.getItem("cash")));
|
||||
}
|
||||
|
||||
if(bank_integration == '1'){
|
||||
if(typeof code2lab != 'undefined'){
|
||||
code2lab.getCommPorts(); //get comportlists from jade
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: '<%= "#{@payment_method} is not available in here!" %>',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param+"/others_payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
console.log("click");
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#amount').text();
|
||||
|
||||
var input_value = $(this).attr("data-value");
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
if (original_value == "0.0"){
|
||||
$('#amount').text(input_value);
|
||||
}else{
|
||||
$('#amount').append(input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
$('#amount').html(amount);
|
||||
|
||||
break;
|
||||
case 'clr':
|
||||
$('#amount').html("0.0");
|
||||
break;
|
||||
case 'del' :
|
||||
var cash=$('#amount').text() > 0 ? $('#amount').text() : 0;
|
||||
$('#amount').text((cash > 0 && cash.substr(0,cash.length-1) > 0) ? cash.substr(0,cash.length-1) : 0);
|
||||
break;
|
||||
case 'nett':
|
||||
var remain_amount = $('#validamount').val();
|
||||
$('#amount').text(remain_amount);
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#pay').on('click',function(){
|
||||
var amount = $('#amount').text();
|
||||
var reference_no = $('#reference_no').val();
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
var receipt_no = "<%= @receipt_no %>";
|
||||
var bank_integration = "<%= @bank_integration %>";
|
||||
var cashier_type = "<%= @cashier_type %>";
|
||||
$("#reference_no_Err").html("");
|
||||
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
|
||||
$(this).off("click");
|
||||
//start member discount 5% by pay card
|
||||
// var sub_total = $('#sub-total').text();
|
||||
// var member_id = $('#membership_id').text();
|
||||
// var member_discount = $('#member_discount').text();
|
||||
// if (member_id && member_discount) {
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: "/origami/" + sale_id + "/member_discount",
|
||||
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
|
||||
// success:function(result){
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//end member discount
|
||||
if(bank_integration == '1'){
|
||||
pay_withBank("SALE", "<%= @payment_method %>", amount, sale_id, receipt_no,cashier_type);
|
||||
}else{
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_path(method: @payment_method.parameterize) %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_path(method: @payment_method.parameterize) %>";
|
||||
}
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||
success:function(result){
|
||||
if(result){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Payment Successfully",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+ "/"+url_param;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}else{
|
||||
if (amount>0) {
|
||||
swal ( "Oops" , "Paid Amount is over!" , "error" );
|
||||
}else{
|
||||
swal ( "Oops" , "Enter Amount!" , "error" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#back').on('click',function(){
|
||||
var url_param = "payment";
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
url_param = "credit_payment";
|
||||
}
|
||||
window.location.href = '/origami/sale/'+'<%= @sale_id %>'+'/<%= @cashier_type %>/'+url_param;
|
||||
// window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
|
||||
});
|
||||
</script>
|
||||
@@ -9,24 +9,24 @@
|
||||
<div class="card-header m-l-5 m-r-5">
|
||||
<div id="order-title">
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale.receipt_no rescue ' '%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
|
||||
</div>
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Table No :</strong> <%=@table_no%></div>
|
||||
<span class="hidden" id="dining"><%if !@dining.nil?%><%= @dining.id%><%end%></span>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale %><%=@sale.sale_id %><% end %></span></div>
|
||||
</div>
|
||||
|
||||
<div class="row p-l-5 p-r-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<strong>Customer :</strong>
|
||||
<% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %>
|
||||
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button>
|
||||
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale.customer.name%></button>
|
||||
<% else %>
|
||||
<span id="customer_name"><%= @sale_data.customer.name%></span>
|
||||
<span id="customer_name"><%= @sale.customer.name%></span>
|
||||
<% end %>
|
||||
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
|
||||
<span class="hidden" id="membership_id"><%= @sale.customer.membership_id%></span>
|
||||
<span class="hidden" id="member_discount"><%= @member_discount%></span></div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
|
||||
<%end%></div>
|
||||
@@ -57,7 +57,7 @@
|
||||
<% sub_total = 0
|
||||
count = 0
|
||||
%>
|
||||
<% @sale_data.sale_items.each do |sale_item|
|
||||
<% @sale.sale_items.each do |sale_item|
|
||||
count += 1
|
||||
%>
|
||||
|
||||
@@ -82,12 +82,12 @@
|
||||
<td class="item-attr"><strong><span id="sub-total"><%=number_format(sub_total, precision: precision.to_i)%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<%if @sale_data.discount_type == 'member_discount'%>
|
||||
<%if @sale.discount_type == 'member_discount'%>
|
||||
<td class="charges-name"><strong>Member Discount:</strong></td>
|
||||
<%else%>
|
||||
<td class="charges-name"><strong>(Discount)</strong></td>
|
||||
<%end%>
|
||||
<td class="item-attr"><strong><span>(<%= number_format(@sale_data.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
<td class="item-attr"><strong><span>(<%= number_format(@sale.total_discount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name">
|
||||
@@ -104,23 +104,23 @@
|
||||
<% else %>
|
||||
No Tax
|
||||
<% end %></strong><br>
|
||||
<%if @sale_payment.nil? && @changable_tax %>
|
||||
<%if @sale_payment && @changable_tax %>
|
||||
<% if @current_user.role == 'cashier' %>
|
||||
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
|
||||
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
|
||||
<% else %>
|
||||
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale_data.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="total_tax"><%= number_format(@sale.total_tax, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong><%= number_format(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
<td class="item-attr"><strong><%= number_format(@sale.rounding_adjustment, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total</strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
<td class="item-attr"><strong><span><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i )%></span></strong></td>
|
||||
</tr>
|
||||
<%if @balance > 0%>
|
||||
<tr>
|
||||
@@ -156,22 +156,14 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %></strong></div>
|
||||
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment %>( Credit )<% end %></strong></div>
|
||||
<div class="col-md-4">
|
||||
<strong>
|
||||
<span id="grand_total" class="hidden">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% else %>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
<%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
</span>
|
||||
<span id="amount_due">
|
||||
<% if @sale_payment.nil? %>
|
||||
<%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
<% else %>
|
||||
<%= number_format(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
<% end %>
|
||||
<%= number_format(@amount_due, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i)%>
|
||||
</span>
|
||||
</strong>
|
||||
</div>
|
||||
@@ -183,7 +175,7 @@
|
||||
<%= number_format(@cash, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %>
|
||||
</div>
|
||||
</div>
|
||||
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
|
||||
<% if @sale_payment && @cashier_type != "food_court" %>
|
||||
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
|
||||
<div class="col-md-8">Credit</div>
|
||||
<div class="col-md-4" id="credit"><%= number_format(@credit, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
@@ -191,155 +183,25 @@
|
||||
<% else %>
|
||||
<div class="col-md-4 hidden" id="credit">0</div>
|
||||
<% end %>
|
||||
<% if @kbz_pay_amount > 0.0 %>
|
||||
<div class="row payment other-payment-color" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments (KBZ Pay)</div>
|
||||
<div class="col-md-4" id="others">
|
||||
<%= number_format(@kbz_pay_amount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
<div class="row payment other-payment-color p-l-5 p-r-5" id="card_payment" >
|
||||
<div class="col-md-8">Other Payments</div>
|
||||
<div class="col-md-4" id="other_payment_amount">
|
||||
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% elsif @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 && @giftvouchercount == 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_format(@other, precision: precision.to_i) rescue number_format(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="other_payment_amount">
|
||||
<%= number_format(@other_payment, precision: precision.to_i) rescue number_format(0, precision: precision.to_i) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title m-l-5 m-r-5">
|
||||
<!-- mpu -->
|
||||
<div class="row <%= @other!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MPU</div>
|
||||
<% if @other != 0.0 %>
|
||||
<div class="col-md-4 mpu is_card" id="others"><%= number_format(@other, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="others"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- paypar -->
|
||||
<div class="row <%= @ppamount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<% if @ppamount != 0.0 %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(@ppamount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="ppamount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Visa -->
|
||||
<div class="row <%= @visacount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">VISA</div>
|
||||
<% if @visacount != 0.0 %>
|
||||
<div class="col-md-4 visa is_card" id="visacount"><%= number_format(@visacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="visacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- JCB -->
|
||||
<div class="row <%= @jcbcount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JCB</div>
|
||||
<% if @jcbcount != 0.0 %>
|
||||
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_format(@jcbcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="jcbcount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Master -->
|
||||
<div class="row <%= @mastercount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">MASTER</div>
|
||||
<% if @mastercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="mastercount"><%= number_format(@mastercount, precision: precision.to_i) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="mastercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
|
||||
<!-- UNIONPAY -->
|
||||
<div class="row <%= @unionpaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">UNIONPAY</div>
|
||||
<% if @unionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_format(@unionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="unionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Alipay -->
|
||||
<div class="row <%= @alipaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Alipay</div>
|
||||
<% if @alipaycount != 0.0 %>
|
||||
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_format(@alipaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="alipaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- PAYMAL -->
|
||||
<div class="row <%= @paymalcount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">PAYMAL</div>
|
||||
<% if @paymalcount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="paymalcount"><%= number_format(@paymalcount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="paymalcount"><%= number_format(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 @dingacount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="dingacount"><%= number_format(@dingacount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="dingacount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Junction Pay -->
|
||||
<div class="row <%= @junctionpaycount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">JUNCTION PAY</div>
|
||||
<% if @junctionpaycount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_format(@junctionpaycount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="junctionpaycount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Gift Voucher -->
|
||||
<div class="row <%= @giftvouchercount!=0.0 ? 'payment others-color' : 'hidden'%>">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">GIFT VOUCHER</div>
|
||||
<% if @giftvouchercount != 0.0 %>
|
||||
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_format(@giftvouchercount, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
<% else %>
|
||||
<div class="col-md-4" id="giftvouchercount"><%= number_format(0, precision: precision.to_i ) %></div>
|
||||
<% end %>
|
||||
<div class="card-title">
|
||||
<% @other_payments.each do |payment| %>
|
||||
<div class="row payment others-color p-l-5 p-r-5">
|
||||
<div class="col-md-8"><%= payment[0] %></div>
|
||||
<div class="col-md-4 <%= payment[0].parameterize %> is_card"><%= number_format(payment[1], precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="row m-l-5 m-r-5">
|
||||
<div class="col-md-8"><strong class='amount_balance'>Balance</strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale_data.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
|
||||
<div class="col-md-4"><strong><span id='balance'><%= number_format(@sale.grand_total, precision: precision.to_i ) rescue number_format(0, precision: precision.to_i ) %></span></strong></div>
|
||||
</div>
|
||||
<!-- <br> -->
|
||||
</div>
|
||||
@@ -404,30 +266,30 @@
|
||||
</button>
|
||||
<!-- -->
|
||||
<% if current_login_employee.role == "cashier" %>
|
||||
<% if @other_payment <= 0 && @sale_payment.nil? %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<% if @other_payment <= 0 && @sale_payment %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
|
||||
<% end %>
|
||||
<%end %>
|
||||
<% if @sale_payment.nil? %>
|
||||
<% if @sale_payment %>
|
||||
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
|
||||
<% if @other_payment <= 0 %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
|
||||
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @other_payment <= 0 && @sale_payment.nil?%>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<% if @other_payment <= 0 && @sale_payment%>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
|
||||
<%end %>
|
||||
<%end %>
|
||||
<% if @sale_payment.nil? %>
|
||||
<% if @sale_payment %>
|
||||
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
|
||||
<% if @other_payment <= 0 %>
|
||||
<%if @sale_data.total_discount == 0 %>
|
||||
<%if @sale.total_discount == 0 %>
|
||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
|
||||
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
|
||||
<% end %>
|
||||
@@ -435,7 +297,7 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %>
|
||||
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment %>
|
||||
<hr>
|
||||
|
||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
||||
@@ -709,10 +571,14 @@ var customer_id = "<%= @customer.id %>";
|
||||
var customer_name = "<%= @customer.name %>";
|
||||
var pdf_view = '<%=@pdf_view%>';
|
||||
var trans_flag = <%= @trans_flag %>;
|
||||
var paymalcount = <%= @paymalcount %>;
|
||||
var other_payments = <%= raw @other_payments %>;
|
||||
var payment_methods = <%= raw @payment_methods %>;
|
||||
|
||||
// console.log(pdf_view)
|
||||
$(document).ready(function(){
|
||||
$("#sxModal").hide();
|
||||
|
||||
var paymalcount = other_payments.some(x => x[0] == 'paymal') ? other_payments.find(x => x[0] == 'paymal')[1] : 0.0;
|
||||
if(cashier_type == "food_court" && paymalcount == 0.0){
|
||||
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
}
|
||||
@@ -726,45 +592,35 @@ $(document).ready(function(){
|
||||
}
|
||||
/* replace url type*/
|
||||
/* start check first bill or not*/
|
||||
var member_id = $('#membership_id').text();
|
||||
var member_discount = $('#member_discount').text();
|
||||
var receipt_no = "";
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
var member_id = $('#membership_id').text();
|
||||
var member_discount = $('#member_discount').text();
|
||||
var receipt_no = "";
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
}
|
||||
|
||||
payment_type = '';
|
||||
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
|
||||
other_payment = payment_methods.find(x => payment_type.indexOf(x) >= 0)
|
||||
// console.log(payment_type)
|
||||
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
|
||||
if (member_id && member_discount) {
|
||||
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
|
||||
$("#credit_payment").hide();
|
||||
} else{
|
||||
$("#credit_payment").show();
|
||||
}
|
||||
|
||||
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
|
||||
// console.log(payment_type)
|
||||
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
|
||||
if (member_id && member_discount) {
|
||||
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
|
||||
$("#credit_payment").hide();
|
||||
} else{
|
||||
$("#credit_payment").show();
|
||||
}
|
||||
if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("VISA", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("JCB", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Master", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("UNIONPAY", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Redeem", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("Alipay", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("DINGA", payment_type)) != -1 ||
|
||||
parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1){
|
||||
$("#card_payment").show();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
}
|
||||
}
|
||||
// }
|
||||
/* end check first bill or not*/
|
||||
if(other_payment){
|
||||
$("#card_payment").show();
|
||||
} else{
|
||||
$("#card_payment").hide();
|
||||
}
|
||||
}
|
||||
// }
|
||||
/* end check first bill or not*/
|
||||
|
||||
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
|
||||
var dining_id = "<%= @sale.bookings[0].dining_facility_id %>";
|
||||
|
||||
$("#back").on('click', function() {
|
||||
localStorage.removeItem('cash');
|
||||
@@ -787,12 +643,10 @@ $(document).ready(function(){
|
||||
window.location.reload();
|
||||
})
|
||||
|
||||
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
|
||||
|
||||
}
|
||||
else {
|
||||
if (localStorage.getItem("cash") && localStorage.getItem("cash") != 'null') {
|
||||
$('#cash').text(localStorage.getItem("cash"));
|
||||
}
|
||||
|
||||
update_balance();
|
||||
//checkChangableTax
|
||||
checkChangableTax();
|
||||
@@ -827,125 +681,96 @@ $(document).ready(function(){
|
||||
sub_total = $('#sub-total').text();
|
||||
member = $('#membership_id').text();
|
||||
// console.log(member)
|
||||
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) {
|
||||
swal("Oops","Please Pay with MPU Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Redeem Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Visa Payment","warning");
|
||||
|
||||
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with jcb Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Master Payment","warning");
|
||||
}
|
||||
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with UNIONPAY Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Alipay Payment","warning");
|
||||
}
|
||||
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
|
||||
}
|
||||
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Credit Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Paymal Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Dinga Payment","warning");
|
||||
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
|
||||
swal("Oops","Please Pay with Gift Voucher","warning");
|
||||
if (other_payment && !other_payments.some(x => x[0] == other_payment && x[1] > 0 ) && sub_total != 0.0 && member) {
|
||||
swal("Oops","Please Pay with " + other_payment + " Payment","warning");
|
||||
} else {
|
||||
$( "#loading_wrapper").show();
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops", "Insufficient Amount!" , "error" );
|
||||
$("#loading_wrapper").hide();
|
||||
}else{
|
||||
$(this).off("click");
|
||||
var sale_id = $('#sale_id').text();
|
||||
// var item_row = $('.is_card');
|
||||
|
||||
$( "#loading_wrapper").show();
|
||||
if($('#balance').text() > 0){
|
||||
swal ( "Oops", "Insufficient Amount!" , "error" );
|
||||
$("#loading_wrapper").hide();
|
||||
}else{
|
||||
$(this).off("click");
|
||||
var sale_id = $('#sale_id').text();
|
||||
// var item_row = $('.is_card');
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var kbz_amt = "<%= @kbz_pay_amount %>";
|
||||
var is_kbz = false;
|
||||
if (kbz_amt > 0) {
|
||||
is_kbz = true
|
||||
}
|
||||
|
||||
// payment
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#card').text();
|
||||
var kbz_amt = "<%= @kbz_pay_amount %>";
|
||||
var is_kbz = false;
|
||||
if (kbz_amt > 0) {
|
||||
is_kbz = true
|
||||
}
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
|
||||
calculate_member_discount(sale_id,tax_type);
|
||||
}
|
||||
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
|
||||
calculate_member_discount(sale_id,tax_type);
|
||||
}
|
||||
// $("#pdfModal").on('shown.bs.modal', function () {
|
||||
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||
/* check credit payment or not*/
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_cash_path %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_cash_path %>";
|
||||
}
|
||||
|
||||
// $("#pdfModal").on('shown.bs.modal', function () {
|
||||
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
|
||||
/* check credit payment or not*/
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
var url = "<%= origami_credit_payment_cash_path %>";
|
||||
}else{
|
||||
var url = "<%= origami_payment_cash_path %>";
|
||||
}
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz,
|
||||
success:function(result){
|
||||
/* start delete receipt no in first bill*/
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
var receipt_no = ($("#receipt_no").html()).trim();
|
||||
deleteReceiptNoInFirstBillData(receipt_no);
|
||||
}
|
||||
/* end delete receipt no in first bill*/
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: url,
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz,
|
||||
success:function(result){
|
||||
/* start delete receipt no in first bill*/
|
||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||
var receipt_no = ($("#receipt_no").html()).trim();
|
||||
deleteReceiptNoInFirstBillData(receipt_no);
|
||||
}
|
||||
/* end delete receipt no in first bill*/
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
}
|
||||
|
||||
localStorage.removeItem("cash");
|
||||
if (result.status) {
|
||||
var msg = result.message;
|
||||
}
|
||||
else{
|
||||
var msg = '';
|
||||
$("#loading_wrapper" ).hide();
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
payment_success_alert();
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||
$("#sale_receipt_no").val(result.receipt_no);
|
||||
$("#filename").val(result.filename);
|
||||
$("#printer_name").val(result.printer_name);
|
||||
$("#receipt_pdf").attr("src", pdfPath);
|
||||
$("#changed_amount").text("");
|
||||
if($('#balance').text() < 0){
|
||||
<% if precision.to_i > 0 %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
||||
<% else %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
||||
<% end %>
|
||||
}
|
||||
|
||||
$("#loading_wrapper" ).hide();
|
||||
if(location.pathname.includes("credit_payment")){
|
||||
payment_success_alert();
|
||||
if (pdf_view == 1) {
|
||||
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
$("#pdfModalLabel").text("Sale Completed");
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
|
||||
$("#sale_receipt_no").val(result.receipt_no);
|
||||
$("#filename").val(result.filename);
|
||||
$("#printer_name").val(result.printer_name);
|
||||
$("#receipt_pdf").attr("src", pdfPath);
|
||||
$("#changed_amount").text("");
|
||||
if($('#balance').text() < 0){
|
||||
<% if precision.to_i > 0 %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
|
||||
<% else %>
|
||||
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
|
||||
<% end %>
|
||||
}
|
||||
|
||||
if (pdf_view == 1) {
|
||||
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
|
||||
$("#pdfModalLabel").text("Sale Completed");
|
||||
}else{
|
||||
//PDF lightbox data
|
||||
print_receipt();
|
||||
}
|
||||
print_receipt();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
|
||||
function customer_display_view(data,status) {
|
||||
@@ -1098,18 +923,8 @@ $(document).ready(function(){
|
||||
break;
|
||||
case 'nett':
|
||||
var credit1 = $('#credit').text();
|
||||
var card1 = $('#others').text();
|
||||
var paypar1 = $('#ppamount').text();
|
||||
var visa1 = $('#visacount').text();
|
||||
var jcb1 = $('#jcbcount').text();
|
||||
var master1 = $('#mastercount').text();
|
||||
var unionpay1 = $('#unionpaycount').text();
|
||||
var paymal1 = $('#paymalcount').text();
|
||||
var alipay1 = $('#alipaycount').text();
|
||||
var junctionpay1 = $('#junctionpaycount').text();
|
||||
var dingapay1 = $('#dingacount').text();
|
||||
var giftvoucherpay1 = $('#giftvouchercount').text();
|
||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1) + parseFloat(paymal1) + parseFloat(dingapay1) + parseFloat(giftvoucherpay1);
|
||||
var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
|
||||
var othertotal = parseFloat(credit1) + parseFloat(others);
|
||||
var total = $('#amount_due').text();
|
||||
var amt = 0;
|
||||
<% if precision.to_i > 0 %>;
|
||||
@@ -1131,19 +946,10 @@ $(document).ready(function(){
|
||||
function update_balance(){
|
||||
var cash = $('#cash').text();
|
||||
var credit = $('#credit').text();
|
||||
var card = $('#others').text();
|
||||
var paypar = $('#ppamount').text();
|
||||
var visa = $('#visacount').text();
|
||||
var jcb = $('#jcbcount').text();
|
||||
var master = $('#mastercount').text();
|
||||
var unionpay = $('#unionpaycount').text();
|
||||
var paymal = $('#paymalcount').text();
|
||||
var alipay = $('#alipaycount').text();
|
||||
var junctionpay = $('#junctionpaycount').text();
|
||||
var dinga = $('#dingacount').text();
|
||||
var giftvoucher = $('#giftvouchercount').text();
|
||||
var others = other_payments.map(x => x[1]).reduce((acc, v) => acc + v, 0);
|
||||
|
||||
var amount_due = $('#amount_due').text();
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay) + parseFloat(paymal) + parseFloat(dinga) + parseFloat(giftvoucher);
|
||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(others);
|
||||
|
||||
var result = parseFloat(amount_due) - parseFloat(total);
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ class ActionController::Base
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
else
|
||||
redirect_to activate_path
|
||||
end
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -244,23 +244,25 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'payment/dinga' => 'dinga#create'
|
||||
post 'payment/gift_voucher' => 'gift_voucher#create'
|
||||
post 'payment/credit_payment' => 'credit_payments#create_credit_payment'
|
||||
post 'payment/:method' => 'others_payments#create', :as => 'payment'
|
||||
|
||||
post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'}
|
||||
|
||||
get 'sale/:sale_id/:type/payment/credit_payment' => "credit_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/MPU' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/JCB' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Voucher' => "voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/Alipay' => "alipay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/DINGA' => "dinga#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/mpu' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/visa' => "visa#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/master' => "master#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/jcb' => "jcb#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/paymal' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/unionpay' => "unionpay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/voucher' => "voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/junctionpay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/alipay' => "alipay#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/dinga' => "dinga#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
#---------Void --------------#
|
||||
post 'sale/:sale_id/:type/void' => 'void#overall_void'
|
||||
@@ -351,20 +353,22 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# post 'credit_payment/junctionpay' => 'junction_pay#create'
|
||||
# post 'credit_payment/dinga' => 'dinga#create'
|
||||
# post 'credit_payment/gift_voucher' => 'gift_voucher#create'
|
||||
post 'credit_payment/:method' => 'others_payments#create', :as => 'credit_payment'
|
||||
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment' => "others_payments#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/MPU' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/VISA' => "visa#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/JCB' => "jcb#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/PAYMAL' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/UNIONPAY' => "unionpay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/Voucher' => "voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/JunctionPay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/mpu' => "mpu#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/visa' => "visa#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/master' => "master#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/jcb' => "jcb#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/paymal' => "paymal#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/unionpay' => "unionpay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/redeem' => "redeem_payments#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/voucher' => "voucher#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/junctionpay' => "junction_pay#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/alipay' => "alipay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/dinga' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/giftvoucher' => "gift_voucher#index"
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/:method' => 'others_payments#new'
|
||||
|
||||
#------------- Start Reservation -------------------#
|
||||
resources :reservation
|
||||
|
||||
Reference in New Issue
Block a user