diff --git a/Gemfile b/Gemfile index 36be43b7..99489d5b 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem 'to_xls-rails' #Reporting gem #gem 'compendium' - +#gem "cancan" # Use jquery as the JavaScript library gem 'jquery-rails' gem 'jquery-ui-rails' @@ -57,8 +57,11 @@ gem 'bcrypt', '~> 3.1.7' gem 'sidekiq' +# XML parser +#gem 'nokogiri', '~> 1.6' + # Pagination -gem 'kaminari', '~> 0.16.3' +gem 'kaminari', '~> 1.0.1' # Datatable gem 'filterrific' diff --git a/Gemfile.lock b/Gemfile.lock index a4441893..e6f683f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,9 +89,18 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - kaminari (0.16.3) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -247,7 +256,7 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails jquery-ui-rails - kaminari (~> 0.16.3) + kaminari (~> 1.0.1) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) pg diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 2cddf699..3674e235 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,6 +17,11 @@ //= require cable $(document).ready(function(){ + // auto refresh every 10 seconds + setTimeout(function(){ + window.location.reload(1); + }, 10000); + $('.queue_station').on('click',function(){ var orderZone=$(this).children().children().children('.order-zone').text(); var orderItem=$(this).children().children().children('.order-item').text(); @@ -39,7 +44,8 @@ $(document).ready(function(){ }); // complete for queue item - $('.order-complete').on('click',function(){ + $('.order-complete').on('click',function(e){ + //e.preventDefault(); var _self = $(this); // To know in ajax return var assigned_item_id=$(this).attr('id').substr(15); var params = { 'id':assigned_item_id }; @@ -72,8 +78,10 @@ $(document).ready(function(){ $("#completed_count").text(parseInt($("#completed_count").text()) + data.length); alert("updated!"); + // Page reload + location.reload(); } - }); + }); }); $('#print_order_item').on('click',function(){ diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 7c79a6c7..4a7e3d50 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -19,8 +19,17 @@ //= require bootstrap-datepicker $(document).ready(function(){ + // auto refresh every 60 seconds + setTimeout(function(){ + window.location.reload(1); + }, 60000); + + // For selected order return + var order_status = ""; + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + // Enable/Disable Button - control_button("disabled"); + control_button(order_status); $(".orders").on('click', function(){ $("#order-sub-total").text(''); @@ -38,10 +47,6 @@ $(document).ready(function(){ // Enable/Disable Button control_button(order_status); - //for customer button - $("#customer").removeAttr('disabled'); - - var customer_id=$(this).find(".customer-id").text(); show_customer_details(customer_id); @@ -66,12 +71,15 @@ $(document).ready(function(){ for (i = 0; i < result.length; i++) { var data = JSON.stringify(result[i]); var parse_data = JSON.parse(data); + var show_date = ""; // Receipt Header receipt_no = result[i].receipt_no; cashier = result[i].cashier_name; - receipt_date = new Date(result[i].receipt_date); - show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() + if(result[i].receipt_date != null){ + receipt_date = new Date(result[i].receipt_date); + show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() + } $("#receipt_no").text(receipt_no); $("#cashier").text(cashier == null ? "" : cashier); @@ -198,11 +206,11 @@ $(document).ready(function(){ var url = "origami/"+customer_id+"/get_customer/" } - $('.customer_detail').removeClass('hide'); - + $('.customer_detail').removeClass('hide'); + //Start Ajax - $.ajax({ - type: "GET", + $.ajax({ + type: "GET", url: url, data: {}, dataType: "json", @@ -212,15 +220,14 @@ $(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); - row = + $('.rebate_amount').removeClass('hide'); + row = '' + data["response_data"]["data"][i]["accountable_type"] +'' - +'' + balance + ''; + +'' + balance + ''; $(".rebate_amount").html(row); } - + } }); } @@ -283,18 +290,21 @@ $(document).ready(function(){ }); /* Button Control by Status */ -function control_button(order_status){ - if(order_status=="billed"){ +function control_button(order_status){ + if(order_status=="billed"){ + $("#customer").prop('disabled', false); $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', false); $("#pay-bill").prop('disabled', false); } else if(order_status=="new") { + $("#customer").prop('disabled', false); $("#request_bills").prop('disabled', false); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); } else { + $("#customer").prop('disabled', true); $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); diff --git a/app/assets/javascripts/payment.js b/app/assets/javascripts/payment.js new file mode 100644 index 00000000..b7aadf05 --- /dev/null +++ b/app/assets/javascripts/payment.js @@ -0,0 +1,40 @@ +// number key pad +$(document).on('click', '.cashier_number', function(event){ + event.stopPropagation(); + event.preventDefault(); + if(event.handled !== true) { + var original_value; + original_value = $('#amount').text(); + + var input_value = $(this).attr("data-value"); + + var input_type = $(this).attr("data-type"); + switch (input_type) { + case 'num': + if (original_value == "0.0"){ + $('#amount').text(input_value); + }else{ + $('#amount').append(input_value); + } + break; + + case 'add': + var input_value = $(this).attr("data-value"); + amount = parseInt(input_value) + parseInt(original_value); + $('#amount').html(amount); + + break; + case 'clr': + $('#amount').html("0.0"); + break; + case 'del' : + var cash=$('#amount').text(); + $('#amount').text(cash.substr(0,cash.length-1)); + break; + + } + event.handled = true; + } else { + return false; + } +}); diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss index 07c98b85..b516836a 100644 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -16,5 +16,6 @@ } .selected-item { + color: #fff !important; background-color: blue; } diff --git a/app/controllers/api/invoices_controller.rb b/app/controllers/api/invoices_controller.rb index 7d6e2cb7..aedfc9f7 100644 --- a/app/controllers/api/invoices_controller.rb +++ b/app/controllers/api/invoices_controller.rb @@ -1,6 +1,6 @@ class Api::InvoicesController < ActionController::API - before :authenticate_token - before :set_sale_params, only:[:show, :update, :destroy] + # before :authenticate_token + # before :set_sale_params, only:[:show, :update, :destroy] #List open invoices for today. def index diff --git a/app/controllers/api/memberships_controller.rb b/app/controllers/api/memberships_controller.rb index 210a4ca0..ea5b5279 100644 --- a/app/controllers/api/memberships_controller.rb +++ b/app/controllers/api/memberships_controller.rb @@ -1,7 +1,7 @@ class Api::MembershipsController < ActionController::API - before :authenticate_token + #before :authenticate_token + - #Add Membership to invoice def create diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 2c2d219b..39219c6b 100644 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -29,56 +29,56 @@ class Api::PaymentsController < ActionController::API #:received_amount, :card_payment_reference, :vochure_no, :giftcard_no, #:customer_id, :external_payment_status - switch (payment_method) - case "cash" + case payment_method + when "cash" sale_payment.payment_method = "cash" sale_payment.received_amount = params[:amount] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "creditnote" + when "creditnote" sale_payment.payment_method = "creditnote" sale_payment.received_amount = params[:amount] sale_payment.customer_id = params[:customer_id] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "visa" + when "visa" sale_payment.payment_method = "visa" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "master" + when "master" sale_payment.payment_method = "master" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "jcb" + when "jcb" sale_payment.payment_method = "jcb" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "mpu" + when "mpu" sale_payment.payment_method = "mpu" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "unionpay" + when "unionpay" sale_payment.payment_method = "unionpay" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "vochure" + when "vochure" sale_payment.payment_method = "vochure" sale_payment.received_amount = params[:amount] sale_payment.customer_id = params[:customer_id] sale_payment.payment_reference = params[:vochure_no] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "giftcard" + when "giftcard" sale_payment.payment_method = "giftcard" sale_payment.received_amount = params[:amount] sale_payment.customer_id = params[:customer_id] sale_payment.payment_reference = params[:giftcard_no] @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name) - case "paypar" + when "paypar" sale_payment.payment_method = "paypar" sale_payment.received_amount = params[:amount] sale_payment.payment_reference = params[:payment_reference] diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index c3dba58b..b89e7c63 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -10,9 +10,12 @@ class HomeController < ApplicationController @login_form.emp_id = params[:login_form][:emp_id] @login_form.password = params[:login_form][:password] @employee = Employee.login(@login_form.emp_id, @login_form.password) - if @employee + if @employee.role == "administrator" session[:session_token] = @employee.token_session redirect_to dashboard_path + elsif @employee.role == "cashier" + session[:session_token] = @employee.token_session + redirect_to origami_root_path else render :index end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 1731f69c..ecbc94e7 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -6,10 +6,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); + # printer for each stations + printer_name = assigned_item.order_queue_station.printer_name + # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(print_settings,assigned_item.order_id, assigned_item.item_code ) + order_queue_printer.print_order_item(printer_name,assigned_item.order_id, assigned_item.item_code ) # update print status for completed same order items assigned_items.each do |ai| @@ -25,10 +28,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); + # printer for each stations + printer_name = assigned_item.order_queue_station.printer_name + # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_summary(print_settings,assigned_item.order_id) + order_queue_printer.print_order_summary(printer_name,assigned_item.order_id) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index b67eb352..dbde3293 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -11,12 +11,11 @@ class Origami::HomeController < BaseOrigamiController @selected_item = Order.find(params[:booking_id]) @selected_item_type="Order" end - end - puts params[:booking_id] + end @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 diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index 9be83462..5bed3470 100644 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -2,6 +2,21 @@ class Origami::JcbController < BaseOrigamiController def index @sale_id = params[:sale_id] + + # limit jcb_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @jcbcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "jcb" + @jcbcount = @jcbcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_jcb = total - @jcbcount - others + end def create @@ -10,7 +25,7 @@ class Origami::JcbController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb") end end diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 92ab7ebb..67107167 100644 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -2,6 +2,20 @@ class Origami::MasterController < BaseOrigamiController def index @sale_id = params[:sale_id] + + # limit master_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @mastercount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "master" + @mastercount = @mastercount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_master = total - @mastercount - others end def create @@ -10,7 +24,7 @@ class Origami::MasterController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master") end end diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 263e55f7..3707d1f4 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -2,6 +2,21 @@ class Origami::MpuController < BaseOrigamiController def index @sale_id = params[:sale_id] + + # limit mpu_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @mpucount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "mpu" + @mpucount = @mpucount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_mpu = total - @mpucount - others + end def create diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 4ac519b0..01cedcbe 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -11,6 +11,21 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") + + unique_code = "ReceiptBillPdf" + customer= Customer.find(saleObj.customer_id) + + # get member information + member_info = Customer.get_member_account(customer) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # Calculate Food and Beverage Total + food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) end end @@ -19,25 +34,18 @@ class Origami::PaymentsController < BaseOrigamiController if Sale.exists?(sale_id) @cash = 0.0 @other = 0.0 + @ppamount = 0.0 + @visacount= 0.0 + @jcbcount= 0.0 + @mastercount = 0.0 @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) - membership = MembershipSetting.find_by_membership_type("paypar_url") + # get member information + response = Customer.get_member_account(@customer) - 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' - } - ) - @balance = 0.00 @accountable_type = '' if response["data"]==true @@ -45,21 +53,28 @@ class Origami::PaymentsController < BaseOrigamiController if res["accountable_type"] == "RebateAccount" @balance = res["balance"] @accountable_type = res["accountable_type"] - end + end end end - + #end customer amount @sale_data.sale_payments.each do |spay| if spay.payment_method == "cash" @cash = spay.payment_amount end - if spay.payment_method == "mpu" || spay.payment_method == "paypar" + if spay.payment_method == "mpu" @other += spay.payment_amount + elsif spay.payment_method == "paypar" + @ppamount += spay.payment_amount + elsif spay.payment_method == "visa" + @visacount += spay.payment_amount + elsif spay.payment_method == "jcb" + @jcbcount += spay.payment_amount + elsif spay.payment_method == "master" + @mastercount += spay.payment_amount end end end end - end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 58ba0b11..5239d121 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,6 +1,5 @@ class Origami::RequestBillsController < BaseOrigamiController - - + # Print Request Bill and add to sale tables def print @sale = Sale.new sale_order=SaleOrder.new @@ -9,7 +8,7 @@ class Origami::RequestBillsController < BaseOrigamiController check_booking = Booking.find_by_booking_id(booking_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) else @@ -20,10 +19,11 @@ class Origami::RequestBillsController < BaseOrigamiController unique_code = "ReceiptBillPdf" customer= Customer.where('customer_id=' + @sale_data.customer_id) + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # find order id by sale id - sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) # Calculate Food and Beverage Total food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index 043bd43c..3cb8cabb 100644 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -2,6 +2,20 @@ class Origami::VisaController < BaseOrigamiController def index @sale_id = params[:sale_id] + + # limit visa_amount + sale_data = Sale.find_by_sale_id(@sale_id) + total = sale_data.grand_total + @visacount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "visa" + @visacount = @visacount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @can_visa = total - @visacount - others end def create @@ -10,7 +24,7 @@ class Origami::VisaController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu") + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa") end end diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 35cefe6f..2d3a819e 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -13,7 +13,7 @@ class Transactions::OrdersController < ApplicationController end end - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(2) respond_to do |format| format.html # index.html.erb format.json { render json: @orders } diff --git a/app/forms/shop_form.rb b/app/forms/shop_form.rb index 19af84a5..179e73fd 100644 --- a/app/forms/shop_form.rb +++ b/app/forms/shop_form.rb @@ -1,7 +1,7 @@ #Form object to use during the installation process - will handle creation of shop model into db after verification from the cloud #provising service through license verification -class ShopForm < ActiveModel - :attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation - -end +# class ShopForm < ActiveModel +# # attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation +# +# end diff --git a/app/models/customer.rb b/app/models/customer.rb index d6d2a0d8..0cbf8d58 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -33,7 +33,6 @@ class Customer < ApplicationRecord # 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 diff --git a/app/models/order.rb b/app/models/order.rb index 10c1a6c2..b250c073 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,7 +25,7 @@ class Order < ApplicationRecord booking = nil if self.new_booking - + booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) @@ -230,20 +230,25 @@ 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("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") + .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,orders.status") + # For PG + # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true + # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end #Origami: Cashier : to view booking order Table def self.get_completed_order - completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.order_id, + completed_orders = Booking.select("sales.receipt_no, sales.sale_status, orders.status as order_status,orders.order_id, bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .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("sales.sale_status='completed'") - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") + .group("sales.sale_id") + # For PG + #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end #Origami: Cashier : to view order type Room @@ -255,10 +260,12 @@ class Order < ApplicationRecord .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .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 sale_orders on sale_orders.order_id = orders.order_id") - .joins("left join sales on sales.sale_id = sale_orders.sale_id") - .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") + .joins("left join sales on sales.sale_id = bookings.sale_id") + .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 + # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id end #Origami: Cashier : to view order type Room @@ -271,31 +278,43 @@ class Order < ApplicationRecord left join order_items on order_items.order_id = orders.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no") - end #Origami: Cashier : to view orders def self.get_orders from = Time.now.beginning_of_day.utc to = Time.now.end_of_day.utc - orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status, - orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id - ,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") - .joins("left join booking_orders on booking_orders.order_id = orders.order_id - left join bookings on bookings.booking_id = booking_orders.order_id - left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - left join order_items on order_items.order_id = orders.order_id - left join sale_orders on sale_orders.order_id = orders.order_id - left join sales on sales.sale_id = sale_orders.sale_id") - .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id") + orders=Booking.select("sales.receipt_no, sales.sale_status as sale_status, orders.status as order_status, + orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id, + bookings.booking_id,orders.customer_id as customer_id, + sales.sale_id as sale_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") + .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')") + + # orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status, + # orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id + # ,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + # .joins("left join booking_orders on booking_orders.order_id = orders.order_id + # left join bookings on bookings.booking_id = booking_orders.order_id + # left join dining_facilities on dining_facilities.id = bookings.dining_facility_id + # left join order_items on order_items.order_id = orders.order_id + # left join sale_orders on sale_orders.order_id = orders.order_id + # left join sales on sales.sale_id = sale_orders.sale_id") + # .where("(orders.status = 'new' or orders.status = 'billed')") + # .group("orders.order_id") + # For PG + # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) + # .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id") end def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("order_id LIKE ?", "%#{search}%") + where("order_id LIKE ?", "%#{search}%") else find(:all) end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 9c928593..9b3f5205 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,25 +1,25 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(printer_settings,order_id, item_code) + def print_order_item(printer_name,order_id, item_code) #Use CUPS service #Generate PDF #Print order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) - pdf = OrderItemPdf.new(order_item[0],printer_settings) + pdf = OrderItemPdf.new(order_item[0]) pdf.render_file "tmp/receipt.pdf" - self.print("tmp/receipt.pdf") + self.print("tmp/receipt.pdf", printer_name) end - def print_order_summary(printer_settings,order_id) + def print_order_summary(printer_name,order_id) #Use CUPS service #Generate PDF #Print order=print_query('order_summary',order_id) filename = "tmp/order_summary_#{order_id}" + ".pdf" - pdf = OrderSummaryPdf.new(order,printer_settings) + pdf = OrderSummaryPdf.new(order) pdf.render_file filename - self.print(filename) + self.print(filename, printer_name) end # Query for OQS with status 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/models/sale.rb b/app/models/sale.rb index 681bed64..67953c14 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -13,7 +13,7 @@ class Sale < ApplicationRecord has_many :sale_payments has_many :sale_orders has_many :bookings - + scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } def generate_invoice_from_booking(booking_id, requested_by) @@ -56,7 +56,12 @@ class Sale < ApplicationRecord #Default Tax - Values self.tax_type = "exclusive" + # set cashier by current login + # TODO: requested_by is string , can't cast to id. error occur. please fix + # self.cashier_id = requested_by.id + self.cashier_name = requested_by self.requested_by = requested_by + self.requested_at = DateTime.now.utc Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}" @@ -252,7 +257,7 @@ class Sale < ApplicationRecord if self.receipt_no.nil? prefix = DateTime.now().utc #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s - self.receipt_no = prefix.strftime("%Y%m%d") + "/" + SeedGenerator.new_receipt_no().to_s + self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s self.receipt_date = prefix Rails.logger.debug "Receipt No #{self.receipt_no} | Date #{ self.receipt_date.to_s}" @@ -262,7 +267,7 @@ class Sale < ApplicationRecord def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("receipt_no LIKE ?", "%#{search}%",) + where("receipt_no LIKE ?", "%#{search}%",) else find(:all) end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index e0fe2e7c..fc085259 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -256,10 +256,11 @@ class SalePayment < ApplicationRecord receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("rebate") + merchant_uid = memberaction.merchant_account_id.to_s campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id, + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index f322de64..96008dfd 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,15 +1,16 @@ class OrderItemPdf < Prawn::Document - attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width - def initialize(order_item, print_settings) - self.page_width = 300 - self.page_height = 400 + 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(order_item) + self.page_width = 254 + self.page_height = 1450 self.margin = 10 - self.price_width = 50 - self.qty_width = 50 - self.item_width = self.page_width - (self.price_width + self.qty_width) + self.price_width = 40 # No Need for item + self.qty_width = 34 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width + (self.margin*4)) self.item_height = 15 - self.item_description_width = self.page_width - (self.price_width + self.qty_width) - self.receipt_width=130 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=80 super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) @@ -17,10 +18,10 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 12 - self.item_font_size = 10 + self.header_font_size = 14 + self.item_font_size = 12 - text "#{order_item.dining}", :size => self.header_font_size,:align => :center + text "#{order_item.dining}", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule move_down 5 @@ -35,36 +36,43 @@ class OrderItemPdf < Prawn::Document def order_info(order_by, order_at) y_position = cursor - bounding_box([0,y_position], :width => self.item_width - 50, :height => self.item_height) do - text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width - 50,y_position], :width => self.item_width + 50, :height => self.item_height) do - text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule - move_down 20 + move_down 10 end # Write Order items to PDF def order_items(order_item) y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "Item", :size => self.item_font_size,:align => :left - end + # No Need for Order Item + # bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + # text "Item", :size => self.item_font_size,:align => :left + # end - bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do - text "Qty", :size => self.item_font_size,:align => :right - end + # bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do + # text "Qty", :size => self.item_font_size,:align => :right + # end - stroke_horizontal_rule - move_down 5 + # stroke_horizontal_rule + # move_down 5 #Add Order Item add_order_items(order_item) + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, self.page_width + move_down 5 end # Add order items under order info @@ -78,7 +86,7 @@ class OrderItemPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do - text "#{order_item.qty}", :size => self.item_font_size,:align => :right + text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left end move_down 5 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 63d75a78..47c1f6a5 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -1,15 +1,16 @@ class OrderSummaryPdf < Prawn::Document - attr_accessor :receipt_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:item_description_width - def initialize(order, print_settings) - self.page_width = 300 - self.page_height = 400 + 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(order) + self.page_width = 254 + self.page_height = 1450 self.margin = 10 - self.price_width = 60 - self.qty_width = 60 - self.item_width = self.page_width - (self.price_width + self.qty_width) + self.price_width = 40 # No Need for item + self.qty_width = 34 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width + (self.margin*4)) self.item_height = 15 - self.item_description_width = self.page_width - (self.price_width + self.qty_width) - self.receipt_width=130 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=100 super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -19,7 +20,7 @@ class OrderSummaryPdf < Prawn::Document self.header_font_size = 12 self.item_font_size = 10 - text "#{order[0].dining}", :size => self.header_font_size,:align => :center + text "#{order[0].dining}", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule move_down 5 @@ -35,17 +36,19 @@ class OrderSummaryPdf < Prawn::Document def order_info(order_by, order_at) y_position = cursor - bounding_box([0,y_position], :width => self.item_width - 20, :height => self.item_height) do - text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end - bounding_box([self.item_width - 20,y_position], :width => self.item_width + 20, :height => self.item_height) do - text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left end stroke_horizontal_rule - move_down 20 + move_down 10 end # Write Order items to PDF @@ -57,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do - text "Qty", :size => self.item_font_size,:align => :right + text "Qty", :size => self.item_font_size,:align => :left end stroke_horizontal_rule @@ -79,7 +82,7 @@ class OrderSummaryPdf < Prawn::Document end bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do - text "#{odi.qty}", :size => self.item_font_size,:align => :right + text "#{odi.qty}", :size => self.item_font_size,:align => :left end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index dbaea572..c766b8cc 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 @@ -8,9 +8,9 @@ class ReceiptBillPdf < Prawn::Document self.qty_width = 20 self.total_width = 40 self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4)) - self.item_height = 15 + self.item_height = 15 self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) - self.label_width=80 + self.label_width=80 # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 @@ -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 @@ -96,7 +101,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule add_line_item_row(sale_items, food_total, beverage_total) - + end def add_line_item_row(sale_items, food_total, beverage_total) @@ -110,17 +115,15 @@ class ReceiptBillPdf < Prawn::Document total_price = item.qty*item.unit_price price = item.unit_price product_name = item.product_name - + y_position = cursor pad_top(15) { - # @item_width.to_i + @half_qty.to_i text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - } move_down 3 end @@ -151,7 +154,7 @@ class ReceiptBillPdf < Prawn::Document end def all_total(sale_data) - item_name_width = self.item_width + item_name_width = self.item_width move_down 5 y_position = cursor @@ -183,7 +186,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/reports/menu_report.rb b/app/reports/menu_report.rb index ca430f0a..2a17e851 100644 --- a/app/reports/menu_report.rb +++ b/app/reports/menu_report.rb @@ -1,5 +1,5 @@ -class MenuReport < Compendium::Report - query :list, collect: :active_record do |params| - Menu.all - end -end +# class MenuReport < Compendium::Report +# query :list, collect: :active_record do |params| +# Menu.all +# end +# end diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index 4fb445fd..c52381e2 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -10,14 +10,14 @@ -<% end -%> +<% end %> diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index f9356f68..9f6cd7d6 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -31,28 +31,28 @@ customer_id = "" # For CSS- Class for Order? Sale? - sale_status="" - if cpo.order_status == 'new' - unique_id=cpo.booking_id + # sale_status="" + # if cpo.order_status == 'new' + # unique_id=cpo.booking_id - customer_id=cpo.order_customer_id - # check selected item and assign - if @selected_item != nil - if cpo.order_id == @selected_item.order_id - sale_status = sale_status + " selected-item" - end - end - else - unique_id=cpo.sale_id - customer_id=cpo.sale_customer_id - sale_status="paid" - # check selected item and assign - if @selected_item != nil - if unique_id == @selected_item.sale_id - sale_status = sale_status + " selected-item" - end + # customer_id=cpo.order_customer_id + # # check selected item and assign + # if @selected_item_type == "Sale" + # if cpo.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end + # else + unique_id=cpo.sale_id + customer_id=cpo.sale_customer_id + sale_status="paid" + # check selected item and assign + if @selected_item != nil + if unique_id == @selected_item.sale_id + sale_status = sale_status + " selected-item" end end + # end %>
@@ -69,9 +69,7 @@

Order Status : - - <%= cpo.order_status %> - + <%= cpo.sale_status %>

@@ -84,10 +82,10 @@
-
+
<% @booking_orders.each do |bko| - # No Show completed + # No Show completed if bko.sale_status == 'completed' next end @@ -101,11 +99,11 @@ unique_id=bko.booking_id customer_id=bko.order_customer_id # check selected item and assign - if !@selected_item.nil? - if bko.order_id == @selected_item.order_id - sale_status = sale_status + " selected-item" - end - end + # if @selected_item != nil + # if bko.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end else unique_id=bko.sale_id customer_id=bko.sale_customer_id @@ -132,9 +130,7 @@

Order Status : - - <%= bko.order_status %> - + <%= bko.order_status %>

@@ -165,11 +161,11 @@ unique_id=rmo.booking_id customer_id=rmo.order_customer_id # check selected item and assign - if @selected_item != nil - if rmo.order_id == @selected_item.order_id - sale_status = sale_status + " selected-item" - end - end + # if @selected_item != nil + # if rmo.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end else unique_id=rmo.sale_id customer_id=rmo.sale_customer_id @@ -196,9 +192,7 @@

Order Status : - - <%= rmo.order_status %> - + <%= rmo.order_status %>

@@ -213,7 +207,7 @@
<% - @orders.each do |odr| + @orders.each do |odr| # No Show completed if odr.sale_status == 'completed' next @@ -227,11 +221,11 @@ if odr.order_status == 'new' unique_id=odr.booking_id customer_id = odr.order_customer_id - if @selected_item != nil - if odr.order_id == @selected_item.order_id - sale_status = sale_status + " selected-item" - end - end + # if @selected_item != nil + # if odr.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end else unique_id=odr.sale_id customer_id = odr.sale_customer_id @@ -258,9 +252,7 @@

Order Status : - - <%= odr.order_status %> - + <%= odr.order_status %>

@@ -308,14 +300,14 @@ Price - + <% # For Sale Items sub_total = 0 if @selected_item_type == "Sale" @selected_item.sale_items.each do |sale_item| sub_total += (sale_item.qty*sale_item.unit_price) - %> + %> <%= sale_item.product_name %> <%= sale_item.qty %> @@ -327,8 +319,7 @@ %> <% - # For Order Items - sub_total = 0 + # For Order Items if @selected_item_type == "Order" @selected_item.order_items.each do |order_item| sub_total += (order_item.qty*order_item.unit_price) @@ -386,13 +377,12 @@ - - - + + - + - +
diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index a0760b38..6d08b25a 100644 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -1,19 +1,41 @@ +
+
+
+

JCB

+
+
+
+
+ + +
+
+
+ <% if @jcbcount != 0 %> +
+
+ + +
+
+
+ <% end %>
- - + +

- -
0.0
+ +
0.0

@@ -21,7 +43,7 @@
-
+
@@ -61,23 +83,26 @@
10000
-
Pay
+
Pay
-
-
+
+ +
- diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index a0760b38..5767ad0f 100644 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -1,19 +1,41 @@ +
+
+
+

Master

+
+
+
+
+ + +
+
+
+ <% if @mastercount != 0 %> +
+
+ + +
+
+
+ <% end %>
- - + +

- -
0.0
+ +
0.0

@@ -21,7 +43,7 @@
-
+
@@ -61,23 +83,25 @@
10000
-
Pay
+
Pay
-
-
+
+ +
- diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index 3d9d1024..f58ca552 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -1,19 +1,41 @@ +
+
+
+

MPU

+
+
- - + + +
+
+
+ <% if @mpucount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ +

- -
0.0
+ +
0.0

@@ -21,7 +43,7 @@
-
+
@@ -61,23 +83,25 @@
10000
-
Pay
+
Pay
-
-
+
+ +
- - - -

MPU

- - -Amount : - - - - - - diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index a6a6dd41..230e8a5a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -101,10 +101,87 @@
0.0

-
-
Others Payment
-
<%= @other %>
-
+ <% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%> +
+
Other Payments
+
<%= @other %>
+
+ <% else %> +
+
Other Payments
+
+ <% end %> + + + <% if @other != 0.0 %> +
+
+
MPU
+
<%= @other %>
+
+ <% else %> + + <% end %> + + <% if @ppamount != 0.0 %> +
+
+
Paypar
+
<%= @ppamount %>
+
+ <% else %> + + <% end %> + + <% if @visacount != 0.0 %> +
+
+
Visa
+
<%= @visacount %>
+
+ <% else %> + + <% end %> + + <% if @jcbcount != 0.0 %> +
+
+
JCB
+
<%= @jcbcount %>
+
+ <% else %> + + <% end %> + + <% if @mastercount != 0.0 %> +
+
+
Master
+
<%= @mastercount %>
+
+ <% else %> + + <% end %>
Balance
@@ -167,6 +244,7 @@ $(document).ready(function(){ update_balance(); }) + $(document).on('click', '.cashier_number', function(event){ if(event.handled !== true) { var original_value; @@ -193,7 +271,10 @@ $(document).on('click', '.cashier_number', function(event){ break; case 'del' : var cash=$('#cash').text(); - $('#cash').text(cash.substr(0,cash.length-1)); + if(cash.length == 1) + $('#cash').text("0.0"); + else + $('#cash').text(cash.substr(0,cash.length-1)); update_balance(); break; case 'clr': @@ -255,9 +336,13 @@ function update_balance(){ var cash = $('#cash').text(); var credit = $('#credit').text(); var card = $('#others').text(); + var paypar = $('#ppamount').text(); + var visa = $('#visacount').text(); + var jcb = $('#jcbcount').text(); + var master = $('#mastercount').text(); var amount_due = $('#amount_due').text(); - var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) - var result = amount_due - total + var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + var result = amount_due - total; $('#balance').text(result.toFixed(2)); } diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 9ae576d4..0991e562 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -5,7 +5,23 @@
- + + +
+
+
+ <% if @payparcount > 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+

@@ -19,10 +35,10 @@
- <% if @payparcount > 0 %> +
@@ -115,7 +131,6 @@ $(document).on('click', '.cashier_number', function(event){ return false; } }); - $("#redeem").click(function(){ valid_amount = $("#valid_amount").val(); sale_id = $("#valid_amount").attr('data-value'); diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index a0760b38..e01ca696 100644 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -1,19 +1,41 @@ +
+
+
+

VISA

+
+
+
+
+ + +
+
+
+ <% if @visacount != 0 %> +
+
+ + +
+
+
+ <% end %>
- - + +

- -
0.0
+ +
0.0

@@ -21,7 +43,7 @@
-
+
@@ -61,23 +83,25 @@
10000
-
Pay
+
Pay
-
-
+
+ +
- diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb index e6ed306b..c5166103 100644 --- a/app/views/print_settings/_form.html.erb +++ b/app/views/print_settings/_form.html.erb @@ -18,5 +18,6 @@
<%= f.button :submit %> + <%= link_to 'Back', print_settings_path, :class => "btn btn-default" %>
<% end %> diff --git a/app/views/print_settings/edit.html.erb b/app/views/print_settings/edit.html.erb index fdae5f78..362dce39 100644 --- a/app/views/print_settings/edit.html.erb +++ b/app/views/print_settings/edit.html.erb @@ -1,6 +1,13 @@ -

Editing Print Setting

+
+ + <%= render 'form', print_setting: @print_setting %> +
+
-<%= render 'form', print_setting: @print_setting %> -<%= link_to 'Show', @print_setting %> | -<%= link_to 'Back', print_settings_path %> diff --git a/app/views/print_settings/index.html.erb b/app/views/print_settings/index.html.erb index 32d3dead..0db16892 100644 --- a/app/views/print_settings/index.html.erb +++ b/app/views/print_settings/index.html.erb @@ -1,49 +1,55 @@

<%= notice %>

+ -

Print Settings

- - - - - - - - - - - - - - - - - - - - - - <% @print_settings.each do |print_setting| %> +
+
+
NameUnique codeTemplateDb nameDb typeDb usernameDb passwordPrinter nameApi settingsPage widthPage heightPrint copies
+ - - - - - - - - - - - - - - - + + + + + + + + + + - <% end %> - -
<%= print_setting.name %><%= print_setting.unique_code %><%= print_setting.template %><%= print_setting.db_name %><%= print_setting.db_type %><%= print_setting.db_username %><%= print_setting.db_password %><%= print_setting.printer_name %><%= print_setting.api_settings %><%= print_setting.page_width %><%= print_setting.page_height %><%= print_setting.print_copies %><%= link_to 'Show', print_setting %><%= link_to 'Edit', edit_print_setting_path(print_setting) %><%= link_to 'Destroy', print_setting, method: :delete, data: { confirm: 'Are you sure?' } %>NameUnique codeTemplatePrinter nameApi settingsPage widthPage heightPrint copies
+ -
- -<%= link_to 'New Print Setting', new_print_setting_path %> + + <% @print_settings.each do |print_setting| %> + + <%= print_setting.name %> + <%= print_setting.unique_code %> + <%= print_setting.template %> + + <%= print_setting.printer_name %> + <%= print_setting.api_settings %> + <%= print_setting.page_width %> + <%= print_setting.page_height %> + <%= print_setting.print_copies %> + <%= link_to 'Show', print_setting %> + <%= link_to 'Edit', edit_print_setting_path(print_setting) %> + <%= link_to 'Destroy', print_setting, method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + +
diff --git a/app/views/print_settings/new.html.erb b/app/views/print_settings/new.html.erb index 810ad9c9..2521a16b 100644 --- a/app/views/print_settings/new.html.erb +++ b/app/views/print_settings/new.html.erb @@ -1,5 +1,15 @@ -

New Print Setting

+
+ + <%= render 'form', print_setting: @print_setting %> +
+
+ + -<%= render 'form', print_setting: @print_setting %> -<%= link_to 'Back', print_settings_path %> diff --git a/app/views/print_settings/show.html.erb b/app/views/print_settings/show.html.erb index 12d15696..b15e4650 100644 --- a/app/views/print_settings/show.html.erb +++ b/app/views/print_settings/show.html.erb @@ -1,5 +1,11 @@

<%= notice %>

- +

Name: <%= @print_setting.name %> diff --git a/app/views/settings/employees/edit.html.erb b/app/views/settings/employees/edit.html.erb index 6948734c..a6c0a4aa 100644 --- a/app/views/settings/employees/edit.html.erb +++ b/app/views/settings/employees/edit.html.erb @@ -1,11 +1,11 @@

- + <%= render 'form', employee: @employee %>
diff --git a/app/views/settings/employees/new.html.erb b/app/views/settings/employees/new.html.erb index 7c6498f5..430df9f2 100644 --- a/app/views/settings/employees/new.html.erb +++ b/app/views/settings/employees/new.html.erb @@ -1,11 +1,11 @@
- + <%= render 'form', employee: @employee %>
diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index ba23771f..a5762fc3 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -116,6 +116,7 @@ item_instance_code + item_instance_name item_attributes price is_on_promotion @@ -131,6 +132,7 @@ <%= settings_menu_item.item_instance_code %> + <%= settings_menu_item.item_instance_name %> <%= settings_menu_item.item_attributes %> <%= settings_menu_item.price %> <%= settings_menu_item.is_on_promotion %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index 11620acd..9bfae1b0 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -122,6 +122,7 @@ item_instance_code + Instances Name item_attributes price is_on_promotion @@ -138,6 +139,7 @@ <%= settings_menu_item.item_instance_code %> + <%= settings_menu_item.item_instance_name %> <%= settings_menu_item.item_attributes %> <%= settings_menu_item.price %> <%= settings_menu_item.is_on_promotion %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 9c5a8b86..56887410 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -166,12 +166,13 @@