add junction pay
This commit is contained in:
58
app/controllers/origami/junction_pay_controller.rb
Normal file
58
app/controllers/origami/junction_pay_controller.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
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
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
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")
|
||||
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"
|
||||
@@ -89,7 +89,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -138,7 +138,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?
|
||||
@@ -202,8 +202,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -221,6 +221,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
|
||||
@@ -333,6 +334,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "junctionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user