Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
70
app/controllers/origami/junction_pay_controller.rb
Normal file
70
app/controllers/origami/junction_pay_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
@junction_pay_count = 0
|
||||
others = 0
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
@shop = Shop::ShopDetail
|
||||
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
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "JunctionPay"
|
||||
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_junction_pay = total - @junction_pay_count - 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
|
||||
|
||||
def create
|
||||
gift_amount = params[:gift_amount]
|
||||
voucher_amount = params[:voucher_amount]
|
||||
voucher_no = params[:voucher_no]
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
# Gift card or Voucher classified and add for payment_reference
|
||||
remarks = ''
|
||||
cash = (gift_amount.to_f + voucher_amount.to_f)
|
||||
if gift_amount.to_f > 0
|
||||
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
|
||||
else
|
||||
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
|
||||
end
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# 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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay", remarks)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -27,7 +27,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
@@ -79,8 +79,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
end
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,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
|
||||
|
||||
def create
|
||||
@@ -131,7 +140,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# For Print
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
@@ -195,7 +204,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
|
||||
|
||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
end
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -213,6 +235,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0.00
|
||||
@@ -325,6 +348,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user