diff --git a/app/assets/javascripts/foodcourt.js b/app/assets/javascripts/foodcourt.js new file mode 100644 index 00000000..4febbe86 --- /dev/null +++ b/app/assets/javascripts/foodcourt.js @@ -0,0 +1,186 @@ +//= require jquery +//= require tether +//= require jquery_ujs +//= require bootstrap/js/popper.min +//= require bootstrap/js/bootstrap-material-design.min +//= require momentjs/moment +//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker +//= require jquery-slimscroll/jquery.slimscroll.js +//= require bootstrap-notify/bootstrap-notify.js +//= require node-waves/waves.js +//= require sweetalert/sweetalert.min.js +//= require fileinput.min +//= require cable +//= require turbolinks +//= require BSBMaterial/turbolink_admin.js +//= require BSBMaterial/demo.js + +/* Constant Varaibles */ +_CREDIT_PAYMENTS_ = "/   CREDIT PAYMENTS"; +_CUSTOMERS_ = "/   CUSTOMERS"; +_DISCOUNTS_ = "/   DISCOUNTS"; +_IN_DUTIES_ = "/   IN DUTIES"; +_JCB_ = "/   JCB PAYMENT"; +_MASTER_ = "/   MASTER PAYMENT"; +_MPU_ = "/   MPU PAYMENT"; +_ALIPAY_ = "/   Alipay"; +_JUNCTIONPAY_ = "/   JunctionPay"; +_PAYMAL_ = "/   PAYMAL"; +_DINGA_ = "/   DINGA PAYMENT"; +_GIFT_VOUCHER_ = "/   GIFT VOUCHER"; +_OTHER_CHARGES_ = "/   CHARGES"; +_OTHER_PAYMENTS_ = "/   OTHER PAYMENT"; +_PAYMENTS_ = "/   PAYMENT"; +_PAYPAR_PAYMENT_ = "/   PAYPAR PAYMENT"; +_COMMISSIONS_ = "/   COMMISSIONS"; +_REDEEM_PAYMENT_ = "/   REDEEM PAYMENT"; +_SALE_EDIT_ = "/   SALE EDIT"; +_SPLIT_BILL_ = "/   SPLIT BILL"; +_UNION_ = "/   UNION PAYMENT"; +_VISA_ = "/   VISA PAYMENT"; +_VOUCHER_ = "/   VOUCHER"; +_SURVEY_ = "/   SURVEY"; +/* Constant Varaibles */ + +$(document).on('turbolinks:load', function() { + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + + $('.datetimepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY - HH:mm', + clearButton: true, + weekStart: 1 + }); + + $('.datepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY', + clearButton: true, + weekStart: 1, + time: false + }); + + $('.timepicker').bootstrapMaterialDatePicker({ + format: 'HH:mm', + clearButton: true, + date: false + }); + + // For selected order return + var order_status = ""; + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + + + $(document).on('click', '.access_modal', function(event){ + type = $(this).data("type"); + $(".ok").attr("data-action",type); + $('#AccessCodeModal').modal('show'); + }); + + $(document).on('click', '.access_number', function(event){ + if(event.handled !== true) { + var original_value = $('#access_code').val(); + var input_type = $(this).attr("data-type"); + + switch (input_type) { + case 'num': + var input_value = $(this).attr("data-value"); + if (original_value){ + $('#access_code').val(original_value + input_value); + }else{ + $('#access_code').val(original_value + input_value); + } + break; + case 'ok': + var type = $(this).attr("data-action"); + code = $('#access_code').val(); + check_emp_access_code(code,type) + break; + case 'clr': + $('#access_code').val(""); + break; + } + event.handled = true; + } else { + return false; + } + }); +}); + +function setHeaderBreadCrumb(params){ + $("#others_payment").html(params); +} + +//show hide nav bar for webview +function showHideNavbar(webview,page){ + if(webview){ + $("nav.navbar").addClass("hidden"); + $("section").addClass("section-margin"); + $(".page-loader-wrapper").addClass("hidden"); + if(page!=undefined){ + $("#back").hide(); + } + }else{ + $("nav.navbar").removeClass("hidden"); + $("section").removeClass("section-margin"); + $(".page-loader-wrapper").removeClass("hidden"); + if(page!=undefined){ + $("#back").show(); + } + } +} + +function createAccessCode(code) { + localStorage.setItem("access_code",code); +} +function check_emp_access_code(access_code,type) { + var url = "/foodcourt/check_emp_access_code/" + access_code ; + $.ajax({ + type: 'POST', + url: url, + data: {}, + success: function (result) { + if (result.status == true) { + createAccessCode(code); + if (type == "edit") { + var dining_id = $('#dining').text(); + var sale_id = $('#sale_id').text(); + if (dining_id) { + window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/food_court/edit"; + }else{ + window.location.href = "/foodcourt/table/sale/" + sale_id + "/food_court/edit"; + } + }else if(type == "void"){ + $('#AccessCodeModal').modal('hide'); + $('#voidModal').modal('show'); + }else if(type == "waste") { + waste_and_spoilage("waste") + }else if(type == "spoile") { + waste_and_spoilage("spoile") + }else if(type == "foc"){ + $('#AccessCodeModal').modal('hide'); + $('#focModal').modal('show'); + } + }else{ + swal("Oops",result.message,"warning"); + } + } + }); +} diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 9d060a51..d59b619f 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -1,5 +1,5 @@ class Api::PaymentsController < Api::ApiController - # skip_before_action :authenticate + skip_before_action :authenticate #Payment by Invoice ID # Payment Method - [Cash | CreditNote | VISA | MASTER | etc..] diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index ca67efdd..7af39af0 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -70,7 +70,8 @@ class Foodcourt::OrdersController < BaseFoodcourtController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq + .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq + # .where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) diff --git a/app/controllers/foodcourt/paymal_controller.rb b/app/controllers/foodcourt/paymal_controller.rb index 5907f6ec..bf69c946 100644 --- a/app/controllers/foodcourt/paymal_controller.rb +++ b/app/controllers/foodcourt/paymal_controller.rb @@ -9,7 +9,7 @@ class Foodcourt::PaymalController < BaseFoodcourtController @receipt_no = sale_data.receipt_no @shop = Shop.current_shop - + if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else diff --git a/app/controllers/foodcourt/paypar_payments_controller.rb b/app/controllers/foodcourt/paypar_payments_controller.rb index 8b917115..ab67b966 100755 --- a/app/controllers/foodcourt/paypar_payments_controller.rb +++ b/app/controllers/foodcourt/paypar_payments_controller.rb @@ -7,7 +7,7 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController payment_method = "paypar" if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - + @shop = Shop.current_shop # rounding adjustment diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index 6d7dd34c..cf148742 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -33,15 +33,6 @@ class Foodcourt::VoidController < BaseFoodcourtController sale.sale_status = 'void' sale.save - # No Need - # bookings = sale.bookings - # bookings.each do |booking| - # orders = booking.orders - # orders.each do |order| - # # order.status = 'void' - # end - # end - if sale.bookings[0].dining_facility_id.to_i > 0 table_avaliable = true table_count = 0 @@ -79,8 +70,14 @@ class Foodcourt::VoidController < BaseFoodcourtController # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" ) - # For Print + #call paymal to void + if sale.sale_payments + membership_response =sale.paymal_payment_void + end + Rails.logger.debug "---------Paymal Payment Void response in VoidController" + Rails.logger.debug membership_response.to_json + # For Print member_info = nil rebate_amount = nil current_balance = nil @@ -102,17 +99,6 @@ class Foodcourt::VoidController < BaseFoodcourtController cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - - # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - # get printer info - # print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf - # - # if !print_settings.nil? - # unique_code = 'ReceiptBillPdf' - # elsif - # unique_code = 'ReceiptBillStarPdf' - # end - customer= Customer.find(sale.customer_id) # get member information diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 30126177..48cb19b4 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -9,7 +9,7 @@ class Origami::RequestBillsController < ApplicationController # Print Request Bill and add to sale tables def print @shop = Shop.current_shop - if !ShiftSale.current_shift(@shop.shop_code).nil? + if !ShiftSale.current_shift.nil? order_id = params[:id] # order_id order = Order.find(order_id) booking = order.booking @@ -46,7 +46,7 @@ class Origami::RequestBillsController < ApplicationController sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type ) # Promotion Activation - Promotion.promo_activate(sale_data,@shop.shop_code) + Promotion.promo_activate(sale_data) #bill channel if ENV["SERVER_MODE"] == 'cloud' diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index d43b4702..2216d5dd 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -320,7 +320,7 @@ class Origami::SplitBillController < BaseOrigamiController end end - Promotion.promo_activate(sale_data,@shop.shop_code) + Promotion.promo_activate(sale_data) if ENV["SERVER_MODE"] == 'cloud' from = request.subdomain + "." + request.domain else diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index e0d4fc85..39cbb431 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -38,20 +38,20 @@ class Printer::PrinterWorker end def print(file_path,printer_destination = nil ) - if printer_destination.nil? - printer_destination = self.printer_destination - end - - puts printer_destination - puts '........Printer Destination..........' - - copy = self.print_copies - #Print only when printer information is not null - if !self.printer_destination.nil? - (1..copy).each do - page = Cups::PrintJob.new(file_path, printer_destination) - page.print - end - end + # if printer_destination.nil? + # printer_destination = self.printer_destination + # end + # + # puts printer_destination + # puts '........Printer Destination..........' + # + # copy = self.print_copies + # #Print only when printer information is not null + # if !self.printer_destination.nil? + # (1..copy).each do + # page = Cups::PrintJob.new(file_path, printer_destination) + # page.print + # end + # end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 6e856245..90ed9f73 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2430,7 +2430,48 @@ def self.get_check_sale_data(transaction_date) .where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void) .group("sales.receipt_no,sales.sale_status") end +def paymal_payment_void + puts self.sale_payments.to_json + membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.shop_code) + membership_actions_data = MembershipAction.find_by_membership_type_and_shop_code("void",self.shop_code) + if !membership_actions_data.nil? + sale_payments =self.sale_payments.where("payment_reference is not null") + account_no =sale_payments[0].payment_reference + url = membership_setting.gateway_url.to_s + membership_actions_data.gateway_url.to_s + merchant_uid = membership_actions_data.merchant_account_id + auth_token = membership_actions_data.auth_token + params = { receipt_no:self.receipt_no, + account_no:account_no, + merchant_uid:merchant_uid, + auth_token:auth_token}.to_json + # Control for Paypar Cloud + begin + response = HTTParty.post(url, + :body => params, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, + :timeout => 10 + ) + rescue Errno::ECONNREFUSED + response = { "status" => false, "message" => "Can't open membership server"} + rescue Net::OpenTimeout + response = { "status" => false, "message" => "No internet connection " } + rescue OpenURI::HTTPError + response = { "status" => false, "message" => "No internet connection "} + rescue SocketError + response = { "status" => false, "message" => "No internet connection "} + end + else + response = { "status" => false} + end + + Rails.logger.debug "Void Payment response" + Rails.logger.debug response.to_json + return response; +end # Loader Service SFTP End private diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 298fb1d2..96be1d56 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -533,11 +533,8 @@ class SalePayment < ApplicationRecord payment_status = false #Next time - validate if the vochure number is valid - within - # customer_data = Customer.find_by_customer_id(self.sale.customer_id) account_no = self.payment_reference - # if account_no.to_i <= 0 - # account_no = customer_data.membership_id - # end + # self.sale.customer.update_attributes(paypar_account_no: ) membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code) membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id) @@ -548,7 +545,7 @@ class SalePayment < ApplicationRecord if membership_data["status"]==true self.payment_method = "paymal" self.payment_amount = self.received_amount - self.payment_reference = self.voucher_no + # self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_status = self.save! diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index 0f751c2d..09deb513 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -7,6 +7,7 @@ } <%= javascript_include_tag 'custom', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'foodcourt', 'data-turbolinks-track': 'reload' %> <% if @booking.nil?%>
<% if !@booking.nil?%> -
+
<% else %>
<% end %> @@ -57,80 +58,168 @@
<% if !@booking.nil?%> -
-
-
-
- ORDER DETAILS | Table-<%=@booking.dining_facility.name%>
- Booking - <%=@booking.booking_id%>
- Order No- <%=@booking.order_id%> + +
+
+
+
+ ORDER DETAILS | Table-<%=@booking.dining_facility.name%>
+ Booking - <%=@booking.booking_id%>
+ Order No- <%=@booking.order_id%> +
-
- -
-
-
-
- - - - - - - - - - - <% sub_total = 0 - count = 0 - %> - <% @sale_data.sale_items.each do |sale_item| - count += 1 - %> - <% sub_total += sale_item.price%> +
+
+
#ItemsQtyPrice
+ - - - - - - <%end %> - -
<%= count %><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%><%=sale_item.qty%><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
+ # + Items + Qty + Price + + + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> + <% sub_total += sale_item.price%> + + <%= count %> + <%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%> + <%=sale_item.qty%> + <%=(number_with_precision(sale_item.price, precision: precision.to_i ))%> + + <%end %> + + +
+
- -
+
+
+
+ + Void +
+ <% end %> +
+ + +
diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb index 336c7a2d..859f35b9 100755 --- a/app/views/foodcourt/payments/show.html.erb +++ b/app/views/foodcourt/payments/show.html.erb @@ -389,53 +389,22 @@
- - <% if current_login_employee.role == "cashier" %> - <% if @other_payment <= 0 && @sale_payment.nil? %> + <% if @sale_payment.nil? %> + - - <% end %> + + <% end %> <% end %> <% end %> - -<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %> -
- <% if current_login_employee.role == "cashier" %> - Edit - <% else %> -