remove conflict data

This commit is contained in:
phyusin
2018-03-05 16:24:45 +06:30
111 changed files with 3612 additions and 1386 deletions

View File

@@ -77,11 +77,19 @@ $(document).on('turbolinks:load', function() {
});
}
}
var table_type = '';
if (data[field]["table_type"]!=null) {
table_type = data[field]["table_type"] +'-'+data[field]["zone"]
}else{
table_type = "No Table"
}
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
+'<div class="card-block">'
+'<div class="row">'
+'<span class="col-md-4 order-zone-type font-13">'+data[field]["table_type"]+'-'+ data[field]["zone"] +'</span>'
+'<span class="col-md-4 order-zone-type font-13">'+table_type +'</span>'
+'<span class="order-zone hidden font-14">'+ data[field]["zone"] +'</span>'
+'<span class="col-md-8"><small class="float-right font-13">'+data[field]["order_id"]+'</small></span>'
+'</div>'
@@ -145,9 +153,22 @@ $(document).on('turbolinks:load', function() {
url: '/oqs/' + orderNo,
data: { 'status' : order_status },
success: function(res){
for (i = 0; i < res.length; i++) {
var data = JSON.stringify(res[i]);
// console.log(res);
for (i = 0; i < res["items"].length; i++) {
var data = JSON.stringify(res["items"][i]);
var parse_data = JSON.parse(data);
var assigned_order_items = [];
var assigned_order_item_id = '';
if(res["assigned_order_items"]!= undefined && res["assigned_order_items"]!=''){
assigned_order_items = JSON.parse(JSON.stringify(res["assigned_order_items"]));
$.each(assigned_order_items,function(key,value){
if(value[parse_data.order_items_id] != undefined){
assigned_order_item_id = value[parse_data.order_items_id];
}
});
}
// console.log(assigned_order_item_id);
var set_menu_items = parse_data.set_menu_items;
var set_instance_items = "";
if(set_menu_items!=null){
@@ -159,10 +180,18 @@ $(document).on('turbolinks:load', function() {
}
if (oqs_id > 0){
var order_item_row = "<tr id='edit_"+assigned_item_id+"' class='order-item-edit'>" +
"<td class='order-items' style='width:80%; text-align:left'>" + parse_data.item_name + set_instance_items + "</td>" +
"<td class='order-qty' style='width:20%; text-align:right'>" + parse_data.qty + "</td>" +
"</tr>";
if(assigned_order_item_id != ''){
var order_item_row = "<tr id='edit_"+assigned_order_item_id+"' class='order-item-edit'>" +
"<td class='order-items' style='width:80%; text-align:left'>" + parse_data.item_name + set_instance_items + "</td>" +
"<td class='order-qty' style='width:20%; text-align:right'>" + parse_data.qty + "</td>" +
"</tr>";
}else{
var order_item_row = "<tr>" +
"<td class='order-items' style='width:80%; text-align:left'>" + parse_data.item_name + set_instance_items + "</td>" +
"<td class='order-qty' style='width:20%; text-align:right'>" + parse_data.qty + "</td>" +
"</tr>";
}
}else{
var order_item_row = "<tr>" +
"<td class='order-items' style='width:80%; text-align:left'>" + parse_data.item_name + set_instance_items + "</td>" +
@@ -185,7 +214,7 @@ $(document).on('turbolinks:load', function() {
$(document).on('click', '.order-item-edit', function(event){
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(5);
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
window.location.href = '/oqs/'+ assigned_item_id + "/edit/oqs";
});
// complete for queue item

View File

@@ -1,7 +1,7 @@
$(function() {
type = $('#type').val();
modify_order = $('#modify_order').val();
var role = $('#role').val();
type = window.location.href.indexOf("quick_service");
modify_order = window.location.href.indexOf("modify_order");
//click menu sidebar menu category
$(".product").on("click", function(){
var url = $(this).attr('data-ref');
@@ -76,8 +76,8 @@ $(function() {
}
//end show list function
//click menu sidebar menu category
// $(".menu_category").on("click", function(){
$(document).on('click', '.menu_category', function(event){
event.preventDefault();
var menu_id = $(this).attr("data-id");
var url = "get_menu_category/"+menu_id;
show_menu_item_list(url);
@@ -88,13 +88,16 @@ $(function() {
function show_menu_item_list(url_item){
var menu_list = $('.menu_items_list');
menu_list.empty();
if (modify_order=="true" && type =="true") {
url_item = '../../../addorders/'+url_item;
}if(modify_order=="false" && type =="true"){
url_item = 'addorders/'+url_item
}else{
url_item = url_item;
type = window.location.href.indexOf("quick_service");
modify_order = window.location.href.indexOf("modify_order");
if (type != -1 && modify_order != -1) {
url_item = '../../../addorders/'+url_item;
}if(modify_order == -1 && type != -1){
url_item = 'addorders/'+url_item;
}
if (type ==-1 && modify_order == -1){
url_item = url_item
}
//Start Ajax
@@ -756,10 +759,10 @@ $(function() {
e.preventDefault();
$("#oqs_loading_wrapper").show();
type = $('#type').val();
if (type == 'true') {
type = 'cashier'
type = window.location.href.indexOf("quick_service");
if (type != -1) {
type = 'quick_service'
var table_type = $('#table_type').text();
var table_id = $('#table_id').val();
var customer_id = $('#customer_id').val();
@@ -773,42 +776,45 @@ $(function() {
var booking_id = $('#booking_id').text();
var ajax_url = '../addorders/create';
}
if (!booking_id.length > 0) {
var order_items = JSON.stringify(get_order_item_rows());
if (booking_id.length > 0) {
var params = {'order_source': type, 'order_type': "dine_in",
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
'table_id': table_id,
'order_items': order_items };
}
var order_items = JSON.stringify(get_order_item_rows());
var params = {'order_source': type, 'order_type': "dine_in",
'order_items': order_items,'create_type' : "create_only" };
}else{
var params = {'order_source': type, 'order_type': "dine_in",
'customer_id': customer_id, 'guest_info': "",
'table_id': table_id,
'order_items': order_items };
if (table_id.length>0) {
$.ajax({
type: "POST",
url: ajax_url,
data: params,
dataType: "json",
success:function(result){
if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id
}
else {
window.location.href = "/origami/room/" + table_id
}
}
});
}else{
$(this).removeAttr('disabled', '');
$("#oqs_loading_wrapper").hide();
swal("Opps","Please Select Table or Room","warning");
'order_items': order_items,'create_type' : "create_only" };
}
// if (table_id.length>0 || role == 'waiter') {
$.ajax({
type: "POST",
url: ajax_url,
data: params,
dataType: "json",
success:function(result){
if (type == "quick_service") {
window.location.href = "/origami/quick_service"
}else{
if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id
}
else {
window.location.href = "/origami/room/" + table_id
}
}
}
});
// }else{
// $(this).removeAttr('disabled', '');
// $("#oqs_loading_wrapper").hide();
// swal("Opps","Please Select Table or Room","warning");
// }
});
@@ -817,9 +823,10 @@ $(function() {
$(this).attr('disabled', 'disabled');
e.preventDefault();
type = "quick_service"
modify_order = window.location.href.indexOf("modify_order");
$("#oqs_loading_wrapper").show();
console.log(modify_order)
if (modify_order == "true") {
if (modify_order !=-1) {
console.log($('#sale_id').text())
var ajax_url = '../../../quick_service/update_modify_order';
var table_type = $('#table_type').text();
@@ -835,21 +842,20 @@ $(function() {
var booking_id = $('#booking_id').text();
var sale_id = ""
}
if (!booking_id.length > 0) {
var order_items = JSON.stringify(get_order_item_rows());
if (booking_id.length > 0) {
var params = {'order_source': type, 'order_type': "dine_in",
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
'table_id': table_id,
'order_items': order_items };
}
var order_items = JSON.stringify(get_order_item_rows());
var params = {'order_source': type, 'order_type': "dine_in",
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
}else{
var params = {'order_source': type, 'order_type': "dine_in",
'customer_id': customer_id, 'guest_info': "",
'table_id': table_id,
'order_items': order_items,'sale_id': sale_id };
console.log(params)
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
}
$.ajax({
type: "POST",
url: ajax_url,
@@ -858,7 +864,11 @@ $(function() {
success:function(result){
console.log(result)
if (result.status) {
if (result.data == null){
window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text();
}else{
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"
}
}
}
});
@@ -975,7 +985,7 @@ $(function() {
$("#back").on("click", function(){
var table_id = $('#table_id').text();
var table_type = $('#table_type').text();
type = $('#type').val();
type = window.location.href.indexOf("quick_service");
if (type == 'true') {
var table_type = $('#table_id').find("option:selected").data('type');
var table_id = $('#table_id').val();
@@ -1089,7 +1099,8 @@ $(function() {
//click menu sidebar menu category
$(".sub_click").on("click", function(){
$(document).on('click', '.sub_click', function(event){
event.preventDefault();
var menu_id = $(this).attr("data-id");
var url = "get_menu_sub_category/"+menu_id;
sub_category = $(this).find('.sub_category_list');
@@ -1100,11 +1111,12 @@ $(function() {
//show menu item list when click menu category
function show_sub_category_list(url,sub_category){
if (modify_order == "true" && type =="true") {
if (type != -1 && modify_order != -1) {
var url = "../../../addorders/"+url;
}if(modify_order=="false" && type =="true"){
}if(modify_order== -1 && type != -1){
var url = 'addorders/'+url;
}else{
}
if (type ==-1 && modify_order == -1){
var url = url;
}

View 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/

View File

@@ -175,7 +175,7 @@ section.content{
text-align: center;
}
.add_icon{
.menu_item_box{
cursor: pointer;
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the reports/ProductSale controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -1,128 +1,26 @@
class ApplicationController < ActionController::Base
include LoginVerification
#before_action :check_installation
protect_from_forgery with: :exception
helper_method :shop_detail
# lookup domain for db from provision
before_action :lookup_domain, :set_locale
helper_method :current_company,:current_login_employee,:current_user,:shop_detail
# before_action :set_locale
# helper_method :current_company,:current_login_employee,:current_user
# alias_method :current_user, :current_login_employee,:current_user
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
#change locallization
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
# logger.info "Location - " + @license.name
ActiveRecord::Base.establish_connection(website_connection(@license))
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
# check for license file
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
end
end
def current_license(url)
@license = License.new(url)
flag = @license.detail_with_local_file()
if (flag == 0)
flash[:notice] = 'Expired or No License!'
elsif (flag == 2)
flash[:notice] = 'Expiring! Please, License extend...'
else
puts "RUN SAY BYAR"
end
end
def cache_license(url, lookup)
@license = License.new(url, lookup)
if (@license.detail_with_local_cache(lookup) == true)
return @license
else
return nil
end
end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)
end
def reconnect_default_db
ActiveRecord::Base.establish_connection(Rails.env)
end
# Regular database.yml configuration hash
def default_connection
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
end
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
# Get current Cashier
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
def current_company
begin
return Company.first
rescue
return nil
end
end
def shop_detail
@shop = Shop.first
end
def current_login_employee
if (!session[:session_token].nil?)
@employee = Employee.find_by_token_session(session[:session_token])
end
end
private
def check_license
if License.check_license_file
return true
end
return false
end
end

View File

@@ -1,5 +1,5 @@
class BaseCrmController < ActionController::Base
include LoginVerification
include LoginVerification
layout "CRM"
#before_action :check_installation
@@ -30,5 +30,4 @@ class BaseCrmController < ActionController::Base
def shop_detail
@shop = Shop.first
end
end

View File

@@ -1,5 +1,5 @@
class BaseInventoryController < ActionController::Base
include LoginVerification
include LoginVerification
layout "inventory"
#before_action :check_installation
@@ -20,5 +20,4 @@ class BaseInventoryController < ActionController::Base
def shop_detail
@shop = Shop.first
end
end

View File

@@ -30,5 +30,4 @@ class BaseOqsController < ActionController::Base
def shop_detail
@shop = Shop.first
end
end

View File

@@ -8,7 +8,6 @@ class BaseOrigamiController < ActionController::Base
protect_from_forgery with: :exception
helper_method :shop_detail
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
# redirect_to origami_root_path

View File

@@ -1,9 +1,9 @@
class BaseReportController < ActionController::Base
include LoginVerification
layout "application"
include LoginVerification
layout "application"
#before_action :check_installation
protect_from_forgery with: :exception
#before_action :check_installation
protect_from_forgery with: :exception
helper_method :shop_detail
@@ -12,10 +12,6 @@ class BaseReportController < ActionController::Base
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
PERIOD = {
"today" => 0,
"yesterday" => 1,
@@ -85,13 +81,10 @@ class BaseReportController < ActionController::Base
end
return from, to
end
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
end

View File

@@ -1,5 +1,5 @@
class BaseWaiterController < ActionController::Base
include LoginVerification
include LoginVerification
layout "waiter"
#before_action :check_installation
@@ -7,9 +7,8 @@ class BaseWaiterController < ActionController::Base
helper_method :shop_detail
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,88 @@
module LicenseVerification
extend ActiveSupport::Concern
included do
before_action :lookup_domain
end
protected
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
# logger.info "Location - " + @license.name
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
# check for license file
# if check_license
# current_license(ENV["SX_PROVISION_URL"])
# else
# redirect_to activate_path
# end
end
authenticate_session_token
end
def authenticate_session_token
token = session[:session_token]
if (token)
#@current_user = User.find_by(api_key: token)
#Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token)
if @user
return true
#Maybe log - login?
else
flash[:notice] = 'Invalid Access!'
# return false
end
end
end
def current_license(url)
@license = License.new(url)
flag = @license.detail_with_local_file()
if (flag == 0)
flash[:notice] = 'Expired or No License!'
elsif (flag == 2)
flash[:notice] = 'Expiring! Please, License extend...'
else
puts "RUN SAY BYAR"
end
end
def cache_license(url, lookup)
@license = License.new(url, lookup)
if (@license.detail_with_local_cache(lookup) == true)
return @license
else
return nil
end
end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)
end
def reconnect_default_db
ActiveRecord::Base.establish_connection(Rails.env)
end
# Regular database.yml configuration hash
def default_connection
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
end
end

View File

@@ -2,15 +2,37 @@ module LoginVerification
extend ActiveSupport::Concern
included do
before_action :authenticate
helper_method :current_company,:current_login_employee
before_action :authenticate_session_token
helper_method :current_company, :current_login_employee, :current_user, :get_cashier
end
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
def current_company
begin
return Company.first
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
# Get current Cashiers
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
protected
# Authenticate the user with token based authentication
def authenticate
def authenticate
authenticate_session_token || render_unauthorized
end
@@ -18,7 +40,7 @@ module LoginVerification
token = session[:session_token]
if (token)
#@current_user = User.find_by(api_key: token)
Rails.logger.debug "token - " + token.to_s
#Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token)
if @user
@@ -32,24 +54,11 @@ module LoginVerification
redirect_to root_path
end
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
def current_company
begin
return Company.first
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
end
private
def check_license
License.check_license_file
end
def check_installation
if current_company.nil?
redirect_to install_path

View File

@@ -1,13 +1,17 @@
class HomeController < ApplicationController
class HomeController < ApplicationController
# layout "application", except: [:index, :show]
<<<<<<< HEAD
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
helper_method :shop_detail
=======
# skip_before_action only: [:index, :show, :create, :update, :destroy]
>>>>>>> 311bef44119baa113cfadf226d6d34e04cfbe991
def index
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.order("name asc")
@login_form = LoginForm.new()
@login_form = LoginForm.new()
render "layouts/login_dashboard", layout: false
end
@@ -48,9 +52,12 @@ class HomeController < ApplicationController
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "supervisor" || @employee.role == "waiter"
elsif @employee.role == "supervisor"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
elsif @employee.role == "waiter"
session[:session_token] = @employee.token_session
redirect_to origami_dashboard_path
elsif @employee.role == "account"
session[:session_token] = @employee.token_session
redirect_to reports_dailysale_index_path
@@ -58,63 +65,65 @@ class HomeController < ApplicationController
render :index
end
else
redirect_to origami_root_path, :notice => "Username and Password doesn't match!"
redirect_to root_path, :notice => "Username and Password doesn't match!"
end
end
def dashboard
@from, @to = get_date_range_from_params
@shop = Shop.first
today = DateTime.now.strftime('%Y-%m-%d')
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@top_products = Sale.top_products(today).sum('i.qty')
@bottom_products = Sale.bottom_products(today).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
@employee_sales = Sale.employee_sales(today)
@employee_sales = Sale.employee_sales(today,@from,@to)
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
@inventories = StockJournal.inventory_balances(today).sum(:balance)
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
@total_sale = Sale.total_sale(today)
@total_count = Sale.total_count(today)
@total_card = Sale.total_card_sale(today)
@total_credit = Sale.credit_payment(today)
@total_sale = Sale.total_sale(today,current_user,@from,@to)
@total_count = Sale.total_count(today,current_user,@from,@to)
@total_card = Sale.total_card_sale(today,current_user,@from,@to)
@total_credit = Sale.credit_payment(today,current_user,@from,@to)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today)
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today)
pay = Sale.payment_sale('card', today, current_user,@from,@to)
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(payment.payment_method, today)
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
@summ_sale = Sale.summary_sale_receipt(today)
@total_customer = Sale.total_customer(today)
@total_dinein = Sale.total_dinein(today)
@total_takeaway = Sale.total_takeaway(today)
@total_other_customer = Sale.total_other_customer(today)
@total_membership = Sale.total_membership(today)
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
@total_customer = Sale.total_customer(today,current_user,@from,@to)
@total_dinein = Sale.total_dinein(today,current_user,@from,@to)
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to)
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to)
@total_membership = Sale.total_membership(today,current_user,@from,@to)
@total_order = Sale.total_order(today)
@total_accounts = Sale.total_account(today)
@total_order = Sale.total_order(today,current_user,@from,@to)
@total_accounts = Sale.total_account(today,current_user,@from,@to)
@account_data = Array.new
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, today)
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
@top_items = Sale.top_items(today)
@total_foc_items = Sale.total_foc_items(today)
@top_items = Sale.top_items(today,current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@@ -156,7 +165,7 @@ class HomeController < ApplicationController
elsif employee.role == "manager"
redirect_to dashboard_path
elsif employee.role == "waiter"
redirect_to oqs_root_path
redirect_to origami_dashboard_path
elsif employee.role == "crm"
redirect_to crm_root_path
elsif @employee.role == "supervisor"
@@ -166,9 +175,24 @@ class HomeController < ApplicationController
end
end
def get_date_range_from_params
from = params[:from]
to = params[:to]
if from.present? && to.present?
f_date = DateTime.parse(from)
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
end
return from, to
end
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
end

View File

@@ -1,4 +1,5 @@
class InstallController < BaseController
skip_before_action :lookup_domain
skip_before_action :verify_authenticity_token
# before_action :check_license

View File

@@ -3,4 +3,10 @@ class Inventory::InventoryController < BaseInventoryController
def index
@products = InventoryDefinition.all.active.order('created_at desc')
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -61,6 +61,12 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
private
# Use callbacks to share common setup or constraints between actions.
def set_inventory_definition

View File

@@ -61,6 +61,12 @@ class Inventory::StockCheckItemsController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
private
# Use callbacks to share common setup or constraints between actions.
def set_stock_check_item

View File

@@ -38,6 +38,12 @@ class Inventory::StockChecksController < BaseInventoryController
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
# GET /stock_checks

View File

@@ -61,6 +61,12 @@ class StockJournalsController < ApplicationController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
private
# Use callbacks to share common setup or constraints between actions.
def set_stock_journal

View File

@@ -1,8 +1,17 @@
class Oqs::EditController < BaseOqsController
def index
assigned_item_id = params[:id]
assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'");
@link_type = params[:type]
@dining_type = nil
if params[:type] == 'oqs'
assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
else
assigned_item = OrderItem.find(assigned_item_id)
dining = DiningFacility.find_by_id(params[:type])
@dining_type = dining.type
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
end
end
def update

View File

@@ -14,19 +14,19 @@ class Oqs::HomeController < BaseOqsController
@queue_stations = OrderQueueStation.all
@queue_completed_item = completed_order(@filter)
# if !@queue_completed_item.empty?
# @queue_completed_item.each do |queue_item|
# if !queue_item.set_menu_items.nil?
# instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
# arr_instance_item_sets = Array.new
# instance_item_sets.each do |instance_item|
# item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
# arr_instance_item_sets.push(item_instance_name)
# end
# queue_item.set_menu_items = arr_instance_item_sets
# end
# end
# end
if !@queue_completed_item.empty?
@queue_completed_item.each do |queue_item|
if !queue_item.set_menu_items.nil?
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
end
queue_item.set_menu_items = arr_instance_item_sets
end
end
end
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
@@ -60,6 +60,7 @@ class Oqs::HomeController < BaseOqsController
# Get Order items
def get_order_items
items = []
assigned_items = []
order_no = params[:order_no]
status = params[:status]
# dining = DiningFacility.find_by_name(table_name);
@@ -90,6 +91,11 @@ class Oqs::HomeController < BaseOqsController
if !items.empty?
items.each do |item|
assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
if !assigned_order_items.nil?
assigned_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
end
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
@@ -101,7 +107,7 @@ class Oqs::HomeController < BaseOqsController
end
end
end
render :json => items.to_json
render :json => {'items' => items, 'assigned_order_items' => assigned_items }
end
def get_items_by_oqs

View File

@@ -37,9 +37,10 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
def get_menu_category ()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
@@ -49,7 +50,6 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
def get_menu()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = Menu.find_by_id(params[:id])
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
@@ -61,10 +61,13 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
end
def get_menu_sub_category ()
id = params[:id]
if (id)
#Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu
end
@@ -153,13 +156,18 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
end
@status, @booking = @order.generate
if @status && @booking && @order.source == 'quick_service'
if current_user.role != "waiter" && params[:create_type] == "create_pay"
if @status && @booking && @order.source == 'quick_service'
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
result = {:status=> @status, :data => @sale }
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
result = {:status=> @status, :data => @sale }
render :json => result.to_json
end
else
result = {:status=> @status, :data => 0 }
render :json => result.to_json
end
end
# render json for http status code

View File

@@ -55,6 +55,7 @@ class Origami::DashboardController < BaseOrigamiController
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user
end
end

View File

@@ -52,7 +52,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.product_name = di["name"]
sale_item.item_instance_code = origin_sale_item.item_instance_code
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.status = "Discount"
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * (-1)
@@ -175,7 +175,7 @@ class Origami::DiscountsController < BaseOrigamiController
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.remark == "Discount" && si.price < 0
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
@@ -343,7 +343,7 @@ class Origami::DiscountsController < BaseOrigamiController
# sale_item.sale_id = sale_id
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
# sale_item.product_name = product_name
# sale_item.remark = remark
# sale_item.status = remark
# sale_item.qty = 1
# sale_item.unit_price = (0-discount_amount.to_f)

View File

@@ -62,6 +62,7 @@ class Origami::HomeController < BaseOrigamiController
@dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
# @assigned_order_items = Array.new
if booking.booking_orders.empty?
@booking = booking
else
@@ -84,15 +85,22 @@ class Origami::HomeController < BaseOrigamiController
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
# end
end
accounts = @customer.tax_profiles
puts accounts.to_json
puts "sssssssssss"
puts @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
@account_arr = Array.new
if @customer.tax_profiles
accounts = @customer.tax_profiles
puts accounts.to_json
puts "sssssssssss"
puts @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
end

View File

@@ -44,7 +44,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.product_code = "Other Charges"
sale_item.product_name = "*" + di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Other Charges"
sale_item.status = "Other Charges"
sale_item.qty = 1
sale_item.unit_price = di["price"]

View File

@@ -8,7 +8,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id)
member_info = nil
survey = Survey.find_by_receipt_no(sale_data.receipt_no)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -67,7 +66,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil,survey)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
end
end
@@ -79,7 +78,6 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -95,7 +93,7 @@ class Origami::PaymentsController < BaseOrigamiController
#end rounding adjustment
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
rebate_amount = nil
@@ -153,7 +151,7 @@ class Origami::PaymentsController < BaseOrigamiController
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,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data,survey)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
@@ -164,7 +162,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id,sale_id)
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end
@@ -192,9 +190,17 @@ class Origami::PaymentsController < BaseOrigamiController
@table_no = ''
@dining = ''
@shop = Shop::ShopDetail
@shop = Shop::ShopDetail #show shop info
saleObj = Sale.find(sale_id)
#total customer with individual total amount
@individual_total = Array.new
if !saleObj.equal_persons.nil?
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
end
# rounding adjustment
if @shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -211,7 +217,9 @@ class Origami::PaymentsController < BaseOrigamiController
@rounding_adj = @sale_data.rounding_adjustment
end
#end rounding adjustment
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
@@ -281,7 +289,6 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil
saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -335,7 +342,7 @@ class Origami::PaymentsController < BaseOrigamiController
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,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data,survey)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
end
end
@@ -343,21 +350,22 @@ class Origami::PaymentsController < BaseOrigamiController
cash = params[:cash]
sale_id = params[:sale_id]
sub_total = params[:sub_total]
remark = params[:remark]
member_info = nil
rebate_amount = nil
current_balance = nil
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
end
saleObj.update_attributes(rounding_adjustment: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "foc")
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -394,7 +402,20 @@ class Origami::PaymentsController < BaseOrigamiController
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,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil,survey)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end
end
end

View File

@@ -2,20 +2,43 @@ class Origami::PendingOrderController < BaseOrigamiController
def index
# @dining= DiningFacility.where("status = 'occupied'")
# @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d'))
@sale = Sale.pending_order
@sale = Sale.pending_sale
@order = Sale.pending_order
end
def show
@sales = Sale.pending_order
@sale = Sale.find(params[:sale_id])
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id
if Booking.find(@booking).dining_facility_id.to_i > 0
@table_id = Booking.find(@booking).dining_facility_id
@sales = Sale.pending_sale
@orders = Sale.pending_order
@id = params[:sale_id]
if(@id[0,3] == "SAL")
@sale = Sale.find(@id)
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id
@bookings = Booking.find(@booking)
@status = "sale"
else
# @booking = BookingOrder.find_by_order_id(@order).booking_id
@bookings = Booking.find(@id)
@status = "order"
@order_items = Array.new
@bookings.booking_orders.each do |booking_order|
@order = Order.find(booking_order.order_id)
if (@order.status == "new")
@order.order_items.each do |item|
@order_items.push(item)
end
end
end
end
puts @status
if @bookings.dining_facility_id.to_i > 0
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
@dining = DiningFacility.find(@table_id)
else
@table_id = nil
@dining = nil
end
end
end

View File

@@ -14,7 +14,7 @@ class Origami::QuickServiceController < ApplicationController
# @rooms = Room.all.active.order('zone_id asc').group("zone_id")
# @all_table = Table.all.active.order('status desc')
# @all_room = Room.all.active.order('status desc')
render "origami/addorders/detail"
render "origami/addorders/detail"
end
def modify_order
@@ -134,21 +134,26 @@ class Origami::QuickServiceController < ApplicationController
end
@status, @booking = @order.generate
if @status && @booking && @order.source == 'quick_service'
if params[:sale_id]
@sale = Sale.find(params[:sale_id])
if @order.table_id.to_i > 0
@table_id = @order.table_id
else
@table_id = nil
if(params[:sale_id][0,3] == "SAL")
if @status && @booking && @order.source == 'quick_service'
if params[:sale_id]
@sale = Sale.find(params[:sale_id])
if @order.table_id.to_i > 0
@table_id = @order.table_id
else
@table_id = nil
end
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
end
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
end
result = {:status=> true, :data => @sale }
render :json => result.to_json
end
result = {:status=> true, :data => @sale }
render :json => result.to_json
end
else
result = {:status=> true, :data => nil }
render :json => result.to_json
end
end
def get_menu_category ()

View File

@@ -8,6 +8,9 @@ class Origami::RequestBillsController < ApplicationController
if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
puts params[:id]
puts bk_order
puts bk_order.booking_id
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil?

View File

@@ -58,6 +58,7 @@ class Origami::RoomsController < BaseOrigamiController
@room.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
# @assigned_order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@customer = order.customer
@@ -78,6 +79,10 @@ class Origami::RoomsController < BaseOrigamiController
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
# end
end
end
end

View File

@@ -16,8 +16,10 @@ class Origami::SaleEditController < BaseOrigamiController
# create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
remark = params[:remark]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void'
saleitemObj.status = 'void'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@@ -27,11 +29,24 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.is_taxable = 1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
booking = Booking.find_by_sale_id(saleitemObj.sale_id)
booking.booking_orders.each do |bo|
order = Order.find(bo.order_id)
order.order_items.each do |o|
if saleitemObj.product_code == o.item_code
o.qty = saleitemObj.qty * -1
o.price = saleitemObj.price * -1
o.save
end
end
end
action_by = current_user.id
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
@@ -42,8 +57,10 @@ class Origami::SaleEditController < BaseOrigamiController
def item_foc
saleitemId = params[:sale_item_id]
remark = params[:remark]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'foc'
saleitemObj.status = 'foc'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@@ -53,6 +70,7 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
@@ -71,7 +89,7 @@ class Origami::SaleEditController < BaseOrigamiController
# update_qty = params[:update_qty]
# update_price = params[:update_price]
# saleitemObj = SaleItem.find(saleitemId)
# saleitemObj.remark = 'void'
# saleitemObj.status = 'void'
# saleitemObj.save
# @newsaleitem = SaleItem.new
# @newsaleitem = saleitemObj.dup
@@ -111,6 +129,18 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
order.order_items.each do |o|
if saleitemObj.product_code == o.item_code
o.qty = update_qty
o.price = update_price
o.save
end
end
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.edit_product_commission(saleitemObj)
@@ -123,7 +153,7 @@ class Origami::SaleEditController < BaseOrigamiController
both = SaleItem.where('product_code=?', saleitemObj.product_code)
both.each do |item|
if item.qty.to_i > 0
item.remark = nil
item.status = nil
item.save
end
end
@@ -148,7 +178,7 @@ class Origami::SaleEditController < BaseOrigamiController
if item.qty.to_i < 0
item.destroy
else
item.remark = nil
item.status = nil
end
item.save
ProductCommission.remove_product_commission(item)

View File

@@ -61,7 +61,21 @@ class Origami::ShiftsController < BaseOrigamiController
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1'
unique_code="CloseCashierCustomisePdf"
else
unique_code="CloseCashierPdf"
end
end
end
end
shop_details = Shop.find(1)
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@@ -73,12 +87,16 @@ class Origami::ShiftsController < BaseOrigamiController
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
#byebug
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges)
end
end
Employee.logout(session[:session_token])
@@ -102,8 +120,7 @@ class Origami::ShiftsController < BaseOrigamiController
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end

View File

@@ -8,6 +8,7 @@ class Origami::SplitBillController < BaseOrigamiController
@orders = Array.new
@order_items = Array.new
@sale_data = Array.new
@current_user = current_user
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
if !table_bookings.nil?
@@ -97,16 +98,16 @@ class Origami::SplitBillController < BaseOrigamiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
else
table = nil
cashier_zone = nil
end
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
get_cashier_by_terminal = current_user
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, get_cashier_by_terminal)
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user)
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
@@ -127,6 +128,7 @@ class Origami::SplitBillController < BaseOrigamiController
if !orders.nil?
orders.each do |order|
BookingOrder.find_by_order_id(order["id"]).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
end
elsif !order_items.nil?
@@ -193,6 +195,8 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
puts new_order_status
if new_order_status
BookingOrder.find_by_order_id(odr_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
@@ -208,17 +212,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
# begin
order = Order.new
order.source = "cashier"
order.order_type = order_type
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.item_count = order_items.count
order.status = "new"
order.table_id = params[:dining_id] # this is dining facilities's id
order.waiters = current_user.name
order.employee_name = current_user.name
order.guest_info = nil
order.save!
order = create_order(params,order_type,order_items.count,current_user)
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
@@ -242,6 +236,8 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
puts new_order_status
if new_order_status
BookingOrder.find_by_order_id(order_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
@@ -260,17 +256,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
# begin
order = Order.new
order.source = "cashier"
order.order_type = order_type
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.item_count = order_items.count
order.status = "new"
order.table_id = params[:dining_id] # this is dining facilities's id
order.waiters = current_user.name
order.employee_name = current_user.name
order.guest_info = nil
order.save!
order = create_order(params,order_type,order_items.count,current_user)
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
@@ -280,7 +266,9 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
else
if order_ids.count == 1 && order_id_count > 0 && order_item_count == 1
# puts order_ids
if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1
BookingOrder.find_by_order_id(order_ids[0]).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
order_items.each do |order_item|
update_order_item(order_ids[0], order_item)
@@ -297,17 +285,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
# begin
order = Order.new
order.source = "cashier"
order.order_type = order_type
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.item_count = order_items.count
order.status = "new"
order.table_id = params[:dining_id] # this is dining facilities's id
order.waiters = current_user.name
order.employee_name = current_user.name
order.guest_info = nil
order.save!
order = create_order(params,order_type,order_items.count,current_user)
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
@@ -319,17 +297,12 @@ class Origami::SplitBillController < BaseOrigamiController
end
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, get_cashier_by_terminal)
sale_data = Sale.find_by_sale_id(sale_id)
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
end
# Bind shift sale id to sale
# sale_data.shift_sale_id = shift_by_terminal.id
# sale_data.save
Promotion.promo_activate(sale)
BillBroadcastJob.perform_later(table)
ActionCable.server.broadcast "bill_channel",table: table
render :json => { status: status }
else
@@ -337,9 +310,35 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
def create_order(params,order_type,items_count,current_user)
order = Order.new
order.source = "cashier"
order.order_type = order_type
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.item_count = items_count
order.status = "new"
order.table_id = params[:dining_id] # this is dining facilities's id
order.waiters = current_user.name
order.employee_name = current_user.name
order.guest_info = nil
order.save!
return order
end
def update_order_item(order_id, order_item)
orderItem = OrderItem.find(order_item["id"])
if orderItem.qty.to_f != order_item['qty'].to_f
set_menu_items_obj = Array.new
if !orderItem.set_menu_items.nil?
instance_item_sets = JSON.parse(orderItem.set_menu_items)
instance_item_sets.each_with_index do |instance_item, instance_index|
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
end
orderItem.set_menu_items = instance_item_sets.to_json
end
OrderItem.processs_item(orderItem.item_code,
orderItem.item_instance_code,
orderItem.item_name,
@@ -348,7 +347,7 @@ class Origami::SplitBillController < BaseOrigamiController
order_item['qty'],
orderItem.price,
orderItem.options,
orderItem.set_menu_items,
set_menu_items_obj.to_json,
order_id,
orderItem.item_order_by,
orderItem.taxable)
@@ -360,4 +359,11 @@ class Origami::SplitBillController < BaseOrigamiController
orderItem.save!
end
def update_sale
sale = Sale.find(params[:sale_id])
sale.equal_persons = params[:total_customer].to_i
sale.save!
render :json => { status: true }
end
end

View File

@@ -84,53 +84,6 @@ class Origami::SurveysController < BaseOrigamiController
end
end
def create_survey
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
@type = params[:cashier_type]
@sale_id = params[:sale_id]
sale = Sale.find(@sale_id)
if @type != "quick_service"
dining_facility = DiningFacility.find(params[:dining_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
cashier_terminal_id = cashier_zone.cashier_terminal_id
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal_id = shift.cashier_terminal_id
end
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_terminal_id,nil)
if @type != "quick_service"
survey = Survey.find_by_dining_name(dining_facility.name)
else
survey = nil
end
if survey.nil?
survey = Survey.new
if @type != "quick_service"
survey.dining_name = dining_facility.name
end
survey.receipt_no = params[:receipt_no]
survey.shift_id = shift_by_terminal.id
survey.created_by = current_user.name
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
else
survey.receipt_no = params[:receipt_no]
survey.total_customer = params[:total_customer]
survey.save!
end
render :json => {status: true}
else
render :json => { status: false, error_message: 'No Current Open Shift!'}
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -65,6 +65,8 @@ class Origami::TableInvoicesController < BaseOrigamiController
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
end
end

View File

@@ -3,10 +3,9 @@ class Origami::VoidController < BaseOrigamiController
def overall_void
sale_id = params[:sale_id]
remark = params[:remark]
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
survey = Survey.find_by_receipt_no(sale.receipt_no)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
@@ -70,12 +69,8 @@ class Origami::VoidController < BaseOrigamiController
end
# FOr Sale Audit
action_by = current_user.id
if table.nil?
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table -> nil"
else
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
end
action_by = current_user.name
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
# For Print
@@ -125,7 +120,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,survey)
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
end
#end print

View File

@@ -0,0 +1,21 @@
class Reports::ProductSaleController < BaseReportController
authorize_resource :class => false
def index
@order_by = 'desc'
if !params[:order_by].nil?
@order_by = params[:order_by]
end
@sale_data = Sale.get_menu_item_query(@order_by)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.json
format.xls
end
end
end

View File

@@ -33,7 +33,7 @@ class Reports::SaleitemController < BaseReportController
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()

View File

@@ -17,7 +17,7 @@ class Reports::StockCheckController < BaseReportController
@from = from_date
@to = to_date
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls

View File

@@ -0,0 +1,2 @@
module Reports::ProductSaleHelper
end

View File

@@ -1,7 +1,7 @@
class OrderQueueProcessorJob < ApplicationJob
queue_as :default
def perform(order_id, table_id,sale_id=nil)
def perform(order_id, table_id)
# Do something later
#Order ID
order = Order.find(order_id)
@@ -9,7 +9,7 @@ class OrderQueueProcessorJob < ApplicationJob
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id,sale_id)
oqs.process_order(order, table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)

View File

@@ -136,6 +136,7 @@ class Ability
#ability for split_bill
can :index, :split_bill
can :create, :split_bill
can :update_sale, :split_bill
elsif user.role == "account"
@@ -190,6 +191,9 @@ class Ability
elsif user.role == "waiter"
can :index, :home
can :show, :home
#ability for split_bill
can :index, :split_bill
can :create, :split_bill
end
end
end

View File

@@ -33,7 +33,7 @@ class License
##Get redis connection from connection pool
redis = Redis.new
cache_license = redis.get(cache_key)
Rails.logger.info "Cache key - " + cache_key.to_s
if cache_license.nil?
##change the d/e key

View File

@@ -52,7 +52,7 @@ class MenuCategory < ApplicationRecord
if from > to
h = to_t.hour
if h < 12 # before noon
if h = 0
if h == 0
to = 24
to = to * 3600 + to_t.min* 60 + to_t.sec
end

View File

@@ -78,7 +78,6 @@ class MenuItem < ApplicationRecord
end
end
# private
# def generate_menu_item_code

View File

@@ -309,9 +309,9 @@ class Order < ApplicationRecord
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id,sale_id=nil)
def self.pay_process_order_queue(id,table_id)
#Send to background job for processing
OrderQueueProcessorJob.perform_later(id, table_id,sale_id)
OrderQueueProcessorJob.perform_later(id, table_id)
end
def check_cup_status(status)

View File

@@ -13,16 +13,16 @@ class OrderQueueStation < ApplicationRecord
# validations
validates_presence_of :station_name, :printer_name
def process_order (order, table_id,sale_id=nil)
def process_order (order, table_id)
oqs_stations = OrderQueueStation.active
order_items = order.order_items
if table_id > 0
if table_id.to_i > 0
# get dining
dining=DiningFacility.find(table_id)
dining = DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
@@ -46,10 +46,10 @@ class OrderQueueStation < ApplicationRecord
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
end
# end
end
end
@@ -64,46 +64,38 @@ class OrderQueueStation < ApplicationRecord
end
end
else
# get dining
sale = Sale.find(sale_id).shift_sale_id
terminal_by_zones = CashierTerminalByZones.where("cashier_terminal_id=#{shift.cashier_terminal_id}")
# ToDo per item per printer
terminal_by_zones.each do |tbz|
OrderQueueProcessByZone.where("zone_id=#{tbz.zone_id}").find_each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
oqs_stations.each do |oqs|
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
# if oqs.id == oqpbz.order_queue_station_id
# #Same Order_items can appear in two location.
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
# end
end
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
# if oqs.id == oqpbz.order_queue_station_id
# #Same Order_items can appear in two location.
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
end
# end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end #end else

View File

@@ -3,6 +3,6 @@ class PrintSetting < ApplicationRecord
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
def self.get_precision_delimiter
PrintSetting.find_by_unique_code("CloseCashierPdf")
PrintSetting.find_by_unique_code("ReceiptBillPdf")
end
end

View File

@@ -22,18 +22,44 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
# def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
# #Use CUPS service
# #Generate PDF
# #Print
# cashier = shift_sale.employee.name
# shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
# pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
# filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
# pdf.render_file filename
# self.print(filename, cashier_terminal.printer_name)
# end
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
else
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
end
end
end
end
pdf.render_file filename
self.print(filename, cashier_terminal.printer_name)
end
#sqa
end

View File

@@ -173,19 +173,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,survey)
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
#Use CUPS service
#Generate PDF
#Print
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,printed_status,balance,card_data,survey)
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,printed_status,balance,card_data)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey)
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
else
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,printed_status,balance,card_data,survey)
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,printed_status,balance,card_data)
end
end
end

View File

@@ -5,11 +5,18 @@ class Product < ApplicationRecord
mount_uploader :image_path, ProductImageUploader
def self.search_by_product_code(item_code)
account = Account.find_by_title('Product')
if !account.nil?
account_id = account.id
else
account_id = 1
end
menu_item_hash = Hash.new
mt_instance = Product.find_by_item_code(item_code)
if (!mt_instance.nil?)
menu_item_hash[:type] = 'Product'
menu_item_hash[:account_id] = 1
menu_item_hash[:account_id] = account_id
menu_item_hash[:item_code] = mt_instance.item_code
menu_item_hash[:item_instance_code] = mt_instance.item_code
menu_item_hash[:name] = mt_instance.name.to_s

File diff suppressed because it is too large Load Diff

View File

@@ -24,9 +24,9 @@ class SaleAudit < ApplicationRecord
sale_audit.sale_id = sale_id
sale_audit.action = "SALECOMPLETE"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = action_by
sale_audit.action_by = Sale.find(sale_id).cashier_id
sale_audit.remark = remark
sale_audit.approved_by = Time.now
sale_audit.approved_by = action_by
sale_audit.save!
end
@@ -72,9 +72,9 @@ class SaleAudit < ApplicationRecord
sale_audit.sale_id = sale_id
sale_audit.action = "SALEPAYMENT"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = action_by
sale_audit.action_by = Sale.find(sale_id).cashier_id
sale_audit.remark = remark
sale_audit.approved_by = Time.now
sale_audit.approved_by = action_by
sale_audit.save!
end
@@ -83,9 +83,9 @@ class SaleAudit < ApplicationRecord
sale_audit.sale_id = sale_id
sale_audit.action = "PAYMAL"
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = action_by
sale_audit.action_by = Sale.find(sale_id).cashier_id
sale_audit.remark = remark
sale_audit.approved_by = Time.now
sale_audit.approved_by = action_by
sale_audit.save!
end

View File

@@ -28,7 +28,7 @@ class SaleItem < ApplicationRecord
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
# Original Item to add remark
item.remark = type
item.status = type
item.save
sale_item = SaleItem.new
@@ -37,7 +37,7 @@ class SaleItem < ApplicationRecord
sale_item.product_name = item.product_name + " (#{type.upcase})"
sale_item.product_alt_name = item.product_alt_name
sale_item.account_id = item.account_id
sale_item.remark = type
sale_item.status = type
if type == "foc" || type == "promotion" || type == "void"
sale_item.qty = qty * (-1)
else
@@ -99,7 +99,7 @@ class SaleItem < ApplicationRecord
discount_account = {:name => a.title, :price => 0}
# Check for actual sale items
sale_items.where("remark = 'Discount'").find_each do |si|
sale_items.where("status = 'Discount'").find_each do |si|
if si.account_id == a.id
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
end

View File

@@ -8,7 +8,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
def process_payment(invoice, action_by, cash_amount, payment_method)
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
self.sale = invoice
self.received_amount = cash_amount
amount_due = invoice.grand_total
@@ -53,7 +53,7 @@ class SalePayment < ApplicationRecord
end
#record an payment in sale-audit
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
# remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
# update complete order items in oqs
@@ -67,7 +67,7 @@ class SalePayment < ApplicationRecord
return true, self.save
else
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
# remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
return false, "No outstanding Amount"
@@ -194,7 +194,7 @@ class SalePayment < ApplicationRecord
payment_status = false
# add to sale item with foc
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and status is null")
sale_items.each do|item|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)

View File

@@ -135,6 +135,27 @@ class ShiftSale < ApplicationRecord
end
def self.get_total_dinein(shift)
query = Sale.select("sum(sales.grand_total) as total_dinein_amount")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Dinein" and c.membership_id is null',shift.id)
.first()
end
def self.get_total_takeway(shift)
query = Sale.select("sum(sales.grand_total) as total_takeway_amount")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Takeaway" and c.membership_id is null',shift.id)
.first()
end
def self.get_total_other_charges(shift)
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
.first()
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''

View File

@@ -36,12 +36,20 @@ class StockJournal < ApplicationRecord
journal.save
end
def self.inventory_balances(today)
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
def self.inventory_balances(today,from,to)
if !from.nil? && !to.nil?
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
.where("stock_journals.created_at between '#{from}' and '#{to}'")
.group("mii.item_instance_name")
.order("mii.item_instance_name ASC")
else
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
.where("DATE_FORMAT(stock_journals.created_at,'%Y-%m-%d') = '#{today}'")
.group("mii.item_instance_name")
.order("mii.item_instance_name ASC")
end
end
end

View File

@@ -0,0 +1,496 @@
class CloseCashierCustomisePdf < 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,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 60
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
self.text_width = (self.page_width - 80) - self.price_width / 3
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 10
self.item_font_size = 8
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
#check delimiter
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header( shop_details)
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges)
end
def header (shop_details)
move_down 7
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 5
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down 5
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Cashier : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.employee.name}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Cashier Station : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Closing Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Shift Sale Summary", :size => self.header_font_size, :align => :center
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Received Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash In :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Out :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_account = 0
total_discount_by_account.each do |amount|
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
end
#end total amount by Account
#start total FOC amount
@total_foc = 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
end
#end total FOC amount
total_grand_total = shift_sale.grand_total + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f
# @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Grand Total :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total FOC :", :size => self.item_font_size, :align => :right
end
if @total_foc.nil?
@total_foc = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
@total_foc = 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Reedem Payment :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
# end
end
else
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
# end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
# start Dinein and Takeaway
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Dinein :", :size => self.item_font_size, :align => :right
end
if total_dinein.nil?
total_dinein = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Takeaway :", :size => self.item_font_size, :align => :right
end
if total_takeway.nil?
total_takeway = 0
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
# stop Dinein and Takeaway
move_down -5
stroke_horizontal_rule
move_down 7
#start service charges and commercial tax
sale_taxes.each do |tax|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Taxes :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
#end for service charges and commercial tax
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total Sale :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
# end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
# total_discount_by_account.each do |amount|
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
# end
# end
#end total amount by Account
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Grand Total :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
# end
#start total amount by Account Like Food / Beverage /..
total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
#start total other charges amount
if total_other_charges.present?
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Other Charges :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end total other charges amount
move_down -5
stroke_horizontal_rule
move_down 7
#start total over all discount
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
if @overall > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
end
#end total over all discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Dine-in Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Takeaway Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Receipts :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
end
move_down 5
stroke_horizontal_rule
move_down 5
move_down 5
end
end

View File

@@ -213,7 +213,7 @@ class CloseCashierPdf < Prawn::Document
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Reedem Payment :", :size => self.item_font_size, :align => :right
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
@@ -392,7 +392,6 @@ class CloseCashierPdf < Prawn::Document
move_down 5
stroke_horizontal_rule
move_down 5
move_down 5
move_down 5
end
end
end

View File

@@ -37,8 +37,12 @@ class OrderItemPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order_item.dining.to_i > 0
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 3

View File

@@ -37,8 +37,12 @@ class OrderItemSlimPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order_item_slim.dining.to_i > 0
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 1

View File

@@ -37,8 +37,11 @@ class OrderSetItemPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order_set_item.dining.to_i > 0
text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 3

View File

@@ -36,8 +36,12 @@ class OrderSummaryPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order[0].dining.to_i > 0
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 5

View File

@@ -36,8 +36,12 @@ class OrderSummarySetPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order[0].dining.to_i > 0
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 5

View File

@@ -36,8 +36,12 @@ class OrderSummarySlimPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
if order[0].dining.to_i > 0
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 1

View File

@@ -1,5 +1,6 @@
class ReceiptBillA5Pdf < 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, :description_width, :price_num_width, :line_move
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, printed_status,current_balance,card_data,survey)
self.page_width = printer_settings.page_width
@@ -81,8 +82,8 @@ class ReceiptBillA5Pdf < Prawn::Document
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
@@ -111,9 +112,12 @@ class ReceiptBillA5Pdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
end
end
move_down line_move
y_position = cursor
@@ -126,8 +130,13 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down line_move
y_position = cursor
if sale_data.bookings[0].dining_facility_id.to_i > 0
time =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')+")"
else
time = time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
end
bounding_box([0,y_position], :width =>self.page_width - 20, :height => self.item_height) do
text "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
text "Date : #{ time }",:size => self.item_font_size,:align => :left
end
@@ -481,17 +490,17 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left
text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down line_move
text "Total", :size => self.item_font_size,:align => :left
move_down 15
text "Amount Due (per person)", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down line_move
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end

View File

@@ -1,5 +1,6 @@
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, :description_width, :price_num_width, :line_move
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, printed_status,current_balance,card_data,survey)
self.page_width = printer_settings.page_width
@@ -81,8 +82,8 @@ class ReceiptBillPdf < Prawn::Document
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
@@ -129,9 +130,9 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
if sale_data.bookings[0].dining_facility_id.to_i > 0
time =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')+")"
time = 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')+")"
else
time = time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
end
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
@@ -492,17 +493,17 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left
text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down 15
text "Total", :size => self.item_font_size,:align => :left
text "Amount Due (per person)", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end

View File

@@ -1,6 +1,7 @@
<div class="container-fluid">
<div class="block-header">
<h2><%= t :dashboard %></h2>
<!-- <h2><%= t :dashboard %></h2> -->
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
</div>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
@@ -65,8 +66,28 @@
<!-- #END# Widgets -->
<!-- CPU Usage -->
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
<!-- Date range for dashboard -->
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
<span id="fromErr" style="color:red;"></span>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
<span id="toErr" style="color:red;"></span>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label></label><br>
<input type="button" value="Generate" class='btn btn-primary btn_generate'>
</div>
</div>
<br>
<!-- Date range for dashboard -->
<div class="row">
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
@@ -122,10 +143,18 @@
</div>
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<% end %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'cashier' %>
<% if !@summ_sale.nil? %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<% else %>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<% end %>
<div class="card">
<div class="body">
<h6><%= t :sale %></h6>
@@ -140,11 +169,11 @@
</tr>
<tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<tr>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<tr>
<td><%= t("views.right_panel.detail.total_sale") %> : </td>
@@ -165,7 +194,7 @@
<td align="right">
<% @sale_data.each do |data| %>
<% pay_mth = payment.payment_method %>
<%= data[""+pay_mth+""] %>
<%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
<% end %>
</td>
</tr>
@@ -178,7 +207,7 @@
<tr>
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
<td align="right">
<%= total_card["card"].to_f %>
<%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
</tr>
<% end %>
@@ -188,11 +217,17 @@
</div>
</div>
</div>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
</div>
<% end %>
<% end %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<% else %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<% end %>
<div class="card">
<div class="body">
<h6><%= t :customer %></h6>
@@ -231,10 +266,16 @@
</div>
</div>
</div>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
</div>
<% end %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<% else %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<% end %>
<div class="card">
<div class="body">
<h6><%= t("views.right_panel.detail.order") %></h6>
@@ -278,6 +319,41 @@
</div>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
var from = '<%= @from.strftime('%d-%m-%Y') rescue '' %>';
var to = '<%= @to.strftime('%d-%m-%Y') rescue '' %>';
if((from!=undefined) && (from != null) && (from != '')){
$('#from').val(from);
}
if((to!=undefined) && (to != null) && (to != '')){
$('#to').val(to);
}
});
$('.btn_generate').on('click',function(){
var from = $("#from").val();
var to = $("#to").val();
if((from=='') && (to=='')){
$('#fromErr').html("can't be blank");
$('#toErr').html("can't be blank");
}else if((from!='') && (to=='')){
$('#fromErr').html("");
$('#toErr').html("can't be blank");
}else if((from=='') && (to!='')){
$('#fromErr').html("can't be blank");
$('#toErr').html("");
}else{
$('#fromErr').html("");
$('#toErr').html("");
}
if((from!='') && (to!='')){
window.location.href = '/dashboard?from='+from+'&to='+to;
}
});
</script>

View File

@@ -18,7 +18,7 @@
<a href="javascript:void(0);" class="bars"></a>
<a class="navbar-brand" href="<%=dashboard_path%>" style="margin-left: 20px;">
<% else %>
<a class="navbar-brand m-0" href="<%=dashboard_path%>">
<a class="navbar-brand m-0" href="<%= origami_dashboard_path%>">
<%end%>
<img src="<%= asset_path('SX-Logo-small.png') %>" width="40" height="40" alt="Logo" />
<span class="navbar-brand-txt">SX Restaurant</span>

View File

@@ -124,6 +124,9 @@
<li>
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
</li>
<li>
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
</li>
<li>
<a href="<%= reports_receipt_no_index_path %>">Receipt</a>
</li>

View File

@@ -118,13 +118,45 @@ $(document).ready(function(){
data: params,
success: function(result){
// alert("Updated!");
window.location.href = '/oqs';
<% if !@link_type.nil? %>
<% if @link_type == 'oqs' %>
window.location.href = '/oqs';
<% else %>
<% if !@dining_type.nil? %>
<% if @dining_type == 'Table' %>
window.location.href = '/origami/table/'+<%=@link_type%>;
<% else %>
window.location.href = '/origami/room/'+<%=@link_type%>;
<% end %>
<% else %>
window.location.href = '/origami/table/'+<%=@link_type%>;
<% end %>
<% end %>
<% else %>
window.location.href = '/oqs';
<% end %>
}
});
});
$('#back').on('click', function () {
<% if !@link_type.nil? %>
<% if @link_type == 'oqs' %>
window.location.href = '/oqs';
<% else %>
<% if !@dining_type.nil? %>
<% if @dining_type == 'Table' %>
window.location.href = '/origami/table/'+<%=@link_type%>;
<% else %>
window.location.href = '/origami/room/'+<%=@link_type%>;
<% end %>
<% else %>
window.location.href = '/origami/table/'+<%=@link_type%>;
<% end %>
<% end %>
<% else %>
window.location.href = '/oqs';
<% end %>
})
// number key pad

View File

@@ -72,7 +72,12 @@
<div class="card queue_station" data-order-no="<%= qid.order_id %>">
<div class="card-block">
<div class="row">
<span class="col-md-4 order-zone-type font-13"><%= qid.type %>-<%= qid.zone %></span>
<%if qid.type.present?%>
<span class="col-md-4 order-zone-type font-13"><%= qid.type %>-<%= qid.zone %></span>
<%else%>
<span class="col-md-4 order-zone-type font-13"></span>
<%end%>
<span class="order-zone hidden font-13"><%= qid.zone %></span>
<span class="col-md-8"><small class="float-right font-13"><%= qid.order_id %></small></span>
</div>
@@ -83,13 +88,13 @@
<span class="order-qty">
<%= qid.qty %>
</span> ]
<% if !qid.set_menu_items.nil?
qid.set_menu_items.each do |item_instance|%>
<br><span class="font-12">
<% if !qid.set_menu_items.nil? %>
<% qid.set_menu_items.each do |item_instance|%>
<br><span class="font-12">
<%= item_instance %>
</span>
<% end
end %>
</span>
<% end %>
<% end %>
</p>
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>

View File

@@ -1,4 +1,3 @@
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
<div id="oqs_loading_wrapper" style="display:none;">
@@ -7,8 +6,8 @@
<% type = request.path_info.include?('quick_service')%>
<% modify_order = request.path_info.include?('modify_order')%>
<input type="hidden" name="type" id="type" value="<%=type%>">
<input type="hidden" name="type" id="modify_order" value="<%=modify_order%>">
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <a href="javascript:void(0);" class="dropdown-toggle waves-block p-t-15 p-l-15 p-b-15" data-toggle="dropdown" aria-haspopup="" aria-expanded="true" style="background-color: #eeeeee;border-bottom: .214rem solid #fff;border-left: 1px solid #54A5AF;
@@ -46,10 +45,10 @@
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
<ul class="sub_category_list hidden fadeInTop animated" id="sub_category_list">
</ul>
</a>
</li>
@@ -58,7 +57,7 @@
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -67,7 +66,7 @@
</li>
<% end%>
<% else %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -82,46 +81,55 @@
<%end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- else quick_service or cashier for table -->
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
<div class="card">
<div class="card-block">
<div id="custom-slimscroll">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 0.5rem;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- else quick_service or cashier for table -->
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<% else %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- end quick_service or cashier for table -->
<% end %>
<% end%>
<% else %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- end quick_service or cashier for table -->
<% end %>
<% end%>
<% end %>
<%end %>
<% end %>
<%end %>
</div>
</div>
</div>
</div>
</div>
@@ -132,15 +140,19 @@
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-7" id='pending_order'>Pending Order
</button>
<%elsif !modify_order && type%>
<button type="button" class="btn btn-lg btn-default waves-effect col-md-2" id='back' style=" padding: .5rem 0.15rem !important;">
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<a class="btn btn-lg bg-blue waves-effect select_table col-md-3" data-toggle="modal" data-target="#TableModal" style=" padding: .5rem 0.15rem !important;">Select</a>
<input type="hidden" name="table_id" value="" id="table_id">
@@ -169,7 +181,7 @@
<% end%>
<p class="hidden" id="booking_id"><%=@booking_id%></p>
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : '---'%></p>
<p class="hidden" id="sale_id"><%=@sale_id%></p>
<% else%>
<p class="hidden" id="table_type"></p>
@@ -204,23 +216,29 @@
</div>
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
<!-- <table class="table" id="order-charges-table" border="0">
<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="sub_total">0.00</strong></td>
<td style="padding:2px;" width="5%"></td>
<td style="padding:2px;" width="15%"></td>
<td style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table> -->
</table>
<% if type && modify_order%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<%elsif !modify_order && type%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary action-btn create col-md-6" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-5" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<% if current_user.role != "waiter"%>
<button type="button" class="btn btn-primary action-btn create col-md-4" id="create_pay_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<button type="button" class="btn btn-primary action-btn create col-md-7" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
<% if current_user.role == "waiter"%>
<button type="button" class="btn btn-primary action-btn create col-md-7" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
<%else%>
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
@@ -465,6 +483,10 @@
</div>
<% end %>
<script>
jQuery(function(){
id = "<%=@menu[0].id%>";
jQuery('.first_'+id).click();
});
$(document).ready(function () {
$(".tables").on('click', function () {
$('.tables').css('background-color','');

View File

@@ -1,111 +0,0 @@
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#table" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#room" role="tab">Rooms</a>
</li>
</ul>
<div class="tab-content" style="max-height:650px; overflow:auto">
<div class="tab-pane active" id="table" role="tabpanel" style="max-height:; overflow:auto">
<% @tables.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_table.each do |table| %>
<% if zone.zone_id == table.zone_id %>
<div class="card click_table <%= table.status=="available" ? "available" : "occupied"%>" data-id = "<%= table.id %>">
<div class="card-block">
<p class="hidden table-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p>
<p style="text-align: center">Seat : <%= table.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
<div class="tab-pane" id="room" role="tabpanel" style="max-height:; overflow:auto">
<% @rooms.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_room.each do |room| %>
<% if zone.zone_id == room.zone_id %>
<div class="card click_table <%= room.status=="available" ? "available" : "occupied"%>" data-id = "<%= room.id %>">
<div class="card-block">
<p class="hidden table-status"><%= room.status %></p>
<p style="text-align: center"><%= room.name %></p>
<p style="text-align: center">Seat : <%= room.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>
Back
</button>
</div>
</div>
<script>
$(document).on('click',".click_table",function(){
var dining_id = $(this).attr('data-id');
var status = $(this).find(".table-status").text();
if (status == "available") {
$.confirm({
title: 'Confirmation !',
content: 'Are you sure to assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/addorders/'+dining_id;
}
}
}
});
} else {
$.confirm({
title: 'Alert!',
content: 'You cannot assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-red',
}
}
});
}
})
</script>
<style type="text/css">
.card-columns {
-webkit-column-count:5;
-moz-column-count:5;
column-count:5;
}
.occupied{
color: #fff !important;
background-color: red;
}
.available{
color: #fff !important;
background-color: #009900;
}
</style>

View File

@@ -14,55 +14,7 @@
delimiter = ""
end
%>
<!-- Widgets -->
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-cyan hover-expand-effect">
<div class="icon">
<i class="material-icons">help</i>
</div>
<div class="content">
<div class="text"><%= t :sale_count %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_count%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-pink hover-expand-effect">
<div class="icon">
<i class="material-icons">attach_money</i>
</div>
<div class="content">
<div class="text"><%= t :total_sale %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_sale%>" data-speed="15" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-light-green hover-expand-effect">
<div class="icon">
<i class="material-icons">person_add</i>
</div>
<div class="content">
<div class="text"><%= t :total_credit %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_credit%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-orange hover-expand-effect">
<div class="icon">
<i class="material-icons">credit_card</i>
</div>
<div class="content">
<div class="text"><%= t :total_card %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_card%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
</div>
<!-- #END# Widgets -->
<!-- Widgets -->
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 qs_view">
@@ -83,6 +35,7 @@
</div>
</div>
<!-- #END# Widgets -->
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<!-- CPU Usage -->
<div class="row clearfix">
@@ -234,6 +187,7 @@
</div>
</div>
</div>
<% end %>
</div>
<script>

View File

@@ -31,6 +31,7 @@
</div>
<div id="order-detail-slimscroll" data-height="160">
<div class="card-text dining">
<span id="discount_itemsErr" style="color:red;"></span>
<table class="table table-default" id="order-items-table">
<thead>
<tr>
@@ -44,7 +45,7 @@
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc"
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">
@@ -117,6 +118,7 @@
<div class="col-md-12">
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
<span id="discount-amountErr" style="color:red;"></span>
</div>
<br>
<div class="form-group">
@@ -253,34 +255,29 @@ var cashier_type = "<%= @cashier_type %>";
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-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"){
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
}
break;
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
break;
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#discount-amount').val("0.0");
break;
$('#discount-amount').val("0.0");
break;
}
event.handled = true;
} else {
@@ -334,24 +331,40 @@ var cashier_type = "<%= @cashier_type %>";
$("#net").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var discount_value = parseFloat($('#discount-amount').val());
var discount_value = $('#discount-amount').val();
var sub_total = parseFloat($('#order-sub-total').text());
var ajax_url = "/origami/" + sale_id + "/discount";
if(discount_value!=""){
if(discount_value > 0){
if(parseFloat(discount_value) > sub_total){
$("#discount-amount").val("");
$("#discount-amountErr").html("Discount is greater than sub total!");
}else{
$("#discount-amountErr").html("");
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
// Selected Account
var account_types = get_selected_account_types();
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(0, discount_value);
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(0, discount_value);
// Remove Selection
selection_remove();
}
}else{
$("#discount-amountErr").html("Discount must be greater than 0!");
}
}else{
$("#discount-amountErr").html("can't be blank");
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
// Remove Selection
selection_remove();
});
// Calculate Percentage Discount for Payment
@@ -362,8 +375,7 @@ var cashier_type = "<%= @cashier_type %>";
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
var sale_items = get_selected_sale_items();
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
@@ -437,7 +449,6 @@ var cashier_type = "<%= @cashier_type %>";
// Selected Items
var sale_items = get_selected_sale_items();
console.log(sale_items.length);
if(sale_items.length == 0){
//swal("Information!", "You have no selected item!");
swal ( "Oops" , "You have no selected item!" , "error" );
@@ -671,113 +682,150 @@ function calculate_item_discount(type, amount, sale_items, account_types){
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
var arrItemName = "";
$("#discount_itemsErr").html("");
$("#discount-amountErr").html("");
// For Net Pay
if(type == 0){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// else {
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount;
// }
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
sub_total = origin_sub_total - total_discount;
}
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
swal({
title:"Oops!",
text:'Percentage Value over 100!',
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
}
else{
// Check sale items exists
if(origin_sub_total > 0){
if(type == 0){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// total_discount = total_discount + amount;
// }
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + dis_amount;
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
arrItemName += ", " + sale_items[i].name;
}else{
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = parseFloat(total_discount) + parseFloat(amount);
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = parseFloat(total_discount) - parseFloat(amount);
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
// }
}
sub_total = origin_sub_total + total_discount;
}
if(arrItemName!=""){
arrItemName = arrItemName.substr(2);
if(arrItemName.match(/,/g || []) != null){
if(arrItemName.match(/,/g || []).length >= 1){
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" prices");
}
}else{
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
swal({
title:"Oops!",
text:'Percentage Value over 100!',
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
}
else{
// Check sale items exists
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = total_discount + dis_amount;
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = total_discount - dis_amount;
$("#discount-amountErr").html("Discount is greater than sub total!");
}
// }
}
sub_total = parseFloat(origin_sub_total) + parseFloat(total_discount);
}
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
}
$("#order-sub-total").text(parseFloat(sub_total).toFixed(2));
}else{
$("#discount-amountErr").html("Discount is greater than sub total!");
}
$("#order-sub-total").text(sub_total);
}
function item_row_template(type, item, discount_amount, amount){

View File

@@ -276,11 +276,11 @@
</tr>
<%
# end
end
end
if @status_order == 'order' && @status_sale != 'sale'
puts
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
@@ -288,19 +288,19 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
# end
@@ -367,21 +367,19 @@
@order_items.each do |order_item|
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
@@ -427,8 +425,10 @@
<%= t("views.btn.back") %>
</button>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<% if current_login_employee.role != "waiter" %>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @dining.status != "available" %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
@@ -447,13 +447,24 @@
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" disabled> Void</button> -->
<% end %>
<% if @status_sale == 'sale' %>
<% if current_login_employee.role != "waiter" %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<% end %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button>
<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<% if current_login_employee.role != "waiter" %>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
@@ -464,14 +475,9 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %>
<% end %>
<!-- Cashier Buttons -->
<!-- <button type="button" id="re-print" class="btn btn-block bg-blue waves-effect" >Re.Print</button> -->
@@ -513,6 +519,30 @@
</div>
</div>
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
cashier_type = "cashier"
$(document).ready(function () {
@@ -845,9 +875,12 @@
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/" + sale_id + '/void';
var remark = $("#remark").val();
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
window.location.href = '/origami/';
}
@@ -898,4 +931,13 @@
}
});
});
/*edit order in oqs*/
$('.edit_order').on('click',function(){
var assigned_order_item_id = $(this).attr('data-id');
var dining_id = "<%= @dining.id %>";
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
</script>

View File

@@ -2,6 +2,21 @@
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<% if !@print_settings.nil? %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% end %>
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="card">
@@ -56,9 +71,9 @@
<% sub_total += sale_item.price%>
<tr>
<td><%= count %></td>
<td class="item-name"><%=sale_item.product_name%>@<%=sale_item.unit_price%></td>
<td class="item-name"><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%></td>
<td class="item-attr"><%=sale_item.qty%></td>
<td class="item-attr"><%=(sale_item.price)%></td>
<td class="item-attr"><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%></td>
</tr>
<%end %>
</tbody>
@@ -71,7 +86,7 @@
<tfooter>
<tr>
<td class="charges-name"><strong>Sub Total</strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=number_with_precision(sub_total, precision: precision.to_i)%></span></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
@@ -79,7 +94,7 @@
<%else%>
<td class="charges-name"><strong>(Discount)</strong></td>
<%end%>
<td class="item-attr"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax
@@ -91,22 +106,36 @@
<%end%>
<%end %>)
</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><%= @sale_data.rounding_adjustment rescue 0%></strong></td>
<td class="item-attr"><strong><%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
<td class="item-attr"><strong><span><%=@balance%></span></strong></td>
<td class="item-attr"><strong><span><%=number_with_precision(@balance, precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
<% if !@individual_total[0].nil? %>
<tr>
<td class="charges-name">
<strong>Split Bill for <%= @individual_total[0]['total_customer'] %> persons</strong>
</td>
<td></td>
</tr>
<tr>
<td class="charges-name">
<strong>Amount Due (per person)</strong>
</td>
<td class="item-attr"><strong><span><%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
</tfooter>
</table>
</div>
@@ -124,24 +153,24 @@
<div class="col-md-8"><strong>Amount Due</strong></div>
<div class="col-md-4">
<strong>
<span id="grand_total" class="hidden"><%= @sale_data.grand_total rescue 0%></span>
<span id="amount_due"><%= @sale_data.grand_total rescue 0%></span></strong>
<span id="grand_total" class="hidden"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%></span>
<span id="amount_due"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong>
</div>
</div>
<div class="row payment cash-color p-l-5 p-r-5">
<div class="col-md-8">Cash</div>
<div class="col-md-4" id="cash" ><%= @cash %></div>
<div class="col-md-4" id="cash" ><%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
<div class="col-md-8">Credit</div>
<div class="col-md-4" id="credit"><%= @credit %></div>
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= @other %></div>
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
@@ -156,13 +185,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4 mpu is_card" id="others"><%= @other %></div>
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others">0.0</div>
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- paypar -->
@@ -170,13 +199,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount">0.0</div>
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- Visa -->
@@ -184,13 +213,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4" id="visacount">0.0</div>
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- JCB -->
@@ -198,13 +227,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= @jcbcount %></div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount">0.0</div>
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- Master -->
@@ -212,13 +241,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4" id="mastercount">0.0</div>
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- <br> -->
@@ -227,18 +256,18 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= @unionpaycount %></div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4" id="unionpaycount">0.0</div>
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
</div>
<!-- <br> -->
</div>
@@ -295,8 +324,8 @@
<i class="material-icons">reply</i>
Back
</button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" class="btn bg-red btn-block" id="void" active="<%= can? :overall_void, :void %>"> Void </button>
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<% if @cashier_type=="quick_service" %>
<hr>
@@ -310,8 +339,52 @@
</div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="focModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="focModalLabel">Please Enter Reason for FOC</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="foc_remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="foc" active="true">FOC</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
@@ -422,7 +495,7 @@ console.log("fffffffffffff")
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Opps","You are not authorized for Discount","warning")
swal("Oops","You are not authorized for Discount","warning")
}
return false;
});
@@ -438,7 +511,7 @@ console.log("fffffffffffff")
}
}else{
swal("Opps","You are not authorized for void","warning")
swal("Oops","You are not authorized for void","warning")
}
});
@@ -488,8 +561,13 @@ console.log("fffffffffffff")
var unionpay1 = $('#unionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(parseFloat(amt).toFixed(1));
var amt = 0;
<% if precision.to_i > 0 %>;
amt = parseFloat(parseFloat(total) - parseFloat(othertotal)).toFixed(<%= precision %>);
<% else %>
amt = parseFloat(parseFloat(total) - parseFloat(othertotal));
<% end %>
$('#cash').text(amt);
update_balance();
break;
}
@@ -520,23 +598,23 @@ console.log("fffffffffffff")
$('#pay').click(function() {
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Opps","Please Pay with MPU Payment","warning");
swal("Oops","Please Pay with MPU Payment","warning");
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Redeem Payment","warning");
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Visa Payment","warning");
swal("Oops","Please Pay with Visa Payment","warning");
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with jcb Payment","warning");
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning");
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with UNIONPAY Payment","warning");
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Credit Payment","warning");
swal("Oops","Please Pay with Credit Payment","warning");
}else{
$( "#loading_wrapper").show();
@@ -615,30 +693,55 @@ console.log("fffffffffffff")
}
});
$('#void').on('click',function () {
if ($(this).attr('active') === "true") {
// $('#void').on('click',function () {
// if ($(this).attr('active') === "true") {
// var sale_id = $('#sale_id').text();
// var remark = $("#remark").val();
// var ajax_url = "/origami/sale/" + sale_id + '/void';
// $.ajax({
// type: 'POST',
// url: ajax_url,
// data: "remark="+ remark + "&sale_id=" + sale_id,
// success: function () {
// window.location.href = '/origami/';
// }
// })
// }else{
// swal("Opps","You are not authorized for void","warning")
// }
// });
$('#void').on('click', function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Information!",
text: 'Are you sure want to Void !',
}, function () {
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
}
})
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
swal("Oops","You are not authorized for void","warning")
}
});
});
@@ -654,43 +757,57 @@ console.log("fffffffffffff")
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
var result = parseFloat(amount_due) - parseFloat(total);
$('#balance').text(result.toFixed(2));
<% if precision.to_i > 0 %>
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
<% else %>
$('#balance').text(parseFloat(result));
<% end %>
}
$('#foc').click(function() {
//$( "#loading_wrapper" ).show();
// payment
var remark = $("#foc_remark").val();
var cash = $('#grand_total').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total,'remark':remark,'type':cashier_type };
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
//$( "#loading_wrapper" ).hide();
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}
swal({
title: "Alert",
text: "Are you sure want to FOC This Receipt?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, FOC it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}
}
});
}
});
});
}else{
swal("Opps","You are not authorized for foc","warning")
swal("Oops","You are not authorized for foc","warning")
}
});

View File

@@ -12,10 +12,17 @@
<% @sale.each do |sale| %>
<div class="card sales bg-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>
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;">Billed</span>
</div>
</div>
<% end %>
<% @order.each do |order| %>
<div class="card sales blue text-white" data-id = "<%= order.booking_id %>">
<div class="card-block">
<%= order.booking_id %><span style="font-size:12px;float:right;line-height:inherit;">new</span>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -10,12 +10,19 @@
<div id="custom-slimscroll">
<div class="card-columns">
<% @sales.each do |sale| %>
<div class="card sales bg-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 %>
<div class="card sales bg-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;">Billed</span>
</div>
</div>
<% end %>
<% @orders.each do |order| %>
<div class="card sales blue text-white" data-id = "<%= order.booking_id %>">
<div class="card-block">
<%= order.booking_id %><span style="font-size:12px;float:right;line-height:inherit;">new</span>
</div>
</div>
<% end %>
</div>
</div>
</div>
@@ -31,19 +38,38 @@
</div>
<div class="card-block">
<div class="card-title row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<%= @sale.receipt_no rescue '' %>
</span>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% if @status == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<%= @sale.receipt_no rescue '' %></span>
</div>
<% else%>
<input type="hidden" id="save_order_id" value="<%=@bookings.booking_orders[0].order_id%>">
<div class="col-lg-8 col-md-8 col-sm-8">
&nbsp; Order No: <span id="receipt_no">
<%= @bookings.booking_orders[0].order_id rescue '' %></span>
</div>
<% end%>
<% if @status == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% else%>
<div class="col-lg-4 col-md-4 col-sm-4 text-right">
Date: <span id="receipt_date"><%= @order.created_at.strftime("%I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% end%>
</div>
<div class="card-title row customer_detail p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Customer : <%= @sale.customer.name rescue "-" %>
<% if @status == 'sale' %>
&nbsp; Customer : <%= @sale.customer.name rescue "-" %>
<% else%>
&nbsp; Customer : <%= @order.customer.name rescue "-" %>
<% end%>
</div>
</div>
@@ -58,55 +84,64 @@
</tr>
</thead>
<tbody>
<%
sub_total = 0
<% if @status == 'sale' %>
<% sub_total = 0
@sale.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
<% #unless sale_item.price <= 0 %>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
#end
end
%>
sub_total = sub_total + sale_item.price %>
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<% end%>
<% else%>
<% sub_total = 0
@order_items.each do |order_item|
sub_total = sub_total + order_item.price %>
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.price %></td>
</tr>
<% end%>
<% end%>
</tbody>
</table>
</div>
</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>
<% if @status == 'sale' %>
<tr>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @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"><%= @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"><%= @sale.grand_total rescue 0%></strong></td>
</tr>
<tr class="rebate_amount"></tr>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @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"><%= @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"><%= @sale.grand_total rescue 0%></strong></td>
</tr>
<tr class="rebate_amount"></tr>
<% else%>
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<% end%>
</table>
</div>
</div>
@@ -115,8 +150,15 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
<% if current_user.role != "waiter" || @status != "sale"%>
<button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<%end%>
<% if current_user.role != "waiter" && @status != "order"%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<%end%>
<% if @status != "sale"%>
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
<%end%>
</div>
</div>
</div>
@@ -135,7 +177,7 @@ $(document).ready(function(){
});
$('#addorder').on('click', function () {
var table_id = "<%=@table_id%>";
var booking_id = "<%=@booking%>";
var booking_id = "<%=@bookings.booking_id%>";
if (table_id) {
window.location.href = '/origami/quick_service/modify_order/' + table_id+"/"+$('#sale_id').val();
}else{
@@ -143,5 +185,23 @@ $(document).ready(function(){
}
});
// Bill Request
$('#request_bills').click(function () {
var order_id = $('#save_order_id').val();
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "GET",
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
}
}
});
});
});
</script>

View File

@@ -277,19 +277,19 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
# end
@@ -345,20 +345,19 @@
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
@@ -397,7 +396,10 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button>
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @room.bookings.length >= 1 %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
@@ -420,6 +422,7 @@
<% if @status_sale == 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
@@ -427,6 +430,13 @@
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<% if current_login_employee.role != "waiter" %>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
@@ -437,14 +447,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%end%>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<% end %>
<!-- <button type="button" id="void" class="btn bg-blue btn-block" > Void </button> -->
<% end %>
<% if current_login_employee.role != "waiter" %>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
@@ -475,9 +482,10 @@
</div>
</div>
<!-- Cashier Buttons -->
<% end %>
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
<% end %>
<% end %>
</div>
</div>
</div>
@@ -901,4 +909,13 @@ $('#add_invoice').on('click',function(){
}
});
});
/*edit order in oqs*/
$('.edit_order').on('click',function(){
var assigned_order_item_id = $(this).attr('data-id');
var dining_id = "<%= @room.id %>";
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
</script>

View File

@@ -1,7 +1,7 @@
<div class="container-fluid">
<div class="row">
<!-- Column Two -->
<div class="col-lg-10 col-md-10 col-sm-10">
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="card">
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
@@ -57,23 +57,26 @@
<td class="p-2" width="20%">
<%= sale_item.product_name %>
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td>
<td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
</td>
<!-- <td class='' width="17%">
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> -->
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
</td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
@@ -148,48 +151,114 @@
</div>
</div>
</div> -->
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
</div>
</div>
</div>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
// Bill Request
$(document).ready(function () {
$('.editModal').on('click', function () {
$("#action").attr('data-type', $(this).attr('data-type'));
$("#action").attr('data-id', $(this).attr('data-id'));
$("#action").text($(this).attr('data-type'))
})
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
console.log(qty + "|" + price);
var qty_status = true;
var price_status = true;
if((qty > 0) && (price > 0)){
qty_status = true;
price_status = true;
$('#' + sale_item_id + "_qtyErr").html("");
$('#' + sale_item_id + "_priceErr").html("");
}else if((qty > 0) && (price <= 0 || price == '')){
price_status = false;
$('#' + sale_item_id + "_qtyErr").html("");
if(price == ''){
$('#' + sale_item_id + "_priceErr").html("can't be blank");
}else{
$('#' + sale_item_id + "_price").val("");
$('#' + sale_item_id + "_priceErr").html("Price must be greater than 0");
}
}else if((qty <= 0 || qty == '') && (price > 0)){
qty_status = false;
if(qty == ''){
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
}else{
$('#' + sale_item_id + "_qty").val("");
$('#' + sale_item_id + "_qtyErr").html("Quantity must be greater than 0");
}
$('#' + sale_item_id + "_priceErr").html("");
}else{
qty_status = false;
price_status = false;
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
$('#' + sale_item_id + "_priceErr").html("can't be blank");
}
if(qty_status && price_status){
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
}
});
$('.void').on('click', function () {
/*$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var remark = $("#remark").val();
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -202,7 +271,27 @@ var cashier_type = "<%= @cashier_type %>";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
});
})*/
$('#action').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var type = $(this).attr('data-type');
var remark = $("#remark").val();
if (type=='foc') {
var ajax_url = "/origami/item_foc";
}else{
var ajax_url = "/origami/item_void";
}
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -225,6 +314,7 @@ var cashier_type = "<%= @cashier_type %>";
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
var sale_id = "<%= @saleobj.sale_id %>"
@@ -311,4 +401,24 @@ var cashier_type = "<%= @cashier_type %>";
return false;
}
});
//check for isNumber
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function checkQuantity(obj_value,sale_item_id) {
if(obj_value == '0'){
$("#"+sale_item_id+"_qty").val('1');
}
}
function checkPrice(obj_value,sale_item_id) {
}
</script>

View File

@@ -65,6 +65,8 @@
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=odr_item['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=odr_item['account_id'] %></span>
<span id="item-code" class="hidden"><%=odr_item['item_code'] %></span>
<span id="item-instance-code" class="hidden"><%=odr_item['item_instance_code'] %></span>
<span id="item-name-price">
<%=odr_item['item_name'] %>
<% if !odr_item['set_menu_items'].nil?
@@ -132,6 +134,8 @@
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=order_item[order.order_id.to_s]['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=order_item[order.order_id.to_s]['account_id'] %></span>
<span id="item-code" class="hidden"><%=order_item[order.order_id.to_s]['item_code'] %></span>
<span id="item-instance-code" class="hidden"><%=order_item[order.order_id.to_s]['item-instance-code'] %></span>
<span id="item-name-price">
<%=order_item[order.order_id.to_s]['item_name'] %>
<% if !order_item[order.order_id.to_s]['set_menu_items'].nil?
@@ -194,7 +198,9 @@
<th>#</th>
<th>Receipt No.</th>
<th>Total</th>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<th>Action</th>
<% end %>
</thead>
<tbody>
<% @sale_data.each_with_index do |sale_data, sale_index| %>
@@ -207,9 +213,12 @@
<td><input type="radio" name="rdn_receipt" id="rdn_receipt" value="<%= sale_data.sale_id %>" <%= checked %>></td>
<td><span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<td><span id="grand_total"><%= sale_data.grand_total %></span></td>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<td>
<button type="button" class="btn btn-block waves-effect btn-primary btn_pay" id=<%= sale_data.sale_id %> >Pay</button>
</td>
<% end %>
</tr>
<% end %>
<% end %>
@@ -228,9 +237,15 @@
<!-- Action Panel -->
<div>
<button type="button" class="btn bg-default btn-block waves-effect" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<% if !@sale_data.empty? %>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<% end %>
<% end %>
<% if !@orders.empty? %>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
<% end %>
</div>
</div>
<!-- Column Three -->
@@ -249,7 +264,7 @@
<div class="modal-body">
<div class="form-horizontal">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<div class="form-group">
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/><br>
<span id="per_personErr" style="color:red;"></span>
</div>
@@ -316,9 +331,7 @@
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){
$('#back').on('click',function(){
backToOrigami();
})
@@ -395,7 +408,7 @@
// orderItemSplitBillProcess(cnt_items);
// }
}else{
swal("Opps","Please select at least one item!","warning");
swal("Oops","Please select at least one item!","warning");
}
});
@@ -459,7 +472,7 @@
// orderSplitBillProcess(cnt_odrs);
// }
}else{
swal("Opps","Please select at least one order!","warning");
swal("Oops","Please select at least one order!","warning");
}
});
@@ -472,14 +485,15 @@
//equal split process
$('#equal_split').on('click', function(){
var dining_id = $("#table_id").text();
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
}
else{
swal("Opps","Please select one receipt!","warning");
swal("Oops","Please select one receipt!","warning");
}
});
@@ -490,15 +504,15 @@
$("#per_personErr").html('');
$('#equal_split_modal').modal('hide');
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
var dining_id = $("#table_id").text();
var ajax_url = "/origami/split_bills/equal_person";
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount },
data: { 'sale_id':split_sale_id, 'total_customer': person },
success: function (result) {
console.log(result);
if(result.status){
@@ -688,6 +702,8 @@ function get_selected_order_items(){
var order_item = {};
order_item.id = $(this).attr('id').substr(0,16);
order_item.order_id = $(this).find('#item-order-id').text().trim();
order_item.item_code = $(this).find('#item-code').text().trim();
order_item.item_instance_code = $(this).find('#item-instance-code').text().trim();
order_item.name = $(this).find('#item-name-price').text().split('@')[0];
order_item.account_id = $(this).find('#item-account-type').text();
order_item.qty = $(this).find('#item-qty').text();

View File

@@ -1,11 +1,26 @@
<div class="container-fluid">
<div class="row">
<% if !@print_settings.nil? %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% end %>
<div class="col-lg-4 col-md-6 col-sm-6">
<!-- <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> -->
<% @sale_array.each do |sale| %>
<div class="card tables" data-id="<%= sale.id %>">
<div class="card tables receipt_block" data-id="<%= sale.id %>">
<% if sale.id == @sale.id %>
<div class="card-block" style="background-color:#6080f0;">
<div class="card-block selected-item">
<%= sale.receipt_no %>
</div>
<% else %>
@@ -15,7 +30,7 @@
<% end %>
</div>
<% end %>
</div>
</div>
<div class="col-lg-7 col-md-5 col-sm-5">
<div class="card" >
@@ -74,7 +89,7 @@
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
<td class='item-attr'><%= number_with_precision(sale_item.price, precision: precision.to_i ) %></td>
</tr>
<%
# end
@@ -93,7 +108,7 @@
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
<td class='item-attr'><%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %></td>
</tr>
<%
end
@@ -109,7 +124,7 @@
<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>
<td class="item-attr"><strong id="order-sub-total"><span id="sub_total"><%= number_with_precision(sub_total, precision: precision.to_i ) %></span></strong></td>
</tr>
<tr>
<%if @sale.discount_type == 'member_discount'%>
@@ -117,19 +132,19 @@
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= number_with_precision(@sale.total_discount, precision: precision.to_i ) rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale.total_tax, precision: precision.to_i ) rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment rescue 0%></strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= number_with_precision(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
<td class="item-attr"><strong id="order-grand-total"><span id="grand_total"><%= number_with_precision(@sale.grand_total, precision: precision.to_i ) rescue 0%></span></strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
@@ -142,7 +157,8 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true" > Void </button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" id="void" class="btn bg-danger btn-block" active="<%= can? :overall_void, :void %>" > Void </button>
</div>
</div>
</div>
@@ -200,13 +216,45 @@ $('#void').on('click',function () {
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
window.location.href = '/origami';
}
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
swal("Opps","You are not authorized for void","warning");
}
});
$('#foc').click(function() {
var cash = $('#grand_total').text();
var sub_total = $('#sub_total').text();
var sale_id = '';
if($('.receipt_block > div').hasClass('selected-item')){
sale_id = $('.receipt_block > div.selected-item').parent().attr('data-id');
}
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
// console.log(sale_id);
if(sale_id != ''){
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
window.location.href = '/origami';
});
}
}
});
}else{
swal("Oops","You are not authorized for foc","warning")
}
}
});
</script>

View File

@@ -91,37 +91,37 @@
<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_precision(sale[:void_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:mpu_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:master_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:visa_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:jcb_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:paypar_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision, delimiter: delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='color:red;text-align:right;'><%= number_with_precision(sale[:void_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision.to_i,delimiter: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_precision(mpu , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(master, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(visa, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(jcb, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(paypar, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_precision(total, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<% total_tax = 0 %>
@@ -130,7 +130,7 @@
<% 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_precision(tax.tax_amount, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
@@ -138,7 +138,7 @@
<% net = total - total_tax %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
<td style='text-align:right;'><%= number_with_precision(net, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td style='text-align:right;'><%= number_with_precision(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>

View File

@@ -0,0 +1,113 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<div class="text-right">
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<div class="p-l-20 p-t-20 p-b-20">
<div class="col-md-6">
<label class="font-16" for="order_by">Order by Qty</label>
<select name="order_by" id="order_by" class="form-control" style="width:10%">
<option value="asc">ASC</option>
<option value="desc">DESC</option>
</select>
</div>
</div>
<div class="table-responsive">
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end %>
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
<th>&nbsp;</th>
<th><%= t("views.right_panel.header.menu_category") %></th>
<th><%= t("views.right_panel.detail.code") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.total") %></th>
</tr>
</thead>
<tbody id="tbd_data">
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% @sale_data.each do |sale| %>
<% grand_total += sale.grand_total %>
<% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<% cate_arr = Array.new %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
</tr>
<!-- sub total -->
<!-- end sub total -->
<% end %>
<tr>
<td colspan="3"></td>
<td><strong>Total</strong></td>
<td><strong><%= total_qty %></strong></td>
<td></td>
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
$('#order_by').val('<%= @order_by %>');
});
$('#order_by').on('change', function(){
var order_by = $("#order_by").val();
window.location.href = "?order_by=" + order_by;
});
</script>

View File

@@ -0,0 +1,59 @@
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
<th>&nbsp;</th>
<th><%= t("views.right_panel.header.menu_category") %></th>
<th><%= t("views.right_panel.detail.code") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
<th><%= t("views.right_panel.detail.unit_price") %></th>
<th><%= t("views.right_panel.detail.total") %></th>
</tr>
</thead>
<tbody>
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% @sale_data.each do |sale| %>
<% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item
grand_total += sale.grand_total
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
grand_total += sale.grand_total
end %>
<tr>
<td>&nbsp;</td>
<td><%= sale.menu_category_name %></td>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<td><%= sale.unit_price rescue '-' %></td>
<td><%= sale.grand_total rescue '-' %></td>
</tr>
<% end %>
<tr>
<td colspan="3"></td>
<td><strong>Total</strong></td>
<td><strong><%= total_qty %></strong></td>
<td></td>
<td><strong><%= grand_total rescue '-' %></strong></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -101,7 +101,7 @@
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision,delimiter:delimiter) %></b>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
@@ -120,8 +120,8 @@
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<td><%= number_with_precision(sale.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
@@ -140,7 +140,7 @@
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision,delimiter:delimiter)%> </span></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
@@ -168,8 +168,8 @@
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item rescue '-' %></td>
<td> <%= number_with_precision(other.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
@@ -179,7 +179,7 @@
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision,delimiter:delimiter)%></span></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
@@ -188,29 +188,35 @@
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision,delimiter:delimiter)%></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= number_with_precision(total_item_foc , precision:precision,delimiter:delimiter) %></span></td>
<td><span><%= number_with_precision(total_item_foc , precision:precision.to_i,delimiter:delimiter) %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision,delimiter:delimiter) %></span></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision.to_i,delimiter:delimiter) %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.foc_sales") %></td>
<td><span><%= number_with_precision(@foc_data , precision:precision,delimiter:delimiter) %></span></td>
<td>
<span><%= number_with_precision(@foc_data, precision:precision.to_i, delimiter:delimiter) %></span>
</td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(@discount_data , precision:precision,delimiter:delimiter) %></span></td>
<td style="border-bottom:2px solid grey;">
<span>
<%= number_with_precision(@discount_data , precision: precision.to_i,delimiter: delimiter) %>
</span>
</td>
</tr>
<% @sale_taxes.each do |tax| %>
@@ -226,7 +232,7 @@
<td colspan="5">&nbsp;</td>
<td style="border-top:2px solid grey;">Net Amount</td>
<!-- <td><span class="double_underline"><%= grand_total.to_f - @discount_data.to_f%></span></td> -->
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision,delimiter:delimiter)%></td>
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision.to_i,delimiter:delimiter)%></td>
</tr>
<!-- <tr>
<td colspan="5">&nbsp;</td>

View File

@@ -98,16 +98,16 @@
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision,delimiter:delimiter) %></td>
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision.to_i,delimiter:delimiter) %></td>
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td>
<%= number_with_precision(result[:foc_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%>
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
</td>
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
<% grand_total = result[:grand_total].to_f %>
@@ -126,15 +126,15 @@
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
<td><b><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= number_with_precision(card, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= number_with_precision(g_total, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
<td><b><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
</tr>
</tbody>
</table>

View File

@@ -28,6 +28,18 @@
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<table class="table table-striped">
<thead>
<tr>
@@ -63,7 +75,7 @@
<% end %>
</td>
<td><%= result.stock_count rescue '-' %></td>
<td><%= result.stock_balance rescue '-' %></td>
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
<td><%= result.different rescue '-' %></td>
<td><%= result.remark rescue '-' %></td>
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
@@ -76,7 +88,7 @@
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
<td><b><%= total_stock_count rescue '-' %></b></td>
<td><b><%= total_stock_balance rescue '-' %></b></td>
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
<td><b><%= total_different rescue '-' %></b></td>
<td colspan="2"></td>
</tr>