update seed generator and remove hard-coded customer id
This commit is contained in:
@@ -193,7 +193,7 @@ $(document).ready(function(){
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale = $(".selected-item").find(".orders-id").text().substr(0,16);
|
||||
if (sale.substring(0, 3)=="SAL") {
|
||||
if (sale.includes("SAL")) {
|
||||
var sale_id = sale
|
||||
}else{
|
||||
var sale_id = $(".selected-item").find(".order-cid").text();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
|
||||
include MultiTenancy
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
include ActionView::Rendering
|
||||
include Customers
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
@@ -140,7 +140,7 @@ class Api::BillController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = "cashier"
|
||||
@order.order_type = "Takeaway"
|
||||
@order.customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
@order.customer_id = takeaway.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
|
||||
@@ -93,7 +93,7 @@ class Api::OrdersController < Api::ApiController
|
||||
@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.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
include Customers
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "CRM"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseInventoryController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "inventory"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseOqsController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class BaseOrigamiController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
include Customers
|
||||
|
||||
layout "origami"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseWaiterController < ActionController::Base
|
||||
|
||||
include MultiTenancy
|
||||
include LoginVerification
|
||||
layout "waiter"
|
||||
|
||||
18
app/controllers/concerns/customers.rb
Normal file
18
app/controllers/concerns/customers.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Customers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
helper_method :walkin, :takeaway if respond_to? :helper_method
|
||||
end
|
||||
|
||||
def walkin
|
||||
return @walkin if defined? @walkin
|
||||
@walkin = Customer.walkin
|
||||
end
|
||||
|
||||
def takeaway
|
||||
return @takeaway if defined? @takeaway
|
||||
@takeaway = Customer.takeaway
|
||||
end
|
||||
|
||||
end
|
||||
@@ -82,8 +82,9 @@ class Crm::CustomersController < BaseCrmController
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
|
||||
# @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")
|
||||
|
||||
@filter = filter
|
||||
|
||||
@@ -619,4 +620,3 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -126,9 +126,9 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
}
|
||||
# begin
|
||||
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
|
||||
customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
customer_id = takeaway.customer_id # for no customer id from mobile
|
||||
else
|
||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
end
|
||||
|
||||
Order.transaction do
|
||||
|
||||
@@ -55,7 +55,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
@page = params[:dir_page]
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
if @sale_id.include? "SAL"
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@@ -117,7 +117,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
id = params[:sale_id]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
order_source = params[:type]
|
||||
@@ -129,7 +129,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
if(id == "SAL")
|
||||
if id.include? "SAL"
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: customer_id)
|
||||
sale.sale_orders.each do |sale_order|
|
||||
@@ -153,7 +153,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
if id.include? "SAL"
|
||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
|
||||
@@ -49,7 +49,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
if params[:id].include? "BKI"
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
@@ -106,7 +106,7 @@ class Origami::FoodCourtController < ApplicationController
|
||||
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.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.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
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
class Origami::HomeController < ApplicationController
|
||||
def index
|
||||
if params[:booking_id] != nil
|
||||
type=params[:booking_id].split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
if params[:booking_id].include? "SAL"
|
||||
@selected_item = Sale.find(params[:booking_id])
|
||||
@selected_item_type="Sale"
|
||||
# Booking
|
||||
@@ -25,9 +24,8 @@ class Origami::HomeController < ApplicationController
|
||||
|
||||
def selection(selected_id, is_ajax)
|
||||
str = []
|
||||
type=selected_id.split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
if selected_id.include? "SAL"
|
||||
@order_details = SaleItem.get_order_items_details(params[:booking_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
@@ -48,9 +46,7 @@ class Origami::HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
if(id == "SAL")
|
||||
if id.inlude? "SAL"
|
||||
sale = Sale.find(params[:sale_id])
|
||||
else
|
||||
sale = Order.find(params[:sale_id])
|
||||
|
||||
@@ -295,7 +295,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
@shop = shop_detail #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
id = params[:sale_id]
|
||||
if id.start_with?("SAL")
|
||||
if id.include? "SAL"
|
||||
@sale = Sale.find(id)
|
||||
if @sale.sale_status == "new"
|
||||
@bookings = @sale.bookings.first
|
||||
@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
else
|
||||
redirect_to "/origami/#{params[:type]}" and return
|
||||
end
|
||||
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
|
||||
elsif id.include? "BKI"
|
||||
@bookings = Booking.find(id)
|
||||
@order = @bookings.orders.where(status: "new").first
|
||||
@order_items = @bookings.order_items
|
||||
|
||||
@@ -42,7 +42,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
if(params[:id][0,3] == "BKI")
|
||||
if params[:id].include? "BKI"
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
@@ -99,7 +99,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
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.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class Origami::RoomInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
puts "room bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@room.bookings.each do |booking|
|
||||
puts booking.sale_id
|
||||
|
||||
@@ -9,7 +9,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
if @id.include? "SAL"
|
||||
@sale = Sale.find(@id)
|
||||
@receipt_no = @sale.receipt_no
|
||||
@grand_total = @sale.grand_total
|
||||
|
||||
@@ -2,7 +2,6 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop.current_shop
|
||||
puts "table bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
puts booking.sale_id
|
||||
|
||||
@@ -5,10 +5,10 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
super
|
||||
|
||||
return unless subclass.superclass == self
|
||||
return unless subclass.column_names.include? 'shop_id'
|
||||
return unless subclass.column_names.include? 'shop_code'
|
||||
|
||||
subclass.class_eval do
|
||||
acts_as_tenant(:shop)
|
||||
acts_as_tenant(:shop, foreign_key: 'shop_code', primary_key: 'shop_code')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,12 +11,20 @@ class Customer < ApplicationRecord
|
||||
|
||||
validates_presence_of :name, :contact_no, :email #,:card_no
|
||||
validates :contact_no, numericality: true #uniqueness: true,
|
||||
validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
|
||||
# validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
|
||||
# validates :card_no, uniqueness: true
|
||||
# validates :paypar_account_no, uniqueness: true
|
||||
|
||||
paginates_per 50
|
||||
|
||||
def self.walkin
|
||||
self.find_by(name: "WALK-IN")
|
||||
end
|
||||
|
||||
def self.takeaway
|
||||
self.find_by(name: "TAKEAWAY")
|
||||
end
|
||||
|
||||
def self.get_member_account(customer)
|
||||
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
|
||||
|
||||
@@ -186,7 +186,7 @@ class Order < ApplicationRecord
|
||||
end
|
||||
|
||||
def default_values
|
||||
self.customer = Customer.find(1) if self.customer_id.nil?
|
||||
self.customer = Customer.walkin if self.customer_id.nil?
|
||||
self.source = "emenu" if self.source.nil?
|
||||
self.order_type = "dine-in" if self.order_type.nil?
|
||||
end
|
||||
|
||||
@@ -1056,7 +1056,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
end
|
||||
|
||||
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_type,customer_id)
|
||||
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account_type, customer_id)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
@@ -1068,8 +1068,6 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_
|
||||
customer_id = customer_id.to_s
|
||||
customer_id[0] = ""
|
||||
customer_id = customer_id.chomp("]")
|
||||
else
|
||||
customer_id = '"CUS-000000000000"'
|
||||
end
|
||||
|
||||
query = self.get_staff_meal_query()
|
||||
|
||||
@@ -3,28 +3,44 @@ class SeedGenerator < ApplicationRecord
|
||||
def self.generate_id(model, prefix)
|
||||
model_name = self.get_model_name(model)
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
prefix = "C#{prefix}"
|
||||
prefix << 'C'
|
||||
else
|
||||
prefix << 'L'
|
||||
end
|
||||
|
||||
cur_val, next_val = self.update_seed(model_name)
|
||||
if shop = Shop.current_shop
|
||||
prefix << shop.shop_code
|
||||
end
|
||||
|
||||
padding_len = 15 - prefix.length
|
||||
saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust(padding_len,'0')
|
||||
return saleOrderId
|
||||
seed = self.update_seed(model_name)
|
||||
length = 15 - prefix.length
|
||||
prefix + seed.to_s.rjust(padding_len, '0')
|
||||
end
|
||||
|
||||
def self.generate_ids(model, prefix, count = 1)
|
||||
model_name = self.get_model_name(model)
|
||||
|
||||
prefix ||= ''
|
||||
prefix << '-' if prefix.present?
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
prefix = "C#{prefix}"
|
||||
prefix << 'C'
|
||||
else
|
||||
prefix << 'L'
|
||||
end
|
||||
|
||||
if shop = Shop.current_shop
|
||||
prefix << shop.shop_code
|
||||
end
|
||||
|
||||
start = self.update_seed(model_name, count)
|
||||
stop = start + count - 1
|
||||
length = 15 - prefix.length
|
||||
(start..stop).map { |c| "#{prefix}-#{c.to_s.rjust(length, '0')}" }
|
||||
(start..stop).map { |c| prefix + c.to_s.rjust(length, '0') }
|
||||
end
|
||||
|
||||
def self.sync_seed_generator_records(seed_generators)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class TaxProfile < ApplicationRecord
|
||||
has_one :lookup, -> { where(lookup_type: 'tax_profiles') }, foreign_key: "value", primary_key: "group_type"
|
||||
|
||||
default_scope { order('order_by asc') }
|
||||
# validations
|
||||
validates_presence_of :name, :rate, :group_type
|
||||
|
||||
@@ -267,11 +267,11 @@
|
||||
</tr>
|
||||
</table>
|
||||
<% if type && modify_order%>
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="<%= walkin.customer_id %>">
|
||||
|
||||
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
|
||||
<%elsif !modify_order && type%>
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
||||
<input type="hidden" name="customer_id" id="customer_id" value="<%= walkin.customer_id %>">
|
||||
<% if current_user.role != "waiter"%>
|
||||
|
||||
<% if @quick_service_only %>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||
<td>
|
||||
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
|
||||
<% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %>
|
||||
<%= @i += 1 %>
|
||||
<%else%>
|
||||
-
|
||||
@@ -734,4 +734,3 @@
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1686,9 +1686,8 @@ $(document).ready(function(){
|
||||
$("#customer_name").on("click",function(){
|
||||
//start customer modal popup
|
||||
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
|
||||
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
|
||||
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
||||
// }
|
||||
|
||||
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user