payment method changed in report

This commit is contained in:
yarzar_code
2020-07-09 14:46:18 +06:30
parent 8f5ea9417d
commit 3d2d18a330
26 changed files with 1836 additions and 1976 deletions

View File

@@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
@cashier_type = params[:type]
path = request.fullpath
if path.include? ("credit_payment")
@payment_method_setting = PaymentMethodSetting.where("LOWER(payment_method) in ('mpu','visa','master','jcb','unionpay','alipay') and is_active='1'")
@payment_method_setting = PaymentMethodSetting.where("is_active='1'")
else
@payment_method_setting = PaymentMethodSetting.all
end
@@ -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

View File

@@ -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
@@ -193,7 +194,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
@@ -209,7 +210,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
#end
@@ -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 == 'paypar' ? 'redeem' : 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 == 'paypar' ? 'redeem' : 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', 'foc'].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 current_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
@@ -465,7 +390,7 @@ class Origami::PaymentsController < BaseOrigamiController
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
shift = ShiftSale.current_open_shift(current_user)
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
@@ -496,7 +421,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = @shop
#shop_detail = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -519,7 +444,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -531,7 +456,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
result = {
:status => true,
@@ -581,7 +506,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
shift = ShiftSale.current_open_shift(current_user)
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
@@ -603,8 +528,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = @shop
#shop_detail = Shop.current_shop
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
@@ -629,7 +553,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil)
result = {
:status => true,
:filepath => filename,
@@ -663,8 +587,9 @@ class Origami::PaymentsController < BaseOrigamiController
def rounding_adj
saleObj = Sale.find(params[:sale_id])
@shop = current_shop
if current_shop.is_rounding_adj
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

View File

@@ -1,10 +1,12 @@
class Origami::VoidController < BaseOrigamiController
authorize_resource :class => false
authorize_resource :class => false
def overall_void
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
access_code = params[:access_code]
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
@@ -41,32 +43,10 @@ class Origami::VoidController < BaseOrigamiController
# end
# end
if sale.bookings[0].dining_facility_id.to_i > 0
table_avaliable = true
table_count = 0
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end
else
table_avaliable = false
table_count += 1
end
end
if table = sale.booking.dining_facility
unless table.current_bookings.exists?
table.update_attributes(status: 'available')
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end
# FOr Sale Audit
@@ -112,46 +92,49 @@ class Origami::VoidController < BaseOrigamiController
# unique_code = 'ReceiptBillStarPdf'
# end
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
customer= Customer.find(sale.customer_id)
printer = PrintSetting.all
#shop detail
shop_details = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
printer = PrintSetting.all
# Mobile Print
render :json => result.to_json
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print