foodcourt apis for app
This commit is contained in:
@@ -62,6 +62,19 @@ class Api::AuthenticateController < Api::ApiController
|
||||
end
|
||||
end
|
||||
|
||||
def check_emp_access_code
|
||||
pin_code = params[:code]
|
||||
employee = Employee.find_by_emp_id(pin_code)
|
||||
if employee && (employee.role == "manager" || employee.role == "supervisor")
|
||||
result = {:status=> true, :message=>"Success" }
|
||||
else
|
||||
result = {:status=> false, :message=>"Invalid Access Code" }
|
||||
end
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authenticate_params
|
||||
params.permit(:emp_id, :password, :session_token)
|
||||
end
|
||||
|
||||
@@ -17,14 +17,18 @@ class Api::BillController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "Operation failed, Could not request bill!"
|
||||
else
|
||||
# for Multiple Cashier by Zone
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
|
||||
order = booking.orders.first
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||
unless shift = ShiftSale.current_open_shift(current_login_employee)
|
||||
# for Multiple Cashier by Zone
|
||||
if booking.dining_facility_id
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
||||
else
|
||||
shift = ShiftSale.current_shift
|
||||
end
|
||||
end
|
||||
|
||||
#for multiple zone with terminal
|
||||
if !shift.nil?
|
||||
@@ -57,22 +61,22 @@ class Api::BillController < Api::ApiController
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||
# @sale_data.save
|
||||
if @sale_data
|
||||
if @sale_data && booking.dining_facility_id.present?
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer,cashier_terminal , booking, table)
|
||||
# print when complete click
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -159,12 +163,11 @@ class Api::BillController < Api::ApiController
|
||||
if !shift.nil?
|
||||
cashier = Employee.find(shift.employee_id)
|
||||
if (@booking.booking_id)
|
||||
booking_order = BookingOrder.find_by_booking_id(@booking.booking_id)
|
||||
order = Order.find(booking_order.order_id)
|
||||
order = @booking.orders.first
|
||||
|
||||
if @sale_data = @booking.sale
|
||||
@status = true
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
class Api::BookingsController < Api::ApiController
|
||||
# skip_before_action :authenticate
|
||||
skip_before_action :authenticate
|
||||
#Show customer by ID
|
||||
def index
|
||||
@customer = Customer.find_by(params[:id])
|
||||
def index
|
||||
@bookings = Booking.all
|
||||
if params[:shift_id].present?
|
||||
@bookings = @bookings.includes(:dining_facility, :sale, orders: :order_items)
|
||||
.where()
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
booking = Booking.find(params[:id])
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
@booking = booking
|
||||
@booking = Booking.find(params[:id])
|
||||
end
|
||||
|
||||
def pending
|
||||
@bookings = Booking.where(checkout_at: nil)
|
||||
end
|
||||
|
||||
def billed
|
||||
if shift = ShiftSale.current_shift
|
||||
@bookings = Booking.includes(:sale)
|
||||
.where(sales: {shift_sale_id: shift.id})
|
||||
.where.not(sales: {sale_status: ['completed', 'void']})
|
||||
end
|
||||
end
|
||||
|
||||
def completed
|
||||
if shift = ShiftSale.current_shift
|
||||
@bookings = Booking.includes(:sale)
|
||||
.where(sales: {shift_sale_id: shift.id, sale_status: ['completed']})
|
||||
end
|
||||
end
|
||||
|
||||
def void
|
||||
if shift = ShiftSale.current_shift
|
||||
@bookings = Booking.includes(:sale)
|
||||
.where(sales: {shift_sale_id: shift.id, sale_status: ['void']})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -21,6 +21,30 @@ class Api::CustomersController < Api::ApiController
|
||||
render json: status
|
||||
end
|
||||
|
||||
def get_customer_by_account
|
||||
account_no = params[:account_no]
|
||||
|
||||
unless @customer = Customer.find_by(paypar_account_no: account_no);
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@customer = Customer.create({
|
||||
name: response["customer_data"]["name"],
|
||||
contact_no: response["customer_data"]["phone"],
|
||||
email: response["customer_data"]["email"],
|
||||
date_of_birth: response["customer_data"]["DOB"],
|
||||
nrc_no: response["customer_data"]["NRC"],
|
||||
address: response["customer_data"]["address"],
|
||||
card_no: response["customer_data"]["customer_card_no"],
|
||||
paypar_account_no: account_no,
|
||||
membership_id: response["customer_data"]["id"],
|
||||
membership_type: response["customer_data"]["member_group_id"],
|
||||
customer_type: "Dinein",
|
||||
tax_profiles: ["1", "2"],
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_customer_by_phone
|
||||
if @customer = Customer.find_by_contact_no(params[:contact_no])
|
||||
status = true
|
||||
|
||||
25
app/controllers/api/foodcourt/bills_controller.rb
Normal file
25
app/controllers/api/foodcourt/bills_controller.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
class Api::Foodcourt::BillsController < Api::ApiController
|
||||
|
||||
def create
|
||||
Sale.transaction do
|
||||
if shift = ShiftSale.current_open_shift(current_login_employee)
|
||||
if booking = Booking.find(params[:booking_id])
|
||||
cashier = Employee.find(shift.employee_id)
|
||||
order = booking.orders.first
|
||||
|
||||
if @sale_data = booking.sale
|
||||
@status = true
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
36
app/controllers/api/foodcourt/orders_controller.rb
Normal file
36
app/controllers/api/foodcourt/orders_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Api::Foodcourt::OrdersController < Api::ApiController
|
||||
|
||||
def create
|
||||
Order.transaction do
|
||||
if params[:order_items].present?
|
||||
if shift = ShiftSale.current_open_shift(current_login_employee)
|
||||
|
||||
@order = Order.new
|
||||
@order.source = params[:source] || "foodcourt"
|
||||
@order.order_type = params[:order_type] || "Takeaway"
|
||||
@order.customer_id = params[: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
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
unless @status && @booking
|
||||
@status = false
|
||||
@error_message = "Create order failed, some error occurred!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "Parameters missing!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
88
app/controllers/api/foodcourt/payments_controller.rb
Normal file
88
app/controllers/api/foodcourt/payments_controller.rb
Normal file
@@ -0,0 +1,88 @@
|
||||
class Api::Foodcourt::PaymentsController < Api::ApiController
|
||||
|
||||
def create
|
||||
SalePayment.transaction do
|
||||
if params[:sale_id] && params[:account_no]
|
||||
@sale = Sale.find_by_sale_id(params[:sale_id])
|
||||
if !@sale.nil?
|
||||
if @sale.sale_status == "new"
|
||||
if !params[:account_no].empty?
|
||||
@status, @message = send_account_paymal(@sale.grand_total, params[:account_no], @sale.receipt_no)
|
||||
if @status
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale_payment, @membership_data = sale_payment.process_payment(@sale, current_login_employee, @sale.grand_total, "paymal",params[:account_no])
|
||||
|
||||
if status == true && @membership_data["status"] == true
|
||||
# sale_payment = SalePayment.new
|
||||
# status = sale_payment.process_payment(@sale, current_login_employee, 0, "cash")
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(params[:sale_id])
|
||||
|
||||
@status = true
|
||||
@card_balance_amount = card_balance_amount
|
||||
@transaction_ref = transaction_ref
|
||||
@message = "Payment successful."
|
||||
else
|
||||
@status = false
|
||||
if @membership_data
|
||||
@card_balance_amount = @membership_data["card_balance_amount"]
|
||||
@message = @membership_data["message"]
|
||||
else
|
||||
@message = "Payment failed!"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Card No is required!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Already paid for '#{params[:sale_id]}'!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "There is no sale for '#{params[:sale_id]}'!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Parameters missing! #{params[:sale_id]} #{params[:account_no]}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def send_account_paymal(amount, account_no, receipt_no)
|
||||
sale = Sale.find_by_receipt_no(receipt_no)
|
||||
@out = []
|
||||
action_by = current_login_employee.name
|
||||
@status = true
|
||||
@message = ""
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions = MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
|
||||
if membership_data["status"]==true
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,current_login_employee.name, current_login_employee.name,remark,"PAYBYACCOUNT" )
|
||||
else
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,current_login_employee.name, current_login_employee.name,remark,"PAYBYACCOUNT" )
|
||||
end
|
||||
@out = membership_data
|
||||
@status = membership_data["status"]
|
||||
@message = membership_data["message"]
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "No gateway url!"
|
||||
end
|
||||
|
||||
return @status, @message
|
||||
end
|
||||
end
|
||||
60
app/controllers/api/foodcourt/void_controller.rb
Normal file
60
app/controllers/api/foodcourt/void_controller.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
class Api::Foodcourt::VoidController < Api::ApiController
|
||||
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type] || "foodcourt" #tax profile source
|
||||
access_code = params[:access_code]
|
||||
remark = params[:remark]
|
||||
|
||||
@sale = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
if @sale.discount_type == "member_discount"
|
||||
@sale.update_attributes(total_discount: 0)
|
||||
@sale.compute_by_sale_items(0, nil, order_source)
|
||||
end
|
||||
|
||||
# update count for shift @sale
|
||||
if(@sale.sale_status == "completed")
|
||||
if @sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(@sale.shift_sale_id)
|
||||
shift.calculate(sale_id, "void")
|
||||
end
|
||||
else
|
||||
# void before @sale payment complete
|
||||
if @sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(@sale.shift_sale_id)
|
||||
shift.total_void = shift.total_void + @sale.grand_total
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
@sale.rounding_adjustment = 0.0
|
||||
@sale.payment_status = 'void'
|
||||
@sale.sale_status = 'void'
|
||||
@sale.save
|
||||
|
||||
if table = @sale.booking.dining_facility
|
||||
unless table.current_bookings.exists?
|
||||
table.update_attributes(status: 'available')
|
||||
end
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_login_employee.name
|
||||
if access_code != "null" && current_login_employee.role == "cashier"
|
||||
action_by = Employee.find_by_emp_id(access_code).name
|
||||
end
|
||||
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{@sale.receipt_no} | Receipt No #{@sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id, current_login_employee.name, action_by, remark, "SALEVOID" )
|
||||
|
||||
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
|
||||
|
||||
@status = true
|
||||
@message = "Void succeed"
|
||||
end
|
||||
end
|
||||
@@ -19,56 +19,6 @@ class Api::PaymentsController < Api::ApiController
|
||||
def update
|
||||
end
|
||||
|
||||
#create paymal payment for cashier app
|
||||
def create_paymal_payment
|
||||
if params[:sale_id] && params[:account_no]
|
||||
@sale = Sale.find_by_sale_id(params[:sale_id])
|
||||
if !@sale.nil?
|
||||
if @sale.sale_status == "new"
|
||||
if !params[:account_no].empty?
|
||||
@status, @message = send_account_paymal(@sale.grand_total, params[:account_no], @sale.receipt_no)
|
||||
if @status
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale_payment, @membership_data = sale_payment.process_payment(@sale, current_login_employee, @sale.grand_total, "paymal",params[:account_no])
|
||||
|
||||
if status == true && @membership_data["status"] == true
|
||||
sale_payment = SalePayment.new
|
||||
status = sale_payment.process_payment(@sale, current_login_employee, 0, "cash")
|
||||
#card_balance amount for Paymal payment
|
||||
card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(params[:sale_id])
|
||||
|
||||
@status = true
|
||||
@card_balance_amount = card_balance_amount
|
||||
@transaction_ref = transaction_ref
|
||||
@message = "Payment successful."
|
||||
else
|
||||
@status = false
|
||||
if @membership_data
|
||||
@card_balance_amount = @membership_data["card_balance_amount"]
|
||||
@message = @membership_data["message"]
|
||||
else
|
||||
@message = "Payment failed!"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Card No is required!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Already paid for '#{params[:sale_id]}'!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "There is no sale for '#{params[:sale_id]}'!"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Parameters missing! #{params[:sale_id]} #{params[:account_no]}"
|
||||
end
|
||||
end
|
||||
|
||||
#create paymal payment for online order app
|
||||
def paymal_payment
|
||||
if params[:account_no] && params[:key] && params[:token] && params[:sale_id]
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
class Api::ShiftsController < Api::ApiController
|
||||
# skip_before_action :authenticate
|
||||
|
||||
|
||||
def create
|
||||
opening_balance = 0
|
||||
cashier_terminal_param = params[:cashier_terminal]
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
|
||||
if cashier_terminal.is_currently_login
|
||||
render json: JSON.generate({:status => false, :error_message => "Cashier Terminal already signin!"})
|
||||
def create
|
||||
opening_balance = 0
|
||||
cashier_terminal_param = params[:cashier_terminal]
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
|
||||
if cashier_terminal.is_currently_login
|
||||
render json: JSON.generate({:status => false, :error_message => "Cashier Terminal already signin!"})
|
||||
else
|
||||
# Update Cashier Terminal
|
||||
cashier_terminal.is_currently_login = 1
|
||||
cashier_terminal.save
|
||||
|
||||
@shift_sale = ShiftSale.new
|
||||
if @shift_sale.create(opening_balance,cashier_terminal_param, current_login_employee)
|
||||
@status = true
|
||||
@message = "Cashier Terminal successfully signin."
|
||||
# render json: JSON.generate({:status => true, :message => "Cashier Terminal successfully signin.", :shift => ActiveSupport::JSON.encode(@shift_sale)})
|
||||
else
|
||||
# Update Cashier Terminal
|
||||
cashier_terminal.is_currently_login = 1
|
||||
cashier_terminal.save
|
||||
@status = false
|
||||
@error_message = "Some error occurred!"
|
||||
# render json: JSON.generate({:status => false, :error_message => "Some error occurred!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@shift_sale = ShiftSale.new
|
||||
if @shift_sale.create(opening_balance,cashier_terminal_param, current_login_employee)
|
||||
@status = true
|
||||
@message = "Cashier Terminal successfully signin."
|
||||
# render json: JSON.generate({:status => true, :message => "Cashier Terminal successfully signin.", :shift => ActiveSupport::JSON.encode(@shift_sale)})
|
||||
else
|
||||
@status = false
|
||||
@error_message = "Some error occurred!"
|
||||
# render json: JSON.generate({:status => false, :error_message => "Some error occurred!"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
def update
|
||||
closing_balance = 0
|
||||
shift_id = params[:shift_id]
|
||||
|
||||
@@ -36,26 +36,55 @@ class Api::ShiftsController < Api::ApiController
|
||||
if !@shift.nil?
|
||||
if @shift.shift_closed_at.nil?
|
||||
@shift.shift_closed_at = DateTime.now.utc
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.save
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
cashier_terminal.is_currently_login = 0
|
||||
cashier_terminal.save
|
||||
|
||||
@shop = current_shop
|
||||
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
|
||||
if @lookup.to_i == 1
|
||||
@sale_items = Sale.get_shift_sale_items(@shift.id)
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(@shift,from=nil,to=nil,type='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
@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_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
logout_status = Employee.logout(current_token)
|
||||
if logout_status
|
||||
render json: JSON.generate({:status => true, :message => "Shift close successfully."})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Session Token Invalid or Missing"})
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Shift already close!"})
|
||||
@status = true
|
||||
@message = "Shift close successfully."
|
||||
else
|
||||
@status = false
|
||||
@message = "Session Token Invalid or Missing"
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@message = "Shift already close!"
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Wrong shift!"})
|
||||
@status = false
|
||||
@message = "Wrong shift!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ class Foodcourt::AddordersController < BaseFoodcourtController
|
||||
@webview = true
|
||||
end
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
@menus = []
|
||||
@menu = []
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
@menus = []
|
||||
@menu = []
|
||||
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
|
||||
@@ -106,6 +106,10 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
@menus = []
|
||||
@menu = []
|
||||
|
||||
@zone = Zone.all
|
||||
@tables = Table.active.order('status desc')
|
||||
@rooms = Room.active.order('status desc')
|
||||
|
||||
if params[:id].include? "BKI"
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@@ -272,7 +276,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
format.json {
|
||||
render :json => { :status => false, :error_message => "No Current Open Shift for This Employee" } }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,7 +88,6 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
end
|
||||
shop_details = current_shop
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
if @lookup.to_i == 1
|
||||
@@ -96,7 +95,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
|
||||
other_charges = Sale.get_other_charges()
|
||||
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
|
||||
end
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@sale_taxes = Sale.get_separate_tax(@shift,from=nil,to=nil,type='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#other payment details for mpu or visa like card
|
||||
|
||||
@@ -8,7 +8,9 @@ class Employee < ApplicationRecord
|
||||
|
||||
validates_presence_of :name, :role
|
||||
validates_presence_of :password, :on => [:create]
|
||||
validates :emp_id, uniqueness: { scope: :shop_code }, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :emp_id, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :emp_id, uniqueness: { scope: :shop_code }, if: -> { Employee.columns.map { |column| column.name }.include?('shop_code') }
|
||||
validates :emp_id, uniqueness: true, if: -> { !Employee.columns.map { |column| column.name }.include?('shop_code') }
|
||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||
|
||||
before_create :generate_app_id, :generate_app_token,
|
||||
|
||||
@@ -1434,9 +1434,9 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
|
||||
end
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?) ", shift.to_a)
|
||||
query = query.where(sales: { shift_sale_id: shift })
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id in (?) ", shift_sale_range.to_a)
|
||||
query = query.where(sales: { shift_sale_id: shift_sale_range.to_a })
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? ", from,to)
|
||||
end
|
||||
@@ -2034,7 +2034,7 @@ end
|
||||
.where("sales.shift_sale_id=?", sh_id)
|
||||
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
|
||||
end
|
||||
end
|
||||
|
||||
def self.pending_sale(type)
|
||||
query = Sale.all
|
||||
@@ -2043,6 +2043,7 @@ end
|
||||
query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}")
|
||||
.group("sales.sale_id")
|
||||
end
|
||||
|
||||
def self.pending_order(type)
|
||||
query = Booking.all
|
||||
query = query.joins("join booking_orders as booking_orders on booking_orders.booking_id = bookings.booking_id")
|
||||
@@ -2050,6 +2051,7 @@ end
|
||||
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}")
|
||||
.group("bookings.booking_id")
|
||||
end
|
||||
|
||||
def self.completed_sale(type)
|
||||
if type == "cashier"
|
||||
type = "and orders.source = 'emenu' or orders.source = 'cashier'"
|
||||
|
||||
@@ -36,7 +36,7 @@ class SaleTax < ApplicationRecord
|
||||
end
|
||||
|
||||
def display_name
|
||||
"#{self.tax_name} (#{'Incl. ' if self.tax_type == 'inclusive'}#{self.tax_rate}%"
|
||||
"#{self.tax_name} (#{'Incl.' if self.inclusive} #{self.tax_rate}%"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -154,9 +154,9 @@ class ShiftSale < ApplicationRecord
|
||||
|
||||
shift_other_payments = Sale.select("sales.sale_id, sale_payments.payment_method as name")
|
||||
if payment_methods.present?
|
||||
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as `#{method == 'paypar' ? 'redeem' : method}`"}.join(', ')}")
|
||||
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "IFNULL(SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end), 0) as `#{method == 'paypar' ? 'redeem' : method}`"}.join(', ')}")
|
||||
end
|
||||
shift_other_payments.select("SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
shift_other_payments.select("IFNULL(SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end), 0) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
|
||||
end
|
||||
@@ -204,7 +204,7 @@ class ShiftSale < ApplicationRecord
|
||||
# end
|
||||
|
||||
def self.get_total_other_charges(shift)
|
||||
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||
query = SaleItem.select("IFNULL(sum(sale_items.qty * sale_items.unit_price), 0) as total_other_charges_amount")
|
||||
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
|
||||
.first()
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
if @status == true
|
||||
#show invoice number and stuff
|
||||
json.status @status
|
||||
json.sale_id @sale_data.sale_id
|
||||
sale = Sale.find(@sale_data.sale_id)
|
||||
|
||||
json.sale_items sale.sale_items do |sale_item|
|
||||
json.sale_item_id sale_item.sale_item_id
|
||||
json.sale_id sale_item.sale_id
|
||||
json.product_code sale_item.product_code
|
||||
json.item_instance_code sale_item.item_instance_code
|
||||
json.product_name sale_item.product_name
|
||||
json.product_alt_name sale_item.product_alt_name
|
||||
json.account_id sale_item.account_id
|
||||
json.status sale_item.status
|
||||
json.remark sale_item.remark
|
||||
json.qty sale_item.qty
|
||||
json.unit_price sale_item.unit_price
|
||||
json.taxable_price sale_item.taxable_price
|
||||
json.price sale_item.price
|
||||
json.is_taxable sale_item.is_taxable
|
||||
end
|
||||
else
|
||||
json.status @status
|
||||
json.error_message @error_message
|
||||
|
||||
8
app/views/api/bookings/_booking_summary.json.jbuilder
Normal file
8
app/views/api/bookings/_booking_summary.json.jbuilder
Normal file
@@ -0,0 +1,8 @@
|
||||
json.booking_id booking.booking_id
|
||||
|
||||
json.sale_id booking.sale.try(:sale_id)
|
||||
json.sale_status booking.sale.try(:sale_status)
|
||||
json.receipt_no booking.sale.try(:receipt_no)
|
||||
|
||||
json.checkin_at booking.try(:checkin_at).try(:utc)
|
||||
json.checkout_at booking.try(:checkout_at).try(:utc)
|
||||
1
app/views/api/bookings/billed.json.jbuilder
Normal file
1
app/views/api/bookings/billed.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @bookings, partial: 'api/bookings/booking_summary', as: :booking
|
||||
1
app/views/api/bookings/completed.json.jbuilder
Normal file
1
app/views/api/bookings/completed.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @bookings, partial: 'api/bookings/booking_summary', as: :booking
|
||||
1
app/views/api/bookings/pending.json.jbuilder
Normal file
1
app/views/api/bookings/pending.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @bookings, partial: 'api/bookings/booking_summary', as: :booking
|
||||
@@ -1,50 +1,15 @@
|
||||
if (@booking)
|
||||
json.success true
|
||||
json.id @booking.booking_id
|
||||
json.status @booking.booking_status
|
||||
if Sale.exists?(@booking.sale_id)
|
||||
json.sale_status Sale.find(@booking.sale_id).sale_status
|
||||
else
|
||||
json.sale_status ""
|
||||
end
|
||||
json.checkin_at @booking.checkin_at.strftime("%d-%m-%Y")
|
||||
json.checkin_by @booking.checkin_by
|
||||
json.table_name @booking.dining_facility.name
|
||||
json.booking_id @booking.booking_id
|
||||
|
||||
if @booking.type == "TableBooking"
|
||||
json.table_id @booking.dining_facility_id
|
||||
else
|
||||
json.room_id @booking.dining_facility_id
|
||||
end
|
||||
@total_amount = 0.00
|
||||
@total_tax = 0.00
|
||||
json.booking_status @booking.booking_status
|
||||
|
||||
if @booking.booking_orders
|
||||
order_items = []
|
||||
@booking.booking_orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
#if (order.status == "new")
|
||||
order_items = order_items + order.order_items
|
||||
#end
|
||||
end
|
||||
|
||||
json.order_items order_items do |item|
|
||||
json.item_instance_code item.item_code
|
||||
json.item_name item.item_name
|
||||
json.price item.price
|
||||
json.qty item.qty
|
||||
json.options item.options
|
||||
json.remark item.remark
|
||||
json.item_status item.order_item_status
|
||||
@total_amount = @total_amount + (item.price * item.qty)
|
||||
else
|
||||
json.success false
|
||||
end
|
||||
json.dining_facility do
|
||||
json.partial! 'api/dining_facilities/dining_facility', dining_facility: @booking.dining_facility
|
||||
end
|
||||
|
||||
json.sub_total @total_amount
|
||||
json.commerical_tax @total_amount * 0.05
|
||||
json.total @total_amount + (@total_amount * 0.05)
|
||||
else
|
||||
json.success false
|
||||
json.sale do
|
||||
json.partial! 'api/sales/sale', sale: @booking.sale
|
||||
end
|
||||
|
||||
json.orders @booking.orders, partial: 'api/orders/order', as: :order
|
||||
end
|
||||
|
||||
1
app/views/api/bookings/void.json.jbuilder
Normal file
1
app/views/api/bookings/void.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @bookings, partial: 'api/bookings/booking_summary', as: :booking
|
||||
@@ -0,0 +1,7 @@
|
||||
if @customer.present?
|
||||
json.status true
|
||||
else
|
||||
json.status false
|
||||
end
|
||||
|
||||
json.data @customer
|
||||
@@ -0,0 +1,3 @@
|
||||
if dining_facility
|
||||
json.name dining_facility.name
|
||||
end
|
||||
26
app/views/api/foodcourt/bills/create.json.jbuilder
Normal file
26
app/views/api/foodcourt/bills/create.json.jbuilder
Normal file
@@ -0,0 +1,26 @@
|
||||
if @status == true
|
||||
#show invoice number and stuff
|
||||
json.status @status
|
||||
json.sale_id @sale_data.sale_id
|
||||
sale = Sale.find(@sale_data.sale_id)
|
||||
|
||||
json.sale_items sale.sale_items do |sale_item|
|
||||
json.sale_item_id sale_item.sale_item_id
|
||||
json.sale_id sale_item.sale_id
|
||||
json.product_code sale_item.product_code
|
||||
json.item_instance_code sale_item.item_instance_code
|
||||
json.product_name sale_item.product_name
|
||||
json.product_alt_name sale_item.product_alt_name
|
||||
json.account_id sale_item.account_id
|
||||
json.status sale_item.status
|
||||
json.remark sale_item.remark
|
||||
json.qty sale_item.qty
|
||||
json.unit_price sale_item.unit_price
|
||||
json.taxable_price sale_item.taxable_price
|
||||
json.price sale_item.price
|
||||
json.is_taxable sale_item.is_taxable
|
||||
end
|
||||
else
|
||||
json.status @status
|
||||
json.error_message @error_message
|
||||
end
|
||||
26
app/views/api/foodcourt/orders/create.json.jbuilder
Normal file
26
app/views/api/foodcourt/orders/create.json.jbuilder
Normal file
@@ -0,0 +1,26 @@
|
||||
if @status == true
|
||||
json.status @status
|
||||
json.id @order.id
|
||||
json.booking_id @booking.id
|
||||
json.order_items do
|
||||
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark,:price
|
||||
end
|
||||
if @sale
|
||||
json.sale_id @sale.sale_id
|
||||
json.sale_items do
|
||||
json.array! @sale.sale_items, :product_name, :qty, :remark,:unit_price,:price
|
||||
end
|
||||
json.grand_total @sale.grand_total
|
||||
json.total_tax @sale.total_tax
|
||||
json.taxes do
|
||||
json.array! @sale.sale_taxes, :tax_name, :tax_rate, :tax_payable_amount, :inclusive
|
||||
end
|
||||
end
|
||||
else
|
||||
json.status @status
|
||||
if @error_messages
|
||||
json.error_messages @error_messages
|
||||
else
|
||||
json.error_messages @message
|
||||
end
|
||||
end
|
||||
@@ -9,6 +9,10 @@ json.data do
|
||||
|
||||
json.booking @sale.booking.booking_id
|
||||
|
||||
if @sale.booking.dining_facility
|
||||
json.dining_facility @sale.booking.dining_facility.name
|
||||
end
|
||||
|
||||
json.shop do
|
||||
json.name current_shop.name
|
||||
json.address current_shop.address
|
||||
61
app/views/api/foodcourt/void/create.json.jbuilder
Normal file
61
app/views/api/foodcourt/void/create.json.jbuilder
Normal file
@@ -0,0 +1,61 @@
|
||||
#show invoice number and stuff
|
||||
json.status @status
|
||||
json.message @message
|
||||
|
||||
json.data do
|
||||
if @status
|
||||
json.sale_id @sale.sale_id
|
||||
json.sale_status @sale.sale_status
|
||||
|
||||
json.booking @sale.booking.booking_id
|
||||
|
||||
if @sale.booking.dining_facility
|
||||
json.dining_facility @sale.booking.dining_facility.name
|
||||
end
|
||||
|
||||
json.shop do
|
||||
json.name current_shop.name
|
||||
json.address current_shop.address
|
||||
json.phone_no current_shop.phone_no
|
||||
end
|
||||
|
||||
order = @sale.orders.first
|
||||
|
||||
json.order do
|
||||
json.order_no order.order_id
|
||||
json.order_by order.waiters
|
||||
json.order_date order.date
|
||||
end
|
||||
|
||||
json.cashier_name @sale.cashier_name
|
||||
json.receipt_no @sale.receipt_no
|
||||
json.receipt_date @sale.receipt_date
|
||||
json.sub_total @sale.total_amount
|
||||
json.discount_type @sale.discount_type
|
||||
json.total_discount @sale.total_discount
|
||||
|
||||
json.sale_taxes @sale.sale_taxes do |sale_tax|
|
||||
json.display_name sale_tax.display_name
|
||||
json.tax_amount sale_tax.tax_payable_amount
|
||||
end
|
||||
|
||||
json.grand_total @sale.grand_total
|
||||
|
||||
json.sale_items @sale.sale_items do |sale_item|
|
||||
json.sale_item_id sale_item.sale_item_id
|
||||
json.sale_id sale_item.sale_id
|
||||
json.product_code sale_item.product_code
|
||||
json.item_instance_code sale_item.item_instance_code
|
||||
json.product_name sale_item.product_name
|
||||
json.product_alt_name sale_item.product_alt_name
|
||||
json.account_id sale_item.account_id
|
||||
json.status sale_item.status
|
||||
json.remark sale_item.remark
|
||||
json.qty sale_item.qty
|
||||
json.unit_price sale_item.unit_price
|
||||
json.taxable_price sale_item.taxable_price
|
||||
json.price sale_item.price
|
||||
json.is_taxable sale_item.is_taxable
|
||||
end
|
||||
end
|
||||
end
|
||||
19
app/views/api/order_items/_order_item.json.jbuilder
Normal file
19
app/views/api/order_items/_order_item.json.jbuilder
Normal file
@@ -0,0 +1,19 @@
|
||||
if order_item
|
||||
json.order_item_id order_item.order_items_id
|
||||
|
||||
json.item_code order_item.item_code
|
||||
|
||||
json.item_instance_code order_item.item_instance_code
|
||||
|
||||
json.item_name order_item.item_name
|
||||
|
||||
json.qty order_item.qty
|
||||
|
||||
json.price order_item.price
|
||||
|
||||
json.options order_item.options
|
||||
|
||||
json.set_menu_items order_item.set_menu_items
|
||||
|
||||
json.remark order_item.remark
|
||||
end
|
||||
15
app/views/api/orders/_order.json.jbuilder
Normal file
15
app/views/api/orders/_order.json.jbuilder
Normal file
@@ -0,0 +1,15 @@
|
||||
if order
|
||||
json.order_id order.order_id
|
||||
|
||||
json.date order.date.try(:utc)
|
||||
|
||||
json.source order.source
|
||||
|
||||
json.customer_id order.customer_id
|
||||
|
||||
json.customer_name order.try(:customer).try(:name)
|
||||
|
||||
json.order_by order.waiters
|
||||
|
||||
json.order_items order.order_items, partial: "api/order_items/order_item", as: :order_item
|
||||
end
|
||||
8
app/views/api/sale_items/_sale_item.json.jbuilder
Normal file
8
app/views/api/sale_items/_sale_item.json.jbuilder
Normal file
@@ -0,0 +1,8 @@
|
||||
if sale_item
|
||||
json.product_name sale_item.product_name
|
||||
json.product_alt_name sale_item.product_alt_name
|
||||
json.qty sale_item.qty
|
||||
json.unit_price sale_item.unit_price
|
||||
json.price sale_item.price
|
||||
json.taxable_price sale_item.taxable_price
|
||||
end
|
||||
6
app/views/api/sale_taxes/_sale_tax.json.jbuilder
Normal file
6
app/views/api/sale_taxes/_sale_tax.json.jbuilder
Normal file
@@ -0,0 +1,6 @@
|
||||
if sale_tax
|
||||
json.tax_name sale_tax.tax_name
|
||||
json.tax_rate sale_tax.tax_rate
|
||||
json.tax_payable_amount sale_tax.tax_payable_amount
|
||||
json.inclusive sale_tax.inclusive
|
||||
end
|
||||
32
app/views/api/sales/_sale.json.jbuilder
Normal file
32
app/views/api/sales/_sale.json.jbuilder
Normal file
@@ -0,0 +1,32 @@
|
||||
if sale
|
||||
json.sale_id sale.id
|
||||
json.cashier_name sale.cashier_name
|
||||
json.receipt_no sale.receipt_no
|
||||
json.receipt_date sale.receipt_date.try(:utc)
|
||||
|
||||
json.customer_id sale.customer_id
|
||||
json.customer_name sale.try(:customer).try(:name)
|
||||
|
||||
json.sale_status sale.sale_status
|
||||
|
||||
json.total_amount sale.total_amount
|
||||
|
||||
json.discount_type sale.discount_type.capitalize
|
||||
json.total_discount sale.total_discount
|
||||
|
||||
json.tax_type sale.tax_type
|
||||
json.total_tax sale.total_tax
|
||||
|
||||
json.grand_total sale.grand_total
|
||||
|
||||
json.rounding_adjustment sale.rounding_adjustment
|
||||
|
||||
json.amount_received sale.amount_received
|
||||
json.amount_changed sale.amount_changed
|
||||
|
||||
json.shift_sale_id sale.shift_sale_id
|
||||
|
||||
json.sale_items sale.sale_items, partial: "api/sale_items/sale_item", as: :sale_item
|
||||
|
||||
json.sale_taxes sale.sale_taxes, partial: "api/sale_taxes/sale_tax", as: :sale_tax
|
||||
end
|
||||
126
app/views/api/shifts/update.json.jbuilder
Normal file
126
app/views/api/shifts/update.json.jbuilder
Normal file
@@ -0,0 +1,126 @@
|
||||
json.status @status
|
||||
json.message @message
|
||||
|
||||
if @status
|
||||
json.data do
|
||||
json.shop do
|
||||
json.name current_shop.name
|
||||
json.address current_shop.address
|
||||
json.phone_no current_shop.phone_no
|
||||
end
|
||||
|
||||
json.cashier @shift.employee.name
|
||||
json.cashier_station @shift.cashier_terminal.name
|
||||
json.opening_date @shift.shift_started_at.strftime('%d-%m-%Y %I:%M %p')
|
||||
json.closing_date @shift.shift_closed_at.strftime('%d-%m-%Y %I:%M %p')
|
||||
json.opening_float @shift.opening_balance
|
||||
json.closing_float @shift.closing_balance
|
||||
|
||||
json.sale_by_payments do
|
||||
json.child! do
|
||||
json.name 'Cash'
|
||||
json.total_amount @shift.credit_sales
|
||||
end
|
||||
json.child! do
|
||||
json.name 'Credit'
|
||||
json.total_amount @shift.credit_sales
|
||||
end
|
||||
|
||||
@payment_methods.each do |payment_method|
|
||||
json.child! do
|
||||
json.name payment_method
|
||||
json.total_amount @other_payment.first[payment_method.parameterize.to_sym]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json.rounding_adjustment @shift.total_rounding
|
||||
json.total @shift.grand_total
|
||||
|
||||
json.sale_taxes @sale_taxes do |sale_tax|
|
||||
json.tax_name sale_tax.tax_name
|
||||
json.tax_amount sale_tax.st_amount
|
||||
end
|
||||
|
||||
json.total_taxes @shift.total_taxes
|
||||
json.nett_sales @shift.nett_sales
|
||||
|
||||
json.total_credit_payment @total_credit_payments
|
||||
|
||||
json.sale_discounts do
|
||||
@total_discount_by_account.each do |account|
|
||||
json.child! do
|
||||
json.name account.account_name
|
||||
json.total_amount account.total_price
|
||||
end
|
||||
end
|
||||
|
||||
if @total_member_discount && @total_member_discount.first.member_discount
|
||||
json.child! do
|
||||
json.name "Member"
|
||||
json.total_amount @total_member_discount.first.member_discount
|
||||
end
|
||||
elsif @total_discount_by_account.size < 1
|
||||
json.array!
|
||||
end
|
||||
end
|
||||
|
||||
json.total_discount @shift.total_discounts
|
||||
|
||||
json.total_foc @other_payment.first.foc_amount
|
||||
json.total_void @shift.total_void.to_d
|
||||
json.total_waste @total_waste
|
||||
json.total_spoile @total_spoile
|
||||
|
||||
json.sale_by_accounts @total_amount_by_account do |account|
|
||||
json.name account.account_name
|
||||
json.total_amount account.total_price
|
||||
end
|
||||
|
||||
json.total_other_amount @total_other_charges
|
||||
json.total_dine_in_count @shift.dining_count
|
||||
json.total_takeaway_count @shift.takeaway_count
|
||||
json.total_receipts @shift.total_receipt
|
||||
|
||||
if @sale_items.present?
|
||||
json.sale_items_summary do
|
||||
total_items = 0
|
||||
total_amount = BigDecimal("0.0")
|
||||
json.sale_items_groups do
|
||||
@sale_items.group_by(&:menu_category_name).each do |menu|
|
||||
json.child! do
|
||||
json.category_name menu[0]
|
||||
json.sale_items menu[1] do |item|
|
||||
json.product_name item.product_name
|
||||
json.unit_price item.unit_price
|
||||
json.total_qty item.total_item
|
||||
json.total_price item.grand_total
|
||||
|
||||
total_items += item.total_item
|
||||
total_amount += item.grand_total
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless @total_other_charges_info.nil?
|
||||
json.child! do
|
||||
json.category_name 'Other Charges'
|
||||
json.sale_items @total_other_charges_info do |item|
|
||||
json.product_name item.product_name
|
||||
json.unit_price item.unit_price
|
||||
json.total_qty item.total_item
|
||||
json.total_price item.grand_total
|
||||
|
||||
total_items += item.total_item
|
||||
total_amount += item.grand_total
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json.total_items total_items
|
||||
json.total_amount total_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -49,6 +49,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post 'authenticate' => "authenticate#create"
|
||||
delete 'authenticate' => "authenticate#destroy"
|
||||
|
||||
post 'check_emp_access_code' => 'authenticate#check_emp_access_code'
|
||||
|
||||
resources :shops, only: [:index, :show]
|
||||
resources :verifications, only: [:new]
|
||||
get 'get_tax_profiles' => "shops#get_tax_profiles"
|
||||
@@ -86,8 +88,19 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "update_order_item" => "orders#update"
|
||||
|
||||
#Current active bookings
|
||||
resources :bookings, only: [:index, :show, :create, :update]
|
||||
resources :bookings, only: [:show] do
|
||||
collection do
|
||||
get 'pending'
|
||||
get 'billed'
|
||||
get 'completed'
|
||||
get 'void'
|
||||
end
|
||||
end
|
||||
|
||||
get "customers/get_by_account" => "customers#get_customer_by_account"
|
||||
|
||||
resources :customers
|
||||
|
||||
# get customer by phone
|
||||
get "get_customer_by_phone" => "customers#get_customer_by_phone"
|
||||
#get customer details by order items
|
||||
@@ -126,13 +139,14 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
post "sound_effect" => "sound_effect#sound_effect"
|
||||
|
||||
resources :sales, only: [:show]
|
||||
|
||||
#API for cashier app
|
||||
post 'authenticate_cashier' => "authenticate#create_cashier"
|
||||
post "shifts/new" => "shifts#create"
|
||||
post "shifts/close" => "shifts#update"
|
||||
post "request_bill" => "bill#request_bill"
|
||||
post "paymal_payment" => "payments#paymal_payment"
|
||||
post "create_paymal_payment" => "payments#create_paymal_payment"
|
||||
get ":sale_id/void" => "void#overall_void"
|
||||
|
||||
#API for sync cloud
|
||||
@@ -150,6 +164,14 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get "search_paypar_account_no" => "payments#search_paypar_account_no"
|
||||
# get "check_security_code" => "payments#check_security_code"
|
||||
|
||||
namespace :foodcourt do
|
||||
resources :bills, only: [:create]
|
||||
resources :orders, only: [:create]
|
||||
resources :payments, only: [:create]
|
||||
resources :void, only: [:create]
|
||||
end
|
||||
|
||||
|
||||
#for display image
|
||||
get "display_image/:shop_code" => "display_images#display_image", as:'display_image'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user