diff --git a/app/controllers/origami/junction_pay_controller.rb b/app/controllers/origami/junction_pay_controller.rb new file mode 100644 index 00000000..c02461aa --- /dev/null +++ b/app/controllers/origami/junction_pay_controller.rb @@ -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 diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index fc07f966..1b4bd5bb 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -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 diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5809dc0f..c49f30a7 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -48,6 +48,8 @@ class SalePayment < ApplicationRecord payment_status = paypar_payment when "foc" payment_status = foc_payment + when "JunctionPay" + payment_status = junction_pay_payment else puts "it was something else" end @@ -297,6 +299,22 @@ class SalePayment < ApplicationRecord end + def junction_pay_payment + payment_status = false + + #Next time - validate if the vochure number is valid - within + self.payment_method = "JunctionPay" + self.payment_amount = self.received_amount + self.payment_reference = self.voucher_no + self.outstanding_amount = self.sale.grand_total- self.received_amount + self.payment_status = "paid" + payment_method = 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 self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 5f0245a9..571758be 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -691,7 +691,7 @@ createReceiptNoInFirstBillData(receipt_no,""); // console.log(result); - code2lab.printBill(result.filepath, result.printer_model, result.printer_url); + // code2lab.printBill(result.filepath, result.printer_model, result.printer_url); location.reload(); } }); diff --git a/app/views/origami/junction_pay/create.json.jbuilder b/app/views/origami/junction_pay/create.json.jbuilder new file mode 100755 index 00000000..9767a7d8 --- /dev/null +++ b/app/views/origami/junction_pay/create.json.jbuilder @@ -0,0 +1,5 @@ +if(@status) + json.status @status +else + json.status false +end diff --git a/app/views/origami/junction_pay/index.html.erb b/app/views/origami/junction_pay/index.html.erb new file mode 100755 index 00000000..4e371f76 --- /dev/null +++ b/app/views/origami/junction_pay/index.html.erb @@ -0,0 +1,259 @@ +