update seed generator and remove hard-coded customer id

This commit is contained in:
Thein Lin Kyaw
2019-12-20 10:35:31 +06:30
parent 92e467d512
commit d87ffee65b
32 changed files with 184 additions and 153 deletions

View File

@@ -69,11 +69,11 @@ $(document).ready(function(){
type: "POST",
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
success:function(result){
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
var show_date = "";
var show_date = "";
// Receipt Header
receipt_no = result[i].receipt_no;
@@ -81,14 +81,14 @@ $(document).ready(function(){
if(result[i].receipt_date != null){
receipt_date = new Date(result[i].receipt_date);
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
}
}
//Receipt Charges
sub_total += parseFloat(parse_data.price);
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
grand_total_amount = parse_data.grand_total_amount;
// Ordered Items
var order_items_rows = "<tr>" +
@@ -135,7 +135,7 @@ $(document).ready(function(){
// Discount for Payment
$('#discount').click(function() {
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
if(order_id!=""){
window.location.href = '/origami/' + order_id + '/discount'
}
@@ -164,7 +164,7 @@ $(document).ready(function(){
}
// For Percentage Discount
if(discount_type == 1){
if(discount_type == 1){
discount_amount=(sub_total*discount_value)/100;
}
@@ -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();
@@ -205,7 +205,7 @@ $(document).ready(function(){
$('#re-print').click(function() {
var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16);
window.location.href = '/origami/'+ sale_id + "/reprint"
return false;

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -113,7 +113,7 @@ class Api::OrdersController < Api::ApiController
end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
end

View File

@@ -1,6 +1,7 @@
class ApplicationController < ActionController::Base
include MultiTenancy
include LoginVerification
include Customers
#before_action :check_installation
protect_from_forgery with: :exception

View File

@@ -1,5 +1,4 @@
class BaseCrmController < ActionController::Base
include MultiTenancy
include LoginVerification
layout "CRM"

View File

@@ -1,5 +1,4 @@
class BaseInventoryController < ActionController::Base
include MultiTenancy
include LoginVerification
layout "inventory"

View File

@@ -1,8 +1,7 @@
class BaseOqsController < ActionController::Base
include MultiTenancy
include LoginVerification
layout "OQS"
before_action :check_user

View File

@@ -1,7 +1,8 @@
class BaseOrigamiController < ActionController::Base
include MultiTenancy
include LoginVerification
include Customers
layout "origami"
before_action :check_user

View File

@@ -1,5 +1,4 @@
class BaseReportController < ActionController::Base
include MultiTenancy
include LoginVerification
layout "application"

View File

@@ -1,5 +1,4 @@
class BaseWaiterController < ActionController::Base
include MultiTenancy
include LoginVerification
layout "waiter"

View 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

View File

@@ -21,7 +21,7 @@ class Crm::CustomersController < BaseCrmController
# paymal_customer = Customer.search_paypar_account_no(filter)
# search account no from paypar
if type == "card"
response = Customer.search_paypar_account_no(filter)
if !@crm_customers.present?
if response["status"] == true
@@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
else
flash[:member_error]="Need to press sync button "
end
end
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
@@ -95,7 +96,7 @@ class Crm::CustomersController < BaseCrmController
lookup_customer = Lookup.collection_of('customer_settings')
if !lookup_customer.empty?
lookup_customer.each do |create_setting|
if create_setting[0].downcase == "create"
if create_setting[0].downcase == "create"
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
@create_flag = false
end
@@ -135,7 +136,7 @@ class Crm::CustomersController < BaseCrmController
params[:type] = nil
params[:customer_id] = params[:id]
@credit_sales = SalePayment.get_credit_sales(params)
#get customer amount
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)
@@ -159,7 +160,7 @@ class Crm::CustomersController < BaseCrmController
@customer = Customer.find(params[:id])
end
def sync
@customer = Customer.find(params[:id])
@customer = Customer.find(params[:id])
respond_to do |format|
name = @customer.name
phone = @customer.contact_no
@@ -170,8 +171,8 @@ class Crm::CustomersController < BaseCrmController
card_no = @customer.card_no
paypar_account_no = @customer.paypar_account_no
id = @crm_customer.membership_id
member_group_id = @customer.membership_type
if !id.present? && !member_group_id.nil?
member_group_id = @customer.membership_type
if !id.present? && !member_group_id.nil?
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
@@ -179,7 +180,7 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
id:id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
@@ -221,7 +222,7 @@ class Crm::CustomersController < BaseCrmController
Rails.logger.debug "--------Sync Member response -------"
Rails.logger.debug response.to_json
if response["status"] == true
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
format.html { redirect_to crm_customers_path }
@@ -252,9 +253,9 @@ class Crm::CustomersController < BaseCrmController
end
# POST /crm/customers
# POST /crm/customers.json
def create
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
def create
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
@checked_contact = Customer.find_by_contact_no(customer_params[:contact_no])
if @checked_contact.nil?
respond_to do |format|
@@ -272,7 +273,7 @@ class Crm::CustomersController < BaseCrmController
nrc = customer_params[:nrc_no]
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
member_group_id = params[:member_group_id]
member_group_id = params[:member_group_id]
if member_group_id.present?
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -282,7 +283,7 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
@@ -333,7 +334,7 @@ class Crm::CustomersController < BaseCrmController
end
# format.json { render :index, status: :created, location: @crm_customers }
else
customer = Customer.find(@crm_customers.customer_id)
customer = Customer.find(@crm_customers.customer_id)
# Check membership id and bind to user
if response["membership_id"] != nil
@@ -399,7 +400,7 @@ class Crm::CustomersController < BaseCrmController
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
# Remove "" default first
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
@checked_contact = nil
@existed_contact = Customer.find_by_customer_id_and_contact_no(customer_params[:id], customer_params[:contact_no])
@@ -409,7 +410,7 @@ class Crm::CustomersController < BaseCrmController
if !@existed_contact.nil? || @checked_contact.nil?
respond_to do |format|
if @crm_customer.update(customer_params)
# update tax profile
# update tax profile
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
@@ -420,7 +421,7 @@ class Crm::CustomersController < BaseCrmController
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
member_group_id = params[:member_group_id]
if !id.present? && !member_group_id.nil?
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -430,7 +431,7 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
id:id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
@@ -471,7 +472,7 @@ class Crm::CustomersController < BaseCrmController
Rails.logger.debug "--------Update Member response -------"
Rails.logger.debug response.to_json
if response["status"] == true
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
format.html { redirect_to crm_customers_path }
@@ -496,7 +497,7 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
id:id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
@@ -601,7 +602,7 @@ class Crm::CustomersController < BaseCrmController
flash[:member_notice]='Membership was successfully updated'
end
end
end
@@ -617,6 +618,5 @@ class Crm::CustomersController < BaseCrmController
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
end
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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])

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -2,14 +2,14 @@ class Origami::SurveysController < BaseOrigamiController
def new
@webview = false
if check_mobile
@webview = true
@webview = true
end
@survey = Survey.new
@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
@@ -27,14 +27,14 @@ class Origami::SurveysController < BaseOrigamiController
@dining_facility = nil
@table_type = nil
end
else
@dining_facility = DiningFacility.find(@id)
@table_type = @dining_facility.type
@receipt_no = nil
@grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
end
end
end
def create
@@ -63,13 +63,13 @@ class Origami::SurveysController < BaseOrigamiController
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
if @type == "quick_service" || @type == "food_court"
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
end
if params[:survey_id].nil? || params[:survey_id] == ""
@survey = Survey.new(survey_params)
@@ -106,5 +106,5 @@ class Origami::SurveysController < BaseOrigamiController
def survey_params
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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")
@@ -26,7 +34,7 @@ class Customer < ApplicationRecord
# urltest =self.url_exist?(url)
if !membership.nil? && !memberaction.nil?
begin
response = HTTParty.get(url, :body => {
response = HTTParty.get(url, :body => {
membership_id: customer.membership_id,
merchant_uid:merchant_uid,
type: "summary",
@@ -39,7 +47,7 @@ class Customer < ApplicationRecord
:timeout => 10)
rescue HTTParty::Error
response = {status: false, message: "Server Error"}
rescue Net::OpenTimeout
response = { status: false , message: "Server Time out"}
@@ -107,7 +115,7 @@ class Customer < ApplicationRecord
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
@customers.each do |customer|
member_params = { name: customer.name,phone: customer.contact_no,
@@ -125,7 +133,7 @@ class Customer < ApplicationRecord
paypar_account_no: customer.paypar_account_no,
card_no:customer.card_no,member_group_id: customer.membership_type,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
end
end
begin
response = HTTParty.post(url,
@@ -136,7 +144,7 @@ class Customer < ApplicationRecord
})
rescue Net::OpenTimeout
response = { status: false, message: "Server Time out" }
rescue OpenURI::HTTPError
response = { status: false, message: "Can't connect server"}
@@ -154,12 +162,12 @@ class Customer < ApplicationRecord
def self.update_rebate
sales = Sale.where("rebate_status = 'false'")
sales.each do |sale|
if sale.customer.membership_id
if sale.customer.membership_id
response = self.rebat(Sale.find(sale.sale_id))
#record an payment in sale-audit
if !response.nil?
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} "
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
end
if response["status"] == true
status = sale.update_attributes(rebate_status: "true")
@@ -172,7 +180,7 @@ class Customer < ApplicationRecord
rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
if generic_customer_id.present?
paypar = sObj.sale_payments
payparcost = 0
@@ -189,7 +197,7 @@ class Customer < ApplicationRecord
end
# overall_dis = SaleItem.get_overall_discount(sObj.id)
overall_dis = sObj.total_discount
if credit != 1
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
@@ -200,8 +208,8 @@ class Customer < ApplicationRecord
# Control for Paypar Cloud
begin
response = HTTParty.get(url,
:body => {
response = HTTParty.get(url,
:body => {
member_group_id:sObj.customer.membership_type,
merchant_uid:merchant_uid,
campaign_type_id: campaign_type_id,
@@ -215,7 +223,7 @@ class Customer < ApplicationRecord
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
@@ -232,7 +240,7 @@ class Customer < ApplicationRecord
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
end
end
@@ -249,7 +257,7 @@ class Customer < ApplicationRecord
actual = a[:amount] - amount
data[:amount] = actual
end
end
end
rebate_arr.push(data)
@@ -272,8 +280,8 @@ class Customer < ApplicationRecord
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => {
response = HTTParty.post(url,
:body => {
generic_customer_id:generic_customer_id ,
total_sale_transaction_amount: sObj.grand_total,
merchant_uid:merchant_uid,
@@ -291,7 +299,7 @@ class Customer < ApplicationRecord
response = { "status": false , "message": "Connect To" }
rescue OpenURI::HTTPError
response = { "status": false, "message": "Can't connect server"}
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
@@ -302,7 +310,7 @@ class Customer < ApplicationRecord
end
else
puts "no Response"
response = { "status": "no_member", "message": "Not membership"}
response = { "status": "no_member", "message": "Not membership"}
end
end
@@ -313,8 +321,8 @@ class Customer < ApplicationRecord
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.get(url,
:body => { paypar_account_no:account_no,
response = HTTParty.get(url,
:body => { paypar_account_no:account_no,
merchant_uid:merchant_uid,
auth_token:auth_token
}.to_json,

View File

@@ -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

View File

@@ -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()

View File

@@ -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)

View File

@@ -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

View File

@@ -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 %>

View File

@@ -22,7 +22,7 @@
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
<input type="hidden" name="type" id="type" value="">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
@@ -72,7 +72,7 @@
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
@@ -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%>
-
@@ -156,7 +156,7 @@
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="tab-content">
<div class="tab-pane active" role="tabpanel" id="step1">
<div class="form-group">
@@ -225,7 +225,7 @@
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
</div>
</div>
</div>
</div> <!-- .end-of-step1 -->
<div class="tab-pane" role="tabpanel" id="complete">
@@ -238,12 +238,12 @@
<% if f.object.image_path? %>
<p><%= f.object.name %></p>
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
<% else %>
<% else %>
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
<% end %>
<% end %>
</div>
<%= f.file_field :image_path, :class => "img-thumbnail" %>
</div>
</div>
</div>
</div>
<div class="form-group">
@@ -291,7 +291,7 @@
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</select>
</div>
</div>
@@ -316,7 +316,7 @@
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
<div class="-group">
<div class="-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
@@ -332,7 +332,7 @@
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</select>
</div>
</div>
<div class="form-group">
@@ -363,7 +363,7 @@
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
var page = "<%= @page %>";
var page = "<%= @page %>";
var paypar_account_no = [];
$(function() {
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
@@ -391,14 +391,14 @@
$('.datepicker').css('cursor','pointer');*/
// Read Card Reader
$("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){
$("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
}
},100);
}
});
$(document).ready(function () {
@@ -406,20 +406,20 @@
});
// Read Card Reader
$("#member_acc_no").on('click', function(e){
$("#member_acc_no").on('click', function(e){
localStorage.setItem("member_card",true);
var cardNo = "";
var cardNo = "";
var customer_id = '';
var customer_name = '';
var sale_id = $("#sale_id").val() || 0;
var customer_mamber_card_no = 0;
$("#sxModal").show();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
@@ -442,7 +442,7 @@
}
}
});
});
}
},100);
});
@@ -450,12 +450,12 @@
/*new customer UI func:*/
//Initialize tooltips
$('.nav-tabs > li a[title]').tooltip();
//Wizard
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
var $target = $(e.target);
if ($target.parent().hasClass('disabled')) {
return false;
}
@@ -522,21 +522,21 @@
}
// QR Code Reader
$("#qr_code").on('click', function(e){
var code = "";
$("#qr_code").on('click', function(e){
var code = "";
var customer_id = '';
var customer_name = '';
var sale_id = $("#sale_id").val() || 0;
var customer_mamber_card_no = 0;
setTimeout(function(){
code=getQRCode();
code=getQRCode();
setQRCode(code);
}, 100);
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
@@ -558,8 +558,8 @@
update_sale(customer_id, customer_name,sale_id);
}
}
});
}
});
}
});
// Read qrcode from java
@@ -595,12 +595,12 @@
data: {},
dataType: "json",
success: function(data) {
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
});
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -701,7 +701,7 @@
location.reload();
}
}
});
});
});
}
@@ -724,9 +724,9 @@
window.location.href = '/origami/room/'+id;
}
}
}
});
$("#sxModal .btn_cancel").on('click',function(){
@@ -734,4 +734,3 @@
});
</script>

View File

@@ -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});
}
});