api/bill_controller edited
This commit is contained in:
3
app/assets/javascripts/reports/dailysale.coffee
Normal file
3
app/assets/javascripts/reports/dailysale.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/javascripts/reports/saleitem.coffee
Normal file
3
app/assets/javascripts/reports/saleitem.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/javascripts/reports/shiftsale.coffee
Normal file
3
app/assets/javascripts/reports/shiftsale.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -13,27 +13,43 @@
|
||||
|
||||
.selected-item {
|
||||
color: #fff !important;
|
||||
background-color: #ccc !important;
|
||||
background-color: #7a62d3 !important;
|
||||
}
|
||||
|
||||
.assign {
|
||||
color: #fff !important;
|
||||
background-color: red;
|
||||
background-color: #009900;
|
||||
}
|
||||
.assign .text-muted{
|
||||
color: #fff !important;
|
||||
}
|
||||
.normal{
|
||||
color: #fff !important;
|
||||
background-color: #54A5AF;
|
||||
}
|
||||
.cancel {
|
||||
color: #fff !important;
|
||||
background-color: #FF0000;
|
||||
}
|
||||
.red{
|
||||
color: #fff !important;
|
||||
background-color: red;
|
||||
}
|
||||
.green{
|
||||
color: #fff !important;
|
||||
background-color: green;
|
||||
background-color: #009900;
|
||||
}
|
||||
.required abbr{
|
||||
color: red !important;
|
||||
}
|
||||
.jconfirm-box-container{
|
||||
margin-left:-40px !important
|
||||
}
|
||||
.card-columns {
|
||||
@include media-breakpoint-only(lg) {
|
||||
column-count: 5;
|
||||
}
|
||||
@include media-breakpoint-only(xl) {
|
||||
column-count: 5;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
// Place all the styles related to the reports/dailysales controller here.
|
||||
// Place all the styles related to the cash_mgmt controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -72,6 +72,7 @@
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
white-space: normal !important;
|
||||
height: 60px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
@@ -168,6 +169,8 @@
|
||||
background-color: blue
|
||||
}
|
||||
|
||||
/* End Colors */
|
||||
|
||||
.left{
|
||||
margin-left:1px;
|
||||
}
|
||||
@@ -175,6 +178,7 @@
|
||||
.bottom{
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
|
||||
/*----- Reset -----*/
|
||||
|
||||
select.form-control {
|
||||
@@ -197,6 +201,7 @@ tr.discount-item-row:hover {
|
||||
.required abbr{
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
/* Jquery Confirm */
|
||||
|
||||
.jconfirm-box-container{
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Place all the styles related to the reports/sale_items controller here.
|
||||
// Place all the styles related to the origami/shifts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/reports/dailysale.scss
Normal file
3
app/assets/stylesheets/reports/dailysale.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the reports/dailysale controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/reports/saleitem.scss
Normal file
3
app/assets/stylesheets/reports/saleitem.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the reports/saleitem controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/reports/shiftsale.scss
Normal file
3
app/assets/stylesheets/reports/shiftsale.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the reports/shiftsale controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
helper_method :current_token, :current_login_employee
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
|
||||
private
|
||||
@@ -13,6 +13,11 @@ class Api::ApiController < ActionController::API
|
||||
end
|
||||
end
|
||||
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
@@ -13,37 +13,54 @@ class Api::BillController < Api::ApiController
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier)
|
||||
else
|
||||
@status = true
|
||||
@sale_id = booking.sale_id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elsif (params[:order_id])
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee)
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
=======
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# @sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
# @sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = Shop.find(1)
|
||||
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
|
||||
|
||||
# # get printer info
|
||||
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
>>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff
|
||||
|
||||
# # Calculate Price by accounts
|
||||
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
|
||||
<<<<<<< HEAD
|
||||
customer= Customer.find(@sale_data.customer_id)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
=======
|
||||
>>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
||||
|
||||
# Calculate Price by accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -67,43 +67,75 @@ class Api::OrdersController < Api::ApiController
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
check_order_with_booking(booking)
|
||||
sale_status = check_order_with_booking(booking)
|
||||
# puts "WWwwWWWWWWww"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
check_order_with_table(params[:table_id])
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
# puts "OOOOOOOOO"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
check_order_with_table(params[:table_id])
|
||||
end
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
# puts "MMMMMMMM"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
@status, @booking = @order.generate
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
# Description
|
||||
|
||||
@@ -7,12 +7,11 @@ class BaseOrigamiController < ActionController::Base
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
redirect_to origami_root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -6,12 +6,12 @@ class Crm::CustomersController < BaseCrmController
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
filter = params[:filter]
|
||||
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.all
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@@ -32,7 +32,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
def show
|
||||
@orders = Order.where("customer_id=?", params[:id])
|
||||
@sales = Sale.where("customer_id=?", params[:id])
|
||||
|
||||
|
||||
if @orders
|
||||
@order_items = []
|
||||
@orders.each do |order|
|
||||
@@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
def create
|
||||
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
name = customer_params[:name]
|
||||
@@ -81,7 +81,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
nrc = customer_params[:nrc_no]
|
||||
card_no = customer_params[:card_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
|
||||
if !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
@@ -90,7 +90,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
response = HTTParty.post(url,
|
||||
:body => {name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
@@ -103,18 +103,24 @@ class Crm::CustomersController < BaseCrmController
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||
end
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
# @crm_customers.destroy
|
||||
@@ -129,7 +135,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
if params[:sale_id]
|
||||
flash[:errors] = @crm_customers.errors
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
else
|
||||
flash[:errors] = @crm_customers.errors
|
||||
@@ -166,7 +172,7 @@ end
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
response = HTTParty.post(url,
|
||||
:body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
card_no:card_no,member_group_id: member_group_id,
|
||||
@@ -176,16 +182,22 @@ end
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
|
||||
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
@@ -199,7 +211,7 @@ end
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
response = HTTParty.post(url,
|
||||
:body => {name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
@@ -211,6 +223,12 @@ end
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
@@ -219,8 +237,8 @@ end
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
@@ -251,7 +269,7 @@ end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,6 +96,17 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
end
|
||||
end
|
||||
|
||||
def cancel_queue
|
||||
queue = DiningQueue.find(params[:id])
|
||||
|
||||
status = queue.update_attributes(id: params[:id],status:"Cancel")
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
||||
@@ -2,7 +2,7 @@ class HomeController < ApplicationController
|
||||
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||
|
||||
def index
|
||||
@employees = Employee.all.order("name asc")
|
||||
@employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@login_form = LoginForm.new()
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class HomeController < ApplicationController
|
||||
|
||||
if @employee != nil
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to origami_root_path
|
||||
route_by_role(@employee)
|
||||
else
|
||||
render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!"
|
||||
end
|
||||
@@ -37,7 +37,7 @@ class HomeController < ApplicationController
|
||||
redirect_to dashboard_path
|
||||
elsif @employee.role == "cashier"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to origami_root_path
|
||||
route_by_role(@employee)
|
||||
elsif @employee.role == "manager"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to dashboard_path
|
||||
@@ -74,4 +74,25 @@ class HomeController < ApplicationController
|
||||
def settings_home_params
|
||||
params.require(:login_form).permit(:emp_id, :password)
|
||||
end
|
||||
|
||||
def route_by_role(employee)
|
||||
if employee.role == "administrator"
|
||||
redirect_to dashboard_path
|
||||
elsif employee.role == "cashier"
|
||||
#check if cashier has existing open cashier
|
||||
shift = ShiftSale.current_open_shift(employee.id)
|
||||
if !shift.nil?
|
||||
redirect_to origami_root_path
|
||||
else
|
||||
redirect_to new_origami_shift_path
|
||||
end
|
||||
elsif employee.role == "manager"
|
||||
redirect_to oqs_root_path
|
||||
elsif employee.role == "waiter"
|
||||
redirect_to oqs_root_path
|
||||
elsif employee.role == "crm"
|
||||
redirect_to crm_root_path
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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(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.item_code, print_status, options )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
@@ -46,7 +46,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_booking_summary(oqs, booking.booking_id, print_status)
|
||||
order_queue_printer.print_booking_summary(print_settings,oqs, booking.booking_id, print_status)
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
|
||||
18
app/controllers/origami/cash_ins_controller.rb
Normal file
18
app/controllers/origami/cash_ins_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Origami::CashInsController < BaseOrigamiController
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
payment_method = params[:payment_method]
|
||||
payment_method_reference = params[:payment_method_reference]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift.cash_in = shift.cash_in + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
10
app/controllers/origami/cash_mgmt_controller.rb
Normal file
10
app/controllers/origami/cash_mgmt_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Origami::CashMgmtController < ApplicationController
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
end
|
||||
16
app/controllers/origami/cash_outs_controller.rb
Normal file
16
app/controllers/origami/cash_outs_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Origami::CashOutsController < BaseOrigamiController
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
reference = params[:reference]
|
||||
remark = params[:remark]
|
||||
amount = params[:amount]
|
||||
p_jour = PaymentJournal.new
|
||||
p_jour.cash_out(reference, remark, amount, current_user.id)
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if discount_items.length > 0
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
puts di
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
sale_item = SaleItem.new
|
||||
|
||||
@@ -53,6 +52,59 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
# Remove selected discount Items
|
||||
def remove_discount_items
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
discount_items.each do |di|
|
||||
sale_item = SaleItem.find(di["id"])
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
sale_item.destroy
|
||||
end
|
||||
end
|
||||
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
sale.save
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
# Remove all discount Items
|
||||
def remove_all_discount
|
||||
sale_id = params[:id]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.remark == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
si.destroy
|
||||
end
|
||||
end
|
||||
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
sale.save
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
#discount for selected order
|
||||
# def create
|
||||
# sale_id = params[:sale_id]
|
||||
|
||||
@@ -6,6 +6,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.all
|
||||
@orders = Order.all.order('date desc')
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
# origami table detail
|
||||
|
||||
@@ -19,9 +19,9 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@orders = Order.get_orders()
|
||||
end
|
||||
|
||||
def item_show
|
||||
selection(params[:booking_id],1)
|
||||
end
|
||||
# def item_show
|
||||
# selection(params[:booking_id],1)
|
||||
# end
|
||||
|
||||
def selection(selected_id, is_ajax)
|
||||
str = []
|
||||
@@ -37,8 +37,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@order_details = OrderItem.get_order_items_details(params[:booking_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if is_ajax == 1
|
||||
render :json => str.to_json
|
||||
|
||||
48
app/controllers/origami/other_charges_controller.rb
Normal file
48
app/controllers/origami/other_charges_controller.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
class Origami::OtherChargesController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
sale_id = params[:sale_id]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||
sub_total = params[:sub_total]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table_type = DiningFacility.find(table_id).type
|
||||
sale.total_amount = sub_total.to_f
|
||||
sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
sale.save
|
||||
if other_charges_items.length > 0
|
||||
#save sale item for discount
|
||||
other_charges_items.each do |di|
|
||||
# origin_sale_item = SaleItem.find(di["id"])
|
||||
sale_item = SaleItem.new
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = "Other Charges"
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.remark = "Other Charges"
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = di["price"]
|
||||
sale_item.taxable_price = di["price"]
|
||||
sale_item.is_taxable = 0
|
||||
|
||||
sale_item.price = di["price"]
|
||||
sale_item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table_type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
end
|
||||
@@ -4,6 +4,39 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def index
|
||||
end
|
||||
|
||||
def first_bill
|
||||
sale_id = params[:sale_id] # sale_id
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
rounding_adj = sale_data.grand_total - new_total
|
||||
|
||||
sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
|
||||
# Print for First Bill to Customer
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer= Customer.find(sale_data.customer_id)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details)
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
@@ -26,9 +59,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,10 +138,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -10,9 +10,9 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
puts "current_login_employee"
|
||||
puts current_login_employee.name
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee)
|
||||
# puts "current_login_employee"
|
||||
# puts current_login_employee.name
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@@ -20,26 +20,26 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer= Customer.find(@sale_data.customer_id)
|
||||
# get member information
|
||||
member_info = Customer.get_member_account(customer)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Not Use for these printed bill cannot give customer
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
# #shop detail
|
||||
# shop_details = Shop.find(1)
|
||||
# # customer= Customer.where('customer_id=' +.customer_id)
|
||||
# customer= Customer.find(@sale_data.customer_id)
|
||||
# # get member information
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# # get printer info
|
||||
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# find order id by sale id
|
||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
# # find order id by sale id
|
||||
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
# # Calculate price_by_accounts
|
||||
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
# redirect_to origami_path(@sale_data.sale_id)
|
||||
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
authorize_resource :class => false
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
@@ -18,6 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 0
|
||||
@newsaleitem.product_name = saleitemObj.product_name + " - void"
|
||||
@newsaleitem.save
|
||||
end
|
||||
|
||||
36
app/controllers/origami/shifts_controller.rb
Normal file
36
app/controllers/origami/shifts_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
puts current_user.id
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
def new
|
||||
@float = Lookup.where('lookup_type=?','float_value')
|
||||
@terminal = CashierTerminal.all
|
||||
end
|
||||
|
||||
def create
|
||||
opening_balance = params[:opening_balance]
|
||||
@shift = ShiftSale.new
|
||||
@shift.create(opening_balance,current_user)
|
||||
end
|
||||
|
||||
def update_shift
|
||||
closing_balance = params[:closing_balance]
|
||||
shift_id = params[:shift_id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
@shift.shift_closed_at = DateTime.now.utc
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
end
|
||||
end
|
||||
@@ -25,7 +25,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
|
||||
if sale.sale_status != "completed"
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
@sale_array.push(sale)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
authorize_resource :class => false
|
||||
def overall_void
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
@@ -9,6 +9,14 @@ class Origami::VoidController < BaseOrigamiController
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
bookings = sale.bookings
|
||||
bookings.each do |booking|
|
||||
orders = booking.orders
|
||||
orders.each do |order|
|
||||
# order.status = 'void'
|
||||
end
|
||||
end
|
||||
|
||||
table_avaliable = true
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
|
||||
@@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def print_setting_params
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies)
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
class Reports::SaleItemsController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
from, to, report_type = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
class Reports::DailySalesController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
from, to ,report_type = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@tax = SaleTax.get_tax(from,to)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
class Reports::DailySalesController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
class Reports::DailysaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from, to ,report_type = get_date_range_from_params
|
||||
@sale_data = Sale.daily_sales_list(from,to)
|
||||
@@ -13,5 +14,4 @@ class Reports::DailySalesController < BaseReportController
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class Reports::ReceiptNoController < BaseReportController
|
||||
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
puts "from..."
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Reports::SaleItemsController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
class Reports::SaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@@ -16,4 +16,4 @@ class Reports::SaleItemsController < BaseReportController
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
18
app/controllers/reports/shiftsale_controller.rb
Normal file
18
app/controllers/reports/shiftsale_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Reports::ShiftsaleController < ApplicationController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@sale_data = Sale.get_by_shiftsales(from,to)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
16
app/forms/open_shift_form.rb
Normal file
16
app/forms/open_shift_form.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class LoginForm
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_accessor :float_amount
|
||||
validates_presence_of :float_amount
|
||||
|
||||
def persisted?
|
||||
false
|
||||
end
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
2
app/helpers/cash_mgmt_helper.rb
Normal file
2
app/helpers/cash_mgmt_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module CashMgmtHelper
|
||||
end
|
||||
@@ -1,2 +1,3 @@
|
||||
module Origami::RequestBillsHelper
|
||||
|
||||
end
|
||||
|
||||
2
app/helpers/origami/shifts_helper.rb
Normal file
2
app/helpers/origami/shifts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Origami::ShiftsHelper
|
||||
end
|
||||
2
app/helpers/reports/dailysale_helper.rb
Normal file
2
app/helpers/reports/dailysale_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Reports::DailysaleHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module Reports::DailysalesHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module Reports::SaleItemsHelper
|
||||
end
|
||||
2
app/helpers/reports/saleitem_helper.rb
Normal file
2
app/helpers/reports/saleitem_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Reports::SaleitemHelper
|
||||
end
|
||||
2
app/helpers/reports/shiftsale_helper.rb
Normal file
2
app/helpers/reports/shiftsale_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Reports::ShiftsaleHelper
|
||||
end
|
||||
@@ -31,16 +31,23 @@ class Ability
|
||||
can :manage, Sale
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
|
||||
can :index, :dailysale
|
||||
can :index, :saleitem
|
||||
can :index, :receipt_no
|
||||
|
||||
can :add_customer, Customer
|
||||
can :update_sale_by_customer, Customer
|
||||
|
||||
can :index, :other_charges
|
||||
can :create, :other_charges
|
||||
can :index, :discount
|
||||
can :create, :discount
|
||||
can :remove_discount_items, :discount
|
||||
can :remove_all_discount, :discount
|
||||
|
||||
can :first_bill, :payment
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
can :reprint, :payment
|
||||
@@ -50,6 +57,14 @@ class Ability
|
||||
|
||||
can :move_dining, :moveroom
|
||||
|
||||
can :edit, :sale_edit
|
||||
can :item_void, :sale_edit
|
||||
can :item_void_cancel, :sale_edit
|
||||
can :cancel_all_void, :sale_edit
|
||||
can :apply_void, :sale_edit
|
||||
|
||||
can :overall_void, :void
|
||||
|
||||
elsif user.role == "cashier"
|
||||
|
||||
can :read, Order
|
||||
@@ -63,6 +78,8 @@ class Ability
|
||||
|
||||
can :index, :discount
|
||||
can :create, :discount
|
||||
can :remove_discount_items, :discount
|
||||
can :remove_all_discount, :discount
|
||||
|
||||
can :show, :payment
|
||||
can :create, :payment
|
||||
@@ -76,12 +93,17 @@ class Ability
|
||||
elsif user.role == "accountant"
|
||||
|
||||
can :index, :dailysale
|
||||
can :index, :saleitem
|
||||
can :index, :receiptno
|
||||
can :show, :dailysale
|
||||
can :show, :saleitem
|
||||
can :show, :receiptno
|
||||
can :manage, :saleitem
|
||||
can :index, :receiptno
|
||||
|
||||
elsif user.role == "supervisour"
|
||||
|
||||
can :index, :dailysale
|
||||
can :manage, :saleitem
|
||||
can :index, :receiptno
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -31,6 +31,12 @@ class Customer < ApplicationRecord
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
return response;
|
||||
@@ -55,6 +61,12 @@ class Customer < ApplicationRecord
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
return response;
|
||||
|
||||
@@ -39,6 +39,16 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def get_moved_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def get_new_booking
|
||||
# query for new
|
||||
# if status
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
class Employee < ApplicationRecord
|
||||
has_secure_password
|
||||
|
||||
has_many :shit_sales
|
||||
validates_presence_of :name, :role
|
||||
validates_presence_of :password, :on => [:create]
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
|
||||
|
||||
def self.all_emp_except_waiter
|
||||
Employee.where('role!=?','waiter')
|
||||
end
|
||||
|
||||
def self.collection
|
||||
Employee.select("id, name").map { |e| [e.name, e.id] }
|
||||
end
|
||||
|
||||
@@ -25,9 +25,8 @@ class Order < ApplicationRecord
|
||||
booking = nil
|
||||
|
||||
if self.new_booking
|
||||
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name,
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
table = DiningFacility.find(self.table_id)
|
||||
table.status = "occupied"
|
||||
@@ -39,6 +38,7 @@ class Order < ApplicationRecord
|
||||
booking.save!
|
||||
self.default_values
|
||||
|
||||
# cashier already opened?
|
||||
if self.save!
|
||||
|
||||
self.adding_line_items
|
||||
@@ -301,7 +301,7 @@ class Order < ApplicationRecord
|
||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||
.joins("left join orders on orders.order_id = booking_orders.order_id")
|
||||
.joins("left join sales on sales.sale_id = bookings.sale_id")
|
||||
.where("(orders.status = 'new' or orders.status = 'billed')")
|
||||
.where("(orders.status = 'new' or orders.status = 'billed') AND orders.date between #{ from } and #{ to }")
|
||||
|
||||
# orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
|
||||
# orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id
|
||||
|
||||
43
app/models/payment_journal.rb
Normal file
43
app/models/payment_journal.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
class PaymentJournal < ApplicationRecord
|
||||
|
||||
def cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
|
||||
self.payment_references = reference
|
||||
self.remark = remark
|
||||
self.credit_amount = amount
|
||||
self.payment_method = payment_method
|
||||
self.payment_status = 'paid'
|
||||
self.payment_method_references = payment_method_reference
|
||||
self.created_by = current_user
|
||||
self.save
|
||||
end
|
||||
|
||||
def cash_out(payment_reference, remark, amount, current_user)
|
||||
self.payment_references = payment_reference
|
||||
self.remark = remark
|
||||
self.debit_amount = amount
|
||||
self.payment_status = 'paid'
|
||||
self.created_by = current_user
|
||||
self.save
|
||||
end
|
||||
|
||||
# def self.today_cash_in(current_user)
|
||||
# credit = 0.0
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
# pj_credit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user)
|
||||
# pj_credit.each do |obj|
|
||||
# credit += obj.credit_amount
|
||||
# end
|
||||
# return credit
|
||||
# end
|
||||
#
|
||||
# def self.today_cash_out(current_user)
|
||||
# debit = 0.0
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
# pj_debit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user)
|
||||
# pj_debit.each do |obj|
|
||||
# debit += obj.debit_amount
|
||||
# end
|
||||
# return debit
|
||||
# end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(oqs,order_id, item_code, print_status, options="")
|
||||
def print_order_item(print_settings,oqs,order_id, item_code, print_status, options="")
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
@@ -10,7 +10,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# check for item not to show
|
||||
if order_item[0].price != 0
|
||||
pdf = OrderItemPdf.new(order_item[0], print_status, options)
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
|
||||
if oqs.print_copy
|
||||
@@ -26,21 +26,22 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
# Query for per order
|
||||
def print_order_summary(oqs, order_id, order_items, print_status)
|
||||
def print_order_summary(print_settings,oqs, order_id, order_items, print_status)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order=print_query('order_summary', order_id)
|
||||
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order_items.each do|odi|
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
# check for item not to show
|
||||
if odi.price != 0 || odi.price != 10
|
||||
pdf = OrderItemPdf.new(odi, print_status, options)
|
||||
if odi.price != 0
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name)
|
||||
# pdf.render_file "tmp/order_item.pdf"
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
@@ -54,7 +55,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{ order_id }" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order, print_status, order_items)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
self.print(filename, oqs.printer_name)
|
||||
@@ -69,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
# Print for orders in booking
|
||||
def print_booking_summary(oqs, booking_id, print_status)
|
||||
def print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
order=print_query('booking_summary', booking_id)
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
@@ -80,7 +81,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
# check for item not to show
|
||||
if odi.price != 0
|
||||
pdf = OrderItemPdf.new(odi, print_status, options)
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
|
||||
if oqs.print_copy
|
||||
@@ -97,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary_#{ booking_id }" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order, print_status)
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
self.print(filename, oqs.printer_name)
|
||||
@@ -114,31 +115,34 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# Query for OQS with status
|
||||
def print_query(type, id)
|
||||
if type == "order_item"
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("order_items.item_code = '#{ id }' AND order_items.price != 0")
|
||||
.group("order_items.item_code")
|
||||
elsif type == "order_summary"
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("orders.order_id = '#{ id }' AND order_items.price != 0")
|
||||
.group("order_items.order_items_id")
|
||||
else
|
||||
# order summary for booking
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
|
||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||
.where("b.booking_id = '#{ id }' AND order_items.price != 0")
|
||||
end
|
||||
|
||||
|
||||
@@ -65,14 +65,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
# print as print copies in printer setting
|
||||
count = printer_settings.print_copies
|
||||
begin
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
count -= 1
|
||||
end until count == 0
|
||||
end
|
||||
|
||||
#Queue No Print
|
||||
|
||||
@@ -25,7 +25,7 @@ class Sale < ApplicationRecord
|
||||
SALE_STATUS_OUTSTANDING = "outstanding"
|
||||
SALE_STATUS_COMPLETED = "completed"
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by)
|
||||
def generate_invoice_from_booking(booking_id, requested_by, cashier)
|
||||
booking = Booking.find(booking_id)
|
||||
status = false
|
||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||
@@ -35,9 +35,9 @@ class Sale < ApplicationRecord
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
if booking.sale_id
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier)
|
||||
else
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by)
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier)
|
||||
end
|
||||
booking.sale_id = sale_id
|
||||
end
|
||||
@@ -47,7 +47,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by)
|
||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil)
|
||||
taxable = true
|
||||
#if sale_id is exsit and validate
|
||||
#add order to that invoice
|
||||
@@ -66,12 +66,19 @@ class Sale < ApplicationRecord
|
||||
#Default Tax - Values
|
||||
self.tax_type = "exclusive"
|
||||
|
||||
# set cashier by current login
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
# set cashier
|
||||
if cashier != nil
|
||||
self.cashier_id = cashier[0].id
|
||||
self.cashier_name = cashier[0].name
|
||||
else
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
end
|
||||
|
||||
# set waiter
|
||||
self.requested_by = requested_by.name
|
||||
|
||||
self.requested_at = DateTime.now.utc
|
||||
self.requested_at = DateTime.now.utc.getlocal
|
||||
|
||||
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
|
||||
if order
|
||||
@@ -263,9 +270,6 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def product_get_unit_price(item_code)
|
||||
menu_item_hash =MenuItem.search_by_item_code(item_code)
|
||||
if (menu_instance_code)
|
||||
@@ -316,6 +320,41 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_rounding_adjustment(num)
|
||||
## 0 -- 25 -- 50 -- 75 -- 100
|
||||
# if get_rounded_amt == true
|
||||
value = 0
|
||||
|
||||
num = num.to_f.round
|
||||
get_last_no = num.to_s.last(2).to_f
|
||||
if get_last_no.between?(0,25)
|
||||
## down to 0
|
||||
num -= get_last_no
|
||||
else
|
||||
if get_last_no.between?(26,50)
|
||||
## up to 50
|
||||
value = 50 - get_last_no.to_f
|
||||
num += value
|
||||
puts 'up to 50'
|
||||
else
|
||||
if get_last_no.between?(51, 75)
|
||||
## down to 50
|
||||
value = get_last_no.to_f - 50
|
||||
num -= value
|
||||
puts 'down to 50'
|
||||
else
|
||||
## up to 100
|
||||
value = 100 - get_last_no.to_f
|
||||
num += value
|
||||
puts 'up to 100'
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
return num
|
||||
end
|
||||
|
||||
|
||||
def self.daily_sales_list(from,to)
|
||||
payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||
@@ -381,13 +420,13 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
.group('mi.id')
|
||||
.order("mi.menu_category_id")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
JOIN menu_items mi ON i.product_code = mi.item_code" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
|
||||
JOIN employees ea ON ea.id = sales.cashier_id")
|
||||
|
||||
|
||||
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
||||
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
|
||||
|
||||
|
||||
|
||||
@@ -403,6 +442,51 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
|
||||
end
|
||||
|
||||
|
||||
def self.get_by_shiftsales(from,to)
|
||||
return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
|
||||
end
|
||||
|
||||
def get_cash_amount
|
||||
cash = 0.0
|
||||
self.sale_payments.each do |pay|
|
||||
if pay.payment_method == 'cash'
|
||||
cash = pay.payment_amount
|
||||
end
|
||||
end
|
||||
return cash
|
||||
end
|
||||
|
||||
def get_credit_amount
|
||||
credit = 0.0
|
||||
self.sale_payments.each do |pay|
|
||||
if pay.payment_method == 'creditnote'
|
||||
credit = pay.payment_amount
|
||||
end
|
||||
end
|
||||
return credit
|
||||
end
|
||||
|
||||
def get_other_amount
|
||||
other = 0.0
|
||||
self.sale_payments.each do |pay|
|
||||
if pay.payment_method != 'cash' && pay.payment_method != 'creditnote'
|
||||
other += pay.payment_amount
|
||||
end
|
||||
end
|
||||
return other
|
||||
end
|
||||
|
||||
def get_commerical_tax
|
||||
tax = 0.0
|
||||
self.sale_taxes.each do |tax|
|
||||
if tax.tax_name == "Commerical Tax"
|
||||
tax += tax.tax_payable_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
@@ -30,15 +30,17 @@ class SaleItem < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
|
||||
# Get Prices for each accounts (eg: food, beverage)
|
||||
def self.calculate_price_by_accounts(sale_items)
|
||||
price_accounts = []
|
||||
Account.all.each do |a|
|
||||
account_price = {:name => a.title, :price => 0}
|
||||
|
||||
# Check for actual sale items
|
||||
sale_items.each do |si|
|
||||
if si.account_id == a.id
|
||||
account_price[:price] = account_price[:price] + si.price
|
||||
end
|
||||
account_price[:price] = account_price[:price] + si.price
|
||||
end
|
||||
end
|
||||
price_accounts.push(account_price)
|
||||
end
|
||||
@@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord
|
||||
return price_accounts
|
||||
end
|
||||
|
||||
# Get discount Prices for each accounts (eg: food, beverage)
|
||||
def self.get_discount_price_by_accounts(sale_items)
|
||||
discount_accounts = []
|
||||
Account.all.each do |a|
|
||||
discount_account = {:name => a.title, :price => 0}
|
||||
|
||||
# Check for actual sale items
|
||||
sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si|
|
||||
if si.account_id == a.id
|
||||
discount_account[:price] = (discount_account[:price] + si.price) * -1
|
||||
end
|
||||
end
|
||||
discount_accounts.push(discount_account)
|
||||
end
|
||||
|
||||
return discount_accounts
|
||||
end
|
||||
|
||||
# Calculate rebate_by_account
|
||||
def self.calculate_rebate_by_account(sale_items)
|
||||
rebateacc = Account.where("rebate=?",true)
|
||||
|
||||
@@ -77,6 +77,12 @@ class SalePayment < ApplicationRecord
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
return response;
|
||||
end
|
||||
@@ -110,6 +116,12 @@ class SalePayment < ApplicationRecord
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = false
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
else
|
||||
response = false;
|
||||
@@ -131,7 +143,6 @@ class SalePayment < ApplicationRecord
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -146,7 +157,6 @@ class SalePayment < ApplicationRecord
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -161,7 +171,6 @@ class SalePayment < ApplicationRecord
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -175,7 +184,6 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
@@ -192,7 +200,6 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
@@ -220,7 +227,6 @@ class SalePayment < ApplicationRecord
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
|
||||
return payment_status
|
||||
|
||||
end
|
||||
@@ -249,10 +255,20 @@ class SalePayment < ApplicationRecord
|
||||
self.sale.save!
|
||||
table_update_status(sObj)
|
||||
rebat(sObj)
|
||||
if paid_amount != "0.0"
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def update_shift
|
||||
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
|
||||
if !shift.nil?
|
||||
shift.update(self.sale)
|
||||
end
|
||||
end
|
||||
|
||||
def table_update_status(sale_obj)
|
||||
status = true
|
||||
booking = Booking.find_by_sale_id(sale_obj.id)
|
||||
@@ -308,6 +324,12 @@ class SalePayment < ApplicationRecord
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
return response
|
||||
# puts response.to_json
|
||||
@@ -315,6 +337,8 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||
|
||||
62
app/models/shift_sale.rb
Normal file
62
app/models/shift_sale.rb
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
#Description
|
||||
#total_revenue = sum of all sub-total from sales table
|
||||
#total_discounts = sum of all discount (overall) from sales tables
|
||||
#total_taxes = sum of all taxes from sales table (Service + Goverment Tax (commercial_taxes))
|
||||
#grand_total = total_revenue - total_discounts + total_taxes
|
||||
#nett_sales = grand_total - commercial_taxes
|
||||
#cash_sales = cash payment total revenue
|
||||
#credit_sales = credit payment total revenue
|
||||
#others_sales = [Sum of each of other payment type --- mpu, jcb, visa,master, rebate, vochure]
|
||||
#commercial_taxes = Total Goverment tax due
|
||||
#cash_in = Payment receive
|
||||
#Cash_out = Payment issues for misc payments
|
||||
|
||||
class ShiftSale < ApplicationRecord
|
||||
belongs_to :cashier_terminal
|
||||
belongs_to :employee, :foreign_key => 'employee_id'
|
||||
|
||||
def self.current_open_shift(current_user)
|
||||
#if current_user
|
||||
#find open shift where is open today and is not closed and login by current cashier
|
||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
puts today_date
|
||||
shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}", today_date).take
|
||||
|
||||
return shift
|
||||
#end
|
||||
end
|
||||
|
||||
def create(opening_balance,current_user)
|
||||
self.cashier_terminal_id = CashierTerminal.first.id
|
||||
self.shift_started_at = DateTime.now
|
||||
self.employee_id = current_user.id
|
||||
self.opening_balance = opening_balance
|
||||
self.save
|
||||
end
|
||||
|
||||
def update(sale)
|
||||
saleobj = Sale.find_by_sale_id(sale)
|
||||
cash = saleobj.get_cash_amount
|
||||
credit = saleobj.get_credit_amount
|
||||
other_sales = saleobj.get_other_amount
|
||||
tax = saleobj.get_commerical_tax
|
||||
self.total_revenue = self.total_revenue.to_f + saleobj.total_amount.to_f
|
||||
self.total_discounts = self.total_discounts + saleobj.total_discount
|
||||
self.total_taxes = self.total_taxes + saleobj.total_tax
|
||||
self.grand_total = self.grand_total + saleobj.grand_total
|
||||
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
||||
self.credit_sales = self.credit_sales.to_i + credit.to_f
|
||||
self.other_sales = self.other_sales.to_i + other_sales.to_f
|
||||
self.nett_sales = self.grand_total.to_i - self.commercial_taxes
|
||||
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
||||
self.save
|
||||
|
||||
end
|
||||
|
||||
def get_closing_balance(shift)
|
||||
shiftobj = ShiftSale.find(shift)
|
||||
closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash
|
||||
return closing_balance
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class OrderItemPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(order_item, print_status, options)
|
||||
def initialize(print_settings,order_item, print_status, options, alt_name)
|
||||
self.page_width = 210
|
||||
self.page_height = 1450
|
||||
self.margin = 5
|
||||
@@ -12,12 +12,13 @@ class OrderItemPdf < Prawn::Document
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=100
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
@@ -29,7 +30,7 @@ class OrderItemPdf < Prawn::Document
|
||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item, options)
|
||||
order_items(order_item, options, alt_name)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
@@ -57,11 +58,11 @@ class OrderItemPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# Write Order items to PDF
|
||||
def order_items(order_item, options)
|
||||
def order_items(order_item, options, alt_name)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, options)
|
||||
add_order_items(order_item, options, alt_name)
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
@@ -69,19 +70,31 @@ class OrderItemPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
def add_order_items(order_item, options)
|
||||
def add_order_items(order_item, options, alt_name)
|
||||
y_position = cursor
|
||||
|
||||
move_down 5
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
if alt_name
|
||||
move_down 4
|
||||
font("public/fonts/Chinese.ttf") do
|
||||
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
end
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
# add option
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class OrderSummaryPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(order, print_status, order_items = nil)
|
||||
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
|
||||
self.page_width = 210
|
||||
self.page_height = 1450
|
||||
self.margin = 5
|
||||
@@ -12,11 +12,11 @@ class OrderSummaryPdf < Prawn::Document
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=100
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
@@ -29,9 +29,9 @@ class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order)
|
||||
order_items(order, alt_name)
|
||||
else
|
||||
order_items(order_items)
|
||||
order_items(order_items, alt_name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# Write Order items to PDF
|
||||
def order_items(order_item)
|
||||
def order_items(order_item, alt_name)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
@@ -75,12 +75,12 @@ class OrderSummaryPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item)
|
||||
add_order_items(order_item, alt_name)
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
def add_order_items(order_item)
|
||||
def add_order_items(order_item, alt_name)
|
||||
y_position = cursor
|
||||
|
||||
move_down 5
|
||||
@@ -92,12 +92,26 @@ class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{odi.qty}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
if alt_name
|
||||
move_down 4
|
||||
font("public/fonts/Chinese.ttf") do
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
# add option
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
|
||||
self.page_width = 210
|
||||
self.page_height = 7000
|
||||
self.margin = 5
|
||||
@@ -16,7 +17,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
# @double = @qty_width * 1.3
|
||||
# @half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
@@ -24,22 +25,33 @@ class ReceiptBillPdf < Prawn::Document
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 8
|
||||
|
||||
if printer_settings.delimiter
|
||||
delimiter = ","
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
|
||||
header( shop_details)
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name)
|
||||
line_items(sale_items)
|
||||
all_total(sale_data)
|
||||
line_items(sale_items,printer_settings.precision,delimiter)
|
||||
all_total(sale_data,printer_settings.precision,delimiter)
|
||||
|
||||
|
||||
if member_info != nil
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data)
|
||||
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter)
|
||||
end
|
||||
|
||||
customer(customer_name)
|
||||
|
||||
items_account(item_price_by_accounts)
|
||||
if discount_price_by_accounts.length > 0
|
||||
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
|
||||
end
|
||||
|
||||
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
|
||||
|
||||
|
||||
footer
|
||||
end
|
||||
@@ -83,7 +95,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
|
||||
text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
|
||||
text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
@@ -97,7 +109,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
|
||||
def line_items(sale_items)
|
||||
def line_items(sale_items,precision,delimiter)
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
@@ -110,10 +122,10 @@ class ReceiptBillPdf < Prawn::Document
|
||||
}
|
||||
move_down -5
|
||||
stroke_horizontal_rule
|
||||
add_line_item_row(sale_items)
|
||||
add_line_item_row(sale_items,precision,delimiter)
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items)
|
||||
def add_line_item_row(sale_items,precision,delimiter)
|
||||
item_name_width = (self.item_width+self.price_width)
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
@@ -132,9 +144,9 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
pad_top(15) {
|
||||
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
move_down 1
|
||||
end
|
||||
@@ -148,20 +160,20 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
end
|
||||
|
||||
def all_total(sale_data)
|
||||
def all_total(sale_data,precision,delimiter)
|
||||
item_name_width = self.item_width
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Discount", :size => self.item_font_size,:align => :left
|
||||
text "Overall Discount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
if sale_data.sale_taxes.length > 0
|
||||
@@ -173,7 +185,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ st.tax_payable_amount }" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -194,18 +206,18 @@ class ReceiptBillPdf < Prawn::Document
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Grand Total", :size => self.header_font_size,:align => :left
|
||||
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{sale_data.grand_total}" , :size => self.header_font_size,:align => :right
|
||||
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
|
||||
sale_payment(sale_data)
|
||||
sale_payment(sale_data,precision,delimiter)
|
||||
|
||||
end
|
||||
|
||||
def sale_payment(sale_data)
|
||||
def sale_payment(sale_data,precision,delimiter)
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
@@ -216,7 +228,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ payment.payment_amount }" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
end
|
||||
@@ -227,7 +239,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Change Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{sale_data.amount_changed}" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
end
|
||||
@@ -235,7 +247,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# show member information
|
||||
def member_info(member_info,customer_name,rebate_amount,sale_data)
|
||||
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter)
|
||||
|
||||
if rebate_amount != nil
|
||||
|
||||
@@ -251,7 +263,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Current Rebate Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
|
||||
@@ -262,15 +274,15 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Current Redeem Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "(#{ res["redeem"] })" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
if member_info["status"] == true
|
||||
balance = 0.0
|
||||
if member_info["status"] == true && member_info["data"].present?
|
||||
balance = 0
|
||||
member_info["data"].each do |res|
|
||||
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@@ -285,7 +297,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "Current Balance", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ balance }" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
@@ -301,8 +313,23 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
def discount_account(discount_price_by_accounts,precision,delimiter)
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
discount_price_by_accounts.each do |ipa|
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def items_account(item_price_by_accounts)
|
||||
def items_account(item_price_by_accounts,precision,delimiter)
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
@@ -313,7 +340,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right
|
||||
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,19 +18,25 @@
|
||||
<div class="active" role="tabpanel">
|
||||
<div class="tab-pane" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @i =0 %>
|
||||
|
||||
<% @dining_queues.each do |queue| %>
|
||||
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" data-id="<%= queue.id %>">
|
||||
<% if queue.status == "Assign"
|
||||
@bg_color = "assign"
|
||||
elsif queue.status == "Cancel"
|
||||
@bg_color = "cancel"
|
||||
else
|
||||
@bg_color = "normal"
|
||||
end
|
||||
%>
|
||||
<div class="card select-queue <%= @bg_color %>" data-id="<%= queue.id %>" style="width: 21.5rem;">
|
||||
<div class="card-block">
|
||||
<p class="hidden queue-id"><%= queue.id %></p>
|
||||
<p class="hidden queue-status"><%= queue.status %></p>
|
||||
<span class="card-title">
|
||||
<%= @i += 1 %> . Queue No </span>
|
||||
<span class="card-title pull-right">Seater : <%= queue.seater %> </span>
|
||||
<p style="font-size: 30px ;text-align: center;">
|
||||
<strong><%= queue.queue_no %></strong>
|
||||
</p>
|
||||
|
||||
<span class="card-title"><strong> Queue No : <%= queue.queue_no %></strong></span>
|
||||
<span class="card-title pull-right"><strong> Seater : <%= queue.seater %></strong></span><br>
|
||||
<span class="card-title"> Name : <%= queue.name %></span><br>
|
||||
<span class="card-title"> Contact No : <%= queue.contact_no %></span>
|
||||
<span class="card-title"> Remark : <%= queue.remark %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -43,7 +49,7 @@
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
|
||||
|
||||
<button type="button" id="cancel" class="btn btn-warning btn-lg btn-block" disabled>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
@@ -53,20 +59,61 @@ $(function(){
|
||||
$('.select-queue').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
var status = $(this).find(".queue-status").text();
|
||||
if(status != "Assign"){
|
||||
if(status != "Assign" && status != "Cancel"){
|
||||
$("#assign").removeAttr("disabled");
|
||||
$("#cancel").removeAttr("disabled");
|
||||
}else{
|
||||
$("#assign").attr("disabled","disabled");
|
||||
$("#cancel").attr("disabled","disabled");
|
||||
}
|
||||
$("#assign").val($(this).find(".queue-id").text());
|
||||
$("#cancel").val($(this).find(".queue-id").text());
|
||||
}); //End Click
|
||||
|
||||
|
||||
});
|
||||
$('#assign').click(function() {
|
||||
var id = $(this).val();
|
||||
window.location.href = "dining_queues/"+id + "/assign"
|
||||
var id = $(this).val();
|
||||
window.location.href = "dining_queues/"+id + "/assign"
|
||||
});
|
||||
|
||||
});
|
||||
$('#cancel').click(function() {
|
||||
var id = $(this).val();
|
||||
url = '<%= crm_cancel_queue_path %>';
|
||||
cancel_queue(id,url);
|
||||
});
|
||||
|
||||
|
||||
function cancel_queue(id,url) {
|
||||
$.confirm({
|
||||
title: 'Confirm!',
|
||||
content: 'Are You Sure to cancel this Queue!',
|
||||
buttons: {
|
||||
cancel: function () {
|
||||
},
|
||||
confirm: {
|
||||
text: 'Confirm',
|
||||
btnClass: 'btn-green',
|
||||
keys: ['enter', 'shift'],
|
||||
action: function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url ,
|
||||
data: {id:id},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true)
|
||||
{
|
||||
location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -1,14 +1,24 @@
|
||||
<style>
|
||||
.pin_pad {
|
||||
width:10rem;
|
||||
height:10rem;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 10rem;
|
||||
margin:2px;
|
||||
margin-top:4px;
|
||||
margin-bottom:4px;
|
||||
font-size:3rem;
|
||||
width: 30%;
|
||||
height:70px;
|
||||
line-height:70px;
|
||||
text-align:center;
|
||||
background:#54A5AF;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
}
|
||||
.bottom{
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
.left{
|
||||
margin-left:1px;
|
||||
}
|
||||
.orange{
|
||||
background-color:#FF7F50;
|
||||
}
|
||||
.purple {
|
||||
background-color:#7a62d3;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -23,21 +33,29 @@
|
||||
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content" style="margin:10px; margin-top:0px; text-align:center">
|
||||
<button class="pin_pad" data-value="1">1</button>
|
||||
<button class="pin_pad" data-value="2">2</button>
|
||||
<button class="pin_pad" data-value="3">3</button>
|
||||
<button class="pin_pad" data-value="4">4</button>
|
||||
<button class="pin_pad" data-value="5">5</button>
|
||||
<button class="pin_pad" data-value="6">6</button>
|
||||
<button class="pin_pad" data-value="7">7</button>
|
||||
<button class="pin_pad" data-value="8">8</button>
|
||||
<button class="pin_pad" data-value="9">9</button>
|
||||
<button class="pin_pad" data-value="CLR">CLR</button>
|
||||
<button class="pin_pad" data-value="8">0</button>
|
||||
<button class="pin_pad btn-warning" data-value="ENT">ENT</button>
|
||||
|
||||
<div class="content row" style="padding-left:10px;margin-left:10px; margin-top:0px; text-align:center">
|
||||
<div class='col-md-12'>
|
||||
<div class='row bottom'>
|
||||
<div class="pin_pad " data-value="1">1</div>
|
||||
<div class="pin_pad left" data-value="2">2</div>
|
||||
<div class="pin_pad left" data-value="3">3</div>
|
||||
</div>
|
||||
<div class='row bottom'>
|
||||
<div class="pin_pad" data-value="4">4</div>
|
||||
<div class="pin_pad left" data-value="5">5</div>
|
||||
<div class="pin_pad left" data-value="6">6</div>
|
||||
</div>
|
||||
<div class='row bottom'>
|
||||
<div class="pin_pad" data-value="7">7</div>
|
||||
<div class="pin_pad left" data-value="8">8</div>
|
||||
<div class="pin_pad left" data-value="9">9</div>
|
||||
</div>
|
||||
<div class='row bottom'>
|
||||
<div class="pin_pad orange" data-value="CLR">CLR</div>
|
||||
<div class="pin_pad left" data-value="8">0</div>
|
||||
<div class="pin_pad left purple" data-value="ENT">ENT</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer text-center" style="margin:10px">
|
||||
|
||||
</div>
|
||||
|
||||
@@ -33,15 +33,16 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li><%= link_to "Orders ", transactions_orders_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Sales ", transactions_sales_path, :tabindex =>"-1" %></li>
|
||||
<!-- <li><%= link_to "Sales ", transactions_credit_notes_path, :tabindex =>"-1" %></li> -->
|
||||
<li><%= link_to "Credit Note ", transactions_credit_notes_path, :tabindex =>"-1" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="navbar-nav mr-auto dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Reports</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><%= link_to "Daily Sale Report", reports_daily_sales_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Sales Item Report", reports_sale_items_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li>
|
||||
<!-- <li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li> -->
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
<%= render 'layouts/header_orgiami' %>
|
||||
<div class="container-fluid">
|
||||
<% flash.each do |type, message| %>
|
||||
<% if !flash["errors"]%>
|
||||
<div class="alert fade in">
|
||||
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
|
||||
<%=message%>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !flash["errors"]%>
|
||||
<div class="alert fade in">
|
||||
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
|
||||
<%=message%>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= yield %>
|
||||
|
||||
</div>
|
||||
|
||||
79
app/views/origami/cash_ins/new.html.erb
Normal file
79
app/views/origami/cash_ins/new.html.erb
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
<div class='row'>
|
||||
<div class="col-lg-11 col-md-11 col-sm-11">
|
||||
<h2> Payment Credit </h2>
|
||||
<br>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td> Payment Reference
|
||||
</td>
|
||||
<td><input type='text' id='reference'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Remark
|
||||
</td>
|
||||
<td><input type="text" id='remark'/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Payment Method
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-primary payment-type' data-id='cash' id='cash'>CASH</button>
|
||||
<button class='btn btn-primary payment-type' data-id='mpu' id='mpu'>MPU</button>
|
||||
<button class='btn btn-primary payment-type' data-id='visa' id='visa'>VISA</button>
|
||||
<button class='btn btn-primary payment-type' data-id='jcb' id='jcb'>JCB</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class='row'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-2'>Reference Number </div>
|
||||
<div class='col-md-4'><input type='text' id='payment_method_reference'/> </div>
|
||||
</div>
|
||||
<br>
|
||||
<div class='row'>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-2'>Amount</div>
|
||||
<div class='col-md-4'><input type='text' id='amount'/></div>
|
||||
</div>
|
||||
<br><br>
|
||||
<div class='row'>
|
||||
<div class='col-md-3'></div>
|
||||
<div class='col-md-4'><button class='btn btn-primary btn-lg' id='cash_in' style='width:200px;'> Cash In</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button class='btn btn-primary ' id='cash_in' style='width:100px;'> Back </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var payment_method = "";
|
||||
$('.payment-type').on('click',function(){
|
||||
$('.payment-type').css("background-color","#7a62d3")
|
||||
$(this).css("background-color","green");
|
||||
var type = $(this).attr('data-id')
|
||||
if(type == 'cash'){
|
||||
payment_method = 'cash';
|
||||
}else if(type == 'mpu'){
|
||||
payment_method = "mpu";
|
||||
}else if(type == 'visa'){
|
||||
payment_method = "visa";
|
||||
}else if(type == 'jcb'){
|
||||
payment_method = "jcb";
|
||||
}
|
||||
})
|
||||
$('#cash_in').on('click',function(){
|
||||
var reference = $('#reference').val();
|
||||
var remark = $('#remark').val();
|
||||
var amount = $('#amount').val();
|
||||
var payment_method_reference = $('#payment_method_reference').val();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_cash_ins_path %>",
|
||||
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount + "&payment_method="+payment_method + "&payment_method_reference="+ payment_method_reference,
|
||||
success:function(result){
|
||||
window.location.href = '/origami';
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
2
app/views/origami/cash_mgmt/create.html.erb
Normal file
2
app/views/origami/cash_mgmt/create.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#create</h1>
|
||||
<p>Find me in app/views/cash_mgmt/create.html.erb</p>
|
||||
2
app/views/origami/cash_mgmt/index.html.erb
Normal file
2
app/views/origami/cash_mgmt/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#index</h1>
|
||||
<p>Find me in app/views/cash_mgmt/index.html.erb</p>
|
||||
2
app/views/origami/cash_mgmt/new.html.erb
Normal file
2
app/views/origami/cash_mgmt/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>CashMgmt#new</h1>
|
||||
<p>Find me in app/views/cash_mgmt/new.html.erb</p>
|
||||
44
app/views/origami/cash_outs/new.html.erb
Normal file
44
app/views/origami/cash_outs/new.html.erb
Normal file
@@ -0,0 +1,44 @@
|
||||
<h2>Payment Debit</h2>
|
||||
<div class='row'>
|
||||
<div class='col-md-9'>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td> Payment Reference
|
||||
</td>
|
||||
<td><input id='reference' type='text' value=''/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Remark
|
||||
</td>
|
||||
<td><input id='remark' type="text" value=''/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Amount
|
||||
</td>
|
||||
<td><input id='amount' type="text" value=''/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br><br>
|
||||
<div class='row'>
|
||||
<div class='col-md-3'></div>
|
||||
<div class='col-md-4'><button class='btn btn-primary btn-lg' id='cash_out'> Cash Out</button></div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$('#cash_out').on('click',function(){
|
||||
var reference = $('#reference').val();
|
||||
var remark = $('#remark').val();
|
||||
var amount = $('#amount').val();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_cash_outs_path %>",
|
||||
data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount,
|
||||
success:function(result){
|
||||
window.location.href = '/origami';
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">20%</div>
|
||||
<div class="fluid cashier_number" data-value="20" data-type="add">15%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="7" data-type="num">7</div>
|
||||
@@ -149,7 +149,7 @@
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">30%</div>
|
||||
<div class="fluid cashier_number" data-value="30" data-type="add">20%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="0" data-type="num">0</div>
|
||||
@@ -160,7 +160,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="50" data-type="add">50%</div>
|
||||
<div class="fluid cashier_number" data-value="50" data-type="add">30%</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number"></div>
|
||||
@@ -172,7 +172,7 @@
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<button id="net" class="btn btn-warning fluid action-btn">Nett</button>
|
||||
<button id="net" class="btn btn-info fluid action-btn">Nett</button>
|
||||
<button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button>
|
||||
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
|
||||
</div>
|
||||
@@ -187,6 +187,8 @@
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
|
||||
<button id="remove-item-discount" class="btn btn-warning btn-block action-btn">Remove Discount</button>
|
||||
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
|
||||
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -358,6 +360,64 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Remove selected given discount item
|
||||
$("#remove-item-discount").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var discount_items = [];
|
||||
|
||||
// Selected Items
|
||||
var sale_items = get_selected_sale_items();
|
||||
if(sale_items.length == 0){
|
||||
alert("You have no selected item!");
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i=0;i < sale_items.length;i++){
|
||||
if(sale_items[i].price < 0){
|
||||
discount_items.push(sale_items[i]);
|
||||
}
|
||||
else {
|
||||
alert("You have selected no discount item!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/" + sale_id + "/remove_discount_items",
|
||||
data: params,
|
||||
success: function(result){
|
||||
alert('Removed Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#remove-all").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/origami/" + sale_id + "/remove_all_discount",
|
||||
success: function(result){
|
||||
alert('Removed All Discount');
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-11 col-md-11 col-sm-11">
|
||||
<div class="col-lg-10 col-md-10 col-sm-10">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
@@ -27,6 +27,7 @@
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %>
|
||||
<span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -102,8 +103,11 @@
|
||||
</div>
|
||||
<!-- tabs - End -->
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<button id="refreshbutton" type="button" class="btn btn-block" style="border-radius:5px;color:#fff;background-color:red;"> Refresh off </button>
|
||||
<button id="cash_in" type="button" class="btn btn-block btn-primary" style="border-radius:5px;color:#fff;"> Cash In </button>
|
||||
<button id="cash_out" type="button" class="btn btn-block btn-primary" style="border-radius:5px;color:#fff;"> Cash Out </button>
|
||||
<button id="close_cashier" type="button" class="btn btn-block btn-primary" style="border-radius:5px;color:#fff;"> Close Cashier </button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
@@ -192,4 +196,16 @@ $(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#cash_in').on('click',function(){
|
||||
window.location.href = '/origami/cash_ins/new';
|
||||
})
|
||||
|
||||
$('#cash_out').on('click',function(){
|
||||
window.location.href = '/origami/cash_outs/new';
|
||||
})
|
||||
|
||||
$('#close_cashier').on('click',function(){
|
||||
window.location.href = '/origami/shift/close';
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist" id="mytab">
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Completed</a>
|
||||
<a class="nav-link" data-toggle="tab" href="#Completed" role="tab">Completed</a>
|
||||
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
|
||||
@@ -21,12 +23,14 @@
|
||||
|
||||
<div class="tab-content" style="max-height:670px; overflow:auto">
|
||||
<!--- Panel 0 - Completed Orders -->
|
||||
|
||||
<div class="tab-pane" id="completed" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %>
|
||||
<span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -38,6 +42,7 @@
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @tables.each do |table| %>
|
||||
<% if table.status == 'occupied' %>
|
||||
|
||||
<% if table.get_booking.nil? %>
|
||||
<div class="card tables red text-white" data-id="<%= table.id %>">
|
||||
<div class="card-block">
|
||||
@@ -70,6 +75,7 @@
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<% @rooms.each do |room| %>
|
||||
<% if room.status == 'occupied' %>
|
||||
|
||||
<div class="card rooms red text-white" data-id="<%= room.id %>">
|
||||
<div class="card-block">
|
||||
<%= room.name %>
|
||||
@@ -94,6 +100,7 @@
|
||||
<!--- Panel 3 - Orders -->
|
||||
<div class="tab-pane" id="orders" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
|
||||
<div class="card-block">
|
||||
@@ -103,7 +110,6 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- tabs - End -->
|
||||
</div>
|
||||
@@ -113,6 +119,7 @@
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<div id="save_order_id" data-order="<%= @obj_order.order_id %>"><strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %></div>
|
||||
<% elsif @status_sale == 'sale' %>
|
||||
@@ -123,12 +130,14 @@
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p> Receipt No: <span id="receipt_no">
|
||||
|
||||
<% if @status_sale == 'sale' %>
|
||||
<%= @sale_array[0].receipt_no rescue '' %>
|
||||
<% end %>
|
||||
</span></p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
|
||||
<p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -145,6 +154,7 @@
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</td>
|
||||
@@ -153,6 +163,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
|
||||
count = 0
|
||||
sub_total = 0
|
||||
if @status_sale == "sale"
|
||||
@@ -172,6 +183,7 @@
|
||||
<td class='item-attr'><%= sale_item.price %></td>
|
||||
</tr>
|
||||
<%
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -191,6 +203,7 @@
|
||||
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
|
||||
</tr>
|
||||
<%
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -207,6 +220,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
|
||||
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<% if @status_sale == "sale" %>
|
||||
@@ -214,6 +228,10 @@
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
|
||||
@@ -270,7 +288,6 @@
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -278,6 +295,7 @@
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
|
||||
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
|
||||
<% if @dining.bookings.length >= 1 %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
|
||||
@@ -285,17 +303,21 @@
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<button type="button" class="btn btn-primary btn-block" >Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
|
||||
<% else %>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
||||
<% end %>
|
||||
@@ -307,6 +329,7 @@
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
$('.invoicedetails').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
var sale_id = this.id;
|
||||
@@ -369,6 +392,25 @@ $(document).ready(function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
// Add Other Charges
|
||||
$('#other-charges').click(function() {
|
||||
var sale = $('#sale_id').val();
|
||||
if (sale!="") {
|
||||
var sale_id = sale
|
||||
}else{
|
||||
var sale_id = $('#save_order_id').attr('data-order');
|
||||
}
|
||||
|
||||
if(sale_id!=""){
|
||||
window.location.href = '/origami/' + sale_id + '/other_charges'
|
||||
}
|
||||
else {
|
||||
alert("Please select an table!");
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Discount for Payment
|
||||
$('#discount').click(function() {
|
||||
var sale = $('#sale_id').val();
|
||||
@@ -387,10 +429,21 @@ $(document).ready(function(){
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Print for first bill
|
||||
$("#first_bill").on('click', function(){
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/"+ sale_id + "/first_bill";
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success:function(result){
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#pay').on('click',function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
@@ -402,9 +455,9 @@ $('#request_bills').click(function() {
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
data: 'order_id='+ order_id,
|
||||
// data: 'order_id='+ order_id,
|
||||
success:function(result){
|
||||
|
||||
location.reload();
|
||||
@@ -468,31 +521,28 @@ function show_customer_details(customer_id){
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
}
|
||||
}
|
||||
|
||||
$('#edit').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
||||
})
|
||||
|
||||
$('#void').on('click',function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
$('#edit').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %>
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
331
app/views/origami/other_charges/index.html.erb
Normal file
331
app/views/origami/other_charges/index.html.erb
Normal file
@@ -0,0 +1,331 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<!-- Order Details -->
|
||||
<div class="card" >
|
||||
<!-- <div class="card-header">
|
||||
<div><strong id="order-title">ORDER DETAILS</strong></div>
|
||||
</div> -->
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||
<p>Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
|
||||
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-text">
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</td>
|
||||
<th class="item-attr">Price</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% sub_total = 0 %>
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<%
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=sale_item.qty%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
end
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<!-- Discount Amount -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">Other Charges Control</strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<div class="form-horizontal">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<textarea id="reasons" name="reasons" rows="2" class="form-control" placeholder="Reasons"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="3000" data-type="add">3000</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="5000" data-type="add">5000</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="10000" data-type="add">10000</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="15000" data-type="add">15000</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 left cashier_number" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="fluid cashier_number" data-value="20000" data-type="add">20000</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-4 cashier_number"></div>
|
||||
<div class="col-md-4 left cashier_number red" data-type="del">DEL</div>
|
||||
<div class="col-md-4 left cashier_number green" data-type="clr">CLR</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<button id="add_charges" class="btn btn-info fluid action-btn">Add</button>
|
||||
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
|
||||
<button id="charge_other" class="btn btn-danger btn-block action-btn">Enter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value=0;
|
||||
original_value = $('#other-charges-amount').val();
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('#other-charges-amount').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('#other-charges-amount').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('#other-charges-amount').val(amount);
|
||||
break;
|
||||
|
||||
case 'del' :
|
||||
var discount_text=$('#other-charges-amount').val();
|
||||
$('#other-charges-amount').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
|
||||
case 'clr':
|
||||
$('#other-charges-amount').val("0.0");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Select discount-item
|
||||
$('#order-items-table tbody').on('click', '.other-item-row',function(){
|
||||
if($(this).hasClass('selected-item') == true){
|
||||
$(this).removeClass('selected-item');
|
||||
}
|
||||
else {
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
});
|
||||
|
||||
// Remove selected discount items
|
||||
$("#remove-item").on('click', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
$('.other-item-row.selected-item').each(function(i){
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var charge_amount = $(this).children('td').find("#item-total-price").text();
|
||||
|
||||
// Update sub total
|
||||
$('#order-sub-total').text(parseFloat(sub_total) - parseFloat(charge_amount));
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
|
||||
// Calculate Net Discount for Payment
|
||||
$("#add_charges").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var charge_amount = $("#other-charges-amount").val();
|
||||
var reasons = $("#reasons").val();
|
||||
|
||||
// Update sub total
|
||||
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
|
||||
|
||||
var item_row = item_row_template(sale_id, charge_amount, reasons);
|
||||
$("#order-items-table tbody").append(item_row);
|
||||
});
|
||||
|
||||
// Calculate Other Charges for Payment
|
||||
$("#charge_other").on('click', function(e){
|
||||
e.preventDefault();
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sub_total = $('#order-sub-total').text();
|
||||
var other_charges_items = JSON.stringify(get_other_item_rows());
|
||||
var ajax_url = "/origami/" + sale_id + "/other_charges";
|
||||
|
||||
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items };
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
success:function(result){
|
||||
alert("Success!");
|
||||
if(result.table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + result.table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + result.table_id
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* Remove Selection */
|
||||
function selection_remove(){
|
||||
$(".item-row").removeClass("selected-item");
|
||||
$(".discount_item_row").removeClass("selected-item");
|
||||
$(".accounts-type").removeClass("selected-account");
|
||||
}
|
||||
|
||||
/* Get discount Item rows */
|
||||
function get_other_item_rows(){
|
||||
var sale_items = [];
|
||||
$('.other-item-row').each(function(i){
|
||||
var sale_item = {};
|
||||
sale_item.id = $(this).attr('id');
|
||||
sale_item.name = $(this).find('#item-name-price').text();
|
||||
sale_item.price = $(this).find('#item-total-price').text();
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
function item_row_template(sale_id, charge_amount, reasons){
|
||||
var item_row = "<tr class='other-item-row' id='SLI-000000000000'>" +
|
||||
"<td style='width: 60%; text-align: left;'>" +
|
||||
"<span id='item_account_type' class='hidden'>" +
|
||||
0 +
|
||||
"</span>" +
|
||||
"<span id='item-name-price'>" +
|
||||
reasons +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-qty'>1</span>" +
|
||||
"</td>" +
|
||||
"<td style='width: 20%; text-align: right;'>" +
|
||||
"<span id='item-total-price'>" +
|
||||
charge_amount +
|
||||
"</span>" +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
return item_row;
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -11,7 +11,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></td>
|
||||
<td><strong>Sale Id</strong> </span><span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></td>
|
||||
<td><strong>Sale Id</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
|
||||
@@ -136,13 +136,13 @@
|
||||
<% if @ppamount != 0.0 %>
|
||||
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Paypar</div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="row" style="display:none">
|
||||
<div class="col-md-5"></div>
|
||||
<div class="col-md-3">Paypar</div>
|
||||
<div class="col-md-3">Redeem</div>
|
||||
<div class="col-md-4" id="ppamount">0.0</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -244,7 +244,7 @@
|
||||
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
|
||||
<button type="button" class="btn btn-primary btn-block"> FOC </button>
|
||||
<button type="button" class="btn btn-primary btn-block"> Void </button>
|
||||
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -354,6 +354,23 @@ $( document ).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
var sale_id = $('#sale_id').text();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function update_balance(){
|
||||
@@ -369,4 +386,5 @@ function update_balance(){
|
||||
var result = amount_due - total;
|
||||
$('#balance').text(result.toFixed(2));
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %>
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -268,61 +268,128 @@
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id="move">Move</button>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block">Customer</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||
<% if @dining.bookings.length >= 1 %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
|
||||
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<button type="button" class="btn btn-primary btn-block" >Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
|
||||
<% else %>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
||||
<% end %>
|
||||
<!-- Cashier Buttons -->
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
|
||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button> -->
|
||||
|
||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button> -->
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// $(".tables").on('click', function(){
|
||||
// var customer_id=$(".customer-id").text();
|
||||
// show_customer_details(customer_id);
|
||||
|
||||
// var dining_id = $(this).attr("data-id");
|
||||
// window.location.href = '/origami/table/' + dining_id;
|
||||
// })
|
||||
// $(".sales").on('click',function(){
|
||||
// var customer_id=$(".customer-id").text();
|
||||
// show_customer_details(customer_id);
|
||||
|
||||
// var sale_id = $(this).attr("data-id");
|
||||
// window.location.href = '/origami/sale/' + sale_id;
|
||||
// })
|
||||
// $(".rooms").on('click', function(){
|
||||
// var customer_id=$(".customer-id").text();
|
||||
// show_customer_details(customer_id);
|
||||
|
||||
// var dining_id = $(this).attr("data-id");
|
||||
// window.location.href = '/origami/room/' + dining_id;
|
||||
// })
|
||||
// $(".orders").on('click',function(){
|
||||
// var customer_id=$(".customer-id").text();
|
||||
// show_customer_details(customer_id);
|
||||
|
||||
// var order_id = $(this).attr("data-id");
|
||||
// window.location.href = '/origami/order/' + order_id;
|
||||
// })
|
||||
|
||||
$('.invoicedetails').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
var sale_id = this.id;
|
||||
window.location.href = '/origami/table/'+ dining_id + "/table_invoice/"+sale_id;
|
||||
})
|
||||
$(".tables").on('click', function(){
|
||||
|
||||
var customer_id=$(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/table/' + dining_id;
|
||||
})
|
||||
});
|
||||
|
||||
$(".sales").on('click',function(){
|
||||
|
||||
var customer_id=$(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/sale/' + sale_id;
|
||||
})
|
||||
var sale_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/sale/' + sale_id;
|
||||
});
|
||||
|
||||
$(".rooms").on('click', function(){
|
||||
|
||||
var customer_id=$(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/room/' + dining_id;
|
||||
})
|
||||
});
|
||||
|
||||
$(".orders").on('click',function(){
|
||||
|
||||
var customer_id=$(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
var order_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/order/' + order_id;
|
||||
})
|
||||
var order_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/order/' + order_id;
|
||||
});
|
||||
|
||||
// bind customer to order or sale
|
||||
$("#customer").on('click', function(){
|
||||
$("#customer").on('click', function(){
|
||||
var sale = $('#sale_id').val();
|
||||
if (sale) {
|
||||
var sale_id = sale
|
||||
}else{
|
||||
var sale_id = $('#save_order_id').attr('data-order');
|
||||
}
|
||||
var table_id = $('.tables').attr("data-id");
|
||||
|
||||
window.location.href = '/origami/'+ sale_id + "/customers"
|
||||
|
||||
});
|
||||
|
||||
$('#re-print').click(function() {
|
||||
var sale_id = $('#sale_id').val();
|
||||
window.location.href = '/origami/'+ sale_id + "/reprint"
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// Discount for Payment
|
||||
$('#discount').click(function() {
|
||||
var sale = $('#sale_id').val();
|
||||
@@ -341,6 +408,20 @@ $("#customer").on('click', function(){
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Print for first bill
|
||||
$("#first_bill").on('click', function(){
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/"+ sale_id + "/first_bill";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success:function(result){
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -354,9 +435,9 @@ $('#request_bills').click(function() {
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
data: 'order_id='+ order_id,
|
||||
// data: 'order_id='+ order_id,
|
||||
success:function(result){
|
||||
|
||||
location.reload();
|
||||
@@ -373,39 +454,109 @@ $('#back').on('click',function(){
|
||||
window.location.href = '/origami/';
|
||||
})
|
||||
|
||||
//show cusotmer rebate amount
|
||||
function show_customer_details(customer_id){
|
||||
$('#add_invoice').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
var ajax_url = "/origami/sale/append_order";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
alert("Invoice updated")
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// //show cusotmer rebate amount
|
||||
// function show_customer_details(customer_id){
|
||||
// var url = '<%= @show_customer_details_path %>'
|
||||
// //Start Ajax
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: url,
|
||||
// data: {},
|
||||
// dataType: "json",
|
||||
// success: function(data) {
|
||||
// $("#customer_name").text(data["customer"].name);
|
||||
// if (data["response_data"]["data"].length) {
|
||||
// $.each(data["response_data"]["data"], function (i) {
|
||||
// if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
||||
// var balance = data["response_data"]["data"][i]["balance"];
|
||||
// if (data["response_data"]["status"]==true) {
|
||||
// $('.rebate_amount').removeClass('hide');
|
||||
// row =
|
||||
// '<td class="charges-name">' + "Rebate Balance" +'</td>'
|
||||
// +'<td class="item-attr">' + balance + '</td>';
|
||||
|
||||
// $(".rebate_amount").html(row);
|
||||
// }
|
||||
|
||||
// }
|
||||
// });
|
||||
// }else{
|
||||
// $('.rebate_amount').addClass('hide');
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// //End Ajax
|
||||
// }
|
||||
|
||||
//show cusotmer rebate amount
|
||||
function show_customer_details(customer_id){
|
||||
var url = '<%= @show_customer_details_path %>'
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$("#customer_name").text(data["customer"].name);
|
||||
if (data["response_data"]["data"].length) {
|
||||
$.each(data["response_data"]["data"], function (i) {
|
||||
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
||||
var balance = data["response_data"]["data"][i]["balance"];
|
||||
if (data["response_data"]["status"]==true) {
|
||||
$('.rebate_amount').removeClass('hide');
|
||||
row =
|
||||
'<td class="charges-name">' + "Rebate Balance" +'</td>'
|
||||
+'<td class="item-attr">' + balance + '</td>';
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$("#customer_name").text(data["customer"].name);
|
||||
if (data["response_data"]["data"].length) {
|
||||
$.each(data["response_data"]["data"], function (i) {
|
||||
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
||||
var balance = data["response_data"]["data"][i]["balance"];
|
||||
if (data["response_data"]["status"]==true) {
|
||||
$('.rebate_amount').removeClass('hide');
|
||||
row =
|
||||
'<td class="charges-name">' + "Rebate Balance" +'</td>'
|
||||
+'<td class="item-attr">' + balance + '</td>';
|
||||
|
||||
$(".rebate_amount").html(row);
|
||||
}
|
||||
|
||||
$(".rebate_amount").html(row);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$('.rebate_amount').addClass('hide');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
});
|
||||
}else{
|
||||
$('.rebate_amount').addClass('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
}
|
||||
|
||||
$('#edit').on('click',function(){
|
||||
var dining_id = "<%= @dining.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
||||
});
|
||||
|
||||
$('#void').on('click',function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<% @complete.each do |sale| %>
|
||||
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
|
||||
<div class="card-block">
|
||||
<%= sale.receipt_no %>
|
||||
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -117,7 +117,7 @@
|
||||
</span></p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
<p>Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-title row customer_detail hide">
|
||||
@@ -185,7 +185,9 @@
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block">VOID</button>
|
||||
<% if @sale.sale_status != 'void' %>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block">VOID</button>
|
||||
<% end %>
|
||||
<button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
1
app/views/origami/shifts/create.json.jbuilder
Normal file
1
app/views/origami/shifts/create.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
1
app/views/origami/shifts/edit.html.erb
Normal file
1
app/views/origami/shifts/edit.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<h1> Close Cashier </h1>
|
||||
2
app/views/origami/shifts/index.html.erb
Normal file
2
app/views/origami/shifts/index.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Origami::Shifts#index</h1>
|
||||
<p>Find me in app/views/origami/shifts/index.html.erb</p>
|
||||
83
app/views/origami/shifts/new.html.erb
Normal file
83
app/views/origami/shifts/new.html.erb
Normal file
@@ -0,0 +1,83 @@
|
||||
<h1>Open Cashier</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<table class='table table-striped'>
|
||||
<% @float.each do |float| %>
|
||||
<tr>
|
||||
<th><%= float.name %></th>
|
||||
<th><input class='float-value' type='text' data-value ="<%= float.value %>" value='' /></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th><div id='total'></div></th>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class='col-md-4'></div>
|
||||
<div class='col-md-2'>
|
||||
<button class='btn btn-primary' id='open_cashier'>Open Cashier</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-md-8'>
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-1 col-sm-1">
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="1" data-type="num">1</div>
|
||||
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
|
||||
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="4" data-type="num">4</div>
|
||||
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
|
||||
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="7" data-type="num">7</div>
|
||||
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
|
||||
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number " data-value="0" data-type="num">0</div>
|
||||
<div class=" cashier_number left" data-value="." data-type="num">.</div>
|
||||
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class=" cashier_number red" data-type="del" >Del</div>
|
||||
<div class=" cashier_number orange left" data-type="clr">Clr</div>
|
||||
<div class=" cashier_number purple left" data-type="ent">Ent</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var total = 0
|
||||
$(document).on('focusout', '.float-value', function(event){
|
||||
var input_type = $(this).attr("data-value");
|
||||
var count = $(this).val();
|
||||
total += input_type * count
|
||||
$('#total').text(total)
|
||||
|
||||
})
|
||||
$('#open_cashier').on('click',function(){
|
||||
var amount = $('#total').text();
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_shifts_path %>",
|
||||
data: "opening_balance=" + amount,
|
||||
success:function(result){
|
||||
if(result){
|
||||
window.location.href = '/origami';
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
48
app/views/origami/shifts/show.html.erb
Normal file
48
app/views/origami/shifts/show.html.erb
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-10'>
|
||||
<h1>Close Cashier</h1>
|
||||
<br>
|
||||
<table class='table table-striped'>
|
||||
<tr>
|
||||
<td>Shift Started At</td>
|
||||
<td><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cashier Name</td>
|
||||
<td><%= @shift.employee.name rescue ''%></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<hr>
|
||||
<div class='row'>
|
||||
<div class='col-md-5'>
|
||||
<span style='font-size:20px;'><b>Closing Balance</b></span>
|
||||
</div>
|
||||
<div class='col-md-6'>
|
||||
<span style='font-size:20px;'><b><input type='text' id='closing_balance_amount' value=''></b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'> Back </button>
|
||||
<button type="button" class="btn btn-primary btn-block green" id='close_cashier'> Close Cashier </button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#close_cashier').on('click',function(){
|
||||
var amount = $('#closing_balance_amount').val();
|
||||
var shift_id = "<%= @shift.id %>"
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_close_shift_path %>",
|
||||
data: "closing_balance="+ amount + "&shift_id="+ shift_id,
|
||||
success:function(result){
|
||||
console.log(result)
|
||||
window.location.href = '/';
|
||||
}
|
||||
});
|
||||
})
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami';
|
||||
})
|
||||
</script>
|
||||
1
app/views/origami/shifts/update_shift.json.jbuilder
Normal file
1
app/views/origami/shifts/update_shift.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
@@ -128,6 +128,7 @@
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block"> Void </button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
@@ -143,5 +144,21 @@ $('#pay').on('click',function() {
|
||||
});
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami/table/<%= @table.id %>';
|
||||
})
|
||||
});
|
||||
$('#void').on('click',function () {
|
||||
var sure = confirm("Are you sure want to Void");
|
||||
if (sure == true) {
|
||||
var sale_id = $('#sale_id').val();
|
||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ajax_url,
|
||||
success: function () {
|
||||
window.location.href = '/origami/';
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<%= f.input :page_width %>
|
||||
<%= f.input :page_height %>
|
||||
<%= f.input :print_copies %>
|
||||
<%= f.input :precision %>
|
||||
<%= f.input :delimiter %>
|
||||
<%= f.input :heading_space %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<th>Page width</th>
|
||||
<th>Page height</th>
|
||||
<th>Print copies</th>
|
||||
<th>Precision</th>
|
||||
<th>Delimiter</th>
|
||||
<th>Heading_space</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -45,6 +48,9 @@
|
||||
<td><%= print_setting.page_width %></td>
|
||||
<td><%= print_setting.page_height %></td>
|
||||
<td><%= print_setting.print_copies %></td>
|
||||
<td><%= print_setting.precision %></td>
|
||||
<td><%= print_setting.delimiter %></td>
|
||||
<td><%= print_setting.heading_space %></td>
|
||||
<td><%= link_to 'Show', print_setting %></td>
|
||||
<td><%= link_to 'Edit', edit_print_setting_path(print_setting) %></td>
|
||||
<td><%= link_to 'Destroy', print_setting, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-2">
|
||||
<label>Select Period</label>
|
||||
<select name="period" id="sel_period" class="form-control">
|
||||
<option value="0">Today</option>
|
||||
<option value="1">Yesterday</option>
|
||||
<option value="2">This week</option>
|
||||
<option value="3">Last week</option>
|
||||
<option value="4">Last 7 days</option>
|
||||
<option value="5">This month</option>
|
||||
<option value="6">Last month</option>
|
||||
<option value="7">Last 30 days</option>
|
||||
<option value="8">This year</option>
|
||||
<option value="9">Last year</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type">
|
||||
<!-- <div class="form-group col-md-2">
|
||||
<label>Select Type</label>
|
||||
<select name="sale_type" id="sel_sale_type" class="form-control">
|
||||
<option value="0">All Sale Type</option>
|
||||
<option value="1">Revenue Only</option>
|
||||
<option value="2">Discount Only</option>
|
||||
<option value="3">Void Only</option>
|
||||
<option value="4">Taxes Only</option>
|
||||
<option value="5">Other Amount Only</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <label class="">Select Shift Period</label> -->
|
||||
<label class="">From</label>
|
||||
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="">To</label>
|
||||
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- <div class="row">
|
||||
<% if defined? show_monthly %>
|
||||
<div class="span3" style="margin-bottom:10px;">
|
||||
<input type="hidden" id="report_type" name="report_type" value="0">
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<button id="btn_report_type_1" onclick="$('#report_type').val(1)" type="button" class="btn btn-inverse">Monthly</button>
|
||||
<button id="btn_report_type_2" onclick="$('#report_type').val(2)" type="button" class="btn btn-inverse">Yearly</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div> -->
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<% if defined? promotions %>
|
||||
<%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? menu_types %>
|
||||
<%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? payments %>
|
||||
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? shift_name %>
|
||||
<!-- Temporary no needs
|
||||
<select name="shift_name" id="shift_name"></select>
|
||||
-->
|
||||
<% end %>
|
||||
|
||||
<% if defined? cashiers %>
|
||||
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? singer %>
|
||||
<%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? bsm %>
|
||||
<%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? guest_role %>
|
||||
<%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? list_by_payment_type %> <!-- for report detail by credit and foc -->
|
||||
<%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? products %>
|
||||
<%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? items %>
|
||||
<%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-md-12">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class = "row">
|
||||
|
||||
<div class = "span3">
|
||||
<input type="button" value="Filter by Shift" class='btn' onclick = "select_shift(this)">
|
||||
</div>
|
||||
<div class = "span3">
|
||||
<select name="shift" id="shift">
|
||||
<option value="">All Shift</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class = "span3">
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#custom_excel').hide();
|
||||
|
||||
$('#custom_excel').click(function(){
|
||||
var url = $('#custom_excel').attr('data-url');
|
||||
$('#frm_report').attr('action',url)
|
||||
$('#frm_report').submit();
|
||||
// window.location = url;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@@ -1,190 +0,0 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Daily Sale Report</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="javascript:export_to('<%=reports_daily_sales_path%>.xls')" class = "btn btn-default">Export to Excel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<% if params[:from]%>
|
||||
<tr>
|
||||
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th style='text-align:center;'>Sr.no</th>
|
||||
<th style='text-align:center;'>Date</th>
|
||||
<th style='text-align:center;'>Void Amount</th>
|
||||
<th style='text-align:center;'>Mpu Sales</th>
|
||||
<th style='text-align:center;'>Master Sales</th>
|
||||
<th style='text-align:center;'>Visa Sales</th>
|
||||
<th style='text-align:center;'>Jcb Sales</th>
|
||||
<th style='text-align:center;'>Paypar Sales</th>
|
||||
<th style='text-align:center;'>Cash Sales</th>
|
||||
<th style='text-align:center;'>Credit Sales</th>
|
||||
<th style='text-align:center;'>FOC Sales</th>
|
||||
<th style='text-align:center;'>(Discount)</th>
|
||||
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
|
||||
<th style='text-align:center;'>Rounding Adj.</th>
|
||||
<th style='text-align:center;'>Grand Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% unless @sale_data.empty? %>
|
||||
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
<% mpu = 0 %>
|
||||
<% master = 0 %>
|
||||
<% visa = 0 %>
|
||||
<% jcb = 0 %>
|
||||
<% paypar = 0 %>
|
||||
<% cash = 0 %>
|
||||
<% credit = 0 %>
|
||||
<% foc = 0 %>
|
||||
<% discount = 0 %>
|
||||
<% total = 0 %>
|
||||
<% grand_total = 0 %>
|
||||
<% count = 1 %> <% rounding_adj = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% void += sale[:void_amount] %>
|
||||
<% mpu += sale[:mpu_amount] %>
|
||||
<% master += sale[:master_amount] %>
|
||||
<% visa += sale[:visa_amount] %>
|
||||
<% jcb += sale[:jcb_amount] %>
|
||||
<% paypar += sale[:paypar_amount] %>
|
||||
<% cash += sale[:cash_amount] %>
|
||||
<% credit += sale[:credit_amount] %>
|
||||
<% foc += sale[:foc_amount] %>
|
||||
<% discount += sale[:total_discount] %>
|
||||
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
|
||||
<% grand_total += sale[:grand_total].to_f %>
|
||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||
<tr>
|
||||
<td style='text-align:right;'><%= count %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
|
||||
</tr>
|
||||
<% count = count + 1 %>
|
||||
<% end %>
|
||||
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="3" style='text-align:center;'>Total</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
|
||||
</tr>
|
||||
|
||||
<% total_tax = 0 %>
|
||||
<% unless @tax.empty? %>
|
||||
<% @tax.each do |tax| %>
|
||||
<% total_tax += tax.tax_amount.to_f %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
<% net = total - total_tax %>
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="12" style='text-align:right;'>Net Amount</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
var check_arr = [];
|
||||
var search = '<%= params[:period_type] %>';
|
||||
if(search){
|
||||
if(parseInt(search) == 0){
|
||||
search_by_period();
|
||||
}
|
||||
else{
|
||||
search_by_date();
|
||||
}
|
||||
}else{
|
||||
search_by_period();
|
||||
}
|
||||
$('#sel_period').change(function(){
|
||||
search_by_period();
|
||||
});
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
}
|
||||
|
||||
$('#from').change(function(){
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
$('#to').change(function(){
|
||||
search_by_date();
|
||||
});
|
||||
function search_by_date(){
|
||||
var from = $('#from').val();
|
||||
var to = $('#to').val();
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
check_arr.push(to);
|
||||
// console.log(check_arr.length)
|
||||
if(check_arr.length == 1){
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -117,23 +117,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class = "row">
|
||||
|
||||
<div class = "span3">
|
||||
<input type="button" value="Filter by Shift" class='btn' onclick = "select_shift(this)">
|
||||
</div>
|
||||
<div class = "span3">
|
||||
<select name="shift" id="shift">
|
||||
<option value="">All Shift</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class = "span3">
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#custom_excel').hide();
|
||||
@@ -145,7 +128,68 @@ $(function(){
|
||||
// window.location = url;
|
||||
});
|
||||
|
||||
var item = $('#item').val();
|
||||
var payment_type = $('#payment_type');
|
||||
|
||||
if(item == 'order'){
|
||||
$('#cashier').hide();
|
||||
$('#waiter').show();
|
||||
if(payment_type){
|
||||
$('#payment_type').hide();
|
||||
}
|
||||
}
|
||||
else if(item == 'sale'){
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
}
|
||||
else{
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
$("#item").val('sale');
|
||||
}
|
||||
});
|
||||
|
||||
//Reset the form to pervious values
|
||||
$("#branch").val(<%=params[:branch]%>);
|
||||
$("#waiter").val("<%=params[:waiter]%>");
|
||||
$("#cashier").val(<%=params[:cashier]%>);
|
||||
$("#product").val(<%=params[:product]%>);
|
||||
$("#singer").val(<%=params[:singer]%>);
|
||||
$("#item").val('<%=params[:item]%>');
|
||||
$("#guest_role").val('<%=params[:guest_role]%>');
|
||||
|
||||
|
||||
$("#from").val("<%=params[:from]%>");
|
||||
$("#to").val("<%=params[:to]%>");
|
||||
$("#sel_period").val(<%=params[:period]%>);
|
||||
$("#sel_sale_type").val(<%=params[:sale_type]%>);
|
||||
|
||||
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
|
||||
$("#rd_period_type_1").attr("checked","checked");
|
||||
<% else %>
|
||||
$("#rd_period_type_0").attr("checked","checked");
|
||||
<% end %>
|
||||
$(".btn-group button").removeClass("active");
|
||||
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
|
||||
$("#btn_report_type_<%= report_type %>").addClass("active");
|
||||
|
||||
$('#item').change(function(){
|
||||
var item = $('#item').val();
|
||||
var payment_type = $('#payment_type');
|
||||
|
||||
if(item == 'sale'){
|
||||
$('#waiter').hide();
|
||||
$('#cashier').show();
|
||||
if(payment_type){
|
||||
$('#payment_type').show();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$('#cashier').hide();
|
||||
$('#waiter').show();
|
||||
if(payment_type){
|
||||
$('#payment_type').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
<div class="container">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %>
|
||||
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_dailysale_index_path} %>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="javascript:export_to('<%=reports_daily_sales_path%>.xls')" class = "btn btn-default">Export to Excel</a>
|
||||
<a href="javascript:export_to('<%=reports_dailysale_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,135 +1,43 @@
|
||||
<div class="span12">
|
||||
<div class="table-responsive">
|
||||
|
||||
<% unless @sale_data.empty? %>
|
||||
<h3 align="center"><%=current_active_location.name%></h3>
|
||||
<h3 align="center">Sales Summary Report (BreadTalk)</h3>
|
||||
<% if params[:from]%>
|
||||
<h4>From Date : <%= params[:from] %> , To Date : <%= params[:to] %></h4>
|
||||
<% end %>
|
||||
<table class="table table-bordered" border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th style='text-align:center;'>Sr.no</th> -->
|
||||
<th style='text-align:center;'>Location Name</th>
|
||||
<th style='text-align:center;'>Date</th>
|
||||
<th style='text-align:center;'>Cash Sales</th>
|
||||
<th style='text-align:center;'>Credit Sales</th>
|
||||
<th style='text-align:center;'>Credit Received</th>
|
||||
<!-- <th style='text-align:center;'>Other Payment</th> -->
|
||||
<th style='text-align:center;'>Card Payment</th>
|
||||
<th style='text-align:center;'>Total Discount</th>
|
||||
<th style='text-align:center;'>Total Taxes</th>
|
||||
<th style='text-align:center;'>Total Other Charges</th>
|
||||
<th style='text-align:center;'>FOC Sales</th>
|
||||
<th style='text-align:center;'>Void Sales</th>
|
||||
<th style='text-align:center;'>Grand Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% void = 0 %>
|
||||
<% card = 0 %>
|
||||
<% credit_payment = 0 %>
|
||||
<% cash = 0 %>
|
||||
<% credit = 0 %>
|
||||
<% foc = 0 %>
|
||||
<% discount = 0 %>
|
||||
<% total = 0 %>
|
||||
<% count = 1 %>
|
||||
<% discount_rev = 0 %>
|
||||
<% total_rev = 0 %>
|
||||
<% grand_rev = 0 %>
|
||||
<% total_other_charges=0 %>
|
||||
<% total_tax=0 %>
|
||||
<% cash_received = 0 %>
|
||||
<% total_cash_received = 0 %>
|
||||
<% today_credit_payment_amount = 0 %>
|
||||
<% old_location_id = 0%>
|
||||
<% sub_total = 0 %>
|
||||
<% count_of_void = 0 %>
|
||||
<% flag = false %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% credit_payment += sale[:credit_payment].to_f %>
|
||||
<% card += sale[:card_amount].to_f %>
|
||||
<% cash += sale[:cash_amount].to_f %>
|
||||
<% credit += sale[:credit_amount].to_f %>
|
||||
<% foc += sale[:foc_amount].to_f %>
|
||||
<% discount += sale[:total_discount].to_f %>
|
||||
<% total += sale[:grand_total].to_f %>
|
||||
<% total_other_charges +=sale[:other_charges].to_f %>
|
||||
<% total_tax +=sale[:total_tax].to_f %>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style='text-align:center;'>Date</th>
|
||||
<th style='text-align:center;'>Receipt No</th>
|
||||
<th style='text-align:center;'>Cashier Name</th>
|
||||
<th style='text-align:center;'>Gross Sales</th>
|
||||
<th style='text-align:center;'>Discount</th>
|
||||
<th style='text-align:center;'>Total Sales</th>
|
||||
<% TaxProfile.all.each do |r|%>
|
||||
<th style='text-align:center;'><%=r.name%></th>
|
||||
<% end %>
|
||||
<th style='text-align:center;'>Nett Sales</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<% cash_received = sale[:cash_amount].to_f + sale[:credit_payment].to_f%>
|
||||
<% total_cash_received = cash.to_f + credit_payment.to_f%>
|
||||
<% today_credit_payment_amount += sale[:today_credit_payment].to_f %>
|
||||
|
||||
<tr>
|
||||
<!-- <td style='text-align:right;'><%= count %></td> -->
|
||||
|
||||
<td style='text-align:right;'><%= sale[:location].to_s rescue '-' %></td>
|
||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:total_discount].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:total_tax].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:other_charges].to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;color: pink;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %></td>
|
||||
<% total_void_amount = 0 %>
|
||||
<% if !@daily_void.nil? %>
|
||||
<% @daily_void.each do |d_v|%>
|
||||
|
||||
<% if d_v[:daily_void_amt].to_i > 0 %>
|
||||
<% if d_v[:location_id] == sale[:location_id] %>
|
||||
<% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%>
|
||||
<%count_of_void+=1%>
|
||||
|
||||
<%total_void_amount += d_v[:daily_void_amt].to_f%>
|
||||
<% flag = true %>
|
||||
|
||||
|
||||
|
||||
<%end %>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% if flag == true%>
|
||||
<% void += total_void_amount.to_f %>
|
||||
<td style='color:red;text-align:right;'> <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %></td>
|
||||
<% flag = false %>
|
||||
<% end%>
|
||||
<%if count_of_void == 0%>
|
||||
<td style='color:red;text-align:right;'> <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %></td>
|
||||
<%end %>
|
||||
<td style='text-align:right;'>
|
||||
<%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<%count_of_void= 0%>
|
||||
<% count = count + 1 %>
|
||||
<% end %>
|
||||
|
||||
<tr style="font-weight:600;">
|
||||
<td colspan="2" style='text-align:center;'>Grand Total</td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total_tax ), :delimiter => ',') %></td>
|
||||
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total_other_charges ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;color: pink;'><%= number_with_delimiter(sprintf("%.2f",foc ), :delimiter => ',') %></td>
|
||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %></td>
|
||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %></td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</table>
|
||||
<tbody>
|
||||
<% total_sales = 0 %>
|
||||
<% net_sales = 0 %>
|
||||
<% @sale_data.each do |sale| %>
|
||||
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
|
||||
<% net_sales = total_sales.to_f + sale.total_tax.to_f%>
|
||||
<tr>
|
||||
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
|
||||
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
|
||||
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
|
||||
<% sale.sale_taxes.each do |sale|%>
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
|
||||
<% end %>
|
||||
|
||||
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-2">
|
||||
<label>Select Period</label>
|
||||
<select name="period" id="sel_period" class="form-control">
|
||||
<option value="0">Today</option>
|
||||
<option value="1">Yesterday</option>
|
||||
<option value="2">This week</option>
|
||||
<option value="3">Last week</option>
|
||||
<option value="4">Last 7 days</option>
|
||||
<option value="5">This month</option>
|
||||
<option value="6">Last month</option>
|
||||
<option value="7">Last 30 days</option>
|
||||
<option value="8">This year</option>
|
||||
<option value="9">Last year</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="hidden" name="report_type" value="sale_item" id="sel_sale_type">
|
||||
<!-- <div class="form-group col-md-2">
|
||||
<label>Select Type</label>
|
||||
<select name="sale_type" id="sel_sale_type" class="form-control">
|
||||
<option value="0">All Sale Type</option>
|
||||
<option value="1">Revenue Only</option>
|
||||
<option value="2">Discount Only</option>
|
||||
<option value="3">Void Only</option>
|
||||
<option value="4">Taxes Only</option>
|
||||
<option value="5">Other Amount Only</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <label class="">Select Shift Period</label> -->
|
||||
<label class="">From</label>
|
||||
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="">To</label>
|
||||
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- <div class="row">
|
||||
<% if defined? show_monthly %>
|
||||
<div class="span3" style="margin-bottom:10px;">
|
||||
<input type="hidden" id="report_type" name="report_type" value="0">
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<button id="btn_report_type_1" onclick="$('#report_type').val(1)" type="button" class="btn btn-inverse">Monthly</button>
|
||||
<button id="btn_report_type_2" onclick="$('#report_type').val(2)" type="button" class="btn btn-inverse">Yearly</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div> -->
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<% if defined? promotions %>
|
||||
<%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? menu_types %>
|
||||
<%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? payments %>
|
||||
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? shift_name %>
|
||||
<!-- Temporary no needs
|
||||
<select name="shift_name" id="shift_name"></select>
|
||||
-->
|
||||
<% end %>
|
||||
|
||||
<% if defined? cashiers %>
|
||||
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? singer %>
|
||||
<%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? bsm %>
|
||||
<%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? guest_role %>
|
||||
<%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? list_by_payment_type %> <!-- for report detail by credit and foc -->
|
||||
<%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]), :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? products %>
|
||||
<%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products", :class => "form-control" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined? items %>
|
||||
<%= select_tag "item", options_for_select(@items, :selected => params[:item_type]), :class => "form-control" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="row">
|
||||
<div class="col-md-12">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class = "row">
|
||||
|
||||
<div class = "span3">
|
||||
<input type="button" value="Filter by Shift" class='btn' onclick = "select_shift(this)">
|
||||
</div>
|
||||
<div class = "span3">
|
||||
<select name="shift" id="shift">
|
||||
<option value="">All Shift</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class = "span3">
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#custom_excel').hide();
|
||||
|
||||
$('#custom_excel').click(function(){
|
||||
var url = $('#custom_excel').attr('data-url');
|
||||
$('#frm_report').attr('action',url)
|
||||
$('#frm_report').submit();
|
||||
// window.location = url;
|
||||
});
|
||||
|
||||
function export_to(path)
|
||||
{
|
||||
var form_params = $("#frm_report").serialize();
|
||||
window.location = path+"?"+ form_params;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -1,141 +0,0 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Daily Sale Report</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<%= render :partial=>'shift_sale_report_filter',
|
||||
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_items_path} %>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<!-- <div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="javascript:export_to('<%=reports_sale_items_path%>.xls')" class = "btn btn-default">Export to Excel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th id="date"></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Menu Category</th>
|
||||
<th>Code</th>
|
||||
<th>Product</th>
|
||||
<th>Total Item</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Revenue</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
var cate = [];
|
||||
var y;
|
||||
var count = 0;
|
||||
var sub_total = 0;
|
||||
var sub_total_arr = [];
|
||||
|
||||
<% @sale_data.each do |result| %>
|
||||
|
||||
count = count + 1;
|
||||
if(count == 1)
|
||||
$('#date').append('<%= result.date_name rescue '-'%>');
|
||||
|
||||
y = $.inArray(<%= result.menu_category_id %>, cate);
|
||||
if(y == -1){
|
||||
//add sub total row
|
||||
sub_total_arr.push(sub_total);
|
||||
var total_row = '<tr><td colspan="4"></td>'+
|
||||
'<td > Sub Total</td> ' +
|
||||
'<td><span class="underline">'+ sub_total +'</span></td>'+
|
||||
'</tr>';
|
||||
|
||||
|
||||
if(count != 1){
|
||||
$('.table').append(total_row);
|
||||
sub_total = 0;
|
||||
}
|
||||
|
||||
cate.push(<%= result.menu_category_id %>);
|
||||
var th = '<tr><td colspan="6"><%= result.menu_category_name rescue '-'%></td></tr>';
|
||||
var tr = '<tr>'+
|
||||
'<td></td>'+
|
||||
'<td><%= result.code rescue '-'%></td>' +
|
||||
'<td><%= result.product_name rescue '-'%></td>' +
|
||||
'<td><%= result.total_item.to_i rescue '-'%></td>' +
|
||||
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
|
||||
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%>'+
|
||||
'</td>'+
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('.table').append(th);
|
||||
$('.table').append(tr);
|
||||
|
||||
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
|
||||
}
|
||||
else{
|
||||
var tr = '<tr>'+
|
||||
'<td></td>'+
|
||||
'<td><%= result.code rescue '-'%></td>' +
|
||||
'<td><%= result.product_name rescue '-'%></td>' +
|
||||
'<td><%= result.total_item.to_i rescue '-'%></td>' +
|
||||
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
|
||||
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%></td></tr>';
|
||||
$('.table').append(tr);
|
||||
|
||||
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
|
||||
}
|
||||
|
||||
<% end %>
|
||||
|
||||
last_line_subtotal(sub_total);
|
||||
sub_total_arr.push(parseInt(sub_total));
|
||||
grand_total(sub_total_arr);
|
||||
})
|
||||
|
||||
function last_line_subtotal(sub_total){
|
||||
|
||||
var total_row = '<tr><td colspan="4"></td>'+
|
||||
'<td > Sub Total</td> ' +
|
||||
'<td><span class="underline">'+ sub_total +'</span></td>'+
|
||||
'</tr>';
|
||||
|
||||
$('.table').append(total_row);
|
||||
}
|
||||
|
||||
function grand_total(sub_total_arr){
|
||||
|
||||
var total = 0;
|
||||
for(var i=0; i< sub_total_arr.length; i++){
|
||||
//total_1 = (total_1) + (sub_total_arr[i]);
|
||||
total = parseInt(total) + parseInt(sub_total_arr[i]);
|
||||
}
|
||||
var row = '<tr><td colspan="4"></td>'+
|
||||
'<td > Grand Total</td> ' +
|
||||
'<td><span class="double_underline">'+ total +'</span></td>'+
|
||||
'</tr>';
|
||||
$('.table').append(row);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@@ -1,136 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div class="span12">
|
||||
<% unless @sale_data.blank? %>
|
||||
|
||||
<table class="table table-striped" id="items_table" border="0">
|
||||
<thead>
|
||||
|
||||
<% if !params[:from].blank?%>
|
||||
<tr>
|
||||
<th colspan="7">From Date : <%= params[:from] %> , To Date : <%= params[:to] %></th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<th colspan="7">Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Menu Category</th>
|
||||
<th>Code</th>
|
||||
<th>Product</th>
|
||||
<th>Total Item</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Revenue</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<% acc_arr = Array.new %>
|
||||
<% cate_arr = Array.new %>
|
||||
|
||||
<% sub_total = 0.0 %>
|
||||
<% count = 0%>
|
||||
<% total_price = 0.0 %>
|
||||
<% cate_count = 0 %>
|
||||
<% acc_count = 0%>
|
||||
<% grand_total = 0%>
|
||||
<% total_discount = 0.0 %>
|
||||
|
||||
<% @sale_data.order("total_item desc").each do |sale| %>
|
||||
|
||||
<% if !acc_arr.include?(sale.account_id) %>
|
||||
<tr>
|
||||
<td><b><%= sale.account_name %></b></td>
|
||||
<td colspan="4"> </td>
|
||||
<td>Total Price By <%= sale.account_name %></td>
|
||||
<td>
|
||||
<% @totalByAccount.each do |account, total| %>
|
||||
<% if sale.account_id == account %>
|
||||
<b><%= total %></b>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% acc_arr.push(sale.account_id) %>
|
||||
|
||||
<% end %>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||
<td><%= sale.menu_category_name %></td>
|
||||
<% cate_arr.push(sale.menu_category_id) %>
|
||||
<% else %>
|
||||
<td> </td>
|
||||
<% end %>
|
||||
<td><%= sale.code rescue '-' %></td>
|
||||
<% if @item_table == 'sale' %>
|
||||
<% if sale.item_remark == 'FOC' %>
|
||||
<td><%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %></td>
|
||||
<% elsif sale.item_remark == 'FOC ITEM' %>
|
||||
<td><%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %></td>
|
||||
<% elsif sale.item_remark == 'DISCOUNT' %>
|
||||
<td><%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %></td>
|
||||
<% else %>
|
||||
<td><%= sale.product_name.to_s rescue '-' %></td>
|
||||
<% end %>
|
||||
<% if sale.item_remark == 'DISCOUNT' %>
|
||||
<td> - </td>
|
||||
<td> - </td>
|
||||
<td><%= sale.total_price.abs rescue '-' %></td>
|
||||
<% total_price += sale.total_price %>
|
||||
<% else %>
|
||||
<td><%= sale.total_item.abs rescue '-' %></td>
|
||||
<td><%= sale.unit_price rescue '-' %></td>
|
||||
<td><%= sale.grand_total.abs rescue '-' %></td>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<td><%= sale.product_name.to_s rescue '-' %></td>
|
||||
<td><%= sale.total_item.abs rescue '-' %></td>
|
||||
<td><%= sale.unit_price rescue '-' %></td>
|
||||
<td><%= sale.grand_total.abs rescue '-' %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<!-- sub total -->
|
||||
<% @menu_cate_count.each do |key,value| %>
|
||||
<% if sale.menu_category_id == key %>
|
||||
<% count = count + 1 %>
|
||||
<% sub_total += sale.grand_total %>
|
||||
<% if count == value %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td>Sub Total</td>
|
||||
<td ><span class="underline"><%= sub_total + total_price %></span></td>
|
||||
</tr>
|
||||
<% sub_total = 0.0%>
|
||||
<% total_discount = total_discount + total_price %>
|
||||
<% total_price = 0.0%>
|
||||
<% count = 0%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!-- end sub total -->
|
||||
<% grand_total += sale.grand_total%>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td>Grand Total</td>
|
||||
<td><span class="double_underline"><%= grand_total + total_discount %></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user