From d379c052980736823e4a5b49523b0fc03a5cb42f Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 13 Jan 2020 15:28:26 +0630 Subject: [PATCH 01/18] edit for shop_code query --- app/controllers/api/orders_controller.rb | 4 +-- app/controllers/api/payments_controller.rb | 7 ++--- app/controllers/crm/customers_controller.rb | 2 -- .../foodcourt/customers_controller.rb | 5 ++-- .../foodcourt/sale_edit_controller.rb | 2 +- .../foodcourt/shifts_controller.rb | 2 +- .../inventory_definitions_controller.rb | 1 - .../origami/customers_controller.rb | 5 ++-- .../origami/payments_controller.rb | 4 +-- .../origami/sale_edit_controller.rb | 2 +- app/controllers/origami/shifts_controller.rb | 2 +- app/controllers/print_settings_controller.rb | 6 ++-- app/controllers/reports/induty_controller.rb | 2 +- .../reports/order_reservation_controller.rb | 4 +-- .../reports/payment_method_controller.rb | 4 +-- .../reports/receipt_no_controller.rb | 10 +++---- .../reports/receipt_no_detail_controller.rb | 4 +-- .../reports/saleitem_controller.rb | 6 ++-- .../reports/shiftsale_controller.rb | 4 +-- .../reports/staff_meal_controller.rb | 2 +- .../reports/stock_check_controller.rb | 2 +- .../reports/void_sale_controller.rb | 2 +- .../reports/waste_and_spoilage_controller.rb | 2 +- .../transactions/shift_sales_controller.rb | 2 +- app/models/employee.rb | 2 +- app/models/lookup.rb | 17 ++++------- app/models/printer/receipt_printer.rb | 8 +++--- app/models/product_commission.rb | 2 +- app/models/sale_payment.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 7 ++--- config/192.168.1.242.crt | 21 -------------- config/192.168.1.242.key | 28 ------------------- 32 files changed, 58 insertions(+), 115 deletions(-) delete mode 100644 config/192.168.1.242.crt delete mode 100644 config/192.168.1.242.key diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 0b17bb60..af3c26e6 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -62,13 +62,13 @@ class Api::OrdersController < Api::ApiController def create Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Table ID - " + params[:table_id].to_s - @shop = Shop.find_by_shop_code(params[:shop_code]) + current_shift = ShiftSale.current_shift if current_shift.nil? @status = false @message = "No Current Open Shift for This Employee" else - current_user =Employee.find(current_shift.employee_id) + current_user = Employee.find(current_shift.employee_id) if checkin_checkout_time(params[:booking_id]) table = DiningFacility.find(params[:table_id]) if params[:table_id].present? diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index e177252c..5802af96 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -27,11 +27,10 @@ class Api::PaymentsController < Api::ApiController if !sale.nil? sale_id =sale.sale_id sale_items = SaleItem.get_all_sale_items(sale_id) - @shop =Shop.find_by_shop_code(sale.shop_code) if sale.sale_status == "new" if !params[:card_no].empty? current_shift = ShiftSale.current_shift - current_login_employee =Employee.find(current_shift.employee_id) + current_login_employee = Employee.find(current_shift.employee_id) @status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no,current_login_employee) if @status sale_payment = SalePayment.new @@ -192,9 +191,9 @@ class Api::PaymentsController < Api::ApiController action_by = current_login_employee.name @status = true @message = "" - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",sale.shop_code) + member_actions =MembershipAction.find_by_membership_type("get_account_balance") if member_actions.gateway_url @campaign_type_id = nil url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f636072e..2dac2713 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -48,7 +48,6 @@ class Crm::CustomersController < BaseCrmController @crm_customers.membership_type = response["customer_data"]["member_group_id"] @crm_customers.customer_type = "Dinein" @crm_customers.tax_profiles = ["1", "2"] - @crm_customers.shop_code = @shop.shop_code @crm_customers.save @crm_customers = Customer.search(filter) flash[:member_notice]='Customer was successfully created.' @@ -263,7 +262,6 @@ class Crm::CustomersController < BaseCrmController if @checked_contact.nil? respond_to do |format| @crm_customers = Customer.new(customer_params) - @crm_customers.shop_code = @shop.shop_code if @crm_customers.save # update tax profile customer = Customer.find(@crm_customers.customer_id) diff --git a/app/controllers/foodcourt/customers_controller.rb b/app/controllers/foodcourt/customers_controller.rb index 316b9837..930d2a83 100644 --- a/app/controllers/foodcourt/customers_controller.rb +++ b/app/controllers/foodcourt/customers_controller.rb @@ -87,8 +87,9 @@ class Foodcourt::CustomersController < BaseFoodcourtController @count_customer = Customer.count_customer # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") - .order("group_type ASC,order_by ASC") + @taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name") + .joins(:lookup) + .order("group_type ASC, order_by ASC") # if flash["errors"] # @crm_customer.valid? # end diff --git a/app/controllers/foodcourt/sale_edit_controller.rb b/app/controllers/foodcourt/sale_edit_controller.rb index 9bebbe0e..de59ec10 100755 --- a/app/controllers/foodcourt/sale_edit_controller.rb +++ b/app/controllers/foodcourt/sale_edit_controller.rb @@ -118,7 +118,7 @@ class Foodcourt::SaleEditController < BaseFoodcourtController sale.compute_by_sale_items(sale.total_discount, nil, order_source) - ProductCommission.edit_product_commission(saleitemObj,sale.shop_code) + ProductCommission.edit_product_commission(saleitemObj) end # make cancel void item diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb index d097282b..e16a7374 100755 --- a/app/controllers/foodcourt/shifts_controller.rb +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -92,7 +92,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController #get tax shift_obj = ShiftSale.where('id =?',@shift.id) sale_items = '' - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value if @lookup.to_i == 1 @sale_items = Sale.get_shift_sale_items(@shift.id) other_charges = Sale.get_other_charges() diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index b3496c49..6b339958 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -91,7 +91,6 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController format.json { head :no_content } end - # inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) StockJournal.delete_stock_journal(inventory.item_code,@shop) StockCheckItem.delete_stock_check_item(inventory.item_code,@shop) if !inventory.nil? diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 4f25cb7d..d3a74713 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -87,8 +87,9 @@ class Origami::CustomersController < BaseOrigamiController @count_customer = Customer.count_customer # @taxes = TaxProfile.where(:group_type => 'cashier') - @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") - .order("group_type ASC,order_by ASC") + @taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name") + .joins(:lookup) + .order("group_type ASC, order_by ASC") # if flash["errors"] # @crm_customer.valid? # end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 07c716e2..ead80104 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -65,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController end end - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt", current_balance, nil, other_amount, nil, nil, nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, nil, @shop, "Frt", current_balance, nil, other_amount, nil, nil, nil) result = { :filepath => filename, @@ -202,7 +202,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, @shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil) #end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 57c1dc93..f575b0e5 100755 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -163,7 +163,7 @@ class Origami::SaleEditController < BaseOrigamiController # end # end - ProductCommission.edit_product_commission(saleitemObj,sale.shop_code) + ProductCommission.edit_product_commission(saleitemObj) end # make cancel void item diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 91033f94..1eb08f72 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -91,7 +91,7 @@ class Origami::ShiftsController < BaseOrigamiController #get tax shift_obj = ShiftSale.where('id =?',@shift.id) sale_items = '' - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value if @lookup.to_i == 1 @sale_items = Sale.get_shift_sale_items(@shift.id) other_charges = Sale.get_other_charges() diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 0d8c5280..0ca6a65a 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1 # GET /print_settings/1.json def show - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value end # GET /print_settings/new @@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1/edit def edit - @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + @lookup = Lookup.shift_sale_items_lookup_value @server_mode = ENV["SERVER_MODE"] end @@ -48,7 +48,7 @@ class PrintSettingsController < ApplicationController respond_to do |format| if @print_setting.update(print_setting_params) if @print_setting.unique_code == 'CloseCashierPdf' - Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code) + Lookup.save_shift_sale_items_settings(params[:shift_sale_items]) end format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } diff --git a/app/controllers/reports/induty_controller.rb b/app/controllers/reports/induty_controller.rb index 2c435f25..ce215b1f 100644 --- a/app/controllers/reports/induty_controller.rb +++ b/app/controllers/reports/induty_controller.rb @@ -19,7 +19,7 @@ class Reports::IndutyController < BaseReportController end @commissioner = params[:commissioner] - @induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner).where("sales.shop_code='#{@shop.shop_code}'") + @induty_data = InDuty.get_induty_by_shift(@shift_sale_range,@shift,from,to,@commissioner) @from = from @to = to diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb index 257623dc..db9a2bb1 100644 --- a/app/controllers/reports/order_reservation_controller.rb +++ b/app/controllers/reports/order_reservation_controller.rb @@ -27,7 +27,7 @@ class Reports::OrderReservationController < BaseReportController provider = params[:provider] payment_type = params[:payment_type] - @order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type).where("sales.shop_code='#{@shop.shop_code}'") + @order_reservation_data = OrderReservation.get_order_reservation_by_shift(@shift_sale_range,@shift,from,to,provider,payment_type) @from = from @to = to # get printer info @@ -49,7 +49,7 @@ class Reports::OrderReservationController < BaseReportController def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 3a82f01d..c0f475d2 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -9,7 +9,7 @@ class Reports::PaymentMethodController < BaseReportController from, to = get_date_range_from_params - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift = '' if params[:shift_name].to_i != 0 @@ -43,7 +43,7 @@ class Reports::PaymentMethodController < BaseReportController def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index e06c1007..03854fc1 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -10,7 +10,7 @@ authorize_resource :class => false @shift = '' if params[:shift_name].to_i != 0 - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? @@ -26,12 +26,12 @@ authorize_resource :class => false @lookup = Lookup.find_by_lookup_type('reprint_receipt') if @lookup.nil? - @lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code) + @lookup = Lookup.create_reprint_receipt_lookup end payment_type = params[:payment_type] - @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") - @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) + @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) @from = from @@ -55,7 +55,7 @@ authorize_resource :class => false def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index 0fe2458d..9102d6d5 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -26,7 +26,7 @@ authorize_resource :class => false payment_type = params[:payment_type] - @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type) @from = from @@ -50,7 +50,7 @@ authorize_resource :class => false def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index b5a55f72..68271c60 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -9,7 +9,7 @@ class Reports::SaleitemController < BaseReportController shift = '' if params[:shift_name].to_i != 0 - shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? @@ -27,7 +27,7 @@ class Reports::SaleitemController < BaseReportController @type = params[:sale_type] @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code) - @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @@ -60,7 +60,7 @@ class Reports::SaleitemController < BaseReportController def show from, to, report_type = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 5d02e9a1..89a83014 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -29,7 +29,7 @@ class Reports::ShiftsaleController < BaseReportController from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| @@ -77,7 +77,7 @@ class Reports::ShiftsaleController < BaseReportController shop_details = shop_detail cashier_terminal = @shift.cashier_terminal - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) #other payment details for mpu or visa like card diff --git a/app/controllers/reports/staff_meal_controller.rb b/app/controllers/reports/staff_meal_controller.rb index 9b3c0236..ccd7415c 100644 --- a/app/controllers/reports/staff_meal_controller.rb +++ b/app/controllers/reports/staff_meal_controller.rb @@ -34,7 +34,7 @@ class Reports::StaffMealController < BaseReportController @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id,@shop.shop_code) - @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index b9e54e8b..79862d12 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -29,7 +29,7 @@ class Reports::StockCheckController < BaseReportController from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index 55560bd2..82d44f5a 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -39,7 +39,7 @@ authorize_resource :class => false def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/waste_and_spoilage_controller.rb b/app/controllers/reports/waste_and_spoilage_controller.rb index 4b15cc01..1e938d91 100755 --- a/app/controllers/reports/waste_and_spoilage_controller.rb +++ b/app/controllers/reports/waste_and_spoilage_controller.rb @@ -4,7 +4,7 @@ authorize_resource :class => false from, to = get_date_range_from_params @sale_type = params[:sale_type] - @sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type).where("sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type) @from = from @to = to # get printer info diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb index db41b03a..dc06c9eb 100644 --- a/app/controllers/transactions/shift_sales_controller.rb +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -38,7 +38,7 @@ class Transactions::ShiftSalesController < ApplicationController #get tax shift_obj = ShiftSale.where('id =?',@shift.id) - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') #other payment details for mpu or visa like card @other_payment = ShiftSale.get_by_shift_other_payment(@shift) diff --git a/app/models/employee.rb b/app/models/employee.rb index a57b300f..420491af 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -43,7 +43,7 @@ class Employee < ApplicationRecord if (session_token) user = Employee.find_by_token_session(session_token) expiry_time = login_expiry_time - if !user.session_expiry.nil? + if user && !user.session_expiry.nil? if user && user.session_expiry.utc > DateTime.now.utc #Extend the login time each time authenticatation take place user.session_expiry = user.session_expiry.utc + expiry_time.minutes diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 323bf664..f6fbfd33 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -1,7 +1,6 @@ class Lookup < ApplicationRecord has_many :accounts - belongs_to :shop scope :number_formats, -> { where(lookup_type: 'number_format')} @@ -26,12 +25,10 @@ class Lookup < ApplicationRecord # Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] } # end - def self.time_limit TIME_LIMIT end - def self.get_checkin_time_limit return RequestStore[:checkin_time_limit] if RequestStore[:checkin_time_limit] RequestStore[:checkin_time_limit] = Lookup.find_by_lookup_type('checkin_time_limit').value.to_i rescue time_limit @@ -63,41 +60,39 @@ class Lookup < ApplicationRecord Lookup.where("lookup_type" => type ).pluck("name, value") end - def self.create_shift_sale_lookup(shop_code) + def self.create_shift_sale_lookup @lookup = Lookup.new @lookup.lookup_type = 'shift_sale_items' @lookup.name = 'Shift Sale Items' @lookup.value = 0 - @lookup.shop_code = shop_code @lookup.save return @lookup end - def self.create_reprint_receipt_lookup(shop_code) + def self.create_reprint_receipt_lookup @lookup = Lookup.new @lookup.lookup_type = 'reprint_receipt' @lookup.name = 'Reprint Receipt in Report' @lookup.value = 0 - @lookup.shop_code = shop_code @lookup.save return @lookup end - def self.save_shift_sale_items_settings(val,shop_code) + def self.save_shift_sale_items_settings(val) @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last if @lookup.nil? - @lookup = Lookup.create_shift_sale_lookup(shop_code) + @lookup = Lookup.create_shift_sale_lookup end @lookup.value = val @lookup.save end - def self.shift_sale_items_lookup_value(shop_code) + def self.shift_sale_items_lookup_value @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last if @lookup.nil? - @lookup = Lookup.create_shift_sale_lookup(shop_code) + @lookup = Lookup.create_shift_sale_lookup end return @lookup.value end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 48925f74..840631cf 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -90,20 +90,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation,transaction_ref) + def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, order_reservation = nil, transaction_ref = nil) #Use CUPS service #Generate PDF #Print if printer_settings if !printer_settings.unique_code.match?(/receiptbillorder/i) if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf - pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount) else - pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, balance, card_data, other_amount, latest_order_no, card_balance_amount, transaction_ref) end else #doemal online order pdf template - pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) + pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) end # print as print copies in printer setting diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb index b017df1e..00de8bed 100755 --- a/app/models/product_commission.rb +++ b/app/models/product_commission.rb @@ -33,7 +33,7 @@ class ProductCommission < ApplicationRecord product_commission.save end - def self.edit_product_commission(saleItemObj,shop_code) + def self.edit_product_commission(saleItemObj) menu_item = MenuItem.find_by_item_code(saleItemObj.product_code) commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 2ee26003..b51aa83f 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -705,7 +705,7 @@ class SalePayment < ApplicationRecord self.sale.cashier_name = Employee.find(shift.employee_id).name self.sale.save else - shift = ShiftSale.current_shift(self.sale.shop_code) + shift = ShiftSale.current_shift shift.update(self.sale) self.sale.shift_sale_id = shift.id self.sale.cashier_id = shift.employee_id diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index aba19030..e8fd36b5 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -5,7 +5,7 @@ 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, :description_width, :price_num_width, :line_move - def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil, shop_details, printed_status, current_balance, card_data, other_charges_amount, latest_order_no, card_balance_amount, transaction_ref) + def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, shop_details, printed_status, current_balance, card_data, other_charges_amount, latest_order_no, card_balance_amount, transaction_ref = nil) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -72,8 +72,7 @@ class ReceiptBillPdf < Prawn::Document else customer(customer_account,nil) end - puts "Card data = >" +card_data - puts "Printed =>" + printed_status + #start card sale trans data if card_data != nil card_sale_data(card_data) @@ -693,7 +692,7 @@ class ReceiptBillPdf < Prawn::Document query = sale_data.sale_payments .merge(SalePayment.where.not(payment_method: 'creditnote') .or(SalePayment.where.not(SalePayment.arel_table[:payment_amount].lteq(sale_data.sale_payments.joins(:sale_audit).sum(:payment_amount))))) - + query.each do |payment| if payment.payment_method == "creditnote" diff --git a/config/192.168.1.242.crt b/config/192.168.1.242.crt deleted file mode 100644 index caa6b07a..00000000 --- a/config/192.168.1.242.crt +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDaDCCAlACCQCMa8dYfX0ohTANBgkqhkiG9w0BAQsFADB2MQswCQYDVQQGEwJZ -RzELMAkGA1UECAwCWUcxCzAJBgNVBAcMAllHMQwwCgYDVQQKDANDMkwxCjAIBgNV -BAsMATMxCzAJBgNVBAMMAlNYMSYwJAYJKoZIhvcNAQkBFhdud2VuaS5hdW5nQGNv -ZGUybGFiLmNvbTAeFw0xOTExMjYwNTM0NTNaFw0yMDExMjUwNTM0NTNaMHYxCzAJ -BgNVBAYTAllHMQswCQYDVQQIDAJZRzELMAkGA1UEBwwCWUcxDDAKBgNVBAoMA0My -TDEKMAgGA1UECwwBMzELMAkGA1UEAwwCU1gxJjAkBgkqhkiG9w0BCQEWF253ZW5p -LmF1bmdAY29kZTJsYWIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC -AQEAzjshIBw0Dnv4nFxBBtDd6TbcIR9GGndM7aKOr8yZBv7qKiRoFr9vtT/M1JZh -MO2G0DxvH9BjR1oVWNuAOBx7JUf9wweZ0ntaYT+kPen66LqTn5gFfCAJ+EAzIvaq -s2zlWB8Opl1kahW3LDLngmJGQPBTXO5UVfZHcxgyEGa4b+KdG9s8xqIC4HpvEOST -JmtZiuk/f/9tD7TqWhLsm/Aaw851/6kNjwZJYLbb/Trw8p04iLyyFl1yxVGQLfKB -uoT9tZizPJwZpxCPcvfk2aea0tO+tzBGvtC0VxIUGmBtsZyexVKj/dRuxYhYhFiT -m+0LXyBVyBU5tnuSlvTTM6Qy+wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBUS4G7 -xFFlR7Jy1pru4sBMJk11r1pXjUU4lW8bgR1GYC/truda9JyIYlsnrpb+AkhKC1wT -cDufZs+mciN9u8K0eBSdwcAE+m1mSxa1AZbRLyXb9JxWEYmY53K/ktocQloBM3id -sNZQpsSsqZ4DEuaIzgc3A8C+bQbKi1/P2vo12quzGqebIryvy5QPXpi47ECmSGqW -mIBLhPoy3gzm6PamdY+0z+nKGTdAPS15tTpYsfRA3u54fiavluJYNRV2cFYlGPsS -6YmcQNV1R+ONfjaPCqH24/NNVgeeaKzb6uGIpgOfB2cb8aXjTDVUT0qVgJ3S9M4p -HflFmRqebVXhDDiE ------END CERTIFICATE----- diff --git a/config/192.168.1.242.key b/config/192.168.1.242.key deleted file mode 100644 index f47102c2..00000000 --- a/config/192.168.1.242.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOOyEgHDQOe/ic -XEEG0N3pNtwhH0Yad0ztoo6vzJkG/uoqJGgWv2+1P8zUlmEw7YbQPG8f0GNHWhVY -24A4HHslR/3DB5nSe1phP6Q96froupOfmAV8IAn4QDMi9qqzbOVYHw6mXWRqFbcs -MueCYkZA8FNc7lRV9kdzGDIQZrhv4p0b2zzGogLgem8Q5JMma1mK6T9//20PtOpa -Euyb8BrDznX/qQ2PBklgttv9OvDynTiIvLIWXXLFUZAt8oG6hP21mLM8nBmnEI9y -9+TZp5rS0763MEa+0LRXEhQaYG2xnJ7FUqP91G7FiFiEWJOb7QtfIFXIFTm2e5KW -9NMzpDL7AgMBAAECggEABCQj0iU+1lue7mTb2WswSZKUcQXTvoxOuybcfqM5H27W -/OmmPW6yq40Qa+RpJzZd0qikApuIotIoQ5SEypunzWPYsKXibNuVQQaqIaQlKa81 -b6r50ThDevyvCjCx1NCG+nIFNUoCzi6JcxXCmFeo2Xz574/JmcBMRv9hYfruETEO -g5KvR+bhymaDGgKPoIgro2ar3DjKYMuWwaHJQClx3laYPIgnyGFvmTG/if5UykF4 -oTDnjVYkWqw8XOvsL5WhDBGbTq/f1jB7IjfIt1+pV51synVsa/zGNe3jQstCNBX0 -LK+7k8ub6v3jg2ZU0xx7z+hPuOIwz9HLjVEMfZWZwQKBgQDrSmJfbb7FMrPMKeaU -TEX6+fJRQkfgUdtfx8MK5PytV4WzkHOyJ2ankkpyh5TQG77MUzubfGPmg5nBT2+I -TEZO8rH83nOvMKLmXoPp0TvyBxGt0OqBb6RE+mc5rQmPk4lEtUq+i0L+/fB4RYMe -CZgn8pjuvBi+4oQOiQPSl+SwuQKBgQDgYffroNTn1i3VYNU3DYp9xjSLor7TPdsv -S2Xi5FXaZr9PcXdviBE9siY9KEBuiWVA5Q9Wv8XdBbA26VmEzyf+k7KzMr4Z6k5H -SlqClr4AFes6KYmvP2DrVaUsxlUeDO0saxahEK8PkMYTWbWDTAv0d2YD/mLcesEr -haeCCpyfUwKBgQCVCUDWgYVdE4ifwcq0FLwfBUNgBUPR6wex267Hr9P9WHrwCoe+ -SQbVDezqLscsKuboNbCEBH6i/KjfsZlMFERUrZXgPme4iG4mzadw63+1BpVELBje -dADxUEsiVWDA+Qrx4oO9vihprCAtjppG5HzkkN4eGjbycjiDnHY3Zs8MwQKBgAqS -kyv3GBEUdnRna6R8btoeTLuHn5Y0g+9mjhZyy9jOnpUPs6D9uFI/4q1fCCotLygv -otljj98qNXNg62bmm+vS6ciny21NLQMO7dTZZXp7jenfqy0mv1pXXsENV1VjJonB -Qf+02YrSN4MR5wuYubd7KMNnaSEaZ5+1XH80IM0hAoGBAJfHi94ZzPW2PDQr1GIm -CS0O0cHjQNI2+5Yde2U+WuXh/U2rMyB9iTyImqw/weTVFXS2AiRmss7CBTpIxhCP -1gVoNcRRfU7kmuiBXthgB/BuhSdeh/OQo7e9pKiNqoieMO+j8ocyvbMi8NSUl7pK -P9O47XLOplsft4lXqG6gkn8C ------END PRIVATE KEY----- From 66c375cc3831fa8e5546ad7bfd452f1c14f8132d Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Mon, 13 Jan 2020 16:23:33 +0630 Subject: [PATCH 02/18] clean shop code --- app/controllers/crm/dining_queues_controller.rb | 1 - app/controllers/foodcourt/addorders_controller.rb | 1 - app/controllers/foodcourt/surveys_controller.rb | 1 - .../inventory/inventory_definitions_controller.rb | 1 - .../inventory/stock_journals_controller.rb | 1 - app/controllers/origami/surveys_controller.rb | 1 - app/controllers/print_settings_controller.rb | 1 - app/controllers/reports/credit_payment_controller.rb | 2 +- app/controllers/reports/payment_method_controller.rb | 2 +- app/controllers/reports/saleitem_controller.rb | 4 ++-- app/controllers/reports/shiftsale_controller.rb | 2 +- app/controllers/reports/staff_meal_controller.rb | 2 +- app/controllers/reports/void_sale_controller.rb | 2 +- app/controllers/settings/accounts_controller.rb | 1 - .../settings/cashier_terminals_controller.rb | 1 - app/controllers/settings/commissioners_controller.rb | 1 - app/controllers/settings/commissions_controller.rb | 1 - app/controllers/settings/employees_controller.rb | 1 - app/controllers/settings/lookups_controller.rb | 1 - .../settings/membership_actions_controller.rb | 1 - .../settings/membership_settings_controller.rb | 1 - app/controllers/settings/menus_controller.rb | 1 - .../settings/order_queue_stations_controller.rb | 1 - .../settings/payment_method_settings_controller.rb | 1 - app/controllers/settings/products_controller.rb | 1 - app/controllers/settings/promotions_controller.rb | 1 - app/controllers/settings/rooms_controller.rb | 1 - app/controllers/settings/tables_controller.rb | 1 - app/controllers/settings/tax_profiles_controller.rb | 1 - app/controllers/settings/zones_controller.rb | 1 - app/models/assigned_order_item.rb | 1 - app/models/inventory_definition.rb | 2 +- app/models/menu.rb | 12 ++++++------ app/models/payment_journal.rb | 2 -- app/models/sale.rb | 8 ++++---- app/models/shift_sale.rb | 1 - app/models/stock_journal.rb | 6 ++---- 37 files changed, 20 insertions(+), 50 deletions(-) diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index da0fe6fa..68f8e8d2 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -40,7 +40,6 @@ class Crm::DiningQueuesController < BaseCrmController # POST /crm/dining_queues.json def create @dining_queue = DiningQueue.new(dining_queue_params) - @dining_queue.shop_code = @shop.shop_code respond_to do |format| if @dining_queue.save diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb index 79ffdb37..0141c9ae 100755 --- a/app/controllers/foodcourt/addorders_controller.rb +++ b/app/controllers/foodcourt/addorders_controller.rb @@ -135,7 +135,6 @@ class Foodcourt::AddordersController < BaseFoodcourtController @order.new_booking = true @order.waiters = current_login_employee.name @order.employee_name = current_login_employee.name - @order.shop_code = @shop.shop_code @order.is_extra_time = is_extra_time @order.extra_time = extra_time diff --git a/app/controllers/foodcourt/surveys_controller.rb b/app/controllers/foodcourt/surveys_controller.rb index e664aca2..8d94a0e1 100644 --- a/app/controllers/foodcourt/surveys_controller.rb +++ b/app/controllers/foodcourt/surveys_controller.rb @@ -76,7 +76,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController @survey = Survey.new(survey_params) @survey.shift_id = shift_by_terminal.id @survey.foreigner = params["survey"]["foreigner"].to_json - @survey.shop_code = @shop.shop_code # respond_to do |format| if @survey.save redirect_to @url diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 6b339958..bd1b9bbc 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -39,7 +39,6 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController @inventory_definition.min_order_level = params[:min_order_level] @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i end - @inventory_definition.shop_code = @shop.shop_code @inventory_definition.created_by = current_user.id if @inventory_definition.save result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition} diff --git a/app/controllers/inventory/stock_journals_controller.rb b/app/controllers/inventory/stock_journals_controller.rb index cdba207e..49439456 100755 --- a/app/controllers/inventory/stock_journals_controller.rb +++ b/app/controllers/inventory/stock_journals_controller.rb @@ -25,7 +25,6 @@ class StockJournalsController < ApplicationController # POST /stock_journals.json def create @stock_journal = StockJournal.new(stock_journal_params) - @stock_journal.shop_code = @shop.shop_code respond_to do |format| if @stock_journal.save format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' } diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index 126f7d11..45af74fd 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -76,7 +76,6 @@ class Origami::SurveysController < BaseOrigamiController @survey = Survey.new(survey_params) @survey.shift_id = shift_by_terminal.id @survey.foreigner = params["survey"]["foreigner"].to_json - @survey.shop_code = @shop.shop_code # respond_to do |format| if @survey.save redirect_to @url diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 0ca6a65a..8931bc07 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -30,7 +30,6 @@ class PrintSettingsController < ApplicationController # POST /print_settings.json def create @print_setting = PrintSetting.new(print_setting_params) - @print_setting.shop_code = @shop.shop_code respond_to do |format| if @print_setting.save format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' } diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index 76465bd8..7b9fd55b 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -20,7 +20,7 @@ authorize_resource :class => false @filter = params[:filter_check] @order_source = params[:order_source] - @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source,@shop.shop_code) + @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source) @from = from @to = to diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index c0f475d2..c9983b9f 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -21,7 +21,7 @@ class Reports::PaymentMethodController < BaseReportController end end @payment_type = params[:payment_type] - @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type,@shop.shop_code) + @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type) @from = from @to = to # get printer info diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 68271c60..eb526b22 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -25,7 +25,7 @@ class Reports::SaleitemController < BaseReportController account_type = params[:account_type] @type = params[:sale_type] - @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code) + @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @@ -114,7 +114,7 @@ class Reports::SaleitemController < BaseReportController @type = params[:period_type] period_name = get_period_name(params[:period]) - @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code) + @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type) other_charges = Sale.get_other_charges() if shift.present? @total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 89a83014..a5231f4d 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController if params[:shift_name].to_i != 0 @shift = ShiftSale.find(params[:shift_name]) end - @sale_data = Sale.get_by_shiftsales(from,to,@shift,@shop.shop_code) + @sale_data = Sale.get_by_shiftsales(from,to,@shift) @from = from @to = to if @shift.present? diff --git a/app/controllers/reports/staff_meal_controller.rb b/app/controllers/reports/staff_meal_controller.rb index ccd7415c..71d363ba 100644 --- a/app/controllers/reports/staff_meal_controller.rb +++ b/app/controllers/reports/staff_meal_controller.rb @@ -32,7 +32,7 @@ class Reports::StaffMealController < BaseReportController account_type = params[:account_type] - @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id,@shop.shop_code) + @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index 82d44f5a..0dc6032a 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -16,7 +16,7 @@ authorize_resource :class => false end end - @sale_data = Sale.get_void_sale(@shift,from,to,@shop.shop_code) + @sale_data = Sale.get_void_sale(@shift,from,to) @from = from @to = to diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index 0f5b0ba7..fe45d957 100755 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -28,7 +28,6 @@ class Settings::AccountsController < ApplicationController def create @settings_account = Account.new(account_params) - @settings_account.shop_code = @shop.shop_code respond_to do |format| if @settings_account.save format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' } diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index 2e1d63c1..eeea0f9f 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -29,7 +29,6 @@ class Settings::CashierTerminalsController < ApplicationController def create @settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params) - @settings_cashier_terminal.shop_code = @shop.shop_code respond_to do |format| if @settings_cashier_terminal.save format.html { redirect_to settings_cashier_terminals_path, notice: 'Cashier terminal was successfully created.' } diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb index 24cc484b..752b0397 100755 --- a/app/controllers/settings/commissioners_controller.rb +++ b/app/controllers/settings/commissioners_controller.rb @@ -31,7 +31,6 @@ class Settings::CommissionersController < ApplicationController @commissioner = Commissioner.new(commissioner_params) @commissioner.created_by = current_user.id - @commissioner.shop_code = @shop.shop_code unless @commissioner.joined_date.nil? @commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') end diff --git a/app/controllers/settings/commissions_controller.rb b/app/controllers/settings/commissions_controller.rb index 60778dab..20cc432c 100755 --- a/app/controllers/settings/commissions_controller.rb +++ b/app/controllers/settings/commissions_controller.rb @@ -32,7 +32,6 @@ class Settings::CommissionsController < ApplicationController @commission = Commission.new(commission_params) @commission.product_type = 'menu_item' @commission.product_code = "[]" - @commission.shop_code = @shop.shop_code respond_to do |format| if @commission.save diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 74c8b410..448816f5 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -31,7 +31,6 @@ class Settings::EmployeesController < ApplicationController # POST /employees.json def create @employee = Employee.new(employee_params) - @employee.shop_code =@shop.shop_code respond_to do |format| if @employee.save format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' } diff --git a/app/controllers/settings/lookups_controller.rb b/app/controllers/settings/lookups_controller.rb index 87c81842..6f7a2bb0 100755 --- a/app/controllers/settings/lookups_controller.rb +++ b/app/controllers/settings/lookups_controller.rb @@ -25,7 +25,6 @@ class Settings::LookupsController < ApplicationController # POST /settings/lookups.json def create @settings_lookup = Lookup.new(settings_lookup_params) - @settings_lookup.shop_code = @shop.shop_code respond_to do |format| if @settings_lookup.save format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' } diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index f6eb77bf..cca64594 100755 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -27,7 +27,6 @@ class Settings::MembershipActionsController < ApplicationController def create @settings_membership_action = MembershipAction.new(settings_membership_action_params) - @settings_membership_action.shop_code = @shop.shop_code respond_to do |format| if @settings_membership_action.save format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' } diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb index 2e128ce0..3cf97628 100755 --- a/app/controllers/settings/membership_settings_controller.rb +++ b/app/controllers/settings/membership_settings_controller.rb @@ -27,7 +27,6 @@ class Settings::MembershipSettingsController < ApplicationController def create @settings_membership_setting = MembershipSetting.new(settings_membership_setting_params) - @settings_membership_setting.shop_code = @shop.shop_code respond_to do |format| if @settings_membership_setting.save format.html { redirect_to settings_membership_settings_path, notice: 'Membership setting was successfully created.' } diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index f448b959..89cb4dec 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -34,7 +34,6 @@ class Settings::MenusController < ApplicationController @settings_menu = Menu.new(settings_menu_params) @settings_menu.created_by = current_login_employee.name - @settings_menu.shop_code = @shop.shop_code respond_to do |format| if @settings_menu.save format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' } diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index e3a30d1f..762168e2 100755 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -33,7 +33,6 @@ class Settings::OrderQueueStationsController < ApplicationController @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) @settings_order_queue_station.created_by = current_login_employee.name @settings_order_queue_station.processing_items = "[]" - @settings_order_queue_station.shop_code = @shop.shop_code respond_to do |format| if @settings_order_queue_station.save format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb index e85e7a99..8850c2c6 100755 --- a/app/controllers/settings/payment_method_settings_controller.rb +++ b/app/controllers/settings/payment_method_settings_controller.rb @@ -26,7 +26,6 @@ class Settings::PaymentMethodSettingsController < ApplicationController # POST /settings/payment_method_settings.json def create @settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params) - @settings_payment_method_setting.shop_code = @shop.shop_code respond_to do |format| if @settings_payment_method_setting.save format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method setting was successfully created.' } diff --git a/app/controllers/settings/products_controller.rb b/app/controllers/settings/products_controller.rb index 4562d132..a8f64c25 100755 --- a/app/controllers/settings/products_controller.rb +++ b/app/controllers/settings/products_controller.rb @@ -29,7 +29,6 @@ load_and_authorize_resource except: [:create] @settings_product = Product.new(settings_product_params) @settings_product.created_by = current_user.name - @settings_product.shop_code = @shop.shop_code respond_to do |format| if @settings_product.save format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' } diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 442a2063..42ede2d4 100755 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -31,7 +31,6 @@ class Settings::PromotionsController < ApplicationController @promotion = Promotion.new(promotion_params) @promotion.created_by = current_login_employee.id - @promotion.shop_code = @shop.shop_code if !@promotion.promo_start_hour.nil? @promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30) end diff --git a/app/controllers/settings/rooms_controller.rb b/app/controllers/settings/rooms_controller.rb index 6617720c..a9410248 100755 --- a/app/controllers/settings/rooms_controller.rb +++ b/app/controllers/settings/rooms_controller.rb @@ -30,7 +30,6 @@ class Settings::RoomsController < ApplicationController @settings_room.type = DiningFacility::ROOM_TYPE @settings_room.zone_id = params[:zone_id] @settings_room.created_by = current_login_employee.name - @settings_room.shop_code = @shop.shop_code respond_to do |format| if @settings_room.save format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' } diff --git a/app/controllers/settings/tables_controller.rb b/app/controllers/settings/tables_controller.rb index ed4afe37..b261a445 100755 --- a/app/controllers/settings/tables_controller.rb +++ b/app/controllers/settings/tables_controller.rb @@ -29,7 +29,6 @@ class Settings::TablesController < ApplicationController @settings_table = Table.new(settings_table_params) @settings_table.type = DiningFacility::TABLE_TYPE @settings_table.zone_id = params[:zone_id] - @settings_table.shop_code = @shop.shop_code @settings_table.created_by = current_login_employee.name respond_to do |format| if @settings_table.save diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 51a8880f..ddf4781a 100755 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -48,7 +48,6 @@ class Settings::TaxProfilesController < ApplicationController @settings_tax_profile = TaxProfile.new(settings_tax_profile_params) @settings_tax_profile.created_by = current_login_employee.name - @settings_tax_profile.shop_code = @shop.shop_code respond_to do |format| if @settings_tax_profile.save format.html { redirect_to settings_tax_profiles_path, notice: 'Tax profile was successfully created.' } diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 1c1524ae..27193c2b 100755 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -30,7 +30,6 @@ class Settings::ZonesController < ApplicationController def create @settings_zone = Zone.new(settings_zone_params) - @settings_zone.shop_code =@shop.shop_code @settings_zone.created_by = current_login_employee.name respond_to do |format| if @settings_zone.save diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index bd20e447..d77248d8 100755 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -36,7 +36,6 @@ class AssignedOrderItem < ApplicationRecord assigned_order_item.order_queue_station = order_queue_station assigned_order_item.print_status = false assigned_order_item.delivery_status = false - assigned_order_item.shop_code =order.shop_code assigned_order_item.save! end diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index 6be91da4..a1393556 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -8,7 +8,7 @@ class InventoryDefinition < ApplicationRecord logger.debug saleObj.sale_items.to_json if !saleObj.nil? saleObj.sale_items.each do |item| - found, inventory_definition = find_product_in_inventory(item,saleObj.shop_code) + found, inventory_definition = find_product_in_inventory(item) if found check_balance(item,inventory_definition) end diff --git a/app/models/menu.rb b/app/models/menu.rb index d9c98e01..6c3d210e 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -62,9 +62,9 @@ class Menu < ApplicationRecord # Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"]) account = Account.find_by_id(row["id"]) if account - Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code) + Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"]) else - Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"],shop_code: shop.shop_code) + Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"]) end elsif sheet_name == "Item Set" # ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty]) @@ -93,9 +93,9 @@ class Menu < ApplicationRecord elsif sheet_name == "Menu" menu = Menu.find_by_id(row["id"]) if menu - Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code) + Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) else - Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"],shop_code: shop.shop_code) + Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) end elsif sheet_name == "Menu Category" # MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"]) @@ -155,7 +155,7 @@ class Menu < ApplicationRecord menu = sheet.row(1)[1] is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0 - imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by,shop_code: shop.shop_code}) + imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by}) (4..sheet.last_row).each do |ii| row = Hash[[sheet.row(3),sheet.row(ii)].transpose] @@ -194,7 +194,7 @@ class Menu < ApplicationRecord if !menu_itm account = Account.find_by_title(row["Account"]) if account.nil? - account = Account.create({title: row["Account"], account_type: "0",shop_code: shop.shop_code}) + account = Account.create({title: row["Account"], account_type: "0"}) end image_path = "" diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb index 51b7fdf3..1b195329 100755 --- a/app/models/payment_journal.rb +++ b/app/models/payment_journal.rb @@ -8,7 +8,6 @@ class PaymentJournal < ApplicationRecord self.payment_status = 'paid' self.payment_method_references = payment_method_reference self.created_by = current_user.id - self.shop_code = current_user.shop_code self.save end @@ -18,7 +17,6 @@ class PaymentJournal < ApplicationRecord self.debit_amount = amount self.payment_status = 'paid' self.created_by = current_user.id - self.shop_code = current_user.shop_code self.save end diff --git a/app/models/sale.rb b/app/models/sale.rb index 2788f449..88cf2fdc 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -847,7 +847,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status) end -def self.get_by_shiftsales(from,to,shift,shop_code) +def self.get_by_shiftsales(from,to,shift) if !shift.blank? query = ShiftSale.where("shift_sales.id =?",shift.id) else @@ -972,7 +972,7 @@ def self.get_other_charges() query = query.group("i.sale_item_id") end -def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type,shop_code) +def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type) # date_type_selection = get_sql_function_for_report_type(report_type) if account_type.blank? account_type = '' @@ -1254,7 +1254,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay return query end -def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source,shop_code) +def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source) payments_for_credits = SalePayment.select(" sales.sale_id, DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') as credit_payment_receipt_date, @@ -1310,7 +1310,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter, credits = credits.group("sale_payments.sale_payment_id, sales_sale_payments.sale_id") end - def self.get_void_sale(shift,from,to,shop_code) + def self.get_void_sale(shift,from,to) sale_arr = Array.new query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 9717f9e5..59432f0b 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -83,7 +83,6 @@ class ShiftSale < ApplicationRecord self.shift_started_at = DateTime.now self.employee_id = current_user.id self.opening_balance = opening_balance - self.shop_code = current_user.shop_code self.other_sales = 0 self.save end diff --git a/app/models/stock_journal.rb b/app/models/stock_journal.rb index f84c6204..f68b61bf 100755 --- a/app/models/stock_journal.rb +++ b/app/models/stock_journal.rb @@ -26,8 +26,7 @@ class StockJournal < ApplicationRecord inventory_definition_id: inventory_definition.id, remark: stock_message, trans_ref: trans_ref, - trans_type: trans_type, - shop_code: inventory_definition.shop_code + trans_type: trans_type ) end @@ -39,7 +38,7 @@ class StockJournal < ApplicationRecord stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first if stock_journal.nil? old_blance = 0 - inventory_definition_id = InventoryDefinition.find_by_item_code_and_shop_code(item.item_code,shop.shop_code).id + inventory_definition_id = InventoryDefinition.find_by_item_code(item.item_code).id else old_blance = stock_journal.balance inventory_definition_id = stock_journal.inventory_definition_id @@ -54,7 +53,6 @@ class StockJournal < ApplicationRecord journal.remark = StockJournal::STOCK_CHECK_TRANS journal.trans_ref = item.id journal.trans_type = StockJournal::STOCK_CHECK_TRANS - journal.shop_code = shop.shop_code journal.save end From 3088aa3016b42edecacf56289c98ef8e4a3db3a9 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 13 Jan 2020 16:35:57 +0630 Subject: [PATCH 03/18] update multi_tenancy and current shop --- app/controllers/concerns/login_verification.rb | 15 +++------------ app/controllers/concerns/multi_tenancy.rb | 14 ++++++++------ app/controllers/concerns/token_verification.rb | 3 +-- app/models/shop.rb | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index ff5e2da2..1e98d048 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -16,28 +16,19 @@ module LoginVerification end end - def current_shop - begin - return Shop.current_shop - rescue - return nil - end - end - def current_login_employee - @employee = Employee.find_by_token_session(session[:session_token]) + @employee ||= current_user end def current_user - @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] end # Get current Cashiers def get_cashier - @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + @cashier ||= Employee.where("role = 'cashier' AND token_session <> ''") end - #Shop Name in Navbor def shop_detail @shop ||= current_shop diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index d495709d..643a7455 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -4,16 +4,18 @@ module MultiTenancy included do set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action + helper_method :current_shop if respond_to? :helper_method end private def find_shop_by_subdomain_or_frist - if request.subdomain.present? - shop_code = request.subdomain.partition('-').last - @shop = Shop.find_by(shop_code: shop_code) - else - @shop = Shop.first + if request.subdomains.last + set_current_tenant(Shop.find_by(shop_code: request.subdomains.last.partition('-').last)) end - set_current_tenant(@shop) + current_shop + end + + def current_shop + @shop ||= Shop.current_shop end end diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb index ec55b8ec..9df9d8e2 100755 --- a/app/controllers/concerns/token_verification.rb +++ b/app/controllers/concerns/token_verification.rb @@ -6,14 +6,13 @@ module TokenVerification before_action :authenticate end - protected # Authenticate the user with token based authentication def authenticate authenticate_token || render_unauthorized end - def authenticate_token + def authenticate_token authenticate_with_http_token do |token, options| # Rails.logger.debug "token - " + token.to_s if(options.length !=0 && options["from"] == "DOEMAL") diff --git a/app/models/shop.rb b/app/models/shop.rb index a9b672b1..ef193a15 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -13,6 +13,6 @@ class Shop < ApplicationRecord end def self.current_shop - ActsAsTenant.current_tenant + RequestStore["current_shop"] ||= ActsAsTenant.current_tenant || Shop.first end end From 98d88218f2d8ed3415328e9c38d223f94d23d237 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 13 Jan 2020 16:41:09 +0630 Subject: [PATCH 04/18] update login_verification --- app/controllers/concerns/login_verification.rb | 2 +- app/models/shop.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 1e98d048..a417c533 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -2,7 +2,7 @@ module LoginVerification extend ActiveSupport::Concern included do before_action :authenticate_session_token - helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail + helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail end #this is base api base controller to need to inherit. diff --git a/app/models/shop.rb b/app/models/shop.rb index ef193a15..e898e4e0 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -2,9 +2,8 @@ class Shop < ApplicationRecord #ShopDetail = Shop.current_shop # Shop Image Uploader - - mount_uploader :logo, ShopImageUploader - has_many :display_images + mount_uploader :logo, ShopImageUploader + has_many :display_images accepts_nested_attributes_for :display_images From f99defc459a33aef91199fe9f4e8766a19e577c7 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Mon, 13 Jan 2020 17:18:02 +0630 Subject: [PATCH 05/18] update action_controller --- config/initializers/action_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 87a7cbe5..091abd33 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -4,8 +4,8 @@ class ActionController::Base private def lookup_domain - if request.subdomain.present? && request.subdomain != "www" - from = request.subdomain.downcase + "." + request.domain.downcase + if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" + from = request.host @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase if (!@license.nil?) logger.info "Location - " + @license.dbschema @@ -20,11 +20,11 @@ class ActionController::Base end else # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end From a3edbb07fd5f20eea6814566b99407e61d8945e7 Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Mon, 13 Jan 2020 17:34:48 +0630 Subject: [PATCH 06/18] replace @shop and shop_details with current_shop --- app/controllers/api/call_waiters_controller.rb | 2 +- .../order_reserve/order_reservation_controller.rb | 2 +- app/controllers/api/orders_controller.rb | 2 +- app/controllers/api/payment/callback_controller.rb | 2 +- .../api/payment/mobilepayment_controller.rb | 2 +- app/controllers/api/payments_controller.rb | 2 +- app/controllers/api/sound_effect_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/concerns/login_verification.rb | 8 ++++---- app/controllers/foodcourt/orders_controller.rb | 2 +- app/controllers/foodcourt/payments_controller.rb | 14 +++++++------- .../foodcourt/paypar_payments_controller.rb | 2 +- app/controllers/foodcourt/shifts_controller.rb | 2 +- app/controllers/foodcourt/void_controller.rb | 2 +- .../foodcourt/waste_spoile_controller.rb | 2 +- .../inventory/inventory_definitions_controller.rb | 4 ++-- .../inventory/stock_checks_controller.rb | 6 +++--- app/controllers/origami/alipay_controller.rb | 2 +- .../origami/credit_payments_controller.rb | 2 +- app/controllers/origami/dinga_controller.rb | 2 +- app/controllers/origami/gift_voucher_controller.rb | 2 +- app/controllers/origami/home_controller.rb | 2 +- app/controllers/origami/jcb_controller.rb | 2 +- app/controllers/origami/junction_pay_controller.rb | 2 +- app/controllers/origami/master_controller.rb | 2 +- app/controllers/origami/mpu_controller.rb | 2 +- app/controllers/origami/paymal_controller.rb | 2 +- app/controllers/origami/payments_controller.rb | 14 +++++++------- .../origami/paypar_payments_controller.rb | 2 +- .../origami/redeem_payments_controller.rb | 2 +- app/controllers/origami/shifts_controller.rb | 2 +- .../origami/table_invoices_controller.rb | 2 +- app/controllers/origami/unionpay_controller.rb | 2 +- app/controllers/origami/visa_controller.rb | 2 +- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/voucher_controller.rb | 2 +- app/controllers/origami/waste_spoile_controller.rb | 2 +- .../reports/hourly_saleitem_controller.bk.rb | 2 +- .../reports/hourly_saleitem_controller.rb | 2 +- app/controllers/reports/receipt_no_controller.rb | 2 +- app/controllers/reports/saleitem_controller.rb | 4 ++-- app/controllers/reports/shiftsale_controller.rb | 4 ++-- app/controllers/settings/menus_controller.rb | 2 +- app/controllers/settings/shops_controller.rb | 10 +++++----- app/controllers/transactions/sales_controller.rb | 2 +- app/views/layouts/_header.html.erb | 2 +- app/views/layouts/_header_foodcourt.html.erb | 2 +- app/views/layouts/login.html.erb | 2 +- 48 files changed, 72 insertions(+), 72 deletions(-) diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index dcb543b7..5861621a 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -26,7 +26,7 @@ class Api::CallWaitersController < ActionController::API unique_code = "CallWaiterPdf" print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_call_waiter(print_settings,@table,@time,@shop) + printer.print_call_waiter(print_settings,@table,@time,current_shop) end diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index f10a00c4..e8f2a6f6 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) if !order_reservation_id.nil? && flag - shop = @shop + shop = current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index af3c26e6..d10f8677 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -47,7 +47,7 @@ class Api::OrdersController < Api::ApiController # end # - return @shop.to_json + return current_shop.to_json end diff --git a/app/controllers/api/payment/callback_controller.rb b/app/controllers/api/payment/callback_controller.rb index 89162fc4..14cd5beb 100644 --- a/app/controllers/api/payment/callback_controller.rb +++ b/app/controllers/api/payment/callback_controller.rb @@ -10,7 +10,7 @@ class Api::Payment::CallbackController < Api::ApiController if trade_status == "PAY_SUCCESS" merch_order_id = params[:Request][:merch_order_id] - status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, 'kbzpay', merch_order_id) + status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, current_shop, current_user, 'kbzpay', merch_order_id) render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) end end diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 0c0ca37a..41e6a706 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -15,7 +15,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - shop_detail = @shop + shop_detail = current_shop # rounding adjustment if !path.include? ("credit_payment") diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 5802af96..c04c4f49 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -154,7 +154,7 @@ class Api::PaymentsController < Api::ApiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,params[:card_no], item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,params[:card_no], item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) render json: JSON.generate({:status => true, :balance_amount => card_balance_amount,:receipt_no => sale.receipt_no,:order_no => latest_order_no, :message => "Payment successful."}) else diff --git a/app/controllers/api/sound_effect_controller.rb b/app/controllers/api/sound_effect_controller.rb index fda3a71d..e6c11bed 100644 --- a/app/controllers/api/sound_effect_controller.rb +++ b/app/controllers/api/sound_effect_controller.rb @@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController #sound effect / alarm api for doemal side calling def sound_effect - shop = @shop + shop = current_shop if !shop.nil? shop_code = shop.shop_code order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 001cf6d9..70d93bf6 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception - helper_method :shop_detail,:order_reservation, :bank_integration + helper_method :current_shop,:order_reservation, :bank_integration # lookup domain for db from provision # before_action :set_locale # helper_method :current_company,:current_login_employee,:current_user diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index a417c533..88b31f6d 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -2,7 +2,7 @@ module LoginVerification extend ActiveSupport::Concern included do before_action :authenticate_session_token - helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail + helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :current_shop end #this is base api base controller to need to inherit. @@ -30,9 +30,9 @@ module LoginVerification end #Shop Name in Navbor - def shop_detail - @shop ||= current_shop - end + # def shop_detail + # @shop ||= current_shop + # end #check order reservation used def order_reservation diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index f7f30fdf..8d75e0ae 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -76,7 +76,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController def completed customer =Customer.find_by_customer_id(params[:customer_id]) phone_number =customer.contact_no - if Order.send_message(phone_number,params[:order_id],@shop.name) + if Order.send_message(phone_number,params[:order_id],current_shop.name) booking =Booking.find(params[:booking_id]) booking.booking_status ='completed' booking.save! diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb index 14a6dd02..c3b0d904 100755 --- a/app/controllers/foodcourt/payments_controller.rb +++ b/app/controllers/foodcourt/payments_controller.rb @@ -20,7 +20,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #shop_detail = Shop.first # rounding adjustment if !path.include? ("credit_payment") - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total - saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0 @@ -154,7 +154,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,account_no, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) #end end @@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,current_shop) @kbz_pay_amount += amount.to_f #for changable on/off @@ -270,7 +270,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #end rounding adjustment # rounding adjustment - if @shop.is_rounding_adj + if current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -472,7 +472,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, @@ -571,7 +571,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) result = { :status => true, :filepath => filename, @@ -606,7 +606,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController saleObj = Sale.find(params[:sale_id]) - if @shop.is_rounding_adj + if current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even diff --git a/app/controllers/foodcourt/paypar_payments_controller.rb b/app/controllers/foodcourt/paypar_payments_controller.rb index 64fe7a6d..9317bf3d 100755 --- a/app/controllers/foodcourt/paypar_payments_controller.rb +++ b/app/controllers/foodcourt/paypar_payments_controller.rb @@ -9,7 +9,7 @@ class Foodcourt::PayparPaymentsController < BaseFoodcourtController saleObj = Sale.find(sale_id) # rounding adjustment - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total-saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb index e16a7374..6866217b 100755 --- a/app/controllers/foodcourt/shifts_controller.rb +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -88,7 +88,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController end end end - shop_details = shop_detail + shop_details = current_shop #get tax shift_obj = ShiftSale.where('id =?',@shift.id) sale_items = '' diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index d86eb652..80154300 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -132,7 +132,7 @@ class Foodcourt::VoidController < BaseFoodcourtController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/foodcourt/waste_spoile_controller.rb b/app/controllers/foodcourt/waste_spoile_controller.rb index aea75d18..a4c76296 100755 --- a/app/controllers/foodcourt/waste_spoile_controller.rb +++ b/app/controllers/foodcourt/waste_spoile_controller.rb @@ -118,7 +118,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index bd1b9bbc..d1bb0753 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -90,8 +90,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController format.json { head :no_content } end - StockJournal.delete_stock_journal(inventory.item_code,@shop) - StockCheckItem.delete_stock_check_item(inventory.item_code,@shop) + StockJournal.delete_stock_journal(inventory.item_code,current_shop) + StockCheckItem.delete_stock_check_item(inventory.item_code,current_shop) if !inventory.nil? inventory.destroy flash[:message] = 'Inventory was successfully destroyed.' diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index b71b7bec..9493b16d 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -19,7 +19,7 @@ class Inventory::StockChecksController < BaseInventoryController item_list = JSON.parse(params[:stock_item]) reason = params[:reason] check = StockCheck.new - @check = check.create(current_user, reason, item_list,@shop) + @check = check.create(current_user, reason, item_list,current_shop) end def show @@ -33,7 +33,7 @@ class Inventory::StockChecksController < BaseInventoryController check = params[:data] stockCheck = StockCheck.find_by_id(check) stockCheck.stock_check_items.each do |item| - StockJournal.from_stock_check(item,@shop) + StockJournal.from_stock_check(item,current_shop) end end @@ -49,7 +49,7 @@ class Inventory::StockChecksController < BaseInventoryController print_settings = PrintSetting.find_by_unique_code(unique_code) if !print_settings.nil? printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop) + printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, current_shop) end end diff --git a/app/controllers/origami/alipay_controller.rb b/app/controllers/origami/alipay_controller.rb index 49a121ca..d6dae6df 100644 --- a/app/controllers/origami/alipay_controller.rb +++ b/app/controllers/origami/alipay_controller.rb @@ -23,7 +23,7 @@ class Origami::AlipayController < BaseOrigamiController others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 16981a5a..6c2e9e51 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -8,7 +8,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController total = sale_data.grand_total @creditcount = 0 others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb index 3098377a..524aa353 100644 --- a/app/controllers/origami/dinga_controller.rb +++ b/app/controllers/origami/dinga_controller.rb @@ -6,7 +6,7 @@ class Origami::DingaController < BaseOrigamiController @membership_rebate_balance=0 @sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = @sale_data.receipt_no - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(@sale_data.grand_total) else new_total = @sale_data.grand_total diff --git a/app/controllers/origami/gift_voucher_controller.rb b/app/controllers/origami/gift_voucher_controller.rb index dac27995..bc2ecdf0 100644 --- a/app/controllers/origami/gift_voucher_controller.rb +++ b/app/controllers/origami/gift_voucher_controller.rb @@ -17,7 +17,7 @@ class Origami::GiftVoucherController < BaseOrigamiController others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 6ea59d86..24bbd3bb 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -33,7 +33,7 @@ class Origami::HomeController < BaseOrigamiController @status_sale = "" @sale_array = Array.new - @shop = shop_detail + @shop = current_shop @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all @dining_booking = @dining.current_bookings diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index 74bcdcd3..63a0a6eb 100644 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -24,7 +24,7 @@ class Origami::JcbController < BaseOrigamiController others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/junction_pay_controller.rb b/app/controllers/origami/junction_pay_controller.rb index f6a7fc78..d0819437 100644 --- a/app/controllers/origami/junction_pay_controller.rb +++ b/app/controllers/origami/junction_pay_controller.rb @@ -11,7 +11,7 @@ class Origami::JunctionPayController < BaseOrigamiController @cashier_id = current_user.emp_id @payment_method_setting_nav = PaymentMethodSetting.all - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 17fe4598..f92602f6 100644 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -23,7 +23,7 @@ class Origami::MasterController < BaseOrigamiController others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 89d6fe7f..c9204f67 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -22,7 +22,7 @@ class Origami::MpuController < BaseOrigamiController others = 0 - if @shop.is_rounding_adj && (!path.include? ("credit_payment")) + if current_shop.is_rounding_adj && (!path.include? ("credit_payment")) new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb index 419e914f..918e3945 100644 --- a/app/controllers/origami/paymal_controller.rb +++ b/app/controllers/origami/paymal_controller.rb @@ -6,7 +6,7 @@ class Origami::PaymalController < BaseOrigamiController @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) @receipt_no = sale_data.receipt_no - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ead80104..7caac687 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -65,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController end end - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, nil, @shop, "Frt", current_balance, nil, other_amount, nil, nil, nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, nil, current_shop, "Frt", current_balance, nil, other_amount, nil, nil, nil) result = { :filepath => filename, @@ -202,7 +202,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, @shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal, sale_items, saleObj, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, rebate_amount, current_shop, "Paid", current_balance, card_data, other_amount, latest_order_no, card_balance_amount, nil) #end end @@ -275,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user, current_shop) @kbz_pay_amount += amount.to_f #for changable on/off @@ -322,7 +322,7 @@ class Origami::PaymentsController < BaseOrigamiController #end rounding adjustment # rounding adjustment - if @shop.is_rounding_adj + if current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even @@ -524,7 +524,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount, current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, @@ -622,7 +622,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) result = { :status => true, :filepath => filename, @@ -657,7 +657,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(params[:sale_id]) - if @shop.is_rounding_adj + if current_shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus b = saleObj.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even diff --git a/app/controllers/origami/paypar_payments_controller.rb b/app/controllers/origami/paypar_payments_controller.rb index 59ddb912..8acb5ca2 100755 --- a/app/controllers/origami/paypar_payments_controller.rb +++ b/app/controllers/origami/paypar_payments_controller.rb @@ -8,7 +8,7 @@ class Origami::PayparPaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) # rounding adjustment - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(saleObj.grand_total) rounding_adj = new_total-saleObj.grand_total saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 6b7802cf..2604e215 100755 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -5,7 +5,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController @cashier_type = params[:type] @membership_rebate_balance=0 sale_data = Sale.find_by_sale_id(@sale_id) - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 1eb08f72..8b7bdf91 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -126,7 +126,7 @@ class Origami::ShiftsController < BaseOrigamiController if find_close_cashier_print[0][1].to_i > 0 - printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + printer.print_close_cashier(print_settings,cashier_terminal,current_shop, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) end end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 0431ff87..7c9514c8 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -9,7 +9,7 @@ class Origami::TableInvoicesController < BaseOrigamiController else sale = Sale.find(booking.sale_id) # rounding adjustment - if @shop.is_rounding_adj + if current_shop.is_rounding_adj a = sale.grand_total % 25 # Modulus b = sale.grand_total / 25 # Division #not calculate rounding if modulus is 0 and division is even diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index 2f708af3..43a1f5bc 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -21,7 +21,7 @@ class Origami::UnionpayController < BaseOrigamiController total = sale_data.grand_total others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index a2e43d5a..e77363d9 100644 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -21,7 +21,7 @@ class Origami::VisaController < BaseOrigamiController total = sale_data.grand_total others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index b4a3c1dc..55ef52f5 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -143,7 +143,7 @@ class Origami::VoidController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index 196d93c4..d1aeb26b 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -7,7 +7,7 @@ class Origami::VoucherController < BaseOrigamiController total = sale_data.grand_total @vouchercount = 0 others = 0 - if @shop.is_rounding_adj + if current_shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else new_total = sale_data.grand_total diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 4ab7b671..46b6f843 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -117,7 +117,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/reports/hourly_saleitem_controller.bk.rb b/app/controllers/reports/hourly_saleitem_controller.bk.rb index ab4f81ea..d2df64a0 100644 --- a/app/controllers/reports/hourly_saleitem_controller.bk.rb +++ b/app/controllers/reports/hourly_saleitem_controller.bk.rb @@ -118,7 +118,7 @@ class Reports::HourlySaleitemController < BaseReportController shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})" end - shop_details = shop_detail + shop_details = current_shop account_type = params[:account_type] @type = params[:period_type] period_name = get_period_name(params[:period]) diff --git a/app/controllers/reports/hourly_saleitem_controller.rb b/app/controllers/reports/hourly_saleitem_controller.rb index 4092ee40..29bc9836 100644 --- a/app/controllers/reports/hourly_saleitem_controller.rb +++ b/app/controllers/reports/hourly_saleitem_controller.rb @@ -119,7 +119,7 @@ class Reports::HourlySaleitemController < BaseReportController shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})" end - shop_details = shop_detail + shop_details = current_shop account_type = params[:account_type] @type = params[:period_type] period_name = get_period_name(params[:period]) diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 03854fc1..007ab864 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -215,7 +215,7 @@ authorize_resource :class => false printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,current_shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index eb526b22..fe8a832a 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -129,11 +129,11 @@ class Reports::SaleitemController < BaseReportController if print_settings.nil? if !print_settings_star.nil? printer = Printer::CashierStationPrinter.new(print_settings_star) - printer.print_sale_items_report(print_settings_star, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) + printer.print_sale_items_report(print_settings_star, current_shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) end else printer = Printer::CashierStationPrinter.new(print_settings) - printer.print_sale_items_report(print_settings, @shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) + printer.print_sale_items_report(print_settings, current_shop, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) end respond_to do |format| diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index a5231f4d..be23d412 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -75,7 +75,7 @@ class Reports::ShiftsaleController < BaseReportController end - shop_details = shop_detail + shop_details = current_shop cashier_terminal = @shift.cashier_terminal @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @@ -97,7 +97,7 @@ class Reports::ShiftsaleController < BaseReportController printer = Printer::CashierStationPrinter.new(print_settings) # printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) - printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, current_shops,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) respond_to do |format| format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'} diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 89cb4dec..186391c8 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -157,7 +157,7 @@ class Settings::MenusController < ApplicationController def import if params[:file] - status = Menu.import(params[:file], current_user.name,@shop) + status = Menu.import(params[:file], current_user.name,current_shop) redirect_to settings_menus_path, notice: status end end diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index c15cf757..82fd7e06 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -32,7 +32,7 @@ class Settings::ShopsController < ApplicationController if @settings_shop.save if params[:display_images].present? params[:display_images]['image'].each do |a| - @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a) + @display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :image => a) end end format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' } @@ -60,16 +60,16 @@ class Settings::ShopsController < ApplicationController File.delete(delete_path) end end - save_path = Rails.root.join("public/#{@shop.shop_code}_#{a.original_filename}") + save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}") File.open(save_path, 'wb') do |f| f.write a.read end - audio_name = "#{@shop.shop_code}_#{a.original_filename}" + audio_name = "#{current_shop.shop_code}_#{a.original_filename}" @settings_shop.display_images.where(:name => "order_audio").destroy_all - @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name) + @display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :name => "order_audio", :image => audio_name) else @aa = Base64.encode64(a.read) - @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => "data:image/jpeg;base64,"+@aa) + @display_image = @settings_shop.display_images.create!(:shop_id => current_shop.id, :image => "data:image/jpeg;base64,"+@aa) end end end diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index b4072855..c76a6828 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -350,7 +350,7 @@ class Transactions::SalesController < ApplicationController customer= Customer.find(sale.customer_id) #shop detail - shop_details = @shop + shop_details = current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 8f1b3581..ab91b06f 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -37,7 +37,7 @@ <% if current_login_employee.role !='foodcourt_cashier' %> diff --git a/app/views/layouts/_header_foodcourt.html.erb b/app/views/layouts/_header_foodcourt.html.erb index e7fb9dcf..6aa822d7 100644 --- a/app/views/layouts/_header_foodcourt.html.erb +++ b/app/views/layouts/_header_foodcourt.html.erb @@ -9,7 +9,7 @@ diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index 08e2e6c6..5f69cca9 100755 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -82,7 +82,7 @@
- <%= shop_detail.name %> + <%= current_shop.name %>
From 270c2a821ef7d2bbb9cb404231fe253c316c36aa Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Mon, 13 Jan 2020 18:41:37 +0630 Subject: [PATCH 07/18] delete shop scope in model --- app/controllers/foodcourt/payments_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- .../inventory/inventory_definitions_controller.rb | 4 ++-- app/controllers/inventory/stock_checks_controller.rb | 4 ++-- app/controllers/origami/home_controller.rb | 2 +- app/controllers/origami/payments_controller.rb | 2 +- app/controllers/settings/menus_controller.rb | 2 +- app/controllers/transactions/credit_notes_controller.rb | 4 ++-- app/controllers/transactions/sales_controller.rb | 6 +++--- app/models/booking.rb | 2 +- app/models/dining_facility.rb | 1 - app/models/menu.rb | 3 +-- app/models/sale.rb | 2 +- app/models/sale_payment.rb | 2 +- app/models/stock_check.rb | 3 +-- app/models/stock_check_item.rb | 2 +- app/models/stock_journal.rb | 6 +++--- app/models/zone.rb | 1 - app/views/settings/cashier_terminals/_form.html.erb | 2 +- app/views/settings/order_queue_stations/_form.html.erb | 2 +- 20 files changed, 25 insertions(+), 29 deletions(-) diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb index c3b0d904..6e7e2859 100755 --- a/app/controllers/foodcourt/payments_controller.rb +++ b/app/controllers/foodcourt/payments_controller.rb @@ -223,7 +223,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,current_shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user) @kbz_pay_amount += amount.to_f #for changable on/off diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 9e9b4866..dcf31a36 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -124,7 +124,7 @@ class HomeController < ApplicationController end end - @inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance) + @inventories = StockJournal.inventory_balances(@from,@to).sum(:balance) @total_trans = Sale.total_trans(current_user,@from,@to) @total_card = Sale.total_card_sale(current_user,@from,@to) diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index d1bb0753..96243b8a 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -90,8 +90,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController format.json { head :no_content } end - StockJournal.delete_stock_journal(inventory.item_code,current_shop) - StockCheckItem.delete_stock_check_item(inventory.item_code,current_shop) + StockJournal.delete_stock_journal(inventory.item_code) + StockCheckItem.delete_stock_check_item(inventory.item_code) if !inventory.nil? inventory.destroy flash[:message] = 'Inventory was successfully destroyed.' diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index 9493b16d..6c501def 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -19,7 +19,7 @@ class Inventory::StockChecksController < BaseInventoryController item_list = JSON.parse(params[:stock_item]) reason = params[:reason] check = StockCheck.new - @check = check.create(current_user, reason, item_list,current_shop) + @check = check.create(current_user, reason, item_list) end def show @@ -33,7 +33,7 @@ class Inventory::StockChecksController < BaseInventoryController check = params[:data] stockCheck = StockCheck.find_by_id(check) stockCheck.stock_check_items.each do |item| - StockJournal.from_stock_check(item,current_shop) + StockJournal.from_stock_check(item) end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 24bbd3bb..f7416704 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -11,7 +11,7 @@ class Origami::HomeController < BaseOrigamiController @customers = Customer.pluck("customer_id, name") - @occupied_table = DiningFacility.where("status='occupied'").shop.count + @occupied_table = DiningFacility.where("status='occupied'").count @shift = ShiftSale.current_open_shift(current_user) end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 7caac687..7951c348 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -275,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController @pdf_view = @lookup_pdf.value end - amount = SalePayment.get_kbz_pay_amount(sale_id, current_user, current_shop) + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user) @kbz_pay_amount += amount.to_f #for changable on/off diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 186391c8..5961a8f4 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -157,7 +157,7 @@ class Settings::MenusController < ApplicationController def import if params[:file] - status = Menu.import(params[:file], current_user.name,current_shop) + status = Menu.import(params[:file], current_user.name) redirect_to settings_menus_path, notice: status end end diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 9622e5e4..c20c8364 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -23,10 +23,10 @@ class Transactions::CreditNotesController < ApplicationController .joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") .where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount) FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') - THEN NULL ELSE payment_method='creditnote' END)").shop + THEN NULL ELSE payment_method='creditnote' END)") @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) else - sale = Sale.search_credit_sales(customer,filter,from,to,order_source).shop + sale = Sale.search_credit_sales(customer,filter,from,to,order_source) if !sale.nil? @credit_notes = sale @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index c76a6828..98b420ff 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -18,13 +18,13 @@ class Transactions::SalesController < ApplicationController if receipt_no.nil? && from.nil? && to.nil? if @shift.blank? - @sales = Sale.where("NOT sale_status='new'").shop.order("sale_id desc") + @sales = Sale.where("NOT sale_status='new'").order("sale_id desc") else - @sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").shop.order("sale_id desc") + @sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc") end @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else - sale = Sale.search(receipt_no,from,to,@shift).shop + sale = Sale.search(receipt_no,from,to,@shift) if sale.count > 0 @sales = sale @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) diff --git a/app/models/booking.rb b/app/models/booking.rb index 3cd13296..e3a8f6e3 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -135,7 +135,7 @@ class Booking < ApplicationRecord joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") .where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") end - .shop.order("sale_id DESC") + .order("sale_id DESC") end def self.get_sync_data(sale_id) diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 8717222e..a93f4742 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -20,7 +20,6 @@ class DiningFacility < ApplicationRecord ROOM_TYPE = "Room" default_scope { order('order_by asc') } - scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) } scope :active, -> {where(is_active: true)} diff --git a/app/models/menu.rb b/app/models/menu.rb index 6c3d210e..a59480a6 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -8,7 +8,6 @@ class Menu < ApplicationRecord #Default Scope to pull the active version only default_scope { order("created_at asc") } scope :active, -> {where("is_active = true")} - scope :shop, -> { where("menus.shop_code=?",Shop.current_shop.shop_code) } def self.current_menu today = DateTime.now @@ -47,7 +46,7 @@ class Menu < ApplicationRecord end end - def self.import(file, created_by,shop) + def self.import(file, created_by) status = "" spreadsheet = open_spreadsheet(file) if spreadsheet.sheets.count > 1 diff --git a/app/models/sale.rb b/app/models/sale.rb index 88cf2fdc..74460cdf 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -791,7 +791,7 @@ def self.daily_sales_list(from,to) SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") .along_with_sale_payments_except_void_between(from, to) - .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to).shop + .where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to) .group("sale_id").to_sql daily_total = connection.select_all("SELECT diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index b51aa83f..3a605f96 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -34,7 +34,7 @@ class SalePayment < ApplicationRecord end end - def self.get_kbz_pay_amount(sale_id, current_user,shop) + def self.get_kbz_pay_amount(sale_id, current_user) amount = 0 kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last diff --git a/app/models/stock_check.rb b/app/models/stock_check.rb index 541a7ea5..c2499c29 100755 --- a/app/models/stock_check.rb +++ b/app/models/stock_check.rb @@ -1,12 +1,11 @@ class StockCheck < ApplicationRecord has_many :stock_check_items - def create(user, reason, item_list,shop) + def create(user, reason, item_list) self.reason = reason self.check_by = user.id self.check_start = Time.now self.check_end = Time.now - self.shop_code = shop.shop_code save item_list.each do |item| stockItem = StockCheckItem.new diff --git a/app/models/stock_check_item.rb b/app/models/stock_check_item.rb index 9cab250e..16699803 100755 --- a/app/models/stock_check_item.rb +++ b/app/models/stock_check_item.rb @@ -67,7 +67,7 @@ class StockCheckItem < ApplicationRecord return query end - def self.delete_stock_check_item(item_code,shop) + def self.delete_stock_check_item(item_code) self.where("item_code=?", item_code).delete_all end end diff --git a/app/models/stock_journal.rb b/app/models/stock_journal.rb index f68b61bf..3f952953 100755 --- a/app/models/stock_journal.rb +++ b/app/models/stock_journal.rb @@ -34,7 +34,7 @@ class StockJournal < ApplicationRecord return balance.to_i - qty.to_i end - def self.from_stock_check(item,shop) + def self.from_stock_check(item) stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first if stock_journal.nil? old_blance = 0 @@ -57,7 +57,7 @@ class StockJournal < ApplicationRecord end - def self.inventory_balances(from,to, current_shop) + def self.inventory_balances(from,to) query = StockJournal.select("mii.item_instance_name as item_instance_name,balance") .joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code") .group("mii.item_instance_name") @@ -76,7 +76,7 @@ class StockJournal < ApplicationRecord end end - def self.delete_stock_journal(item_code,shop) + def self.delete_stock_journal(item_code) self.where("item_code=?", item_code).delete_all end diff --git a/app/models/zone.rb b/app/models/zone.rb index 5d1c9309..e9ca27cb 100755 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -5,7 +5,6 @@ class Zone < ApplicationRecord has_many :order_queue_stations has_many :cashier_terminals - scope :shop, -> { where("shop_code=?",Shop.current_shop.shop_code) } # validations validates_presence_of :name, :created_by diff --git a/app/views/settings/cashier_terminals/_form.html.erb b/app/views/settings/cashier_terminals/_form.html.erb index c1f1d2ee..7a47bd3a 100755 --- a/app/views/settings/cashier_terminals/_form.html.erb +++ b/app/views/settings/cashier_terminals/_form.html.erb @@ -11,7 +11,7 @@ <%= f.input :is_currently_login %> <%= f.input :auto_print_receipt %> <%= f.label "Select Zones", :class => 'control-label' %> - <%= f.collection_check_boxes :zone_ids , Zone.shop, :id, :name , :class => 'checkbox form-group'%> + <%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox form-group'%> <% if(@server_mode != 'cloud') %> <%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %> <% else %> diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index 41185fca..3b8d120f 100755 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -31,7 +31,7 @@ div.form-inputs span{ <%= f.input :print_copy %> <%= f.hidden_field :processing_items %> <%= f.label "Select Zones", :class => 'control-label' %> - <%= f.collection_check_boxes :zone_ids , Zone.shop, :id, :name , :class => 'checkbox'%> + <%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox'%> <%= f.input :cut_per_item %> <%= f.input :use_alternate_name %> <%= f.input :processing_items, as: :hidden %> From 79a04ea9980192be65a94e8f4728d5c9c08afadb Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 14 Jan 2020 11:14:21 +0630 Subject: [PATCH 08/18] rake --- .../20200113100120_addcolumnsubdomain_shop.rb | 5 + lib/tasks/add_shopcode.rake | 172 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 db/migrate/20200113100120_addcolumnsubdomain_shop.rb create mode 100644 lib/tasks/add_shopcode.rake diff --git a/db/migrate/20200113100120_addcolumnsubdomain_shop.rb b/db/migrate/20200113100120_addcolumnsubdomain_shop.rb new file mode 100644 index 00000000..5c9a223b --- /dev/null +++ b/db/migrate/20200113100120_addcolumnsubdomain_shop.rb @@ -0,0 +1,5 @@ +class AddcolumnsubdomainShop < ActiveRecord::Migration[5.1] + def change + add_column :shops, :subdomain, :string + end +end diff --git a/lib/tasks/add_shopcode.rake b/lib/tasks/add_shopcode.rake new file mode 100644 index 00000000..fe2fb5de --- /dev/null +++ b/lib/tasks/add_shopcode.rake @@ -0,0 +1,172 @@ +namespace :shop_code do + task :add => :environment do + # rake shop_code:add shop_code= + puts ENV[shop_code] + gateway_communication_type = Lookup.create([{lookup_type:'gateway_communication_type',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'gateway_communication_type',name: 'USB',value: 'usb',shop_code: '#{ENV[shop_code]}'}]) + + payment_methods = Lookup.create([{lookup_type:'payment_methods',name: 'Cash',value: 'cash',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'CreditNote',value: 'creditnote',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - VISA',value: 'visa',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - MASTER',value: 'master',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - JCB',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - UnionPay',value: 'unionpay',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Card - MPU',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Vochure',value: 'vochure',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_methods',name: 'Giftcard',value: 'gift',shop_code: '#{ENV[shop_code]}'}]) + + payment_status = Lookup.create([{lookup_type:'payment_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'paid',value: 'paid',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'Fail',value: 'fail',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'payment_status',name: 'Outstanding',value: 'outstanding',shop_code: '#{ENV[shop_code]}'}]) + + sales_status = Lookup.create([{lookup_type:'sales_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'sales_status',name: 'Void',value: 'void',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'sales_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + + order_status = Lookup.create([{lookup_type:'order_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + + order_item_status = Lookup.create([{lookup_type:'order_item_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_item_status',name: 'Processing',value: 'processing',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_item_status',name: 'Served',value: 'served',shop_code: '#{ENV[shop_code]}'},{lookup_type:'order_item_status',name: 'BIlled',value: 'billed',shop_code: '#{ENV[shop_code]}'}]) + + #order_source [tablet,order_station,emenu,api] + order_source = Lookup.create([{lookup_type:'order_source',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'Tablet',value: 'tablet',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'EMenu',value: 'emenu',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_source',name: 'Order Station',value: 'order_station',shop_code: '#{ENV[shop_code]}'}]) + + #order_type [dine-in,takeaway,delivery] + order_type = Lookup.create([{lookup_type:'order_type',name: 'Dine-in',value: 'dine-in',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_type',name: 'Takeaway',value: 'takeaway',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'order_type',name: 'Delivery',value: 'delivery',shop_code: '#{ENV[shop_code]}'}]) + + #menu_item_type:[simple| set| DIY] + menu_item_type = Lookup.create([{lookup_type:'menu_item_type',name: 'SIMPLE',value: 'simpleItem',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'menu_item_type',name: 'Set Menu',value: 'setMenu',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'menu_item_type',name: 'DIY',value: 'diy',shop_code: '#{ENV[shop_code]}'} + ]) + + member_group_type = Lookup.create([{lookup_type:'member_group_type',name: 'Normal',value: '1',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Platinum',value: '5',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Silver',value: '4',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'member_group_type',name: 'Gold',value: '3',shop_code: '#{ENV[shop_code]}'} + ]) + + #menu_item_attribute:[size|] + menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type',name: 'Size',value: 'size',shop_code: '#{ENV[shop_code]}'}]) + + #Employee Roles + employee_roles = Lookup.create([{lookup_type:'employee_roles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Waiter',value: 'waiter',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Supervisor',value: 'supervisor',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Manager',value: 'manager',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Accountant',value: 'account',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'Administrator',value: 'administrator',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'employee_roles',name: 'FoodCourt Cashier',value: 'foodcourt_cashier',shop_code: '#{ENV[shop_code]}'}]) + + #booking_status + booking_status = Lookup.create([{lookup_type:'booking_status',name: 'Available',value: 'available',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Reserved',value: 'reserved',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Occupied',value: 'occupied',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Cleaning',value: 'cleaning',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'booking_status',name: 'Moved',value: 'moved',shop_code: '#{ENV[shop_code]}'}]) + + #booking_status + account_type = Lookup.create([{lookup_type:'account_type',name: 'Income',value: '0',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'account_type',name: 'Expense',value: '1',shop_code: '#{ENV[shop_code]}'}]) + + # sale void reason + void_reason = Lookup.create([{lookup_type:'void_reason',name: 'Approve By Manager',value: 'Approve By Manager',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Customer Mistake',value: 'Customer Mistake',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Cashier Mistake',value: 'Cashier Mistake',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'void_reason',name: 'Waiter Mistake',value: 'Waiter Mistake',shop_code: '#{ENV[shop_code]}'}]) + + # sale void reason + float_value = Lookup.create([{lookup_type:'float_value',name: '500',value: '500',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '1000',value: '1000',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '5000',value: '5000',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'float_value',name: '10000',value: '10000',shop_code: '#{ENV[shop_code]}'}]) + + # customer type + customer_type = Lookup.create([{lookup_type:'customer_type',name: 'Dinein',value: 'Dinein',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'FoodCourt',value: 'FoodCourt',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'Takeaway',value: 'Takeaway',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'customer_type',name: 'Delivery',value: 'Delivery',shop_code: '#{ENV[shop_code]}'}]) + + #unit + units = Lookup.create([{lookup_type:'unit',name: 'PCS',value: 'pcs',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'unit',name: 'KG',value: 'kg',shop_code: '#{ENV[shop_code]}'}]) + + + # Country + countries = Lookup.create({lookup_type:'country',name: 'Japan',value: 'Japan',shop_code: '#{ENV[shop_code]}'}) + + # number formats + number_formats = Lookup.create([{lookup_type: 'number_format',name: 'precision','2',shop_code: '#{ENV[shop_code]}'}, + {lookup_type: 'number_format',name: 'delimiter','1',shop_code: '#{ENV[shop_code]}'}, + {lookup_type: 'number_format',name: 'strip_insignificant_zeros','0',shop_code: '#{ENV[shop_code]}'}]) + + # tax_profiles + tax_profiles = Lookup.create([{lookup_type:'tax_profiles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'tax_profiles',name: 'FoodCourt',value: 'food_court',shop_code: '#{ENV[shop_code]}'}, + {lookup_type:'tax_profiles',name: 'Online Order',value: 'online_order',shop_code: '#{ENV[shop_code]}'}]) + + # Default CUSTOMER + customer = Customer.create({name:"WALK-IN",email: "cus1@customer.com",contact_no:"000000000",card_no:"000",customer_type:"Dinein",tax_profiles:["2","1"],shop_code: '#{ENV[shop_code]}'}) + customer2 = Customer.create({name:"TAKEAWAY",email: "cus2@customer.com",contact_no:"111111111",card_no:"111",customer_type:"Takeaway",tax_profiles:["1"],shop_code: '#{ENV[shop_code]}'}) + + # Tax Profile FoodCourt + commercial_taxes_online_order = TaxProfile.create({id:1,name: "Commercial Tax",group_type: "food_court",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + service_charges_online_order = TaxProfile.create({id:2,name: "Service Charges",group_type: "food_court",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + #Tax Profile Online Order + commercial_taxes_online_order = TaxProfile.create({id:3,name: "Commercial Tax",group_type: "online_order",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + service_charges_online_order = TaxProfile.create({id:4,name: "Service Charges",group_type: "online_order",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + convenience_charges_online_order= TaxProfile.create({id:5,name: "Convenience Charges",group_type: "online_order",rate:5.0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + shop = Shop.create({name: "",address:'',township:"",state:"",city:"Yangon",country:"Myanmar",phone_no:"",reservation_no:"111",license:"", + license_data:"test",base_currency:"111",id_prefix:"111",is_rounding_adj:"0",quick_sale_summary:"0",shop_code: '#{ENV[shop_code]}'}) + + #Create Adminstrator employee + admin_employee = Employee.create({name: "Administrator",role: "administrator",password: "99999",emp_id:"999",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + foodcourt_employee = Employee.create({name: "FoodCourt Cashier",role: "foodcourt_cashier",password: "22222",emp_id:"221",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + + order_item_printer=PrintSetting.create({name: "OrderItemPdf",unique_code: "OrderItemPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + order_summary_printer=PrintSetting.create({name: "Order Summary",unique_code: "OrderSummaryPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + request_bill_printer=PrintSetting.create({name: "Receipt Bill",unique_code: "ReceiptBillPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + close_cashier_printer=PrintSetting.create({name: "Close Cashier",unique_code: "CloseCashierPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + crm_order_printer=PrintSetting.create({name: "CRM Order",unique_code: "CrmOrderPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + queue_no_printer=PrintSetting.create({name: "Queue No",unique_code: "QueueNoPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + + zone = Zone.create({id:1,name: "H1",is_active:true,created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + + member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",shop_code: '#{ENV[shop_code]}'}) + + member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, + {membership_type:"search_paypar_security_code",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_security_code",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'} + ]) + + payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "/api/membership_campaigns/redeem",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"PAYMAL",gateway_url: "/api/create_payment",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) + + puts " Finished System Default Set Up Data" + + end +end From 34e65ed562e6e41b377123c3c593770c7355b09d Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 14 Jan 2020 12:33:53 +0630 Subject: [PATCH 09/18] update multi_tenancy --- app/controllers/concerns/multi_tenancy.rb | 12 ++++++------ app/models/shop.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index 643a7455..a88cc9e0 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -3,19 +3,19 @@ module MultiTenancy included do set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter - before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action + before_action :set_current_tenant_by_subdomain_or_frist if respond_to? :before_action helper_method :current_shop if respond_to? :helper_method end private - def find_shop_by_subdomain_or_frist - if request.subdomains.last - set_current_tenant(Shop.find_by(shop_code: request.subdomains.last.partition('-').last)) + def set_current_tenant_by_subdomain_or_frist + if request.subdomains.last && request.subdomains.last != 'www' + set_current_tenant(Shop.find_by(subdomain: request.subdomains.last)) end - current_shop + set_current_tenant(Shop.first) if current_tenant.nil? end def current_shop - @shop ||= Shop.current_shop + ActsAsTenant.current_tenant end end diff --git a/app/models/shop.rb b/app/models/shop.rb index e898e4e0..2a366927 100755 --- a/app/models/shop.rb +++ b/app/models/shop.rb @@ -12,6 +12,6 @@ class Shop < ApplicationRecord end def self.current_shop - RequestStore["current_shop"] ||= ActsAsTenant.current_tenant || Shop.first + ActsAsTenant.current_tenant end end From e0e15ac908883c3a0d17fbab0b3316c87bf1e739 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 14 Jan 2020 13:17:19 +0630 Subject: [PATCH 10/18] rake --- README.md | 3 - lib/tasks/add_shopcode.rake | 273 ++++++++++++++++++------------------ 2 files changed, 134 insertions(+), 142 deletions(-) diff --git a/README.md b/README.md index 8ea6f139..629492b3 100755 --- a/README.md +++ b/README.md @@ -314,9 +314,6 @@ settings/lookups => { type:customer_type, name: Staff, value:Staff } For FoodCourt Cashier role settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodcourt_cashier } -For Search Paypar security_code -settings/lookups => { type:employee_roles, name: FoodCourt Cashier, value:foodcourt_cashier } - * ToDo list diff --git a/lib/tasks/add_shopcode.rake b/lib/tasks/add_shopcode.rake index fe2fb5de..c9b6624a 100644 --- a/lib/tasks/add_shopcode.rake +++ b/lib/tasks/add_shopcode.rake @@ -1,172 +1,167 @@ -namespace :shop_code do - task :add => :environment do - # rake shop_code:add shop_code= - puts ENV[shop_code] - gateway_communication_type = Lookup.create([{lookup_type:'gateway_communication_type',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'gateway_communication_type',name: 'USB',value: 'usb',shop_code: '#{ENV[shop_code]}'}]) +task :add_manual_data, [:shop_code] do |task, args| + puts args[:shop_code] + # shop_code= args[:var] + puts "#{args[:shop_code]}" + gateway_communication_type = Lookup.create([{lookup_type:'gateway_communication_type',name: 'API',value: 'api',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'gateway_communication_type',name: 'USB',value: 'usb',shop_code: "#{args[:shop_code]}"}]) - payment_methods = Lookup.create([{lookup_type:'payment_methods',name: 'Cash',value: 'cash',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'CreditNote',value: 'creditnote',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Card - VISA',value: 'visa',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Card - MASTER',value: 'master',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Card - JCB',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Card - UnionPay',value: 'unionpay',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Card - MPU',value: 'jcb',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Vochure',value: 'vochure',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_methods',name: 'Giftcard',value: 'gift',shop_code: '#{ENV[shop_code]}'}]) + payment_methods = Lookup.create([{lookup_type:'payment_methods',name: 'Cash',value: 'cash',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'CreditNote',value: 'creditnote',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Card - VISA',value: 'visa',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Card - MASTER',value: 'master',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Card - JCB',value: 'jcb',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Card - UnionPay',value: 'unionpay',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Card - MPU',value: 'jcb',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Vochure',value: 'vochure',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_methods',name: 'Giftcard',value: 'gift',shop_code: "#{args[:shop_code]}"}]) - payment_status = Lookup.create([{lookup_type:'payment_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_status',name: 'paid',value: 'paid',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_status',name: 'Fail',value: 'fail',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'payment_status',name: 'Outstanding',value: 'outstanding',shop_code: '#{ENV[shop_code]}'}]) + payment_status = Lookup.create([{lookup_type:'payment_status',name: 'New',value: 'new',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_status',name: 'paid',value: 'paid',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_status',name: 'Fail',value: 'fail',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'payment_status',name: 'Outstanding',value: 'outstanding',shop_code: "#{args[:shop_code]}"}]) - sales_status = Lookup.create([{lookup_type:'sales_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'sales_status',name: 'Void',value: 'void',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'sales_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + sales_status = Lookup.create([{lookup_type:'sales_status',name: 'New',value: 'new',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'sales_status',name: 'Void',value: 'void',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'sales_status',name: 'Completed',value: 'completed',shop_code: "#{args[:shop_code]}"}]) - order_status = Lookup.create([{lookup_type:'order_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_status',name: 'Completed',value: 'completed',shop_code: '#{ENV[shop_code]}'}]) + order_status = Lookup.create([{lookup_type:'order_status',name: 'New',value: 'new',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_status',name: 'Completed',value: 'completed',shop_code: "#{args[:shop_code]}"}]) - order_item_status = Lookup.create([{lookup_type:'order_item_status',name: 'New',value: 'new',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_item_status',name: 'Processing',value: 'processing',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_item_status',name: 'Served',value: 'served',shop_code: '#{ENV[shop_code]}'},{lookup_type:'order_item_status',name: 'BIlled',value: 'billed',shop_code: '#{ENV[shop_code]}'}]) + order_item_status = Lookup.create([{lookup_type:'order_item_status',name: 'New',value: 'new',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_item_status',name: 'Processing',value: 'processing',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_item_status',name: 'Served',value: 'served',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_item_status',name: 'BIlled',value: 'billed',shop_code: "#{args[:shop_code]}"}]) - #order_source [tablet,order_station,emenu,api] - order_source = Lookup.create([{lookup_type:'order_source',name: 'API',value: 'api',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_source',name: 'Tablet',value: 'tablet',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_source',name: 'EMenu',value: 'emenu',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_source',name: 'Order Station',value: 'order_station',shop_code: '#{ENV[shop_code]}'}]) + #order_source [tablet,order_station,emenu,api] + order_source = Lookup.create([{lookup_type:'order_source',name: 'API',value: 'api',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_source',name: 'Tablet',value: 'tablet',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_source',name: 'EMenu',value: 'emenu',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_source',name: 'Order Station',value: 'order_station',shop_code: "#{args[:shop_code]}"}]) - #order_type [dine-in,takeaway,delivery] - order_type = Lookup.create([{lookup_type:'order_type',name: 'Dine-in',value: 'dine-in',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_type',name: 'Takeaway',value: 'takeaway',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'order_type',name: 'Delivery',value: 'delivery',shop_code: '#{ENV[shop_code]}'}]) + #order_type [dine-in,takeaway,delivery] + order_type = Lookup.create([{lookup_type:'order_type',name: 'Dine-in',value: 'dine-in',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_type',name: 'Takeaway',value: 'takeaway',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'order_type',name: 'Delivery',value: 'delivery',shop_code: "#{args[:shop_code]}"}]) - #menu_item_type:[simple| set| DIY] - menu_item_type = Lookup.create([{lookup_type:'menu_item_type',name: 'SIMPLE',value: 'simpleItem',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'menu_item_type',name: 'Set Menu',value: 'setMenu',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'menu_item_type',name: 'DIY',value: 'diy',shop_code: '#{ENV[shop_code]}'} - ]) + #menu_item_type:[simple| set| DIY] + menu_item_type = Lookup.create([{lookup_type:'menu_item_type',name: 'SIMPLE',value: 'simpleItem',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'menu_item_type',name: 'Set Menu',value: 'setMenu',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'menu_item_type',name: 'DIY',value: 'diy',shop_code: "#{args[:shop_code]}"}]) - member_group_type = Lookup.create([{lookup_type:'member_group_type',name: 'Normal',value: '1',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'member_group_type',name: 'Platinum',value: '5',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'member_group_type',name: 'Silver',value: '4',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'member_group_type',name: 'Gold',value: '3',shop_code: '#{ENV[shop_code]}'} - ]) + member_group_type = Lookup.create([{lookup_type:'member_group_type',name: 'Normal',value: '1',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'member_group_type',name: 'Platinum',value: '5',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'member_group_type',name: 'Silver',value: '4',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'member_group_type',name: 'Gold',value: '3',shop_code: "#{args[:shop_code]}"}]) - #menu_item_attribute:[size|] - menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type',name: 'Size',value: 'size',shop_code: '#{ENV[shop_code]}'}]) + #menu_item_attribute:[size|] + menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type',name: 'Size',value: 'size',shop_code: "#{args[:shop_code]}"}]) - #Employee Roles - employee_roles = Lookup.create([{lookup_type:'employee_roles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'Waiter',value: 'waiter',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'Supervisor',value: 'supervisor',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'Manager',value: 'manager',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'Accountant',value: 'account',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'Administrator',value: 'administrator',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'employee_roles',name: 'FoodCourt Cashier',value: 'foodcourt_cashier',shop_code: '#{ENV[shop_code]}'}]) + #Employee Roles + employee_roles = Lookup.create([{lookup_type:'employee_roles',name: 'Cashier',value: 'cashier',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'Waiter',value: 'waiter',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'Supervisor',value: 'supervisor',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'Manager',value: 'manager',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'Accountant',value: 'account',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'Administrator',value: 'administrator',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'employee_roles',name: 'FoodCourt Cashier',value: 'foodcourt_cashier',shop_code: "#{args[:shop_code]}"}]) - #booking_status - booking_status = Lookup.create([{lookup_type:'booking_status',name: 'Available',value: 'available',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'booking_status',name: 'Reserved',value: 'reserved',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'booking_status',name: 'Occupied',value: 'occupied',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'booking_status',name: 'Cleaning',value: 'cleaning',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'booking_status',name: 'Moved',value: 'moved',shop_code: '#{ENV[shop_code]}'}]) + #booking_status + booking_status = Lookup.create([{lookup_type:'booking_status',name: 'Available',value: 'available',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'booking_status',name: 'Reserved',value: 'reserved',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'booking_status',name: 'Occupied',value: 'occupied',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'booking_status',name: 'Cleaning',value: 'cleaning',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'booking_status',name: 'Moved',value: 'moved',shop_code: "#{args[:shop_code]}"}]) - #booking_status - account_type = Lookup.create([{lookup_type:'account_type',name: 'Income',value: '0',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'account_type',name: 'Expense',value: '1',shop_code: '#{ENV[shop_code]}'}]) + #booking_status + account_type = Lookup.create([{lookup_type:'account_type',name: 'Income',value: '0',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'account_type',name: 'Expense',value: '1',shop_code: "#{args[:shop_code]}"}]) - # sale void reason - void_reason = Lookup.create([{lookup_type:'void_reason',name: 'Approve By Manager',value: 'Approve By Manager',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'void_reason',name: 'Customer Mistake',value: 'Customer Mistake',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'void_reason',name: 'Cashier Mistake',value: 'Cashier Mistake',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'void_reason',name: 'Waiter Mistake',value: 'Waiter Mistake',shop_code: '#{ENV[shop_code]}'}]) + # sale void reason + void_reason = Lookup.create([{lookup_type:'void_reason',name: 'Approve By Manager',value: 'Approve By Manager',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'void_reason',name: 'Customer Mistake',value: 'Customer Mistake',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'void_reason',name: 'Cashier Mistake',value: 'Cashier Mistake',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'void_reason',name: 'Waiter Mistake',value: 'Waiter Mistake',shop_code: "#{args[:shop_code]}"}]) - # sale void reason - float_value = Lookup.create([{lookup_type:'float_value',name: '500',value: '500',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'float_value',name: '1000',value: '1000',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'float_value',name: '5000',value: '5000',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'float_value',name: '10000',value: '10000',shop_code: '#{ENV[shop_code]}'}]) + # sale void reason + float_value = Lookup.create([{lookup_type:'float_value',name: '500',value: '500',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'float_value',name: '1000',value: '1000',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'float_value',name: '5000',value: '5000',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'float_value',name: '10000',value: '10000',shop_code: "#{args[:shop_code]}"}]) - # customer type - customer_type = Lookup.create([{lookup_type:'customer_type',name: 'Dinein',value: 'Dinein',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'customer_type',name: 'FoodCourt',value: 'FoodCourt',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'customer_type',name: 'Takeaway',value: 'Takeaway',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'customer_type',name: 'Delivery',value: 'Delivery',shop_code: '#{ENV[shop_code]}'}]) + # customer type + customer_type = Lookup.create([{lookup_type:'customer_type',name: 'Dinein',value: 'Dinein',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'customer_type',name: 'FoodCourt',value: 'FoodCourt',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'customer_type',name: 'Takeaway',value: 'Takeaway',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'customer_type',name: 'Delivery',value: 'Delivery',shop_code: "#{args[:shop_code]}"}]) - #unit - units = Lookup.create([{lookup_type:'unit',name: 'PCS',value: 'pcs',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'unit',name: 'KG',value: 'kg',shop_code: '#{ENV[shop_code]}'}]) + #unit + units = Lookup.create([{lookup_type:'unit',name: 'PCS',value: 'pcs',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'unit',name: 'KG',value: 'kg',shop_code: "#{args[:shop_code]}"}]) - # Country - countries = Lookup.create({lookup_type:'country',name: 'Japan',value: 'Japan',shop_code: '#{ENV[shop_code]}'}) + # Country + countries = Lookup.create({lookup_type:'country',name: 'Japan',value: 'Japan',shop_code: "#{args[:shop_code]}"}) - # number formats - number_formats = Lookup.create([{lookup_type: 'number_format',name: 'precision','2',shop_code: '#{ENV[shop_code]}'}, - {lookup_type: 'number_format',name: 'delimiter','1',shop_code: '#{ENV[shop_code]}'}, - {lookup_type: 'number_format',name: 'strip_insignificant_zeros','0',shop_code: '#{ENV[shop_code]}'}]) + # number formats + number_formats = Lookup.create([{lookup_type: 'number_format',name: 'precision',value: '2',shop_code: "#{args[:shop_code]}"}, + {lookup_type: 'number_format',name: 'delimiter',value:',',shop_code: "#{args[:shop_code]}"}, + {lookup_type: 'number_format',name: 'strip_insignificant_zeros',value:'0',shop_code: "#{args[:shop_code]}"}]) - # tax_profiles - tax_profiles = Lookup.create([{lookup_type:'tax_profiles',name: 'Cashier',value: 'cashier',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'tax_profiles',name: 'FoodCourt',value: 'food_court',shop_code: '#{ENV[shop_code]}'}, - {lookup_type:'tax_profiles',name: 'Online Order',value: 'online_order',shop_code: '#{ENV[shop_code]}'}]) + # tax_profiles + tax_profiles = Lookup.create([{lookup_type:'tax_profiles',name: 'Cashier',value: 'cashier',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'tax_profiles',name: 'FoodCourt',value: 'food_court',shop_code: "#{args[:shop_code]}"}, + {lookup_type:'tax_profiles',name: 'Online Order',value: 'online_order',shop_code: "#{args[:shop_code]}"}]) + #foodcourt use + foodcourt = Lookup.create([{lookup_type:'food_court',name: 'FoodCourt',value: '1',shop_code: "#{args[:shop_code]}"}]) + # Default CUSTOMER + customer = Customer.create({name:"WALK-IN",email: "cus1@customer.com",contact_no:"000000000",card_no:"000",customer_type:"Dinein",tax_profiles:["2","1"],shop_code: "#{args[:shop_code]}"}) + customer2 = Customer.create({name:"TAKEAWAY",email: "cus2@customer.com",contact_no:"111111111",card_no:"111",customer_type:"Takeaway",tax_profiles:["1"],shop_code: "#{args[:shop_code]}"}) - # Default CUSTOMER - customer = Customer.create({name:"WALK-IN",email: "cus1@customer.com",contact_no:"000000000",card_no:"000",customer_type:"Dinein",tax_profiles:["2","1"],shop_code: '#{ENV[shop_code]}'}) - customer2 = Customer.create({name:"TAKEAWAY",email: "cus2@customer.com",contact_no:"111111111",card_no:"111",customer_type:"Takeaway",tax_profiles:["1"],shop_code: '#{ENV[shop_code]}'}) + # Tax Profile FoodCourt + commercial_taxes_online_order = TaxProfile.create({name: "Commercial Tax",group_type: "food_court",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) + service_charges_online_order = TaxProfile.create({name: "Service Charges",group_type: "food_court",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) - # Tax Profile FoodCourt - commercial_taxes_online_order = TaxProfile.create({id:1,name: "Commercial Tax",group_type: "food_court",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) - service_charges_online_order = TaxProfile.create({id:2,name: "Service Charges",group_type: "food_court",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + #Tax Profile Online Order + commercial_taxes_online_order = TaxProfile.create({name: "Commercial Tax",group_type: "online_order",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) + service_charges_online_order = TaxProfile.create({name: "Service Charges",group_type: "online_order",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) + convenience_charges_online_order= TaxProfile.create({name: "Convenience Charges",group_type: "online_order",rate:5.0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) - #Tax Profile Online Order - commercial_taxes_online_order = TaxProfile.create({id:3,name: "Commercial Tax",group_type: "online_order",rate:5.0,order_by:2,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) - service_charges_online_order = TaxProfile.create({id:4,name: "Service Charges",group_type: "online_order",rate:0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) - convenience_charges_online_order= TaxProfile.create({id:5,name: "Convenience Charges",group_type: "online_order",rate:5.0,order_by:1,created_by:"SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) - - shop = Shop.create({name: "",address:'',township:"",state:"",city:"Yangon",country:"Myanmar",phone_no:"",reservation_no:"111",license:"", - license_data:"test",base_currency:"111",id_prefix:"111",is_rounding_adj:"0",quick_sale_summary:"0",shop_code: '#{ENV[shop_code]}'}) - - #Create Adminstrator employee - admin_employee = Employee.create({name: "Administrator",role: "administrator",password: "99999",emp_id:"999",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) - foodcourt_employee = Employee.create({name: "FoodCourt Cashier",role: "foodcourt_cashier",password: "22222",emp_id:"221",created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + #Create Adminstrator employee + admin_employee = Employee.create({name: "Administrator",role: "administrator",password: "99999",emp_id:"999",created_by: "SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) + foodcourt_employee = Employee.create({name: "Cashier",role: "cashier",password: "22222",emp_id:"221",created_by: "SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) - order_item_printer=PrintSetting.create({name: "OrderItemPdf",unique_code: "OrderItemPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) - order_summary_printer=PrintSetting.create({name: "Order Summary",unique_code: "OrderSummaryPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) - request_bill_printer=PrintSetting.create({name: "Receipt Bill",unique_code: "ReceiptBillPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) - close_cashier_printer=PrintSetting.create({name: "Close Cashier",unique_code: "CloseCashierPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) - crm_order_printer=PrintSetting.create({name: "CRM Order",unique_code: "CrmOrderPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) - queue_no_printer=PrintSetting.create({name: "Queue No",unique_code: "QueueNoPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: '#{ENV[shop_code]}'}) + order_item_printer=PrintSetting.create({name: "OrderItemPdf",unique_code: "OrderItemPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) + order_summary_printer=PrintSetting.create({name: "Order Summary",unique_code: "OrderSummaryPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) + request_bill_printer=PrintSetting.create({name: "Receipt Bill",unique_code: "ReceiptBillPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) + close_cashier_printer=PrintSetting.create({name: "Close Cashier",unique_code: "CloseCashierPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) + crm_order_printer=PrintSetting.create({name: "CRM Order",unique_code: "CrmOrderPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) + queue_no_printer=PrintSetting.create({name: "Queue No",unique_code: "QueueNoPdf",printer_name: "Cashier",precision: "0",delimiter: 0,heading_space: 5,page_width: 210,page_height: 1450,shop_code: "#{args[:shop_code]}"}) - zone = Zone.create({id:1,name: "H1",is_active:true,created_by: "SYSTEM DEFAULT",shop_code: '#{ENV[shop_code]}'}) + zone = Zone.create({id:1,name: "H1",is_active:true,created_by: "SYSTEM DEFAULT",shop_code: "#{args[:shop_code]}"}) - member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",shop_code: '#{ENV[shop_code]}'}) + member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",shop_code: "#{args[:shop_code]}"}) - member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}, - {membership_type:"search_paypar_security_code",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_security_code",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'} - ]) + member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}, + {membership_type:"search_paypar_security_code",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_security_code",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}]) - payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) - payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) - payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) - payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws",shop_code: '#{ENV[shop_code]}'}) - payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "/api/membership_campaigns/redeem",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) - payment_methods = PaymentMethodSetting.create({payment_method:"PAYMAL",gateway_url: "/api/create_payment",merchant_account_id:"pZBHXEFbGNj/G",shop_code: '#{ENV[shop_code]}'}) + payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws",shop_code: "#{args[:shop_code]}"}) + payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://membership.paypar.ws",shop_code: "#{args[:shop_code]}"}) + payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://membership.paypar.ws",shop_code: "#{args[:shop_code]}"}) + payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://membership.paypar.ws",shop_code: "#{args[:shop_code]}"}) + payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "/api/membership_campaigns/redeem",merchant_account_id:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}) + payment_methods = PaymentMethodSetting.create({payment_method:"PAYMAL",gateway_url: "/api/create_payment",merchant_account_id:"pZBHXEFbGNj/G",shop_code: "#{args[:shop_code]}"}) - puts " Finished System Default Set Up Data" + puts " Finished System Default Set Up Data" - end end From 4c69c1d5d2d3a8adddeda90fa742fe29cdec4557 Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Tue, 14 Jan 2020 14:21:46 +0630 Subject: [PATCH 11/18] Print close cashier --- app/controllers/home_controller.rb | 2 +- app/controllers/origami/payments_controller.rb | 2 +- app/controllers/origami/shifts_controller.rb | 2 +- app/models/sale.rb | 4 ++-- app/views/home/dashboard.html.erb | 2 +- app/views/layouts/_header.html.erb | 8 +++++++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index dcf31a36..0da2bbf5 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -100,7 +100,7 @@ class HomeController < ApplicationController @sales = Sale.receipt_date_between(@from, @to).completed if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') - if shift = ShiftSale.current_open_shift(current_user.id) + if shift = ShiftSale.current_open_shift(current_user) @orders = @orders.where(shift_sale_id: shift.id) @sales = @sales.where(shift_sale_id: shift.id) end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 7951c348..a5b38db2 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -192,7 +192,7 @@ class Origami::PaymentsController < BaseOrigamiController end #card_balance amount for Paymal payment - card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info print_settings = PrintSetting.find_by_unique_code(unique_code) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 8b7bdf91..bbe2cf57 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -126,7 +126,7 @@ class Origami::ShiftsController < BaseOrigamiController if find_close_cashier_print[0][1].to_i > 0 - printer.print_close_cashier(print_settings,cashier_terminal,current_shop, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + printer.print_close_cashier(print_settings,cashier_terminal, @shift, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 74460cdf..c2faae54 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1496,7 +1496,7 @@ end end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') - if shift = ShiftSale.current_open_shift(current_user.id) + if shift = ShiftSale.current_open_shift(current_user) query = query.where("shift_sale_id='#{shift.id}'") end @@ -1523,7 +1523,7 @@ end end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') - if shift = ShiftSale.current_open_shift(current_user.id) + if shift = ShiftSale.current_open_shift(current_user) query = query.where("shift_sale_id='#{shift.id}'") end end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 71f7398a..4cb3bde2 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -347,7 +347,7 @@ <% end %> <% end %> - <% if isMobile.include? "Mobile" %> + <% if isMobile.to_s.include? "Mobile" %>
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index ab91b06f..e3bba515 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -19,8 +19,14 @@ <% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "account" %> - <% elsif current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %> + <% elsif current_login_employee.role == "supervisor" %> + <% elsif current_login_employee.role == "cashier" || current_login_employee.role == "waiter"%> + <%if ShiftSale.current_open_shift(current_login_employee) %> + + <%else%> + + <%end%> <%else%> <% end %> From c5eb5d667898d2c3e709bea3c97e33f0d6be2fae Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Tue, 14 Jan 2020 14:58:23 +0630 Subject: [PATCH 12/18] add app_id and auth_token to employee --- .../settings/employees_controller.rb | 11 ++++- app/models/employee.rb | 12 +++++ app/views/settings/employees/show.html.erb | 14 +++++- config/initializers/action_controller.rb | 44 +++++++++---------- config/locales/en.yml | 3 ++ config/routes.rb | 4 +- ..._add_app_id_and_auth_token_to_employees.rb | 9 ++++ 7 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 db/migrate/20200114053707_add_app_id_and_auth_token_to_employees.rb diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 448816f5..172ccd5e 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -1,6 +1,6 @@ class Settings::EmployeesController < ApplicationController load_and_authorize_resource - before_action :set_employee, only: [:show, :edit, :update, :destroy] + before_action :set_employee, only: [:show, :edit, :update, :destroy, :change_auth_token] # GET /employees @@ -38,6 +38,13 @@ class Settings::EmployeesController < ApplicationController format.html { render :new } end end + end + + def change_auth_token + @employee.auth_token = SecureRandom.hex(10) + @employee.save + flash[:notice] = 'Auth Token was successfully updated.' + redirect_to settings_employee_url(@employee) end # PATCH/PUT /employees/1 @@ -71,6 +78,6 @@ class Settings::EmployeesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def employee_params - params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path) + params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :auth_token) end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 420491af..69b41fd2 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,5 +1,6 @@ class Employee < ApplicationRecord has_secure_password + # has_secure_token :auth_token has_many :commissioners has_many :shit_sales has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale" @@ -11,6 +12,7 @@ class Employee < ApplicationRecord validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true + before_create :generate_app_id, :generate_auth_token #, if: Proc.new { self.role == "app" } # Employee Image Uploader mount_uploader :image_path, EmployeeImageUploader @@ -89,4 +91,14 @@ class Employee < ApplicationRecord return expiry_time end + + def generate_app_id + return if self.role != 'app' + self.app_id = SecureRandom.urlsafe_base64(nil, false) + end + + def generate_auth_token + return if self.role != 'app' + self.auth_token = SecureRandom.hex(10) + end end diff --git a/app/views/settings/employees/show.html.erb b/app/views/settings/employees/show.html.erb index 87707b22..b5508f1b 100755 --- a/app/views/settings/employees/show.html.erb +++ b/app/views/settings/employees/show.html.erb @@ -54,12 +54,24 @@ <%= t("views.right_panel.detail.employee_photo") %> <%= image_tag @employee.image_path, :size => '200x200'%> + <% if @employee.role == 'app' %> + + <%= t("views.right_panel.detail.employee_app_id") %> + <%= @employee.app_id %> + + + <%= t("views.right_panel.detail.employee_auth_token") %> + <%= @employee.auth_token %> + + <% end %> <%= link_to t("views.btn.edit"), edit_settings_employee_path(@employee),:class => 'btn btn-primary btn-lg waves-effect' %> + <% if @employee.role == 'app' %> + <%= link_to t("views.btn.change_auth_token"), settings_change_auth_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %> + <% end %> <%if @employee.role != "administrator"%> - diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 091abd33..b0bed108 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -4,28 +4,28 @@ class ActionController::Base private def lookup_domain - if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" - from = request.host - @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase - if (!@license.nil?) - logger.info "Location - " + @license.dbschema - ActiveRecord::Base.establish_connection(website_connection(@license)) - # authenticate_session_token - # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema - else - # reconnect_default_db - logger.info 'License is nil' - # redirect_to root_url(:host => request.domain) + "store_error" - render :json => [{ status: false, message: 'Invalid Access!'}] - end - else - # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end - end + # if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" + # from = request.host + # @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase + # if (!@license.nil?) + # logger.info "Location - " + @license.dbschema + # ActiveRecord::Base.establish_connection(website_connection(@license)) + # # authenticate_session_token + # # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema + # else + # # reconnect_default_db + # logger.info 'License is nil' + # # redirect_to root_url(:host => request.domain) + "store_error" + # render :json => [{ status: false, message: 'Invalid Access!'}] + # end + # else + # # check for license file + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end + # end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 36cf661c..68c7bc53 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -112,6 +112,7 @@ en: del: "DEL" clr: "CLR" assign: "ASSIGN" + change_auth_token: "Change Auth Token" print_order_summary: "Print Order Summary" memeber_card: "Member Card" @@ -678,6 +679,8 @@ en: edit_btn_txt: "to edit " delete_btn_txt: "to delete " update_btn_txt: "to update " + employee_app_id: "App ID" + employee_auth_token: "Auth Token" helpers: page_entries_info: diff --git a/config/routes.rb b/config/routes.rb index cdb0901d..0ba5e788 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -432,7 +432,9 @@ scope "(:locale)", locale: /en|mm/ do resources :display_images end #employees - resources :employees + resources :employees + get '/:id/change_auth_token' => 'employees#change_auth_token', as: 'change_auth_token' + #menu resources :menus do collection do diff --git a/db/migrate/20200114053707_add_app_id_and_auth_token_to_employees.rb b/db/migrate/20200114053707_add_app_id_and_auth_token_to_employees.rb new file mode 100644 index 00000000..a76b895e --- /dev/null +++ b/db/migrate/20200114053707_add_app_id_and_auth_token_to_employees.rb @@ -0,0 +1,9 @@ +class AddAppIdAndAuthTokenToEmployees < ActiveRecord::Migration[5.1] + def change + add_column :employees, :app_id, :string, unique: true + add_column :employees, :auth_token, :string, unique: true + + add_index :employees, :app_id + add_index :employees, :auth_token + end +end From dda9f9d04c4f5ae478e3123d4495f137533b2cc2 Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Tue, 14 Jan 2020 15:14:20 +0630 Subject: [PATCH 13/18] . --- app/controllers/origami/payments_controller.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index af1e57e6..a5b38db2 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -192,11 +192,7 @@ class Origami::PaymentsController < BaseOrigamiController end #card_balance amount for Paymal payment -<<<<<<< HEAD card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) -======= - card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) ->>>>>>> 60af9124bb181c662358624e1e6fbee1be36a2bb # get printer info print_settings = PrintSetting.find_by_unique_code(unique_code) From 37ff82ae5d2cbb46ae02deac9937cf8f2258b697 Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Tue, 14 Jan 2020 15:34:02 +0630 Subject: [PATCH 14/18] modify generate auth token method --- app/models/employee.rb | 2 ++ config/initializers/action_controller.rb | 44 ++++++++++++------------ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/models/employee.rb b/app/models/employee.rb index 69b41fd2..907aa9ad 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -100,5 +100,7 @@ class Employee < ApplicationRecord def generate_auth_token return if self.role != 'app' self.auth_token = SecureRandom.hex(10) + rescue ActiveRecord::RecordNotUnique + retry end end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index b0bed108..091abd33 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -4,28 +4,28 @@ class ActionController::Base private def lookup_domain - # if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" - # from = request.host - # @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase - # if (!@license.nil?) - # logger.info "Location - " + @license.dbschema - # ActiveRecord::Base.establish_connection(website_connection(@license)) - # # authenticate_session_token - # # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema - # else - # # reconnect_default_db - # logger.info 'License is nil' - # # redirect_to root_url(:host => request.domain) + "store_error" - # render :json => [{ status: false, message: 'Invalid Access!'}] - # end - # else - # # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end - # end + if request.subdomains.last && request.subdomains.last != "www" && ENV["SERVER_CODE"] = "cloud" + from = request.host + @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase + if (!@license.nil?) + logger.info "Location - " + @license.dbschema + ActiveRecord::Base.establish_connection(website_connection(@license)) + # authenticate_session_token + # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema + else + # reconnect_default_db + logger.info 'License is nil' + # redirect_to root_url(:host => request.domain) + "store_error" + render :json => [{ status: false, message: 'Invalid Access!'}] + end + else + # check for license file + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end + end end From 406a18d1d6b67b7b066502580dd7e660e695f686 Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Tue, 14 Jan 2020 15:47:27 +0630 Subject: [PATCH 15/18] . --- app/controllers/settings/employees_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 172ccd5e..fd5fd796 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -41,7 +41,7 @@ class Settings::EmployeesController < ApplicationController end def change_auth_token - @employee.auth_token = SecureRandom.hex(10) + @employee.auth_token = @employee.generate_auth_token #SecureRandom.hex(10) @employee.save flash[:notice] = 'Auth Token was successfully updated.' redirect_to settings_employee_url(@employee) From 93928aedd509f9b6f328c1886bcf0f7cb4fd66a0 Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Tue, 14 Jan 2020 17:23:52 +0630 Subject: [PATCH 16/18] change cloumn auth_token to app_token in employees --- app/controllers/settings/employees_controller.rb | 6 +++--- app/models/employee.rb | 12 +++++++----- app/views/settings/employees/show.html.erb | 10 +++++----- config/locales/en.yml | 4 ++-- config/routes.rb | 2 +- ...14103715_change_column_auth_token_to_app_token.rb | 5 +++++ 6 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20200114103715_change_column_auth_token_to_app_token.rb diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index fd5fd796..bcbec6ff 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -40,8 +40,8 @@ class Settings::EmployeesController < ApplicationController end end - def change_auth_token - @employee.auth_token = @employee.generate_auth_token #SecureRandom.hex(10) + def change_app_token + @employee.app_token = @employee.generate_app_token #SecureRandom.hex(10) @employee.save flash[:notice] = 'Auth Token was successfully updated.' redirect_to settings_employee_url(@employee) @@ -78,6 +78,6 @@ class Settings::EmployeesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def employee_params - params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :auth_token) + params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path, :app_id, :app_token) end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 907aa9ad..9d18c6c6 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -12,7 +12,7 @@ class Employee < ApplicationRecord validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true - before_create :generate_app_id, :generate_auth_token #, if: Proc.new { self.role == "app" } + before_create :generate_app_id, :generate_app_token , if: Proc.new { self.role == "application" } # Employee Image Uploader mount_uploader :image_path, EmployeeImageUploader @@ -93,13 +93,15 @@ class Employee < ApplicationRecord end def generate_app_id - return if self.role != 'app' + # return if self.role != 'application' self.app_id = SecureRandom.urlsafe_base64(nil, false) + rescue ActiveRecord::RecordNotUnique + retry end - def generate_auth_token - return if self.role != 'app' - self.auth_token = SecureRandom.hex(10) + def generate_app_token + # return if self.role != 'application' + self.app_token = SecureRandom.hex(10) rescue ActiveRecord::RecordNotUnique retry end diff --git a/app/views/settings/employees/show.html.erb b/app/views/settings/employees/show.html.erb index b5508f1b..807dc54a 100755 --- a/app/views/settings/employees/show.html.erb +++ b/app/views/settings/employees/show.html.erb @@ -54,22 +54,22 @@ <%= t("views.right_panel.detail.employee_photo") %> <%= image_tag @employee.image_path, :size => '200x200'%> - <% if @employee.role == 'app' %> + <% if @employee.role == 'application' %> <%= t("views.right_panel.detail.employee_app_id") %> <%= @employee.app_id %> - <%= t("views.right_panel.detail.employee_auth_token") %> - <%= @employee.auth_token %> + <%= t("views.right_panel.detail.employee_app_token") %> + <%= @employee.app_token %> <% end %> <%= link_to t("views.btn.edit"), edit_settings_employee_path(@employee),:class => 'btn btn-primary btn-lg waves-effect' %> - <% if @employee.role == 'app' %> - <%= link_to t("views.btn.change_auth_token"), settings_change_auth_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %> + <% if @employee.role == 'application' %> + <%= link_to t("views.btn.change_app_token"), settings_change_app_token_url(id: @employee.id), class: 'btn btn-primary btn-lg waves-effect' %> <% end %> <%if @employee.role != "administrator"%>
- <% if current_login_employee.role !='foodcourt_cashier' %> + <%food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")%> + <% if !food_court %>