diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index cb0b997a..3674e235 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,10 +17,10 @@ //= require cable $(document).ready(function(){ - // auto refresh every 5 seconds + // auto refresh every 10 seconds setTimeout(function(){ window.location.reload(1); - }, 5000); + }, 10000); $('.queue_station').on('click',function(){ var orderZone=$(this).children().children().children('.order-zone').text(); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index ca54f6f6..4a7e3d50 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -220,8 +220,7 @@ $(document).ready(function(){ if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ var balance = data["response_data"]["data"][i]["balance"]; if (data["response_data"]["status"]==true) { - $('.rebate_amount').removeClass('hide'); - console.log(balance); + $('.rebate_amount').removeClass('hide'); row = '' + data["response_data"]["data"][i]["accountable_type"] +'' +'' + balance + ''; diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 96e76574..4cacae00 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -51,34 +51,14 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) + response = Customer.get_member_account(@customer) - membership = MembershipSetting.find_by_membership_type("paypar_url") - - memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - merchant_uid = memberaction.merchant_account_id.to_s - auth_token = memberaction.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - } - ) if(response["status"] == true) @membership = response["data"] else @membership = 0 end - # @type = "-" - # @balance = 0.00 - # response["data"].each do |res| - # if res["accountable_type"] == "RebateAccount" - # @balance = res["balance"] - # @type = "RebateAccount" - # end - # end - + #end customer amount end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3f453565..dbde3293 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -15,7 +15,7 @@ class Origami::HomeController < BaseOrigamiController @completed_orders = Order.get_completed_order() @booking_orders = Order.get_booking_order_table() - @booking_rooms = Order.get_booking_order_rooms() + @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() end @@ -68,20 +68,8 @@ class Origami::HomeController < BaseOrigamiController def get_customer @customer = Customer.find(params[:customer_id]) - - membership = MembershipSetting.find_by_membership_type("paypar_url") - - memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - merchant_uid = memberaction.merchant_account_id.to_s - auth_token = memberaction.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - - response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - } - ) + + response = Customer.get_member_account(@customer) respond_to do |format| format.js do diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 7ba72486..b7963541 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -13,10 +13,10 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment.process_payment(saleObj, @user, cash, "cash") unique_code = "ReceiptBillPdf" - customer= Customer.where('customer_id=' + saleObj.customer_id) + customer= Customer.find(saleObj.customer_id) # get member information - response = get_member_information(customer, "get_all_member_account") + member_info = Customer.get_member_account(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -25,7 +25,7 @@ class Origami::PaymentsController < BaseOrigamiController food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) end end @@ -38,10 +38,10 @@ class Origami::PaymentsController < BaseOrigamiController @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount - @customer = Customer.find(@sale_data.customer_id) + @customer = Customer.find(@sale_data.customer_id) # get member information - response = get_member_information(@customer, "get_all_member_account") + response = Customer.get_member_account(@customer) @balance = 0.00 @accountable_type = '' diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 36b2be3d..c8ecb725 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -92,6 +92,16 @@ class Transactions::SalesController < ApplicationController end end + def void + @sale = params[:sale_id] + @reason = Lookup.where("lookup_type = 'void_reason'") + end + + def manual_void_sale + sale_id = params[:sale_id] + + end + private # Use callbacks to share common setup or constraints between actions. def set_transactions_sale diff --git a/app/models/customer.rb b/app/models/customer.rb index 93834b43..0cbf8d58 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -12,21 +12,39 @@ class Customer < ApplicationRecord paginates_per 50 - def self.get_member_group + # def self.get_member_group - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("get_all_member_group") - app_token = membership.auth_token.to_s + # membership = MembershipSetting.find_by_membership_type("paypar_url") + # memberaction = MembershipAction.find_by_membership_type("get_all_member_group") + # app_token = membership.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.get(url, - :body => { app_token: app_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json' - } - ) - puts response.body, response.code, response.message, response.headers.inspect + # url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + # response = HTTParty.get(url, + # :body => { app_token: app_token}.to_json, + # :headers => { + # 'Content-Type' => 'application/json', + # 'Accept' => 'application/json' + # } + # ) + # puts response.body, response.code, response.message, response.headers.inspect + + # return response; + + # end + + def self.get_member_account(customer) + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("get_all_member_account") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + } + ) return response; diff --git a/app/models/order.rb b/app/models/order.rb index aa6cb26f..bac7cd20 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -230,7 +230,7 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("(orders.status = 'new' or orders.status = 'billed')") + .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true @@ -261,7 +261,7 @@ class Order < ApplicationRecord .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") - .where("(orders.status = 'new' or orders.status = 'billed')") + .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) .group("bookings.booking_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index a8a27db3..e8fb111a 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info) pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index dbaea572..43b513fd 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total) + def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil) self.page_width = 250 self.page_height = 1450 self.margin = 10 @@ -31,7 +31,12 @@ class ReceiptBillPdf < Prawn::Document cashier_info(sale_data, customer_name) line_items(sale_items, food_total, beverage_total) - all_total(sale_data) + all_total(sale_data) + + if member_info != nil + member_info(member_info) + end + footer end @@ -183,7 +188,24 @@ class ReceiptBillPdf < Prawn::Document end move_down 5 # stroke_horizontal_rule + end + # show member information + def member_info(member_info) + move_down 7 + if member_info["data"] == true + member_info["data"].each do |res| + stroke_horizontal_rule + move_down 5 + y_position = cursor + + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "#{ res["accountable_type"] } : #{ res["balance"] }", :size => self.item_font_size,:align => :left + end + + move_down 5 + end + end end def footer diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 09d9b7ef..9f6cd7d6 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -85,8 +85,7 @@
<% @booking_orders.each do |bko| - # No Show completed - puts bko.sale_status + # No Show completed if bko.sale_status == 'completed' next end @@ -208,8 +207,7 @@
<% - @orders.each do |odr| - puts odr + @orders.each do |odr| # No Show completed if odr.sale_status == 'completed' next diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 3ff7557e..26fcc62f 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -93,7 +93,7 @@ Grand Total <%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%> -   +   Pay Amount @@ -108,7 +108,7 @@ Payment <%= r.payment_method rescue ' '%> - <%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> + <%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> @@ -166,16 +166,22 @@
diff --git a/app/views/transactions/sales/show__.html.erb b/app/views/transactions/sales/show__.html.erb deleted file mode 100644 index b9a57ed9..00000000 --- a/app/views/transactions/sales/show__.html.erb +++ /dev/null @@ -1,112 +0,0 @@ -
-
- -
-
- - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <% @sale.sale_items.each do |s| %> - - - - - - - - - <% end %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
 
Receipt Date Receipt noCashierSales statusReceipt generated at
<%= @sale.receipt_date.strftime("%d-%M-%Y") %><%= @sale.receipt_no %><%= @sale.cashier rescue '-' %> <%= @sale.sale_status %> <%= @sale.requested_at.strftime("%d-%m-%Y") %>
Sale item name QtyUnit priceTotal pirce Created at
<%=s.product_name rescue ' '%><%=s.qty rescue ' '%><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %>
Total<%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%>
Discount<%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%>
Tax<%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%>
Grand Total<%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%>
 
Pay Amount<%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%>
Change<%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%>
- - -
-
- -
-
- - - - - diff --git a/app/views/transactions/sales/void.html.erb b/app/views/transactions/sales/void.html.erb new file mode 100644 index 00000000..6d0d9fb7 --- /dev/null +++ b/app/views/transactions/sales/void.html.erb @@ -0,0 +1,59 @@ +
+
+ +
+
+
+ +
+
+ +
+

Choose your reason

+ + + + + + + + +
+
+ + +
+
+ +  
+
+
+
+ + +
+ + + Back + + + +
+ +
+ + + + + + diff --git a/config/routes.rb b/config/routes.rb index ee9b44a0..299c1b87 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -198,6 +198,8 @@ Rails.application.routes.draw do namespace :transactions do resources :sales resources :orders + get "/sales/:sale_id/void" =>"sales#void", :as => "void" + post "sales/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale" end #--------- Reports Controller Sections ------------#