From b0f6368248aad0d245f0ec3c8250ce932a0344b6 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 5 Dec 2019 14:56:47 +0630 Subject: [PATCH] shop_code --- app/controllers/foodcourt/dashboard_controller.rb | 2 +- app/controllers/foodcourt/surveys_controller.rb | 2 ++ app/controllers/foodcourt/waste_spoile_controller.rb | 2 +- app/controllers/inventory/inventory_controller.rb | 2 +- app/controllers/oqs/home_controller.rb | 1 + app/controllers/origami/cash_ins_controller.rb | 1 + app/controllers/origami/cash_outs_controller.rb | 1 + app/controllers/origami/credit_payments_controller.rb | 5 +++-- app/controllers/origami/customers_controller.rb | 4 +++- app/controllers/origami/dashboard_controller.rb | 2 +- app/controllers/origami/discounts_controller.rb | 1 + app/controllers/origami/food_court_controller.rb | 1 + app/controllers/origami/home_controller.rb | 2 ++ app/controllers/origami/order_reservation_controller.rb | 3 +++ app/controllers/origami/pending_order_controller.rb | 4 ++++ app/controllers/origami/request_bills_controller.rb | 1 + app/controllers/origami/rooms_controller.rb | 3 ++- app/controllers/origami/shifts_controller.rb | 1 + app/controllers/origami/split_bill_controller.rb | 1 + app/controllers/origami/surveys_controller.rb | 2 ++ app/controllers/origami/table_invoices_controller.rb | 4 ++-- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/waste_spoile_controller.rb | 2 +- app/controllers/reports/commission_controller.rb | 2 ++ app/controllers/reports/credit_payment_controller.rb | 2 ++ app/controllers/reports/dailysale_controller.rb | 1 + app/controllers/reports/hourly_saleitem_controller.rb | 3 ++- app/controllers/reports/induty_controller.rb | 2 ++ app/controllers/reports/order_reservation_controller.rb | 2 ++ app/controllers/reports/payment_method_controller.rb | 3 ++- app/controllers/reports/receipt_no_controller.rb | 3 +++ app/controllers/reports/receipt_no_detail_controller.rb | 2 ++ app/controllers/reports/saleitem_controller.rb | 4 +++- app/controllers/reports/shiftsale_controller.rb | 4 +++- app/controllers/reports/staff_meal_controller.rb | 2 +- app/controllers/reports/stock_check_controller.rb | 2 ++ app/controllers/reports/void_sale_controller.rb | 6 +++--- app/controllers/reports/waste_and_spoilage_controller.rb | 1 + app/controllers/settings/accounts_controller.rb | 2 ++ app/controllers/settings/cashier_terminals_controller.rb | 1 + app/controllers/settings/commissioners_controller.rb | 1 + app/controllers/settings/commissions_controller.rb | 1 + app/controllers/settings/membership_actions_controller.rb | 1 + app/controllers/settings/membership_settings_controller.rb | 1 + app/controllers/settings/menus_controller.rb | 3 +++ app/controllers/settings/order_queue_stations_controller.rb | 1 + app/controllers/settings/products_controller.rb | 2 +- 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 | 2 ++ app/controllers/transactions/credit_notes_controller.rb | 1 + .../transactions/order_reservations_controller.rb | 1 + app/controllers/transactions/orders_controller.rb | 2 +- app/controllers/transactions/shift_sales_controller.rb | 3 ++- app/controllers/transactions/surveys_controller.rb | 1 + app/models/sale_payment.rb | 6 +++--- 58 files changed, 95 insertions(+), 26 deletions(-) diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb index 23c905b7..de47ecf4 100644 --- a/app/controllers/foodcourt/dashboard_controller.rb +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -109,7 +109,7 @@ def get_all_menu end def get_credit_sales - credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code) + credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code) if !credit_sales.nil? result = {:status=> true, :data=> credit_sales } else diff --git a/app/controllers/foodcourt/surveys_controller.rb b/app/controllers/foodcourt/surveys_controller.rb index 363bc6ba..bfdd30f6 100644 --- a/app/controllers/foodcourt/surveys_controller.rb +++ b/app/controllers/foodcourt/surveys_controller.rb @@ -1,5 +1,6 @@ class Foodcourt::SurveysController < BaseFoodcourtController def new + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -38,6 +39,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController end def create + @shop = Shop.current_shop @type = params[:cashier_type] @sale_id = params[:sale_id] if params[:table_id].to_i>0 diff --git a/app/controllers/foodcourt/waste_spoile_controller.rb b/app/controllers/foodcourt/waste_spoile_controller.rb index d7847b27..bcc29f6a 100755 --- a/app/controllers/foodcourt/waste_spoile_controller.rb +++ b/app/controllers/foodcourt/waste_spoile_controller.rb @@ -1,6 +1,6 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController def waste_and_spoilage - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index e06e2341..fa5cffc6 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -21,7 +21,7 @@ class Inventory::InventoryController < BaseInventoryController #Shop Name in Navbor helper_method :shop_detail - + def shop_detail @shop = Shop.current_shop end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index c89f6e0a..abbe2295 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,6 +1,7 @@ class Oqs::HomeController < BaseOqsController authorize_resource :class => false def index + @shop = Shop.current_shop # Query for OQS with delivery status false # @queue_items_details = queue_items_query(false) diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index ac3c0648..fa0fcfc7 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -3,6 +3,7 @@ class Origami::CashInsController < BaseOrigamiController end def create + @shop = Shop.current_shop reference = params[:reference] remark = params[:remark] amount = params[:amount] diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index e576bfc5..e714ff22 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -3,6 +3,7 @@ class Origami::CashOutsController < BaseOrigamiController end def create + @shop = Shop.current_shop reference = params[:reference] remark = params[:remark] amount = params[:amount] diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 564945f5..cd83a346 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -9,7 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController @creditcount = 0 others = 0 - @shop = Shop.current_shop + @shop = Shop.current_shop if @shop.is_rounding_adj new_total = Sale.get_rounding_adjustment(sale_data.grand_total) else @@ -33,7 +33,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) - shop_details = Shop.current_shop + shop_details = Shop.current_shop # rounding adjustment # if shop_details.is_rounding_adj # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) @@ -49,6 +49,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController end def create_credit_payment + @shop = Shop.current_shop arr_sale = JSON.parse(params[:data]) if !ShiftSale.current_shift(@shop.shop_code).nil? if !arr_sale.nil? diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index b812605b..5c536815 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -46,6 +46,7 @@ class Origami::CustomersController < BaseOrigamiController end def add_customer + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -162,6 +163,7 @@ class Origami::CustomersController < BaseOrigamiController end def send_account + @shop = Shop.current_shop amount = params[:amount] account_no = params[:account_no] receipt_no = params[:receipt_no] @@ -178,7 +180,7 @@ class Origami::CustomersController < BaseOrigamiController auth_token = member_actions.auth_token.to_s membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no) puts membership_data.to_json - + if membership_data["status"]==true remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}" sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index bc01dc27..2a0c9a4f 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -114,7 +114,7 @@ def get_all_menu end def get_credit_sales - credit_sales = SalePayment.get_credit_sales(params,current_shop.shop_code) + credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code) if !credit_sales.nil? result = {:status=> true, :data=> credit_sales } else diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 4d9f26f8..1de3f61c 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -3,6 +3,7 @@ class Origami::DiscountsController < BaseOrigamiController #discount page show from origami index with selected order def index + @shop = Shop.current_shop # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = false diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb index b44ac29b..fe1ad251 100644 --- a/app/controllers/origami/food_court_controller.rb +++ b/app/controllers/origami/food_court_controller.rb @@ -154,6 +154,7 @@ class Origami::FoodCourtController < ApplicationController end def get_all_product() + @shop = Shop.current_shop @product = Product..where("shop_code='#{@shop.shop_code}'") end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index b31e1a17..a977a2c2 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -3,6 +3,7 @@ class Origami::HomeController < BaseOrigamiController before_action :set_dining, only: [:show] def index + @shop = Shop.current_shop @webview = check_mobile @@ -19,6 +20,7 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show + @shop = Shop.current_shop # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 3e26e07a..79acf1c5 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -10,6 +10,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def update + @shop = Shop.current_shop @id = params[:order_id] @status = params[:status] min_type = params[:min_type] @@ -86,6 +87,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def send_status + @shop = Shop.current_shop order_reservation = OrderReservation.find_by_transaction_ref(params[:ref_no]) if !order_reservation.nil? if !ShiftSale.current_shift(@shop.shop_code).nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected') @@ -105,6 +107,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def check_receipt_bill + @shop = Shop.current_shop receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation") status = 0 diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index c6bdb2e7..689b2424 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -1,5 +1,6 @@ class Origami::PendingOrderController < BaseOrigamiController def index + @shop = Shop.current_shop # @dining= DiningFacility.where("status = 'occupied'") # @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d')) @cashier_type = params[:type] @@ -13,6 +14,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def show + @shop = Shop.current_shop id = params[:sale_id] if id.start_with?("SAL") @sale = Sale.find(id) @@ -43,6 +45,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def completed_sale + @shop = Shop.current_shop @cashier_type = params[:type] @sales = Sale.pending_sale(@cashier_type) @orders = Sale.pending_order(@cashier_type) @@ -78,6 +81,7 @@ class Origami::PendingOrderController < BaseOrigamiController end def credit_sale + @shop = Shop.current_shop @cashier_type = params[:type] @sales = Sale.pending_sale(@cashier_type) @orders = Sale.pending_order(@cashier_type) diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index a3cdf679..30126177 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -8,6 +8,7 @@ class Origami::RequestBillsController < ApplicationController end # Print Request Bill and add to sale tables def print + @shop = Shop.current_shop if !ShiftSale.current_shift(@shop.shop_code).nil? order_id = params[:id] # order_id order = Order.find(order_id) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 6f219691..a20bfb7c 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -13,12 +13,13 @@ class Origami::RoomsController < BaseOrigamiController end def show + @shop = Shop.current_shop @webview = false if check_mobile @webview = true end - + @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 15f0d2d9..1b6fd355 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -42,6 +42,7 @@ class Origami::ShiftsController < BaseOrigamiController def update_shift + @shop = Shop.current_shop closing_balance = params[:closing_balance] shift_id = params[:shift_id] @shift = ShiftSale.find_by_id(shift_id) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index b723af80..d43b4702 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -84,6 +84,7 @@ class Origami::SplitBillController < BaseOrigamiController end def create + @shop = Shop.current_shop cashier_type = params[:cashier_type] order_ids = params[:order_ids] arr_order_ids = nil diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index be8d6b1c..0312c2ef 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -1,5 +1,6 @@ class Origami::SurveysController < BaseOrigamiController def new + @shop = Shop.current_shop @webview = false if check_mobile @webview = true @@ -38,6 +39,7 @@ class Origami::SurveysController < BaseOrigamiController end def create + @shop = Shop.current_shop @type = params[:cashier_type] @sale_id = params[:sale_id] if params[:table_id].to_i>0 diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 3605d8e6..5cf20f30 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -2,7 +2,7 @@ class Origami::TableInvoicesController < BaseOrigamiController def index @table = DiningFacility.find(params[:table_id]) - shop = Shop.current_shop + @shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| @@ -33,7 +33,7 @@ class Origami::TableInvoicesController < BaseOrigamiController @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - shop = Shop.current_shop + @shop = Shop.current_shop @sale_array = Array.new @table.bookings.each do |booking| if booking.sale_id.nil? diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index a4fd46d1..1a041638 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -1,7 +1,7 @@ class Origami::VoidController < BaseOrigamiController authorize_resource :class => false def overall_void - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] #tax profile source diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 18391443..68a29b8a 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -1,6 +1,6 @@ class Origami::WasteSpoileController < BaseOrigamiController def waste_and_spoilage - + @shop = Shop.current_shop sale_id = params[:sale_id] remark = params[:remark] order_source = params[:type] diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb index b30299d2..9d855cea 100755 --- a/app/controllers/reports/commission_controller.rb +++ b/app/controllers/reports/commission_controller.rb @@ -2,6 +2,7 @@ class Reports::CommissionController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop from_date, to_date = get_date_range_from_params commissioner = params[:commissioner].to_i @@ -21,6 +22,7 @@ class Reports::CommissionController < BaseReportController end def show + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index c1c16623..fc3b77cf 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -1,6 +1,7 @@ class Reports::CreditPaymentController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']] @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] from, to = get_date_range_from_params @@ -42,6 +43,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index a4fac509..44ee4bf0 100755 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -2,6 +2,7 @@ class Reports::DailysaleController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop from, to = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to,@shop.shop_code) @tax = SaleTax.get_tax(from,to,@shop.shop_code) diff --git a/app/controllers/reports/hourly_saleitem_controller.rb b/app/controllers/reports/hourly_saleitem_controller.rb index 97264236..0bc57168 100644 --- a/app/controllers/reports/hourly_saleitem_controller.rb +++ b/app/controllers/reports/hourly_saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::HourlySaleitemController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -65,6 +65,7 @@ class Reports::HourlySaleitemController < BaseReportController end def show + @shop = Shop.current_shop from, to, report_type = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) sale_data = @sale_data diff --git a/app/controllers/reports/induty_controller.rb b/app/controllers/reports/induty_controller.rb index efc821a7..d02b1378 100644 --- a/app/controllers/reports/induty_controller.rb +++ b/app/controllers/reports/induty_controller.rb @@ -1,6 +1,7 @@ class Reports::IndutyController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'") from, to = get_date_range_from_params @@ -41,6 +42,7 @@ class Reports::IndutyController < BaseReportController end def show + @shop = Shop.current_shop from, to = get_date_range_from_params @induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb index 4625c1f1..1fa7ac50 100644 --- a/app/controllers/reports/order_reservation_controller.rb +++ b/app/controllers/reports/order_reservation_controller.rb @@ -1,6 +1,7 @@ class Reports::OrderReservationController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop @providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["TURBO","turbo"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]] @payment_types = [["All",''], ["COD","cash_on_delivery"],["DINGA","dinga"]] @@ -47,6 +48,7 @@ class Reports::OrderReservationController < BaseReportController end def show + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 7b51131a..1c1900bc 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -1,7 +1,7 @@ class Reports::PaymentMethodController < BaseReportController # authorize_resource :class => false def index - + @shop = Shop.current_shop @payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"], @@ -42,6 +42,7 @@ class Reports::PaymentMethodController < BaseReportController end def show + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 3a5848d4..0b590421 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,6 +1,7 @@ class Reports::ReceiptNoController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -53,6 +54,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop 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}'") @@ -76,6 +78,7 @@ authorize_resource :class => false end def sync_data + @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales = Booking.get_sync_data(params[:sale_id]) # Here comes to call the sync api diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index 59bf70c5..ebadb2cf 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -1,6 +1,7 @@ class Reports::ReceiptNoDetailController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -48,6 +49,7 @@ authorize_resource :class => false end def show + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 57680e07..bc2ba6c9 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::SaleitemController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params @@ -60,6 +60,7 @@ class Reports::SaleitemController < BaseReportController end def show + @shop = Shop.current_shop 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}'") @@ -85,6 +86,7 @@ class Reports::SaleitemController < BaseReportController end def print_sale_items + @shop = Shop.current_shop from, to = get_date_range_from_params shift_sale_range = '' diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 5f842790..504ad815 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -2,7 +2,7 @@ class Reports::ShiftsaleController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop from, to = get_date_range_from_params @shift = '' if params[:shift_name].to_i != 0 @@ -26,6 +26,7 @@ class Reports::ShiftsaleController < BaseReportController end def show + @shop = Shop.current_shop 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}'") @@ -49,6 +50,7 @@ class Reports::ShiftsaleController < BaseReportController end def print_close_receipt + @shop = Shop.current_shop shift_id = params[:id] @shift = ShiftSale.find_by_id(shift_id) shift_obj = ShiftSale.where('id =?',shift_id) diff --git a/app/controllers/reports/staff_meal_controller.rb b/app/controllers/reports/staff_meal_controller.rb index 7049ec27..b047d729 100644 --- a/app/controllers/reports/staff_meal_controller.rb +++ b/app/controllers/reports/staff_meal_controller.rb @@ -1,7 +1,7 @@ class Reports::StaffMealController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop @account = Account.where("shop_code='#{@shop.shop_code}'") from, to = get_date_range_from_params diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index 6b6d88d6..a3e86f81 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -2,6 +2,7 @@ class Reports::StockCheckController < BaseReportController # authorize_resource :class => false def index + @shop = Shop.current_shop # from_date = DateTime.now.beginning_of_day.utc.getlocal # to_date = DateTime.now.end_of_day.utc.getlocal # unless params[:daterange].blank? @@ -25,6 +26,7 @@ class Reports::StockCheckController < BaseReportController end def show + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index c31b030a..f318adb9 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -1,7 +1,7 @@ class Reports::VoidSaleController < BaseReportController authorize_resource :class => false def index - + @shop = Shop.current_shop from, to = get_date_range_from_params # @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) @@ -9,10 +9,10 @@ authorize_resource :class => false if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#@shop.shop_code' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end diff --git a/app/controllers/reports/waste_and_spoilage_controller.rb b/app/controllers/reports/waste_and_spoilage_controller.rb index ccf8a47f..882218e7 100755 --- a/app/controllers/reports/waste_and_spoilage_controller.rb +++ b/app/controllers/reports/waste_and_spoilage_controller.rb @@ -1,6 +1,7 @@ class Reports::WasteAndSpoilageController < BaseReportController authorize_resource :class => false def index + @shop = Shop.current_shop 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}'") diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index d46ba093..b78038b6 100755 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -5,6 +5,7 @@ class Settings::AccountsController < ApplicationController # GET /settings/accounts # GET /settings/accounts.json def index + @shop = Shop.current_shop @settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'") end @@ -25,6 +26,7 @@ class Settings::AccountsController < ApplicationController # POST /settings/accounts # POST /settings/accounts.json def create + @shop = Shop.current_shop @settings_account = Account.new(account_params) @settings_account.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index 987674d5..7bd3bfc6 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -27,6 +27,7 @@ class Settings::CashierTerminalsController < ApplicationController # POST /settings/cashier_terminals # POST /settings/cashier_terminals.json def create + @shop = Shop.current_shop @settings_cashier_terminal = CashierTerminal.new(settings_cashier_terminal_params) @settings_cashier_terminal.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/commissioners_controller.rb b/app/controllers/settings/commissioners_controller.rb index 54a9e926..f3e506d1 100755 --- a/app/controllers/settings/commissioners_controller.rb +++ b/app/controllers/settings/commissioners_controller.rb @@ -28,6 +28,7 @@ class Settings::CommissionersController < ApplicationController # POST /commissioners # POST /commissioners.json def create + @shop = Shop.current_shop @commissioner = Commissioner.new(commissioner_params) @commissioner.created_by = current_user.id @commissioner.shop_code = @shop.shop_code diff --git a/app/controllers/settings/commissions_controller.rb b/app/controllers/settings/commissions_controller.rb index 519074c7..0174a526 100755 --- a/app/controllers/settings/commissions_controller.rb +++ b/app/controllers/settings/commissions_controller.rb @@ -28,6 +28,7 @@ class Settings::CommissionsController < ApplicationController # POST /commissions # POST /commissions.json def create + @shop = Shop.current_shop @commission = Commission.new(commission_params) @commission.product_type = 'menu_item' @commission.product_code = "[]" diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index 0f1b8c93..fc79ad2c 100755 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -25,6 +25,7 @@ class Settings::MembershipActionsController < ApplicationController # POST /settings/membership_actions # POST /settings/membership_actions.json def create + @shop = Shop.current_shop @settings_membership_action = MembershipAction.new(settings_membership_action_params) @settings_membership_action.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb index 698c755c..61b4a648 100755 --- a/app/controllers/settings/membership_settings_controller.rb +++ b/app/controllers/settings/membership_settings_controller.rb @@ -25,6 +25,7 @@ class Settings::MembershipSettingsController < ApplicationController # POST /settings/membership_settings # POST /settings/membership_settings.json def create + @shop = Shop.current_shop @settings_membership_setting = MembershipSetting.new(settings_membership_setting_params) @settings_membership_setting.shop_code = @shop.shop_code respond_to do |format| diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index d7cb6b8a..449ae573 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -5,6 +5,7 @@ class Settings::MenusController < ApplicationController # GET /settings/menus # GET /settings/menus.json def index + @shop = Shop.current_shop @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) respond_to do |format| format.html @@ -30,6 +31,7 @@ class Settings::MenusController < ApplicationController # POST /settings/menus # POST /settings/menus.json def create + @shop = Shop.current_shop @settings_menu = Menu.new(settings_menu_params) @settings_menu.created_by = current_login_employee.name @settings_menu.shop_code = @shop.shop_code @@ -74,6 +76,7 @@ class Settings::MenusController < ApplicationController end def export + @shop = Shop.current_shop @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) menu = Menu.find(params[:id]) diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index d28bdd91..fba533ff 100755 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -29,6 +29,7 @@ class Settings::OrderQueueStationsController < ApplicationController # POST /settings/order_queue_stations # POST /settings/order_queue_stations.json def create + @shop = Shop.current_shop @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 = "[]" diff --git a/app/controllers/settings/products_controller.rb b/app/controllers/settings/products_controller.rb index b473a54e..a7955b22 100755 --- a/app/controllers/settings/products_controller.rb +++ b/app/controllers/settings/products_controller.rb @@ -26,7 +26,7 @@ load_and_authorize_resource except: [:create] # POST /settings/products # POST /settings/products.json def create - + @shop = Shop.current_shop @settings_product = Product.new(settings_product_params) @settings_product.created_by = current_user.name @settings_product.shop_code = @shop.shop_code diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 25b1b9d7..57ee2d6d 100755 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -28,6 +28,7 @@ class Settings::PromotionsController < ApplicationController # POST /promotions # POST /promotions.json def create + @shop = Shop.current_shop @promotion = Promotion.new(promotion_params) @promotion.created_by = current_login_employee.id @promotion.shop_code = @shop.shop_code diff --git a/app/controllers/settings/rooms_controller.rb b/app/controllers/settings/rooms_controller.rb index 5ba5c0ef..77d91885 100755 --- a/app/controllers/settings/rooms_controller.rb +++ b/app/controllers/settings/rooms_controller.rb @@ -25,6 +25,7 @@ class Settings::RoomsController < ApplicationController # POST /settings/rooms # POST /settings/rooms.json def create + @shop = Shop.current_shop @settings_room = Room.new(settings_room_params) @settings_room.type = DiningFacility::ROOM_TYPE @settings_room.zone_id = params[:zone_id] diff --git a/app/controllers/settings/tables_controller.rb b/app/controllers/settings/tables_controller.rb index 91f35eed..60b1ca59 100755 --- a/app/controllers/settings/tables_controller.rb +++ b/app/controllers/settings/tables_controller.rb @@ -25,6 +25,7 @@ class Settings::TablesController < ApplicationController # POST /settings/tables # POST /settings/tables.json def create + @shop = Shop.current_shop @settings_table = Table.new(settings_table_params) @settings_table.type = DiningFacility::TABLE_TYPE @settings_table.zone_id = params[:zone_id] diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 298d077d..112de9fc 100755 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -45,6 +45,7 @@ class Settings::TaxProfilesController < ApplicationController # POST /settings/tax_profiles # POST /settings/tax_profiles.json def create + @shop = Shop.current_shop @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 diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 22b5165d..fcad9b8d 100755 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -5,6 +5,7 @@ class Settings::ZonesController < ApplicationController # GET /settings/zones # GET /settings/zones.json def index + @shop = Shop.current_shop @settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") end @@ -27,6 +28,7 @@ class Settings::ZonesController < ApplicationController # POST /settings/zones # POST /settings/zones.json def create + @shop = Shop.current_shop @settings_zone = Zone.new(settings_zone_params) @settings_zone.shop_code =@shop.shop_code @settings_zone.created_by = current_login_employee.name diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 4042091b..6052e4b5 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -6,6 +6,7 @@ class Transactions::CreditNotesController < ApplicationController # GET /transactions/sales # GET /transactions/sales.json def index + @shop = Shop.current_shop @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] @customers = Customer.all diff --git a/app/controllers/transactions/order_reservations_controller.rb b/app/controllers/transactions/order_reservations_controller.rb index c59688e8..6a5c3c60 100644 --- a/app/controllers/transactions/order_reservations_controller.rb +++ b/app/controllers/transactions/order_reservations_controller.rb @@ -6,6 +6,7 @@ class Transactions::OrderReservationsController < ApplicationController # GET /transactions/order_reservations # GET /transactions/order_reservations.json def index + @shop = Shop.current_shop from, to = get_date_range_from_params filter = params[:filter] diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 30a82ac4..dbff1b43 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -3,7 +3,7 @@ class Transactions::OrdersController < ApplicationController before_action :check_user def index - + @shop = Shop.current_shop filter = params[:filter] from = params[:from] to = params[:to] diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb index 7e9684bb..00442a30 100644 --- a/app/controllers/transactions/shift_sales_controller.rb +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -4,6 +4,7 @@ class Transactions::ShiftSalesController < ApplicationController before_action :check_user def index + @shop = Shop.current_shop filter = params[:filter] from = params[:from] @@ -32,7 +33,7 @@ class Transactions::ShiftSalesController < ApplicationController # GET /transactions/shift_sales/1 # GET /transactions/shift_sales/1.json def show - + @shop = Shop.current_shop @shift = ShiftSale.find(params[:id]) #get tax diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index 6e75a9de..cc975810 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -1,5 +1,6 @@ class Transactions::SurveysController < ApplicationController def index + @shop = Shop.current_shop filter = params[:filter] from = params[:from] to = params[:to] diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index a111a2da..298fb1d2 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -329,7 +329,7 @@ class SalePayment < ApplicationRecord merchant_uid:merchant_uid, auth_token:auth_token}.to_json end - + # Control for Paypar Cloud begin response = HTTParty.post(url, @@ -957,14 +957,14 @@ class SalePayment < ApplicationRecord #credit payment query - def self.get_credit_sales(params) + def self.get_credit_sales(params,shop_code) payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount") .select("SUM(sale_payments.payment_amount) OVER (PARTITION BY sale_payments.sale_id) total_payment_amount") credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name") .select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name") .joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders) - .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount") + .completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount and sales.shop_code=?",shop_code) .group(:receipt_no) .order(:receipt_date).order(:receipt_no)