Merge branch 'master' into license

This commit is contained in:
Yan
2017-11-24 10:15:37 +06:30
143 changed files with 23874 additions and 3746 deletions

View File

@@ -33,12 +33,14 @@ class Crm::CustomersController < BaseCrmController
end
end
end
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(15)
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
@filter = filter
# if flash["errors"]
# @crm_customer.valid?
# end

View File

@@ -5,9 +5,20 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues
# GET /crm/dining_queues.json
def index
today = DateTime.now.strftime('%Y-%m-%d')
today = DateTime.now.strftime('%Y-%m-%d')
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
@complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
if params[:term]
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
else
@customer = Customer.all
end
respond_to do |format|
format.html
format.json { render :json => @customer.to_json }
end
end
# GET /crm/dining_queues/1
@@ -28,6 +39,7 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues
# POST /crm/dining_queues.json
def create
puts dining_queue_params
@dining_queue = DiningQueue.new(dining_queue_params)
respond_to do |format|
@@ -128,6 +140,6 @@ class Crm::DiningQueuesController < BaseCrmController
# Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status,:seater,:remark)
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
end
end

View File

@@ -45,7 +45,7 @@ class HomeController < ApplicationController
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "supervisour"
elsif @employee.role == "supervisor"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
elsif @employee.role == "account"
@@ -82,6 +82,7 @@ class HomeController < ApplicationController
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today)
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today)
@@ -92,7 +93,6 @@ class HomeController < ApplicationController
end
end
@summ_sale = Sale.summary_sale_receipt(today)
p @summ_sale
@total_customer = Sale.total_customer(today)
@total_dinein = Sale.total_dinein(today)
@total_takeaway = Sale.total_takeaway(today)
@@ -151,7 +151,7 @@ class HomeController < ApplicationController
redirect_to oqs_root_path
elsif employee.role == "crm"
redirect_to crm_root_path
elsif @employee.role == "supervisour"
elsif @employee.role == "supervisor"
redirect_to origami_root_path
elsif @employee.role == "account"
redirect_to reports_dailysale_index_path

View File

@@ -44,9 +44,9 @@ class Oqs::HomeController < BaseOqsController
# Get Order items
def get_order_items
items = []
table_name = params[:table_id]
order_no = params[:order_no]
status = params[:status]
dining = DiningFacility.find_by_name(table_name);
# dining = DiningFacility.find_by_name(table_name);
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
# if status == ""
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
@@ -60,22 +60,18 @@ class Oqs::HomeController < BaseOqsController
# end
# end
booking = Booking.find_by_dining_facility_id(dining.id)
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
order=Order.find(bo.order_id)
order.order_items.each do |oi|
items.push(oi)
end
end
# booking_id = dining.get_new_booking
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id);
# order.order_items.each do |oi|
# items.push(oi)
# end
# booking = Booking.find_by_dining_facility_id(dining.id)
# BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id)
# order.order_items.each do |oi|
# items.push(oi)
# end
# end
OrderItem.where("order_id='#{ order_no }'").find_each do |oi|
items.push(oi)
end
render :json => items.to_json
end
@@ -129,10 +125,10 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id")
.group("odt.order_items_id")
end
@@ -147,7 +143,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.where("assigned_order_items.delivery_status = true AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.order_id")
.limit(20)
@@ -166,7 +162,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("oqs.id")

View File

@@ -16,7 +16,7 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, assigned_item.instance_code, print_status, options )
# update print status for completed same order items
assigned_items.each do |ai|
@@ -40,13 +40,16 @@ class Oqs::PrintController < ApplicationController
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# get dining
dining = DiningFacility.find_by_name(table_name);
booking = Booking.find_by_dining_facility_id(dining.id)
# dining = DiningFacility.find_by_name(table_name);
# booking = Booking.find_by_dining_facility_id(dining.id)
# Get Booking ID
booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0]
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_booking_summary(print_settings,oqs, booking.booking_id, print_status)
order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|

View File

@@ -40,10 +40,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * (-1)
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 0
sale_item.is_taxable = 1
sale_item.account_id = origin_sale_item.account_id
sale_item.price = di["price"]

View File

@@ -36,11 +36,11 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = 0
sale_item.is_taxable = 0
sale_item.taxable_price = di["price"] * 1
sale_item.is_taxable = 1
sale_item.account_id = 0
sale_item.price = di["price"]
sale_item.price = di["price"] * 1
sale_item.save
action_by = current_user.id

View File

@@ -209,7 +209,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
end
def foc
def foc
cash = params[:cash]
sale_id = params[:sale_id]
sub_total = params[:sub_total]
@@ -233,6 +233,9 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Re-call Sale Data
saleObj = Sale.find(sale_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)

View File

@@ -19,6 +19,7 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
@newsaleitem.save
@@ -29,7 +30,7 @@ class Origami::SaleEditController < BaseOrigamiController
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
saleObj.compute_without_void
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -41,9 +42,10 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.unit_price = saleitemObj.unit_price * -1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
@newsaleitem.save
@@ -54,7 +56,7 @@ class Origami::SaleEditController < BaseOrigamiController
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
saleObj.compute_without_void
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -103,7 +105,7 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.edit_product_commission(saleitemObj)
end
@@ -128,7 +130,7 @@ class Origami::SaleEditController < BaseOrigamiController
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_without_void
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.remove_product_commission(saleitemObj)
end
@@ -147,7 +149,7 @@ class Origami::SaleEditController < BaseOrigamiController
end
# re-calc tax
saleObj.compute_without_void
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
end
def apply_void

View File

@@ -30,6 +30,7 @@ class Origami::SurveysController < BaseOrigamiController
end
# end
end
private
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -8,12 +8,12 @@ class Origami::VoidController < BaseOrigamiController
sale = Sale.find_by_sale_id(sale_id)
# update count for shift sale
if(sale.sale_status == "completed")
# if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.calculate(sale_id, "void")
end
end
# end
sale.payment_status = 'void'
sale.sale_status = 'void'

View File

@@ -57,11 +57,15 @@ class Settings::DiningChargesController < ApplicationController
@dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"])
@dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"])
@dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"])
if @dining_charge.update(dining_charge_params)
@dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"])
@dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"])
@dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"])
# @dining_charge.minimum_free_time = @dining_charge.minimum_free_time.to_datetime.advance(hours: +6, minutes: +30)
# @dining_charge.charge_block = @dining_charge.charge_block.to_datetime.advance(hours: +6, minutes: +30)
# @dining_charge.time_rounding_block = @dining_charge.time_rounding_block.to_datetime.advance(hours: +6, minutes: +30)
# @dining_charge.save
@dining_charge.save
if @table
format.html { redirect_to settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
else

View File

@@ -72,6 +72,6 @@ class Settings::MembershipActionsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_membership_action_params
params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter)
params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by)
end
end

View File

@@ -71,6 +71,6 @@ class Settings::ShopsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def shop_params
params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order)
params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
end
end

View File

@@ -83,7 +83,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }
else
else
format.html { render :new }
format.json { render json: @settings_menu_item.errors, status: :unprocessable_entity }
end

View File

@@ -20,7 +20,9 @@ class Transactions::BookingsController < ApplicationController
@bookings = 0
end
end
@receipt_no = filter
@from = from
@to = to
respond_to do |format|
format.html # index.html.erb
format.json { render json: @bookings }

View File

@@ -14,20 +14,21 @@ class Transactions::CreditNotesController < ApplicationController
to = params[:to]
if filter.nil? && from.nil? && to.nil? && customer.nil?
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
@credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
else
sale = Sale.search_credit_sales(customer,filter,from,to)
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
@credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
@sales = 0
@credit_notes = 0
end
end
puts "sssssssssssss"
puts @credit_notes.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
format.json { render json: @credit_notes }
end
end

View File

@@ -20,6 +20,10 @@ class Transactions::OrdersController < ApplicationController
else
@orders = []
end
@receipt_no = filter
@from = from
@to = to
respond_to do |format|
format.html # index.html.erb
@@ -30,7 +34,7 @@ class Transactions::OrdersController < ApplicationController
def show
@order = Order.find(params[:id])
@dining = BookingOrder.find_by_order_id(@order.order_id).booking.dining_facility
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }

View File

@@ -22,6 +22,9 @@ class Transactions::SalesController < ApplicationController
@sales = 0
end
end
@receipt_no = receipt_no
@from = from
@to = to
# if receipt_no.nil? && search_date.nil?
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)

View File

@@ -41,9 +41,9 @@ class Transactions::ShiftSalesController < ApplicationController
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)