shop
This commit is contained in:
@@ -13,7 +13,8 @@ module MultiTenancy
|
||||
shop_code = request.subdomain.partition('-').last
|
||||
@shop = Shop.find_by(shop_code: shop_code)
|
||||
else
|
||||
@shop = Shop.first
|
||||
# @shop = Shop.first
|
||||
@shop = Shop.find_by(shop_code: '262')
|
||||
end
|
||||
set_current_tenant(@shop)
|
||||
end
|
||||
|
||||
@@ -130,7 +130,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
params[:type] = nil
|
||||
params[:customer_id] = params[:id]
|
||||
@credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
@credit_sales = SalePayment.get_credit_sales(params)
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(params[:id])
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
class Foodcourt::CashInsController < BaseFoodcourtController
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
payment_method = params[:payment_method]
|
||||
payment_method_reference = params[:payment_method_reference]
|
||||
type = params[:type]
|
||||
|
||||
p_jour = PaymentJournal.new
|
||||
|
||||
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
shift.cash_in = shift.cash_in + amount.to_f
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,39 +0,0 @@
|
||||
class Foodcourt::CashOutsController < BaseFoodcourtController
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_out(reference, remark, amount, current_user)
|
||||
shift = ShiftSale.current_open_shift(current_user)
|
||||
|
||||
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||
|
||||
# set cashier
|
||||
if shift != nil
|
||||
shift = shift
|
||||
else
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
if open_cashier.count>0
|
||||
|
||||
shift = ShiftSale.current_open_shift(open_cashier[0])
|
||||
|
||||
if shift
|
||||
emp = Employee.find_by_id(shift.employee_id)
|
||||
shift = ShiftSale.current_open_shift(emp)
|
||||
else
|
||||
shift = ShiftSale.current_open_shift(current_shift)
|
||||
end
|
||||
else
|
||||
# shift = Employee.find(current_shift.employee_id).name
|
||||
shift =current_shift
|
||||
end
|
||||
end
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,121 +1,18 @@
|
||||
class Foodcourt::DashboardController < BaseFoodcourtController
|
||||
|
||||
def index
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
|
||||
@display_type = Lookup.find_by_lookup_type("display_type")
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale(@shop,'card', today, current_user)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
else
|
||||
@sale_data = nil
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(@shop,today,current_user)
|
||||
@total_accounts = Sale.total_account(@shop,today,current_user)
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(@shop,account.account_id, today,current_user)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
else
|
||||
@account_data = nil
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(@shop,today,current_user)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
#dine-in cashier
|
||||
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
|
||||
@dinein_cashier = 0
|
||||
if !dinein_cashier[0].nil?
|
||||
@dinein_cashier = dinein_cashier[0][1]
|
||||
end
|
||||
|
||||
#quick service
|
||||
quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service')
|
||||
@quick_service = 0
|
||||
if !quick_service[0].nil?
|
||||
@quick_service = quick_service[0][1]
|
||||
end
|
||||
|
||||
#fourt court
|
||||
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
|
||||
@food_court = 0
|
||||
@food_court_name = nil
|
||||
if !food_court[0].nil?
|
||||
@food_court = food_court[0][1]
|
||||
@food_court_name = food_court[0][0]
|
||||
end
|
||||
|
||||
#order reservation
|
||||
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
|
||||
@order_reservation = 0
|
||||
if !order_reservation.empty?
|
||||
order_reservation.each do |order_reserve|
|
||||
if order_reserve[0] == 'OrderReservation'
|
||||
@order_reservation = order_reserve[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#dashboard settings on/off for supervisor and cashier
|
||||
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
|
||||
@setting_flag = true
|
||||
if !dashboard_settings.empty?
|
||||
dashboard_settings.each do |setting|
|
||||
if setting[0].to_s.downcase == current_user.role.downcase && setting[1] == '0'
|
||||
@setting_flag = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#reservation
|
||||
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
|
||||
@reservation = 0
|
||||
if !reservation.empty?
|
||||
reservation.each do |reserve|
|
||||
if reserve[0] == 'Reservation'
|
||||
@reservation = reserve[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
def get_all_menu
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.shop
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_all_menu
|
||||
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
result = {:status=> false, :message=>"There is no record." }
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
result = {:status=> false, :message=>"There is no record." }
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -42,12 +42,6 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
table = nil
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
# sale.save
|
||||
if discount_items.length > 0
|
||||
|
||||
#save sale item for discount
|
||||
@@ -56,14 +50,6 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
|
||||
sale_item = SaleItem.new
|
||||
|
||||
# if !origin_sale_item.nil?
|
||||
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
|
||||
# if !menu_category.nil?
|
||||
# sale_item.menu_category_code = menu_category.code
|
||||
# sale_item.menu_category_name = menu_category.name
|
||||
# end
|
||||
# end
|
||||
|
||||
sale_item.menu_category_code = origin_sale_item.menu_category_code
|
||||
sale_item.menu_category_name = origin_sale_item.menu_category_name
|
||||
|
||||
@@ -153,9 +139,6 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
|
||||
@@ -10,17 +10,8 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all.where("is_active= true")
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@cashier_type = "food_court"
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
@@ -40,104 +31,9 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
||||
|
||||
render "foodcourt/addorders/detail"
|
||||
end
|
||||
|
||||
def modify_order
|
||||
@cashier_type = "food_court"
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
else
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = @booking.sale_id
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
|
||||
render "foodcourt/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
booking = Booking.find(params[:booking_id])
|
||||
sale = booking.sale
|
||||
if sale && sale.sale_status != 'new'
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
cashier_type = "food_court"
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"]
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
# begin
|
||||
order = Order.new
|
||||
order.source = params[:order_source]
|
||||
order.order_type = params[:order_type]
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.items = items_arr
|
||||
order.guest = params[:guest_info]
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
order.waiters = current_login_employee.name
|
||||
order.employee_name = current_login_employee.name
|
||||
|
||||
order.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
else
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
@@ -150,7 +46,6 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_menu_sub_category ()
|
||||
id = params[:id]
|
||||
if (id)
|
||||
@@ -173,35 +68,4 @@ class Foodcourt::FoodCourtController < ApplicationController
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -66,11 +66,12 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
@sale_data = Sale.find_by_sale_id(@booking.sale_id)
|
||||
end
|
||||
@bookings = Booking.select("bookings.*,customers.*")
|
||||
.joins(" JOIN sales ON bookings.sale_id=sales.sale_id")
|
||||
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||
.where("orders.source='app' and bookings.shop_code=? and DATE(bookings.created_at)=?",@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
|
||||
.where("sales.sale_status !=? and orders.source='app' and bookings.shop_code=? and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
|
||||
end
|
||||
def completed
|
||||
customer =Customer.find_by_customer_id(params[:customer_id])
|
||||
|
||||
@@ -15,7 +15,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
|
||||
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
|
||||
@@ -71,11 +71,12 @@ class Foodcourt::VoidController < BaseFoodcourtController
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" )
|
||||
|
||||
#call paymal to void
|
||||
if sale.sale_payments.nil?
|
||||
if !sale.sale_payments.nil?
|
||||
membership_response =sale.paymal_payment_void
|
||||
Rails.logger.debug "---------Paymal Payment Void response in VoidController"
|
||||
Rails.logger.debug membership_response.to_json
|
||||
end
|
||||
Rails.logger.debug "---------Paymal Payment Void response in VoidController"
|
||||
Rails.logger.debug membership_response.to_json
|
||||
|
||||
|
||||
# For Print
|
||||
member_info = nil
|
||||
|
||||
@@ -105,14 +105,14 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def get_all_menu
|
||||
|
||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
|
||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.shop
|
||||
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
end
|
||||
|
||||
def get_credit_sales
|
||||
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
|
||||
credit_sales = SalePayment.get_credit_sales(params)
|
||||
if !credit_sales.nil?
|
||||
result = {:status=> true, :data=> credit_sales }
|
||||
else
|
||||
|
||||
@@ -6,14 +6,14 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@webview = check_mobile
|
||||
|
||||
|
||||
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
|
||||
@tables = Table.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
|
||||
@occupied_table = DiningFacility.where("status='occupied'").shop.count
|
||||
@shift = ShiftSale.current_open_shift(current_user)
|
||||
end
|
||||
|
||||
@@ -24,8 +24,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@webview = check_mobile
|
||||
|
||||
|
||||
@tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
|
||||
@tables = Table.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@rooms = Room.unscope(:order).includes(:zone).shop.active.order('status desc')
|
||||
@complete = Sale.completed_sale("cashier")
|
||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code)
|
||||
@terminal = CashierTerminal.available
|
||||
end
|
||||
|
||||
|
||||
@@ -2,17 +2,15 @@ class Reports::DailysaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
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)
|
||||
@from = from
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code='#{@shop.shop_code}'").pluck("payment_method")
|
||||
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
from, to = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
@from = from
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code=?",@shop.shop_code).pluck("payment_method")
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class Transactions::BookingsController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@bookings = Booking.order("sale_id desc")
|
||||
@bookings = Booking.where("shop_code=?",@shop.shop_code).order("sale_id desc")
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
|
||||
else
|
||||
booking = Booking.search(filter,from,to)
|
||||
|
||||
@@ -6,7 +6,7 @@ class Transactions::CreditNotesController < ApplicationController
|
||||
# GET /transactions/sales
|
||||
# GET /transactions/sales.json
|
||||
def index
|
||||
|
||||
|
||||
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
|
||||
@customers = Customer.all
|
||||
|
||||
@@ -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) and sales.shop_code='#{@shop.shop_code}'")
|
||||
THEN NULL ELSE payment_method='creditnote' END)").shop
|
||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to,order_source).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to,order_source).shop
|
||||
if !sale.nil?
|
||||
@credit_notes = sale
|
||||
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||
|
||||
@@ -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'").order("sale_id desc")
|
||||
@sales = Sale.where("NOT sale_status='new'").shop.order("sale_id desc")
|
||||
else
|
||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
|
||||
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").shop.order("sale_id desc")
|
||||
end
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search(receipt_no,from,to,@shift)
|
||||
sale = Sale.search(receipt_no,from,to,@shift).shop
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
@@ -271,6 +271,10 @@ class Transactions::SalesController < ApplicationController
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
#call paymal to void
|
||||
if !sale.sale_payments.nil?
|
||||
membership_response =sale.paymal_payment_void
|
||||
end
|
||||
# No Need
|
||||
# bookings = sale.bookings
|
||||
# bookings.each do |booking|
|
||||
|
||||
Reference in New Issue
Block a user