Pull from master

This commit is contained in:
San Wai Lwin
2018-03-29 18:17:10 +06:30
122 changed files with 4008 additions and 1115 deletions

2
.gitignore vendored
View File

@@ -26,7 +26,7 @@ capybara-*.html
/public/assets/*
/public/uploads/*
/public/swf/*
/public/receipts
/public/receipts/
/coverage/
/spec/tmp/*
*.orig

View File

@@ -47,9 +47,11 @@ gem 'jquery-fileupload-rails'
gem 'cups'
gem 'prawn'
gem 'prawn-table'
gem 'spreadsheet'
gem 'to_xls-rails'
gem 'rubyzip', '= 1.0.0'
gem 'axlsx', '= 2.0.1'
gem 'axlsx_rails'
gem 'roo'
#Reporting gem
#gem 'compendium'
#gem "cancan"
@@ -82,7 +84,6 @@ gem 'kaminari', '~> 1.0.1'
gem 'filterrific'
gem 'cancancan', '~> 1.10'
#pageless no need for current
# gem 'will_paginate'
# gem 'pageless-rails', github: 'rorlab/pageless-rails'

View File

@@ -50,6 +50,13 @@ GEM
airbrussh (1.3.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (8.0.0)
axlsx (2.0.1)
htmlentities (~> 4.3.1)
nokogiri (>= 1.4.1)
rubyzip (~> 1.0.0)
axlsx_rails (0.5.1)
actionpack (>= 3.1)
axlsx (>= 2.0.1)
bcrypt (3.1.11)
bindex (0.5.0)
builder (3.2.3)
@@ -100,6 +107,7 @@ GEM
railties (>= 3.2, < 5.2)
globalid (0.4.1)
activesupport (>= 4.2.0)
htmlentities (4.3.4)
httparty (0.15.6)
multi_xml (>= 0.5.2)
i18n (0.9.1)
@@ -201,6 +209,10 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (3.3.5)
roo (1.13.2)
nokogiri
rubyzip
spreadsheet (> 0.6.4)
rspec-core (3.7.0)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
@@ -219,6 +231,7 @@ GEM
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
ruby-ole (1.2.12.1)
rubyzip (1.0.0)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
@@ -290,6 +303,8 @@ PLATFORMS
DEPENDENCIES
aescrypt
axlsx (= 2.0.1)
axlsx_rails
bcrypt (~> 3.1.7)
byebug
cancancan (~> 1.10)
@@ -325,13 +340,14 @@ DEPENDENCIES
rack-cors
rails (~> 5.1.0)
redis (~> 3.0)
roo
rspec-rails (~> 3.5)
rubyzip (= 1.0.0)
sass-rails (~> 5.0)
schema_to_scaffold
shoulda-matchers (~> 3.1)
sidekiq
simple_form
spreadsheet
spring
spring-watcher-listen (~> 2.0.0)
tether-rails

View File

@@ -10,7 +10,7 @@ ruby 2.4.1p111
* Membership Details
Osaka =>
Auth Token => wu8YvlLmah0CL => New => v3
=> rj0MJ0XI5GsKZehE => Old => v
=> rj0MJ0XI5GsKZehE => Old => v2
=> code2lab => Old
Merchant account => RxzaYyAGzm7VqAZ4hKnv
@@ -25,6 +25,7 @@ BITP
Campaign Id => {"campaign_type_id": 1}
java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
java -jar ~/Documents/c2l_jade.jar http://192.168.1.151:3002
Person and Extra Time
category_code = SPL... //for menu categories special
@@ -103,6 +104,9 @@ For Sidekiq
1) If you want to use sidekiq
=> Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0
For Clear Menu
1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set
For Check CUp status
###please open
sudo cat /etc/sudoers
@@ -132,12 +136,29 @@ ADD COLUMN image_path VARCHAR(255);
ALTER TABLE sales
ADD COLUMN equal_persons INT(11) after rebate_status;
ALTER TABLE sale_items
ADD COLUMN remark VARCHAR(255) after status;
ALTER TABLE shops
ADD COLUMN shop_code VARCHAR(255) after name,
ADD COLUMN client_name VARCHAR(255) after shop_code,
ADD COLUMN client_code VARCHAR(255) after client_name;
ALTER TABLE print_settings
ADD COLUMN brand_name VARCHAR(255) after api_settings,
ADD COLUMN type VARCHAR(255) after brand_name;
ALTER TABLE tax_profiles
ADD COLUMN group_type VARCHAR(255) after name;
<---- Extra Fields Script ----->
For CloseCashierCustomisePdf in lookups
*** change CloseCashierPdf to CloseCashierCustomisePdf
1) settings/print_settings
2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 }
<<<<<<< HEAD
<---- Extra Fields Script ----->
For MoveTablePdf in lookups
*** Both Table and Room Moving ***
@@ -149,6 +170,13 @@ For MoveTablePdf in print settings
ii) Unique Code: MoveTablePdf
iii)Template: ...
iv) Font: Zawgyi-One v) Printer: #printer name
=======
/* Tax Profile Group Types in lookups */
1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier }
2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service }
3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal }
/* Tax Profile Group Types in lookups */
>>>>>>> 1c13b0469758fb968c0dfcc1f0a876ed2c5e395a
* ToDo list

View File

@@ -36,7 +36,7 @@ $(function() {
image_path = "/image/logo.png";
}
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">'
row = '<div class="card custom-card testimonial-card fadeInRight" style="">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;">'
+'<div class="col-md-9">'+ product[field].name +'</div>'
+"<div class='col-md-3 add_icon' data-item-code='"
@@ -180,9 +180,8 @@ $(function() {
image_path = "image/logo.png";
}
}
console.log(menu_items[field].options)
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
row = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
+'<div class="col-md-9">'+ menu_items[field].name +'</div>'
+"<div class='col-md-3 "+menu_item_box+"' data-item-code='"
@@ -190,18 +189,20 @@ $(function() {
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(menu_items[field].options)+"'data-opt = '"
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' >"
+"<i class='fa "+fa_plus+" '>"
+add+ '</i>'
+'</div>'
+'</div>'
+"<div class='"+add_icon+" p-t-65 m-r--5' data-item-code='"
+"<div class='"+add_icon+" p-t-65 m-r-' data-item-code='"
+ menu_items[field].code +"' data-name='"
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ JSON.stringify(menu_items[field].options) +"' data-opt = '"
+ JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
@@ -296,7 +297,7 @@ $(function() {
$('.set-item').attr('data-code',instances[0]['code']);
$('.set-item').attr('data-name',instances[0]['name']);
$('.set-item').attr('data-price',instances[0]['price']);
// $('.set-item').attr('data-options','[]');
$('.set-item').attr('data-options','');
$('.set-item').attr('data-parent',true);
$('#set_change_qty').val(1);
@@ -351,6 +352,7 @@ $(function() {
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
options = $(this).attr('data-options','');
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
@@ -379,14 +381,14 @@ $(function() {
item = get_set_item(items);
customer_display_view(item,"set_add");
var option = ''
attribute_arr = []
var rowCount = $('.summary-items tbody tr').length+1;
code = $('.set-item').attr('data-code');
name = $('.set-item').attr('data-name');
price = $('.set-item').attr('data-price');
option = $('.set-item').attr('data-options');
option = ($('.set-item').attr('data-options') === 'undefined') ? '' :$('.set-item').attr('data-options');
parent = $('.set-item').attr('data-parent');
total = qty * price ;
row ="<tr class='item_box' data-price ='"
@@ -396,7 +398,7 @@ $(function() {
+attribute_arr+"' data-options ='"
+option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'-' + option +'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + option +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
@@ -404,22 +406,23 @@ $(function() {
+'</tr>';
$(".summary-items tbody").append(row);
var rowCount = $('.summary-items tbody tr').length+1;
var set_option = ''
$(items).each(function(i){
code = $(items[i]).attr('data-code');
name = $(items[i]).attr('data-name');
price = $(items[i]).attr('data-price');
option = $(items[i]).attr('data-options');
set_option = ($(items[i]).attr('data-options') === 'undefined') ? ' ' :$(items[i]).attr('data-options');
sub_item = $(items[i]).attr('data-sub-item');
option = $(items[i]).attr('data-options');
total = qty * price ;
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+set_option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'-' + option +'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + set_option +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
@@ -659,7 +662,6 @@ $(function() {
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
if (item_row.length>0) {
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
@@ -698,9 +700,9 @@ $(function() {
$('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
var item_data = $(this);
item = get_item(item_data);
item = get_item(item_data,"add_to_order");
customer_display_view(item,"add");
show_item_detail(item_data);
show_item_detail(item_data,"add_to_order");
calculate_sub_total();
}); //End add order Click
@@ -708,13 +710,13 @@ $(function() {
// click plus icon for add
$(document).on('click', '.add_icon', function(event){
var item_data = $(this);
item = get_item(item_data);
item = get_item(item_data,"add_icon");
customer_display_view(item,"add");
show_item_detail(item_data);
show_item_detail(item_data,"add_icon");
calculate_sub_total();
}); //End Add Icon Click
function show_item_detail(data){
function show_item_detail(data,click_type){
qty = parseInt(data.attr('data-qty'));
append = 0;
@@ -726,23 +728,24 @@ $(function() {
}else{
instance = "("+data.attr('data-instance')+")";
}
d_option = data.attr('data-options');
if (d_option){
option_name = "-"+data.attr('data-options');
d_option = data.attr('data-opt');
if (click_type != "add_icon"){
option_name = "-"+data.attr('data-options');
data_option = data.attr('data-options') ;
}else{
option_name = '';
option_name = ' ';
data_option = '[]';
}
var rowCount = $('.summary-items tbody tr').length+1;
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
item_code = $(item_row[i]).attr('data-code');
instance_code = $(item_row[i]).attr('data-instance-code');
r_option = $(item_row[i]).attr('data-options');
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option==d_option) {
r_option = $(item_row[i]).attr('data-opt');
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
if (qty > 1) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
}else{
@@ -766,9 +769,10 @@ $(function() {
+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
+data.attr('data-instance-code')+"' data-attributes='"
+data.attr('data-attributes')+"' data-options ='"
+data_option+"' data-opt ='"
+data.attr('data-options')+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +' ' + option_name +'</td>'
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +''+option_name+'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(price).toFixed(2)
@@ -822,8 +826,6 @@ $(function() {
data: params,
dataType: "json",
success:function(result){
console.log(type)
console.log(table_type)
if (type == "quick_service") {
window.location.href = "/origami/quick_service"
}else{
@@ -889,7 +891,7 @@ $(function() {
dataType: "json",
success:function(result){
if (result.status) {
console.log(result)
if (result.data == null){
swal({
title: "Please Open Shift !",
@@ -1178,7 +1180,7 @@ $(function() {
for(var i in data) {
row = '<li class="menu_category fadeInTop animated" data-id="'+data[i].id+'">'
row = '<li class="menu_category fadeInTop" data-id="'+data[i].id+'">'
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ data[i].name+'</a>'
+'</li>' ;
$(sub_category).append(row);
@@ -1191,7 +1193,7 @@ $(function() {
}
/* Get Item rows */
function get_item(data){
function get_item(data,click_type){
var sale_items = [];
var sale_item = {};
@@ -1202,6 +1204,8 @@ $(function() {
sale_item.instance_code = data.attr('data-instance-code')
sale_item.attributes = data.attr('data-attributes')
sale_item.options = data.attr('data-options')
sale_item.opt = data.attr('data-opt')
sale_item.click_type = click_type
sale_item.instance = data.attr('data-instance')
sale_items.push(sale_item);

View File

@@ -30,11 +30,20 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
instance = "("+items[i].instance+")";
}
d_option = items[i].options;
if (d_option){
option_name = "-"+items[i].options;
// d_option = items[i].options;
// if (d_option){
// option_name = "-"+items[i].options;
// }else{
// option_name = '';
// }
d_option = items[i].opt;
if (items[i].click_type != "add_icon"){
option_name = "-"+items[i].options;
data_option = items[i].options ;
}else{
option_name = '';
option_name = ' ';
data_option = '[]';
}
var rowCount = $('.second_display_items tbody tr').length+1;
@@ -68,7 +77,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
+items[i].instance_code+"' data-attributes='"
+items[i].attributes+"' data-options ='"
+items[i].options+"' data-row ='"+rowCount+ "'>"
+data_option+"' data-opt ='"
+items[i].options+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'

View File

@@ -9,7 +9,8 @@ $(document).ready(function() {
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
railBorderRadius: '0',
touchScrollStep : 25
});
$('#order-detail-slimscroll').slimScroll({
@@ -18,7 +19,18 @@ $(document).ready(function() {
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
railBorderRadius: '0',
touchScrollStep : 25
});
$('#menu-slimscroll').slimScroll({
height: height-$('#menu-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0',
touchScrollStep : 25
});
// $('.delete').click(function(){

View File

@@ -270,7 +270,7 @@ function setCommPorts(comPortLists) {
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment";
});
}
}
@@ -363,6 +363,8 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
}else{
if(payment_type!="master"){
payment_type = payment_type.toUpperCase();
}else{
payment_type = "Master";
}
swal({
title: 'Oops',
@@ -381,4 +383,4 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
function setHeaderBreadCrumb(params){
$("#others_payment").html(params);
}
}

View File

@@ -198,6 +198,18 @@ select.form-control {
background-color: blue !important;
}
.selected-payment {
color: #fff !important;
background-color: blue !important;
}
.payment_btn {
white-space: normal !important;
margin-bottom: 15px;
margin-right: 15px;
color:#fff !important;
# background-color: green !important;
}
/* Reciept Style */
#order-charges-table td {
border-top: none !important;
@@ -399,7 +411,7 @@ i.logout_icon{
/* Start Is Member Modal */
#is_memberModal .modal-body {
height: 200px !important;
height: 260px !important;
}
#is_memberModal .btn {

View File

@@ -67,7 +67,8 @@ class Api::OrdersController < Api::ApiController
end
}
#end extra time
puts params[:order_items]
puts "ORDER ITEMS"
# begin
@order = Order.new
@order.source = params[:order_source]
@@ -171,9 +172,9 @@ class Api::OrdersController < Api::ApiController
# Update customer info, Guest Info
# Input Params
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
def update
# def update
end
# end
def order_params
params.permits(:order_source, :booking_id,:order_type,
@@ -198,4 +199,59 @@ class Api::OrdersController < Api::ApiController
end
return status
end
def update
Rails.logger.debug "Booking ID - " + params[:booking_id].to_s
if checkin_checkout_time(params[:booking_id])
Rails.logger.debug "Order Item ID - " + params[:order_item_id].to_s
order_items_id = params[:order_item_id]
qty_weight = params[:quantity].to_f
remarks = params[:remark]
order_item = OrderItem.find(order_items_id)
before_updated_qty = order_item.qty
order_item.item_order_by = current_login_employee.name
order_item.qty = qty_weight
order_item.remark = remarks
order_item.save
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
# order queue stations
oqs = assigned_item.order_queue_station
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
order_slim_pdf.each do |order_item_slim|
if order_item_slim[0] == 'OrderSlimPdf'
if order_item_slim[1] == '1'
unique_code="OrderItemSlimPdf"
else
unique_code="OrderItemPdf"
end
elsif order_item_slim[0] == 'OrderSetPdf'
if order_item_slim[1] == '1'
unique_code="OrderSetItemPdf"
else
unique_code="OrderItemPdf"
end
end
end
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
return return_json_status_with_code(200, "updated successfully!")
else
return return_json_status_with_code(406, "Checkout time is over!")
end
end
end

View File

@@ -2,6 +2,8 @@ class BaseCrmController < ActionController::Base
include LoginVerification
layout "CRM"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
@@ -22,8 +24,10 @@ class BaseCrmController < ActionController::Base
{ locale: I18n.locale }
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
def check_user
if current_user.nil?
redirect_to root_path
end
end
#Shop Name in Navbor

View File

@@ -2,6 +2,8 @@ class BaseInventoryController < ActionController::Base
include LoginVerification
layout "inventory"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
@@ -12,8 +14,10 @@ class BaseInventoryController < ActionController::Base
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
def check_user
if current_user.nil?
redirect_to root_path
end
end
#Shop Name in Navbor

View File

@@ -2,6 +2,8 @@ class BaseOqsController < ActionController::Base
include LoginVerification
layout "OQS"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
@@ -21,9 +23,11 @@ class BaseOqsController < ActionController::Base
def default_url_options
{ locale: I18n.locale }
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
def check_user
if current_user.nil?
redirect_to root_path
end
end
#Shop Name in Navbor

View File

@@ -2,7 +2,7 @@ class BaseOrigamiController < ActionController::Base
include LoginVerification
layout "origami"
# before_action :checkin_process
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
@@ -14,8 +14,10 @@ class BaseOrigamiController < ActionController::Base
redirect_to origami_dashboard_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
def check_user
if current_user.nil?
redirect_to root_path
end
end
# def checkin_process

View File

@@ -2,6 +2,8 @@ class BaseReportController < ActionController::Base
include LoginVerification
layout "application"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
@@ -83,6 +85,12 @@ class BaseReportController < ActionController::Base
return from, to
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
#Shop Name in Navbor
def shop_detail
@shop = Shop.first

View File

@@ -2,13 +2,21 @@ class BaseWaiterController < ActionController::Base
include LoginVerification
layout "waiter"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
helper_method :shop_detail
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
#Shop Name in Navbor
def shop_detail
@shop = Shop.first
end
end

View File

@@ -33,10 +33,10 @@ module LoginVerification
protected
# Authenticate the user with token based authentication
def authenticate
authenticate_session_token || render_unauthorized
authenticate_session_token || render_unauthorized
end
def authenticate_session_token
def authenticate_session_token
token = session[:session_token]
if (token)
#@current_user = User.find_by(api_key: token)
@@ -50,7 +50,7 @@ module LoginVerification
end
end
def render_unauthorized()
def render_unauthorized
redirect_to root_path
end

View File

@@ -2,8 +2,21 @@ class HomeController < ApplicationController
# layout "application", except: [:index, :show]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
before_action :check_user, only: :dashboard
helper_method :shop_detail
# Special check for only dashboard
def check_user
if current_user.nil?
redirect_to root_path
end
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
def index
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.order("name asc")
@@ -67,63 +80,78 @@ class HomeController < ApplicationController
end
def dashboard
@from, @to = get_date_range_from_params
@from, @to, @from_time, @to_time = 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,@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)
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
else
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
end
else
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
end
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
else
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
end
else
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
end
@top_products = Sale.top_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
@bottom_products = Sale.bottom_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
@employee_sales = Sale.employee_sales(today,@from,@to)
@employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)
@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)
@total_sale = Sale.total_sale(today,current_user,@from,@to,@from_time,@to_time)
@total_count = Sale.total_count(today,current_user,@from,@to,@from_time,@to_time)
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time)
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time)
if !@total_payment_methods.nil?
@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, current_user,@from,@to)
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay"
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
end
@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)
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
@total_customer = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
@total_dinein = Sale.total_dinein(today,current_user,@from,@to,@from_time,@to_time)
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to,@from_time,@to_time)
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to,@from_time,@to_time)
@total_membership = Sale.total_membership(today,current_user,@from,@to,@from_time,@to_time)
@total_order = Sale.total_order(today,current_user,@from,@to)
@total_accounts = Sale.total_account(today,current_user,@from,@to)
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
acc = Sale.account_data(account.account_id, today,current_user,@from,@to,@from_time,@to_time)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
end
@top_items = Sale.top_items(today,current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
@top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@@ -177,18 +205,23 @@ class HomeController < ApplicationController
def get_date_range_from_params
from = params[:from]
to = params[:to]
to = params[:to]
from_time = params[:from_time]
to_time = params[:to_time]
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
# 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
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
end
return from, to
return from, to, from_time, to_time
end
#Shop Name in Navbor

18
app/controllers/oqs/edit_controller.rb Executable file → Normal file
View File

@@ -3,9 +3,15 @@ class Oqs::EditController < BaseOqsController
assigned_item_id = params[:id]
@link_type = params[:type]
@dining_type = nil
@booking = 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 }'")
elsif params[:type] == "pending"
assigned_item = OrderItem.find(assigned_item_id)
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
.where("bko.order_id = '#{assigned_item.order_id}'").first()
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
else
assigned_item = OrderItem.find(assigned_item_id)
dining = DiningFacility.find_by_id(params[:type])
@@ -25,13 +31,6 @@ class Oqs::EditController < BaseOqsController
order_item.item_order_by = current_user.name
order_item.qty = qty_weight
order_item.remark = remarks
if !order_item.set_menu_items.nil?
instance_item_sets = JSON.parse(order_item.set_menu_items)
instance_item_sets.each_with_index do |instance_item, instance_index|
instance_item_sets[instance_index]["quantity"] = qty_weight
end
order_item.set_menu_items = instance_item_sets.to_json
end
order_item.save
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
@@ -67,4 +66,9 @@ class Oqs::EditController < BaseOqsController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -1,6 +1,6 @@
class Origami::AddordersController < BaseOrigamiController
# before_action :set_dining, only: [:detail]
def index
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
@@ -94,20 +94,20 @@ class Origami::AddordersController < BaseOrigamiController
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"]
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
if i["parent_order_item_id"];
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
else
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
end
items_arr.push(items)
}
# begin
if params[:order_source] == "quick_service"
customer_id = "CUS-000000000002" # for no customer id from mobile
else
# if params[:order_source] == "quick_service"
# customer_id = "CUS-000000000002" # for no customer id from mobile
# else
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
end
# end
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]

View File

@@ -98,10 +98,10 @@ class Origami::CustomersController < BaseOrigamiController
def update_sale_by_customer
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
order_source = params[:type]
# Check and find with card no
# if(!customer_id.include? "CUS")
# customer = Customer.find_by_paypar_account_no(customer_id)
@@ -135,7 +135,7 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
if(id == "SAL")
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
end
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})

View File

@@ -20,10 +20,12 @@ class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def create
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -82,7 +84,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
if !table.nil?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
@@ -102,6 +104,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove selected discount Items
def remove_discount_items
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
if Sale.exists?(sale_id)
@@ -136,7 +139,7 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
@@ -158,6 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Remove all discount Items
def remove_all_discount
sale_id = params[:id]
order_source = params[:type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -197,7 +201,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
@@ -218,7 +222,7 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount
def member_discount
order_source = params[:cashier_type]
sale_id = params[:sale_id]
is_card = params[:is_card]
sub_total = params[:sub_total]
@@ -297,7 +301,7 @@ class Origami::DiscountsController < BaseOrigamiController
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source)
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }

63
app/controllers/origami/jcb_controller.rb Executable file → Normal file
View File

@@ -5,32 +5,44 @@ class Origami::JcbController < BaseOrigamiController
@cashier_type = params[:type]
# limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@jcbcount = 0
others = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_jcb = 0
@member_discount= 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_jcb = total - @jcbcount - others
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "jcb"
@jcbcount = @jcbcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_jcb = total - @jcbcount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -58,4 +70,9 @@ class Origami::JcbController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,70 @@
class Origami::JunctionPayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
# limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@junction_pay_count = 0
others = 0
@cashier_id = current_user.emp_id
@payment_method_setting_nav = PaymentMethodSetting.all
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "JunctionPay"
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_junction_pay = total - @junction_pay_count - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
def create
gift_amount = params[:gift_amount]
voucher_amount = params[:voucher_amount]
voucher_no = params[:voucher_no]
sale_id = params[:sale_id]
# Gift card or Voucher classified and add for payment_reference
remarks = ''
cash = (gift_amount.to_f + voucher_amount.to_f)
if gift_amount.to_f > 0
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
else
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
end
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
# rounding adjustment
# if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# rounding_adj = new_total-saleObj.grand_total
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay", remarks)
end
end
end

59
app/controllers/origami/master_controller.rb Executable file → Normal file
View File

@@ -5,31 +5,41 @@ class Origami::MasterController < BaseOrigamiController
@cashier_type = params[:type]
# limit master_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@mastercount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_master = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master"
@mastercount = @mastercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "master"
@mastercount = @mastercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_master = total - @mastercount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
@can_master = total - @mastercount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +67,9 @@ class Origami::MasterController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

62
app/controllers/origami/mpu_controller.rb Executable file → Normal file
View File

@@ -4,32 +4,43 @@ class Origami::MpuController < BaseOrigamiController
@cashier_type = params[:type]
# limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@mpucount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_mpu = total - @mpucount - others
@rounding_adj = 0
@can_mpu = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_mpu = total - @mpucount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +68,9 @@ class Origami::MpuController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -19,6 +19,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total]
cashier_type = params[:cashier_type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
@@ -68,7 +69,7 @@ class Origami::OtherChargesController < BaseOrigamiController
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
end
if !table.nil?
dining = {:table_id => table_id, :table_type => table.type }

View File

@@ -27,7 +27,7 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
@@ -79,8 +79,17 @@ 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)
end
filename, receipt_no, cashier_printer = 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)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
end
def create
@@ -131,7 +140,7 @@ class Origami::PaymentsController < BaseOrigamiController
end
# For Print
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
@@ -170,8 +179,11 @@ class Origami::PaymentsController < BaseOrigamiController
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
# Order.pay_process_order_queue(order.order_id, table_id)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
end
end
#for card sale data
@@ -197,7 +209,8 @@ class Origami::PaymentsController < BaseOrigamiController
filename, sale_receipt_no, printer_name = 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)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
end
#end
end
end
@@ -215,15 +228,18 @@ class Origami::PaymentsController < BaseOrigamiController
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0.00
@balance = 0
@accountable_type = ''
@table_no = ''
@dining = ''
@shop = Shop::ShopDetail #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
saleObj = Sale.find(sale_id)
#total customer with individual total amount
@@ -273,10 +289,11 @@ class Origami::PaymentsController < BaseOrigamiController
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
accounts = @customer.tax_profiles
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
account = TaxProfile.find(acc.id)
@account_arr.push(account)
end
@@ -287,7 +304,7 @@ class Origami::PaymentsController < BaseOrigamiController
if response["status"]==true
response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance += res["balance"]
@balance = @balance.to_f + res["balance"].to_f
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
@@ -327,6 +344,8 @@ class Origami::PaymentsController < BaseOrigamiController
@mastercount += spay.payment_amount
elsif spay.payment_method == "unionpay"
@unionpaycount += spay.payment_amount
elsif spay.payment_method == "JunctionPay"
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
end
@@ -404,19 +423,19 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil
rebate_amount = nil
current_balance = nil
order_source = params[:type]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
end
saleObj.update_attributes(rounding_adjustment: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
# if bookings.count > 1
@@ -438,7 +457,7 @@ class Origami::PaymentsController < BaseOrigamiController
# Re-call Sale Data
saleObj = Sale.find(sale_id)
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
@@ -452,7 +471,17 @@ 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)
filename, sale_receipt_no, printer_name = 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)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
@@ -466,7 +495,7 @@ class Origami::PaymentsController < BaseOrigamiController
Order.pay_process_order_queue(order.order_id,table_id)
end
end
end
# end
end
end
@@ -512,6 +541,15 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
render :json => {status: true}
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# render :json => {status: true}
end
end

View File

@@ -1,6 +1,12 @@
class Origami::QuickServiceController < ApplicationController
# before_action :set_dining, only: [:detail]
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
def index
today = DateTime.now
day = Date.today.wday
@@ -211,6 +217,11 @@ class Origami::QuickServiceController < ApplicationController
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"

View File

@@ -1,5 +1,11 @@
class Origami::RequestBillsController < ApplicationController
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
# Print Request Bill and add to sale tables
def print
@sale = Sale.new
@@ -13,7 +19,7 @@ class Origami::RequestBillsController < ApplicationController
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user)
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else

View File

@@ -76,11 +76,14 @@ 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)
action_by = current_user.id
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -141,7 +144,7 @@ class Origami::SaleEditController < BaseOrigamiController
end
end
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
ProductCommission.edit_product_commission(saleitemObj)
end
@@ -162,17 +165,21 @@ 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)
action_by = current_user.id
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order.source)
ProductCommission.remove_product_commission(saleitemObj)
end
# remove all void items
def cancel_all_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item|
if item.qty.to_i < 0
@@ -185,13 +192,14 @@ class Origami::SaleEditController < BaseOrigamiController
end
# re-calc tax
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
end
def apply_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
saleObj.compute_without_void(order_source)
saleObj.sale_items.each do |item|
ProductCommission.remove_product_commission(item)
end

View File

@@ -3,7 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
def show
@type = params[:type]
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user.id)
#for bank integration
bank_integration = Lookup.collection_of('bank_integration')

View File

@@ -3,6 +3,7 @@ class Origami::SplitBillController < BaseOrigamiController
def index
dining_id = params[:dining_id]
@cashier_type = params[:type]
@table = DiningFacility.find(dining_id)
@booking = @table.get_booking
@orders = Array.new
@@ -76,6 +77,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
def create
cashier_type = params[:cashier_type]
order_ids = params[:order_ids]
arr_order_ids = nil
if !params[:arr_order_ids].nil?
@@ -111,7 +113,7 @@ class Origami::SplitBillController < BaseOrigamiController
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user)
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
@@ -233,7 +235,7 @@ class Origami::SplitBillController < BaseOrigamiController
puts "order_id_count < 1"
new_order_status = true
order_items.each do |order_item|
orderItem = OrderItem.find_by_order_id(order_id)
orderItem = OrderItem.find(order_item["id"])
if !orderItem.nil?
if order_item["id"] == orderItem.order_items_id
if orderItem.qty.to_f != order_item['qty'].to_f
@@ -324,7 +326,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
end
Promotion.promo_activate(sale)

View File

@@ -31,6 +31,8 @@ class Origami::TableInvoicesController < BaseOrigamiController
def show
@table = DiningFacility.find(params[:table_id])
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
shop = Shop::ShopDetail
@sale_array = Array.new
@table.bookings.each do |booking|

View File

@@ -4,31 +4,40 @@ class Origami::UnionpayController < BaseOrigamiController
@cashier_type = params[:type]
# limit unionpay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@unionpaycount = 0
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
@rounding_adj = 0
@can_unionpay = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_unionpay = total - @unionpaycount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +66,9 @@ class Origami::UnionpayController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

58
app/controllers/origami/visa_controller.rb Executable file → Normal file
View File

@@ -4,31 +4,40 @@ class Origami::VisaController < BaseOrigamiController
@cashier_type = params[:type]
# limit visa_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = 0
@visacount = 0
others = 0
@shop = Shop::ShopDetail
@rounding_adj = 0
@can_visa = 0
@member_discount = 0
@sub_total = 0
@membership_id = nil
@receipt_no = nil
if !sale_data.nil?
total = sale_data.grand_total
others = 0
@shop = Shop::ShopDetail
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa"
@visacount = @visacount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_visa = total - @visacount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
#for bank integration
@receipt_no = sale_data.receipt_no
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@@ -57,4 +66,9 @@ class Origami::VisaController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -4,12 +4,13 @@ class Origami::VoidController < BaseOrigamiController
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
end
# update count for shift sale
@@ -86,8 +87,6 @@ class Origami::VoidController < BaseOrigamiController
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
end
end
if bookings[0].dining_facility_id.to_i > 0
@@ -99,7 +98,7 @@ class Origami::VoidController < BaseOrigamiController
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
@@ -119,9 +118,17 @@ class Origami::VoidController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
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)
end
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = 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)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print

View File

@@ -64,6 +64,17 @@ class PrintSettingsController < ApplicationController
end
end
def get_printer_options
printer_name = params[:printer_name]
printer_options = Printer::PrinterWorker.printer_options(printer_name)
options = {
:url => printer_options['device-uri'],
:model => printer_options['printer-info'],
}
render :json => options.to_json
end
private
# Use callbacks to share common setup or constraints between actions.
def set_print_setting
@@ -72,7 +83,7 @@ class PrintSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def print_setting_params
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
end
#Shop Name in Navbor

View File

@@ -15,7 +15,8 @@ class Reports::SaleitemController < BaseReportController
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED)
@type = params[:sale_type]
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)

View File

@@ -1,6 +1,7 @@
class Settings::CommissionersController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /commissioners
# GET /commissioners.json
@@ -82,7 +83,11 @@ class Settings::CommissionersController < ApplicationController
end
render json: @transactions
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner

View File

@@ -1,6 +1,7 @@
class Settings::CommissionsController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_commission, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /commissions
# GET /commissions.json
@@ -68,6 +69,12 @@ class Settings::CommissionsController < ApplicationController
# end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commission

View File

@@ -8,7 +8,7 @@ class Settings::MenusController < ApplicationController
@settings_menus = Menu.all.page(params[:page]).per(10)
respond_to do |format|
format.html
format.csv { send_data Menu.to_csv }
format.xlsx
end
end
@@ -71,6 +71,14 @@ class Settings::MenusController < ApplicationController
# end
end
def import
if params[:file]
Menu.import(params[:file])
redirect_to settings_menus_path, notice: "Menu was successfully Imported"
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_menu

View File

@@ -1,6 +1,7 @@
class Settings::OrderQueueStationsController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /settings/order_queue_stations
# GET /settings/order_queue_stations.json
@@ -67,6 +68,12 @@ class Settings::OrderQueueStationsController < ApplicationController
# end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_order_queue_station

View File

@@ -1,6 +1,7 @@
class Settings::ProductsController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_settings_product, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /settings/products
# GET /settings/products.json
@@ -65,6 +66,12 @@ load_and_authorize_resource except: [:create]
# end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_product

View File

@@ -1,6 +1,7 @@
class Settings::PromotionProductsController < ApplicationController
before_action :set_promotion, only: [:show, :edit, :update, :destroy,:new]
before_action :set_promotion_product, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /promotion_products
# GET /promotion_products.json
@@ -63,6 +64,12 @@ class Settings::PromotionProductsController < ApplicationController
# end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_promotion

View File

@@ -1,6 +1,7 @@
class Settings::PromotionsController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_promotion, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /promotions
# GET /promotions.json
@@ -119,6 +120,12 @@ class Settings::PromotionsController < ApplicationController
render json: res
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_promotion

View File

@@ -6,6 +6,18 @@ class Settings::TaxProfilesController < ApplicationController
# GET /settings/tax_profiles.json
def index
@settings_tax_profiles = TaxProfile.all
tax_profiles = Lookup.collection_of("tax_profiles")
if !@settings_tax_profiles.nil?
@settings_tax_profiles.each_with_index do |setting_tax_profile, tax_index|
if !tax_profiles.nil?
tax_profiles.each do |group|
if setting_tax_profile.group_type == group[1]
@settings_tax_profiles[tax_index].group_type = group[0]
end
end
end
end
end
end
# GET /settings/tax_profiles/1
@@ -15,11 +27,19 @@ class Settings::TaxProfilesController < ApplicationController
# GET /settings/tax_profiles/new
def new
@name = nil
@settings_tax_profile = TaxProfile.new
@tax_profiles = TaxProfile.all
end
# GET /settings/tax_profiles/1/edit
def edit
@settings_tax_profile = TaxProfile.find(params[:id])
@name = nil
if !@settings_tax_profile.nil?
@name = @settings_tax_profile.name
end
@tax_profiles = TaxProfile.all
end
# POST /settings/tax_profiles
@@ -69,10 +89,20 @@ class Settings::TaxProfilesController < ApplicationController
# Use callbacks to share common setup or constraints between actions.
def set_settings_tax_profile
@settings_tax_profile = TaxProfile.find(params[:id])
tax_profiles = Lookup.collection_of("tax_profiles")
if !@settings_tax_profile.nil?
if !tax_profiles.nil?
tax_profiles.each do |group|
if @settings_tax_profile.group_type == group[1]
@settings_tax_profile.group_type = group[0]
end
end
end
end
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_tax_profile_params
params.require(:tax_profile).permit(:name, :rate, :inclusive, :order_by, :created_by)
params.require(:tax_profile).permit(:name, :group_type, :rate, :inclusive, :order_by, :created_by)
end
end

View File

@@ -1,6 +1,7 @@
class Transactions::CreditNotesController < ApplicationController
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /transactions/sales
# GET /transactions/sales.json
@@ -25,12 +26,18 @@ class Transactions::CreditNotesController < ApplicationController
@credit_notes = 0
end
end
puts "sssssssssssss"
puts @credit_notes.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @credit_notes }
end
end
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
end

View File

@@ -1,5 +1,7 @@
class Transactions::OrdersController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :check_user
def index
filter = params[:filter]
@@ -21,11 +23,12 @@ class Transactions::OrdersController < ApplicationController
@receipt_no = filter
@from = from
@to = to
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
format.html
format.json { render json: @orders }
# format.csv { send_data OrdersCsvExport.generate }
end
end
def show
@@ -38,4 +41,10 @@ class Transactions::OrdersController < ApplicationController
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
end

View File

@@ -1,20 +1,30 @@
class Transactions::SalesController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
before_action :check_user
# GET /transactions/sales
# GET /transactions/sales.json
def index
receipt_no = params[:receipt_no]
from = params[:from]
to = params[:to]
# from = params[:from]
# to = params[:to]
from, to = get_date_range_from_params
@shift = ''
if params[:shift_name].to_i != 0
@shift = ShiftSale.find(params[:shift_name])
end
if receipt_no.nil? && from.nil? && to.nil?
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc")
if @shift.blank?
@sales = Sale.where("NOT sale_status='new'").order("sale_id desc")
else
@sales = Sale.where("NOT sale_status='new' and shift_sale_id ='#{@shift.id}'").order("sale_id desc")
end
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
else
sale = Sale.search(receipt_no,from,to)
sale = Sale.search(receipt_no,from,to,@shift)
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
@@ -25,6 +35,12 @@ class Transactions::SalesController < ApplicationController
@receipt_no = receipt_no
@from = from
@to = to
if @shift.present?
@shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = @shift
end
# if receipt_no.nil? && search_date.nil?
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
@@ -45,6 +61,24 @@ class Transactions::SalesController < ApplicationController
# end
# end
@sale_audits = []
@sale_item_audits = []
if @sales != 0
@sales.each do |sale|
sale_audit = SaleAudit.where("(action = 'SALEPAYMENT' or action = 'SALEVOID') and sale_id = ? and remark IS NOT NULL",sale.sale_id)
if !sale_audit.nil?
sale_audit.each do |audit|
@sale_audits.push({sale.sale_id => audit.remark})
end
end
sale_item_audit = SaleAudit.where("(action LIKE '%ITEM%') and sale_id = ?",sale.sale_id)
if !sale_item_audit.nil? && sale_item_audit.count > 0
@sale_item_audits.push({sale.sale_id => sale_item_audit.count})
end
end
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
@@ -129,6 +163,80 @@ class Transactions::SalesController < ApplicationController
end
end
# date range
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now.utc.getlocal
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
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_sale

View File

@@ -1,6 +1,7 @@
class Transactions::ShiftSalesController < ApplicationController
load_and_authorize_resource except: [:create]
before_action :set_transactions_shift_sale, only: [:show, :edit, :update, :destroy]
before_action :check_user
def index
@@ -53,6 +54,12 @@ class Transactions::ShiftSalesController < ApplicationController
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_shift_sale

View File

@@ -0,0 +1,28 @@
class Transactions::SurveysController < ApplicationController
def index
filter = params[:filter]
from = params[:from]
to = params[:to]
if filter.nil? && from.nil? && to.nil?
surveys = Survey.all
else
surveys = Survey.search(filter,from,to)
end
if !surveys.nil?
@surveys = Kaminari.paginate_array(surveys).page(params[:page]).per(20)
else
@surveys = []
end
@filter = filter
@from = from
@to = to
respond_to do |format|
format.html # index.html.erb
format.json { render json: @surveys }
end
end
end

View File

@@ -105,7 +105,7 @@ class Ability
can :show, :home
can :read, Order
can :update, Order
can :menage, Booking
can :manage, Booking
can :manage, OrderQueueStation
can :read, Sale
can :update, Sale

View File

@@ -12,7 +12,7 @@ class InventoryDefinition < ApplicationRecord
end
def self.find_product_in_inventory(item)
product = InventoryDefinition.find_by_item_code(item.product_code)
product = InventoryDefinition.find_by_item_code(item.item_instance_code)
if product.nil?
return false, nil
else
@@ -21,7 +21,7 @@ class InventoryDefinition < ApplicationRecord
end
def self.check_balance(item,inventory_definition) # item => saleItemOBj
stock = StockJournal.where('item_code=?', item.product_code).order('created_at desc').take
stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take
unless stock.nil?
modify_balance(item, stock, inventory_definition)
else

View File

@@ -1,7 +1,7 @@
class License
include HTTParty
base_uri "connect.smartsales.dev/api"
base_uri "connect.smartsales.asia/api"
attr_accessor :name, :address_1, :address_2, :township, :city, :country, :email, :phone, :fax, :logo, :subdomain,
:plan_activation_date, :plan_next_renewal_date, :plan_max_products,:plan_max_customers, :plan_active_connections,

View File

@@ -1,4 +1,6 @@
class Menu < ApplicationRecord
require 'spreadsheet'
has_many :menu_categories, dependent: :destroy
validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to
@@ -33,27 +35,118 @@ class Menu < ApplicationRecord
end
def self.to_csv
m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
CSV.generate(headers: true) do |csv|
m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
CSV.generate(headers: true, row_sep: "\r\n") do |csv|
csv << m_attributes
menu = Menu.all
menu.each do |user|
puts user
csv << m_attributes.map{ |attr| user.send(attr)}
end
end
end
# mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
# CSV.generate(headers: true) do |csv|
# csv << m_attributes
def self.import(file)
spreadsheet = open_spreadsheet(file)
sheet_count = spreadsheet.sheets.count-1
for i in 0..sheet_count do
header = spreadsheet.sheet(i).row(1)
sheet_name = spreadsheet.sheets[i]
# csv << mc_attributes
# MenuCategory.all.each do |user|
# puts user
# csv << mc_attributes.map{ |attr| user.send(attr)}
# end
# end
(2..spreadsheet.sheet(i).last_row).each do |ii|
row = Hash[[header,spreadsheet.sheet(i).row(ii)].transpose]
if sheet_name == "Account"
# Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
account = Account.find_by_id(row["id"])
if account
Account.create(title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
else
Account.create(id:row["id"], title: row["title"],account_type: row["account_type"],discount: row["discount"],point: row["point"],bonus: row["bonus"],rebate: row["rebate"])
end
elsif sheet_name == "Item Set"
# ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
item_set = ItemSet.find_by_id(row["id"])
if item_set
ItemSet.create( name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
else
ItemSet.create(id:row["id"], name: row[name], alt_name: row[alt_name], min_selectable_qty: row[min_selectable_qty], max_selectable_qty: row[max_selectable_qty])
end
elsif sheet_name == "Menu Item Options"
# MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
item_options = MenuItemOption.find_by_id(row["id"])
if item_options
MenuItemOption.create( option_type: row["option_type"],name: row["name"],value: row["value"])
else
MenuItemOption.create(id:row["id"], option_type: row["option_type"],name: row["name"],value: row["value"])
end
elsif sheet_name == "Menu Item Attributes"
# MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
item_attributes = MenuItemAttribute.find_by_id(row["id"])
if item_attributes
MenuItemAttribute.create( attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
else
MenuItemAttribute.create(id:row["id"], attribute_type: row["attribute_type"],name: row["name"],value: row["value"])
end
elsif sheet_name == "Menu"
menu = Menu.find_by_id(row["id"])
if menu
Menu.create(name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
else
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
end
elsif sheet_name == "Menu Category"
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
menu_category = MenuCategory.find_by_id(row["id"])
if menu_category
MenuCategory.create(menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
else
MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
end
elsif sheet_name == "Menu Item"
# MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: row["item_attributes"], item_options: row["item_options"], account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
menu_item = MenuItem.find_by_id(row["id"])
if menu_item
MenuItem.create(item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
else
MenuItem.create(id:row["id"], item_code: row["item_code"], name: row["name"], alt_name: row["alt_name"], image_path: row["image_path"], description: row["description"], information: row["information"], unit: row["unit"], type: row["type"], menu_category_id: row["menu_category_id"], item_attributes: JSON.parse(row["item_attributes"]), item_options: JSON.parse(row["item_options"]), account_id: row["account_id"], min_qty: row["min_qty"], taxable: row["taxable"], is_sub_item: row["is_sub_item"], is_available: row["is_available"], created_by: row["created_by"])
end
elsif sheet_name == "Menu Item Instance"
# MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: row["item_attributes"], price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
item_instance = MenuItemInstance.find_by_id(row["id"])
if item_instance
MenuItemInstance.create(menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
else
MenuItemInstance.create(id:row["id"], menu_item_id: row["menu_item_id"].to_i, item_instance_code: row["item_instance_code"], item_instance_name: row["item_instance_name"], item_attributes: JSON.parse(row["item_attributes"]), price: row["price"], is_on_promotion: row["is_on_promotion"], promotion_price: row["promotion_price"], is_available: row["is_available"], is_default: row["is_default"])
end
elsif sheet_name == "Menu Instance Item Set"
# MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
menu_instance_set = MenuInstanceItemSet.find_by_id(row["id"])
if menu_instance_set
MenuInstanceItemSet.create(item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
else
MenuInstanceItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_instance_id: row["menu_item_instance_id"])
end
elsif sheet_name == "Menu Item Set"
# MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
menu_item_set = MenuItemSet.find_by_id(row["id"])
if menu_item_set
MenuItemSet.create(item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
else
MenuItemSet.create(id:row["id"], item_set_id: row["item_set_id"], menu_item_id: row["menu_item_id"])
end
end
end
end
end
def self.open_spreadsheet(file)
case File.extname(file.original_filename)
when ".csv" then Roo::CSV.new(file.path,nil,:ignore)
when ".xls" then Roo::Excel.new(file.path,nil,:ignore)
when ".xlsx" then Roo::Excelx.new(file.path,nil,:ignore)
else raise "Unknown File type: #{original_filename}"
end
end
end

View File

@@ -1,7 +1,7 @@
class MenuCategory < ApplicationRecord
# before_create :generate_menu_category_code
belongs_to :menu
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
has_many :menu_items
@@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord
# def generate_menu_category_code
# self.code = SeedGenerator.generate_code(self.class.name, "C")
# end
def self.to_csv
mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
CSV.generate(headers: true) do |csv|
csv << mc_attributes
csv << mc_attributes
MenuCategory.all.each do |user|
puts user
csv << mc_attributes.map{ |attr| user.send(attr)}
end
end
end
end

View File

@@ -71,9 +71,9 @@ class Order < ApplicationRecord
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
if self.source != "quick_service"
# if self.source != "quick_service"
process_order_queue
end
# end
#send order to broadcast job
send_order_broadcast(booking)
@@ -297,7 +297,7 @@ class Order < ApplicationRecord
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
@@ -313,7 +313,7 @@ class Order < ApplicationRecord
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
@@ -326,7 +326,7 @@ class Order < ApplicationRecord
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id)
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order

View File

@@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord
before_create :generate_custom_id
#Associations
belongs_to :order, autosave: true
belongs_to :order, autosave: true
# belongs_to :order, counter_cache: true
#Validation
validates_presence_of :item_code, :item_name, :qty

View File

@@ -13,7 +13,7 @@ class OrderQueueStation < ApplicationRecord
# validations
validates_presence_of :station_name, :printer_name
def process_order (order, table_id)
def process_order (order, table_id, order_source = nil)
oqs_stations = OrderQueueStation.active
@@ -55,7 +55,7 @@ class OrderQueueStation < ApplicationRecord
end
end
if oqs.auto_print
if oqs.auto_print && order_source != "quick_service"
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
@@ -90,7 +90,81 @@ class OrderQueueStation < ApplicationRecord
end
end
if oqs.auto_print
if oqs.auto_print && order_source != "quick_service"
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end #end else
end
def pay_process_order_queue (order_id, table_id)
oqs_stations = OrderQueueStation.active
order = Order.find(order_id)
order_items = order.order_items
if table_id.to_i > 0
# get dining
dining = DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
# ToDo per item per printer
oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
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 (order_item.qty > 0)
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
end
else
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 (order_item.qty > 0)
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

View File

@@ -1,6 +1,6 @@
class PrintSetting < ApplicationRecord
# validations
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
validates_presence_of :name, :unique_code, :printer_name, :brand_name, :api_settings, :page_width, :page_height, :print_copies
def self.get_precision_delimiter
PrintSetting.find_by_unique_code("ReceiptBillPdf")

View File

@@ -24,6 +24,11 @@ class Printer::PrinterWorker
end
end
# Options from printer name
def self.printer_options(printer_name)
Cups.options_for(printer_name)
end
def self.printers()
Cups.show_destinations
end

View File

@@ -176,7 +176,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
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
#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)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
@@ -202,14 +202,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
begin
if count == 1
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf"
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
pdf.render_file filename
if printed_status != 'Paid'
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
end
else
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
pdf.render_file filename
if printed_status != 'Paid'
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
end
@@ -272,11 +272,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
def print_receipt_pdf(filename,receipt_no,print_copies,printer_name)
count = print_copies.to_i
# if count == 0
# self.print("public"+filename, printer_name)
# self.print(filename, printer_name)
# else
begin
if count == 1
self.print("public"+filename, printer_name)
self.print(filename, printer_name)
else
filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf"
self.print(filename, printer_name)

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@ class SalePayment < ApplicationRecord
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
self.sale = invoice
self.received_amount = cash_amount
self.payment_reference = remark
amount_due = invoice.grand_total
#get all payment for this invoices
@@ -48,6 +49,8 @@ class SalePayment < ApplicationRecord
payment_status = paypar_payment
when "foc"
payment_status = foc_payment
when "JunctionPay"
payment_status = junction_pay_payment
else
puts "it was something else"
end
@@ -205,8 +208,7 @@ class SalePayment < ApplicationRecord
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
sale_update_payment_status(self.received_amount)
return payment_status
end
@@ -297,6 +299,22 @@ class SalePayment < ApplicationRecord
end
def junction_pay_payment
payment_status = false
#Next time - validate if the vochure number is valid - within
self.payment_method = "JunctionPay"
self.payment_amount = self.received_amount
# self.payment_reference = self.payment_reference
self.outstanding_amount = self.sale.grand_total- self.received_amount
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
return payment_status
end
def sale_update_payment_status(paid_amount,check_foc = false)
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
@@ -306,6 +324,7 @@ class SalePayment < ApplicationRecord
sObj = Sale.find(self.sale_id)
is_credit = 0
is_foc = 0
method_status = false
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
@@ -314,8 +333,12 @@ class SalePayment < ApplicationRecord
if spay.payment_method == "foc"
is_foc = 1
end
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
method_status = true
end
end
if (self.sale.grand_total <= all_received_amount)
if (self.sale.grand_total <= all_received_amount) && method_status
if is_credit == 0
self.sale.payment_status = "paid"
else
@@ -355,11 +378,15 @@ class SalePayment < ApplicationRecord
end
self.sale.save!
table_update_status(sObj)
if check_foc
table_update_status(sObj)
update_shift
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
table_update_status(sObj)
update_shift
elsif method_status && paid_amount.to_f == 0
table_update_status(sObj)
update_shift
end
end

View File

@@ -8,7 +8,7 @@ class StockJournal < ApplicationRecord
balance = calculate_balance(balance, item.qty)
journal = StockJournal.new
journal.item_code = item.product_code
journal.item_code = item.item_instance_code
journal.inventory_definition_id = inventory_definition.id
journal.debit = item.qty
journal.balance = balance
@@ -36,12 +36,16 @@ class StockJournal < ApplicationRecord
journal.save
end
def self.inventory_balances(today,from,to)
def self.inventory_balances(today,from,to,from_time,to_time)
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")
if !from_time.nil? && !to_time.nil?
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'")
else
query = query.where("DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(stock_journals.created_at,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'")
end
query = query.group("mii.item_instance_name")
.order("mii.item_instance_name ASC")
else
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")

View File

@@ -1,2 +1,17 @@
class Survey < ApplicationRecord
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
keyword = "dining_name LIKE ?","%#{filter}%"
end
if from.present? && to.present?
survey = Survey.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ?", from,to)
query = survey.where(keyword)
else
where("dining_name LIKE ?", "%#{filter}%")
end
end
end

View File

@@ -1,5 +1,5 @@
class TaxProfile < ApplicationRecord
default_scope { order('order_by asc') }
# validations
validates_presence_of :name, :rate
validates_presence_of :name, :rate, :group_type
end

View File

@@ -110,7 +110,7 @@ class OrderItemPdf < Prawn::Document
end
if alt_name
if !(order_item.alt_name).empty?
if order_item.alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true

View File

@@ -110,7 +110,7 @@ class OrderItemSlimPdf < Prawn::Document
end
# if alt_name
# if !(order_item_slim.alt_name).empty?
# if order_item_slim.alt_name
# move_down 1
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
# text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true

View File

@@ -109,7 +109,7 @@ class OrderSetItemPdf < Prawn::Document
end
if alt_name
if !(order_set_item.alt_name).empty?
if order_set_item.alt_name
move_down 4
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_set_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true

View File

@@ -1,111 +1,113 @@
class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
self.price_width = 60
self.qty_width = 25
self.total_width = 60
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
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)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
self.price_width = 60
self.qty_width = 25
self.total_width = 60
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
self.description_width = 150
self.price_num_width = 50
self.line_move = 2
# @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])
self.description_width = 150
self.price_num_width = 50
self.line_move = 2
# @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])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# 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
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
end
# 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
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
end
def header (shop_details)
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down line_move
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down line_move
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down line_move
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
def header (shop_details)
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down line_move
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down line_move
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down line_move
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
move_down line_move
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
@@ -117,17 +119,10 @@ class ReceiptBillPdf < Prawn::Document
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
if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([0,y_position], :width => self.label_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 => :left
end
end
bounding_box([self.label_width, y_position], :width =>self.label_width, :height => self.item_height) do
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -141,12 +136,11 @@ class ReceiptBillPdf < Prawn::Document
else
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
text "Date : #{ time }",:size => self.item_font_size,:align => :left
end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
@@ -155,7 +149,7 @@ class ReceiptBillPdf < Prawn::Document
move_down line_move
stroke_horizontal_rule
end
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
@@ -250,7 +244,6 @@ class ReceiptBillPdf < Prawn::Document
end
def all_total(sale_data,precision,delimiter)
move_down line_move
item_name_width = self.item_width
y_position = cursor
@@ -316,8 +309,7 @@ class ReceiptBillPdf < Prawn::Document
end
move_down line_move
sale_payment(sale_data,precision,delimiter)
sale_payment(sale_data,precision,delimiter)
end
def sale_payment(sale_data,precision,delimiter)
@@ -494,8 +486,8 @@ class ReceiptBillPdf < Prawn::Document
end
#individual payment per person
def individual_payment(sale_data, precision, delimiter)
per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
stroke_horizontal_rule
move_down line_move
y_position = cursor
@@ -548,8 +540,7 @@ class ReceiptBillPdf < Prawn::Document
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
end
end
def footer(printed_status)

View File

@@ -68,16 +68,48 @@
<!-- Date range for dashboard -->
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4">
<%
if !@from.nil?
from_date = DateTime.parse(@from).utc.getlocal.strftime("%d-%m-%Y")
else
from_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
end
if !@to.nil?
to_date = DateTime.parse(@to).utc.getlocal.strftime("%d-%m-%Y")
else
to_date = Time.now.utc.getlocal.strftime('%d-%m-%Y')
end
if !@from_time.nil?
from_time = @from_time
else
from_time = ''
end
if !@to_time.nil?
to_time = @to_time
else
to_time = ''
end
%>
<div class="col-lg-3 col-md-3 col-sm-3">
<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;">
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= from_date %>" 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">
<div class="col-lg-3 col-md-3 col-sm-3">
<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;">
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= to_date %>" 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 class="font-14"><%= t("views.right_panel.detail.from_time") %></label>
<input data-behaviour='timepicker' class="form-control timepicker" name="from_time" id="from_time" type="text" value="<%= from_time %>" placeholder="From Time" style="height: 35px;">
<span id="from_timeErr" style="color:red;"></span>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.to_time") %></label>
<input data-behaviour='timepicker' class="form-control timepicker" name="to_time" id="to_time" type="text" value="<%= to_time %>" placeholder="To time" style="height: 35px;">
<span id="to_timeErr" 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'>
@@ -340,21 +372,53 @@
$('.btn_generate').on('click',function(){
var from = $("#from").val();
var to = $("#to").val();
var from_time = $("#from_time").val();
var to_time = $("#to_time").val();
if(check(from,to,from_time,to_time)){
var params = '?';
if((from!='' && to!='') && (from_time!='' && to_time!='')){
params += 'from='+from+'&to='+to+'&from_time='+from_time+'&to_time='+to_time;
}else{
params += 'from='+from+'&to='+to;
}
window.location.href = '/dashboard'+params;
}
});
function check(from,to,from_time,to_time){
var status = true;
if((from=='') && (to=='')){
status = false;
$('#fromErr').html("can't be blank");
$('#toErr').html("can't be blank");
}else if((from!='') && (to=='')){
status = false;
$('#fromErr').html("");
$('#toErr').html("can't be blank");
}else if((from=='') && (to!='')){
status = false;
$('#fromErr').html("can't be blank");
$('#toErr').html("");
}else{
status = true;
$('#fromErr').html("");
$('#toErr').html("");
}
if((from!='') && (to!='')){
window.location.href = '/dashboard?from='+from+'&to='+to;
if(((from_time=='') && (to_time=='')) || ((from_time!='') && (to_time!=''))){
status = true;
$('#from_timeErr').html("");
$('#to_timeErr').html("");
}else if((from_time!='') && (to_time=='')){
status = false;
$('#from_timeErr').html("");
$('#to_timeErr').html("can't be blank");
}else if((from_time=='') && (to_time!='')){
status = false;
$('#from_timeErr').html("can't be blank");
$('#to_timeErr').html("");
}
});
return status;
}
</script>

5
app/views/layouts/_left_sidebar.html.erb Executable file → Normal file
View File

@@ -109,6 +109,11 @@
<a href="<%= transactions_shift_sales_path %>"><%= (t :shiftsale) %></a>
</li>
<% end %>
<% if can? :menage, Survey %>
<li>
<a href="<%= transactions_surveys_path %>"><%= t("views.right_panel.detail.survey") %></a>
</li>
<% end %>
</ul>
</li>
<% if can? :index, :dailysale %>

13
app/views/oqs/edit/index.html.erb Executable file → Normal file
View File

@@ -112,6 +112,11 @@ $(document).ready(function(){
var remarks = $("textarea[name='remarks']").val();
var order_items_id = $(this).attr('data-id');
var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks }
var booking_id = '';
<% if !@booking.nil? %>
booking_id = '<%= @booking.booking_id %>';
<% end %>
$.ajax({
type: 'POST',
url: '/oqs/' + order_items_id,
@@ -121,6 +126,8 @@ $(document).ready(function(){
<% if !@link_type.nil? %>
<% if @link_type == 'oqs' %>
window.location.href = '/oqs';
<% elsif @link_type == 'pending' %>
window.location.href = '/origami/quick_service/pending_order/'+booking_id;
<% else %>
<% if !@dining_type.nil? %>
<% if @dining_type == 'Table' %>
@@ -140,9 +147,15 @@ $(document).ready(function(){
});
$('#back').on('click', function () {
var booking_id = '';
<% if !@booking.nil? %>
booking_id = '<%= @booking.booking_id %>';
<% end %>
<% if !@link_type.nil? %>
<% if @link_type == 'oqs' %>
window.location.href = '/oqs';
<% elsif @link_type == 'pending' %>
window.location.href = '/origami/quick_service/pending_order/'+booking_id;
<% else %>
<% if !@dining_type.nil? %>
<% if @dining_type == 'Table' %>

View File

@@ -35,6 +35,7 @@
<%end%>
</ul>
</li>
<div id="menu-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list" role="tablist" id="ul-navbar">
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
@@ -80,14 +81,15 @@
<% end %>
<%end %>
</ul>
</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-block" style="">
<div class="card-text" id="custom-slimscroll">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 0.5rem;">
<!-- append data -->
<% @menu.each do |menu| %>
@@ -199,7 +201,7 @@
</div>
<div class="card-block">
<div class="card-text" id="order-detail-slimscroll" data-height="180">
<div class="card-text" id="order-detail-slimscroll" data-height="140">
<table class="table table-striped summary-items" id="order-items-table" >
<thead>
<tr>
@@ -375,7 +377,7 @@
<div class="modal-body">
<div class="row set-item">
<div class="col-md-4">
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
<p class="set_default_option" style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
<!-- <div class="form-group">
<label class="col-md-6" style="margin-top:5px">Quantity</label>
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="set_change_qty" value="" min="1" max="100">

View File

@@ -23,7 +23,7 @@
<div class="icon" >
<i class="material-icons">arrow_forward</i>
</div>
<div class="text font-20 m-l-5" style="line-height: 80px;">Quick Service</div>
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :quick_service %></div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 cashier_view">
@@ -31,7 +31,7 @@
<div class="icon" >
<i class="material-icons">arrow_forward</i>
</div>
<div class="text font-20 m-l-5" style="line-height: 80px;">Cashier</div>
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :dine_in_order %></div>
</div>
</div>
</div>

View File

@@ -436,7 +436,7 @@ var cashier_type = "<%= @cashier_type %>";
var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/discount";
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'discount_items': discount_items, 'overall_discount': overall_discount };
$.ajax({
type: "POST",
@@ -487,7 +487,7 @@ var cashier_type = "<%= @cashier_type %>";
}
}
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
var params = { 'cashier_type': cashier_type,'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/remove_discount_items",
@@ -518,7 +518,7 @@ var cashier_type = "<%= @cashier_type %>";
var sale_id = $('#sale-id').text();
$.ajax({
type: "GET",
url: "/origami/" + sale_id + "/remove_all_discount",
url: "/origami/" + sale_id + "/" + cashier_type + "/remove_all_discount",
success: function(result){
swal({
title: "Information!",
@@ -554,7 +554,7 @@ var cashier_type = "<%= @cashier_type %>";
// var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
var params = {'sale_id':sale_id, 'sub_total':sub_total };
var params = {'cashier_type': cashier_type,'sale_id':sale_id, 'sub_total':sub_total };
$.ajax({
type: "POST",

View File

@@ -498,15 +498,13 @@
<% 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>
<% else %>
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %>
<% end %>
@@ -522,30 +520,31 @@
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
</div>
<div class="modal-body">
<!-- <select class="form-control show-tick payment_method" multiple="true" id="payment_method" > -->
<!-- <option value="Cash">Cash</option> -->
<option value="Credit">Credit</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
<!-- </select> -->
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -715,6 +714,7 @@
$("#first_bill").on('click', function () {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
var server_mode =
$.ajax({
type: "GET",
@@ -723,17 +723,40 @@
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
// console.log(result);
// code2lab.printBill(result.filepath, result.printer_model, result.printer_url);
location.reload();
}
});
});
});
// click select option icon for add
$(document).on('click', '.payment_btn', function(event){
active = $(this).hasClass('selected-payment');
value = $(this).data('value');
type = $(this).data('type');
group = $(this).data('group');
payments = $(".payment_btn");
if (active) {
$(this).removeClass('selected-payment');
}else{
$(this).addClass('selected-payment');
}
}); //End selecct attribute buttom
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
calculate_member_discount(sale_id,"Card");
@@ -751,7 +774,11 @@
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
location.reload();
}
});
});
@@ -801,7 +828,7 @@
//split bill process
$('#split_bills').click(function(){
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
window.location.href = '/origami/table/' + dining_id + "/" + cashier_type +"/split_bills";
});
$('#move').on('click', function () {
@@ -905,15 +932,19 @@
}, function (isConfirm) {
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/" + sale_id + '/void';
var ajax_url = "/origami/sale/" + sale_id + '/cashier/void';
var remark = $("#remark").val();
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
window.location.href = '/origami/';
success: function (result) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/origami/';
}
});
}
@@ -971,4 +1002,16 @@
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
// Get Selected Class
function get_selected_attributes(selected_class) {
var item_row = $('.'+selected_class);
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
return attribute_arr;
}
</script>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -0,0 +1,300 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%=origami_root_path %>"><%= t :home %></a></li>
<li class="breadcrumb-item"><a href="/origami/sale/<%=@sale_id %>/payment"><%= t("views.btn.payment") %></a></li>
<li class="breadcrumb-item active"><%= t("views.btn.jcb") %></li>
<span class="float-right">
<%= link_to t('.back',:default => t("views.btn.back")),'/origami/sale/'+@sale_id+'/payment/others_payment'%>
</span>
</ol>
</div> -->
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label for="com_port_name">Select Device</label>
<select id="com_port_name" name="com_port_name" class="form-control select col-lg-7 col-md-7 col-sm-7">
</select>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>You can pay up to </label>
<%@can_junction_pay = @can_junction_pay +@rounding_adj%>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_junction_pay %>" data-member-value="">
</div>
<hr>
</div>
<% if @jcbcount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Recent junction pay paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@junction_pay_count %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Reference Number</label>
<input type="text" name="reference_no" id="reference_no" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
<br><span id="reference_no_Err" style="color:red;"></span>
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label>Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="m-t-10 p-l-20">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number green border-left" data-type="nett" >Nett</div>
<div class="col-md-4 cashier_number red border-left" data-type="del">Del</div>
<div class="col-md-4 cashier_number orange border-left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom m-l-5">
<div class="cashier_number long border-left" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom m-l-5">
<div class="pay purple left" id="junction_pay">Pay</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-default btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() {
var sale_id = "<%= @sale_id %>";
var bank_integration = "<%= @bank_integration %>";
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_junction_pay %>") - parseFloat(localStorage.getItem("cash")));
}
code2lab.getCommPorts(); //get comportlists from jade
});
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#junction_pay').on('click',function(){
var amount = $('#amount').text();
var reference_no = $('#reference_no').val();
var sale_id = "<%= @sale_id %>";
var receipt_no = "<%= @receipt_no %>";
var cashier_id = "<%= @cashier_id %>";
$("#reference_no_Err").html("");
if(reference_no.length > 0){
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){
$(this).off("click");
//start member discount 5% by pay card
// var sub_total = $('#sub-total').text();
// var member_id = $('#membership_id').text();
// var member_discount = $('#member_discount').text();
// if (member_id && member_discount) {
// $.ajax({
// type: "POST",
// url: "/origami/" + sale_id + "/member_discount",
// data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
// });
// }
//end member discount
$("#loading_wrapper").show();
var com_port = '/dev/' + $("#com_port_name").val();
var is_rebate=false;
//alert(cashier_id + amount + com_port);
code2lab.reqJunctionPay(true, cashier_id, parseFloat(amount), receipt_no, com_port);
resJunctionPayUpdate = function(totalBillAmount , finalBillAmt,giftCardAmount, voucherAmount,voucherNumber,receiptNumber){
$("#loading_wrapper").hide();
var voucher_no = voucherNumber;
if (voucher_no == ''){
voucher_no = reference_no;
}
$.ajax({
type: "POST",
url: "<%= origami_payment_junctionpay_path %>",
data: "gift_amount="+ giftCardAmount + "&voucher_amount=" + voucherAmount +
"&voucher_no=" + voucher_no + "&sale_id="+ sale_id,
success:function(result){
if(result){
var desc = 'Payment Successfully';
// is_rebate get from resJunctionPay and if member
if(is_rebate){ desc = desc + ". And You get Rebate!"}
swal({
title: "Information!",
text: desc,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
});
}
}
});
};
resJunctionPay = function(memberno,transactionNo,finalBillingAmt){
if(memberno != ''){ is_rebate = true; }
};
// $("#loading_wrapper").hide();
// $.ajax({type: "POST",
// url: "/origami/payment/"+payment_type,
// data: "amount="+ finalBillingAmt + "&sale_id="+ sale_id,
// success:function(result){
// if(result){
// swal({
// title: "Information!",
// text: "Payment Successfully",
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
// });
// }
// }
// });
// });
// var resError = function(message){
// console.log(message);
// $("#loading_wrapper").hide();
// swal ( "Oops" , message , "error" );
// };
}
}
});
// var resJunctionPayUpdate = function(totalBillAmount , finalBillAmt,giftCardAmount,voucherAmount, voucherNumber,receiptNumber){
// $("#loading_wrapper").hide();
// // alert(voucherNumber + ' ' + totalBillAmount + ' ' + receiptNumber + ' ' + giftCardAmount);
// $.ajax({
// type: "POST",
// url: "<%= origami_payment_junctionpay_path %>",
// data: "amount="+ totalBillAmount + "&sale_id="+ sale_id,
// success:function(result){
// if(result){
// swal({
// title: "Information!",
// text: "Payment Successfully",
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function () {
// window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment";
// });
// }
// }
// });
// };
</script>

View File

@@ -309,7 +309,7 @@ var cashier_type = "<%= @cashier_type %>";
var other_charges_items = JSON.stringify(get_other_item_rows());
var ajax_url = "/origami/" + sale_id + "/other_charges";
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items };
var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items };
$.ajax({
type: "POST",

View File

@@ -100,10 +100,10 @@
<td class="charges-name"><strong>Tax
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%=ct.name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
</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>
@@ -265,6 +265,20 @@
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- Junction Pay -->
<% if @junctionpaycount != 0.0 %>
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">JUNCTION PAY</div>
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_with_precision(@junctionpaycount, 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">JUNCTION PAY</div>
<div class="col-md-4" id="junctionpaycount"><%= 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'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
@@ -406,11 +420,11 @@
</div>
<div class="modal-footer ">
<div class="row m-b-10 m-r-30">
<% if ENV["SERVER_MODE"] != 'cloud' %>
<div class="col-md-5 m-r-20">
<button type="button" class="btn btn-link bg-red waves-effect print_receipt">Print</button>
</div>
<% end %>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">CLOSE</button>
</div>
@@ -431,6 +445,17 @@
<div class="modal-body">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="row text-center m-t-20">
<% if !@customer_lists.nil? %>
<% @customer_lists.each do |cus| %>
<% if cus.customer_id != @customer.id %>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_customer_assign" data-id='<%= cus.customer_id %>'><%= cus.name %></button>
</div>
<% end %>
<% end %>
<% end %>
</div>
<div class="row text-center m-t-20">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_member">Card Member</button>
@@ -473,9 +498,9 @@ var customer_name = "<%= @customer.name %>";
setHeaderBreadCrumb(_PAYMENTS_);
//start customer modal popup
if((cashier_type=='quick_service') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
}
// }
}
/* start check first bill or not*/
@@ -489,10 +514,7 @@ var customer_name = "<%= @customer.name %>";
payment_type = '';
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
console.log("ssssssssssss")
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
console.log(member_id);
console.log(member_discount);
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
@@ -500,7 +522,7 @@ var customer_name = "<%= @customer.name %>";
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1){
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1 || parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) !=-1){
$("#card_payment").show();
} else{
$("#card_payment").hide();
@@ -563,6 +585,9 @@ var customer_name = "<%= @customer.name %>";
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "JUNCTIONPAY" && $('#junctionpaycount').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Oops","Please Pay with Credit Payment","warning");
}else{
@@ -610,7 +635,7 @@ var customer_name = "<%= @customer.name %>";
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", result.filename);
$("#receipt_pdf").attr("src", result.filename.substring(6));
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
$("#changed_amount").text("");
@@ -692,13 +717,17 @@ var customer_name = "<%= @customer.name %>";
if (isConfirm) {
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
var ajax_url = "/origami/sale/" + sale_id +'/'+cashier_type+ '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
success: function (result) {result
customer_display_view(null,"reload");
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
@@ -838,7 +867,8 @@ var customer_name = "<%= @customer.name %>";
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var unionpay1 = $('#unionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
var junctionpay1 = $('#junctionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(junctionpay1);
var total = $('#amount_due').text();
var amt = 0;
<% if precision.to_i > 0 %>;
@@ -866,8 +896,9 @@ var customer_name = "<%= @customer.name %>";
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var unionpay = $('#unionpaycount').text();
var junctionpay = $('#junctionpaycount').text();
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 total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(junctionpay)
var result = parseFloat(amount_due) - parseFloat(total);
<% if precision.to_i > 0 %>
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
@@ -898,7 +929,7 @@ var customer_name = "<%= @customer.name %>";
if (isConfirm) {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
url: "/origami/payment/"+cashier_type+"/foc",
data: params,
success:function(result){
customer_display_view(null,"reload");
@@ -907,6 +938,10 @@ var customer_name = "<%= @customer.name %>";
title: "Information!",
text: 'Thank You !',
}, function () {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
@@ -982,6 +1017,10 @@ var customer_name = "<%= @customer.name %>";
data: params,
success:function(result){
console.log(result);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
@@ -1115,4 +1154,11 @@ var customer_name = "<%= @customer.name %>";
$("#sxModal .btn_cancel").on('click',function(){
$("#sxModal").hide();
});
$(".btn_customer_assign").on('click', function(){
var customer_id = $(this).attr('data-id');
var customer_name = $(this).text();
var sale_id = $("#sale_id").text() || 0;
update_sale("", customer_id, customer_name, sale_id);
});
</script>

0
app/views/origami/pending_order/index.html.erb Executable file → Normal file
View File

18
app/views/origami/pending_order/show.html.erb Executable file → Normal file
View File

@@ -97,13 +97,15 @@
<% end%>
<% else%>
<% sub_total = 0
total = 0
@order_items.each do |order_item|
sub_total = sub_total + order_item.price %>
total = order_item.qty * order_item.price
sub_total = sub_total + total %>
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
<tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<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>
<td class='item-attr'><%= total %></td>
</tr>
<% end%>
<% end%>
@@ -211,7 +213,7 @@ $(document).ready(function(){
swal("Information!", result.error_message);
}
else {
window.location.href = '../pending_order/'+ result.data;
window.location.href = '/origami/quick_service/pending_order';
}
}
});
@@ -290,5 +292,13 @@ $(document).ready(function(){
window.location.href = linkURL;
});
}
/*edit order in oqs*/
$('.edit_order').on('click',function(){
var assigned_order_item_id = $(this).attr('data-id');
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending";
}
});
});
</script>

View File

@@ -465,15 +465,15 @@
<% end %>
<% if current_login_employee.role != "waiter" %>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<!--<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<% else %>
<% else %>-->
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%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> -->
@@ -489,16 +489,13 @@
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<option value="Cash">Cash</option>
<option value="Credit">Credit</option>
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
@@ -680,6 +677,21 @@ $(document).ready(function(){
});
// click select option icon for add
$(document).on('click', '.payment_btn', function(event){
active = $(this).hasClass('selected-payment');
value = $(this).data('value');
type = $(this).data('type');
group = $(this).data('group');
payments = $(".payment_btn");
if (active) {
$(this).removeClass('selected-payment');
}else{
$(this).addClass('selected-payment');
}
}); //End selecct attribute buttom
// Print for first bill
$("#first_bill").on('click', function(){
var sale_id = $('#sale_id').val();
@@ -691,7 +703,10 @@ $("#first_bill").on('click', function(){
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
location.reload();
}
});
@@ -701,7 +716,9 @@ $(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
// type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
calculate_member_discount(sale_id,"Card");
@@ -719,6 +736,12 @@ $(".choose_payment").on('click', function () {
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
location.reload();
}
});
@@ -776,7 +799,7 @@ $('#request_bills').click(function() {
//split bill process
$('#split_bills').click(function(){
var dining_id = "<%= @room.id %>";
window.location.href = '/origami/room/' + dining_id + "/split_bills";
window.location.href = '/origami/room/' + dining_id + "/" + cashier_type + "/split_bills";
});
$('#move').on('click',function(){
@@ -889,7 +912,7 @@ $('#add_invoice').on('click',function(){
var sure = confirm("Are you sure want to Void");
if (sure == true) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
var ajax_url = "/origami/sale/" + sale_id + '/cashier/void';
$.ajax({
type: 'POST',
url: ajax_url,
@@ -945,4 +968,15 @@ $('#add_invoice').on('click',function(){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
// Get Selected Class
function get_selected_attributes(selected_class) {
var item_row = $('.'+selected_class);
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
return attribute_arr;
}
</script>

View File

@@ -333,7 +333,7 @@ var cashier_type = "<%= @cashier_type %>";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
data: 'sale_id=' + sale_id +'&type='+cashier_type,
success: function (result) {
location.reload();
}
@@ -347,7 +347,7 @@ var cashier_type = "<%= @cashier_type %>";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
data: 'sale_id=' + sale_id+'&type='+cashier_type,
success: function (result) {
if (cashier_type=="quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';

View File

@@ -58,7 +58,7 @@
</div>
</div>
<script>
var type = '<%= @type %>';
var cashier_type = '<%= @cashier_type %>';
$('#close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id rescue ""%>"
@@ -73,7 +73,7 @@
});
$('#back').on('click',function(){
if(type!='quick_service'){
if(cashier_type!='quick_service'){
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
@@ -95,7 +95,7 @@
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/'+type+'/close';
window.location.href = '/origami/shift/'+cashier_type+'/close';
});
}
});
@@ -120,7 +120,7 @@
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/'+type+'/close';
window.location.href = '/origami/shift/'+cashier_type+'/close';
});
}
}
@@ -184,7 +184,7 @@
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/shift/close';
window.location.href = '/origami/shift/'+cashier_type+'/close';
});
// reqCBBankAlipaySettlement();
}

14
app/views/origami/split_bill/index.html.erb Executable file → Normal file
View File

@@ -53,12 +53,14 @@
</tr>
</thead>
<tbody>
<% order_item_count = 0 %>
<% if !@order_items.nil? %>
<% sub_total = 0 %>
<% @order_items.each do |order_item| %>
<% if order_item.include? ('all_order') %>
<% order_item['all_order'].each do |odr_item| %>
<%
order_item_count = order_item_count.to_i + 1
sub_total += odr_item['qty'].to_f * odr_item['price'].to_f
%>
<tr class="item-row" id=<%= odr_item['order_items_id'] %> >
@@ -331,6 +333,7 @@
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var cashier_type = '<%= @cashier_type %>';
$(document).ready(function(){
setHeaderBreadCrumb(_SPLIT_BILL_);
$('#back').on('click',function(){
@@ -386,10 +389,9 @@
//order_item_split
$('#order_item_split').on('click',function () {
var cnt_order_item = "<%= @order_items.count %>";
var cnt_order_item = "<%= order_item_count %>";
var order_items = get_selected_order_items();// Selected Order Items
var cnt_items = parseInt(cnt_order_item - 1) - parseInt(order_items.length);
var cnt_items = parseInt(cnt_order_item) - parseInt(order_items.length);
if (order_items.length > 0){
// if(cnt_items > 0){
swal({
@@ -424,6 +426,7 @@
$.each(orders, function(key,value){
if($("a[href$='#"+value.order_id+"']").parent().hasClass('selected-split-item')){
$("a[href$='#"+value.order_id+"']").parent().removeClass('selected-split-item');
$(".item-row").removeClass('selected-split-item');
}
});
}
@@ -622,6 +625,7 @@ function orderItemSplitBillProcess(cnt_items){
if(cnt_items == 0){
booking_id = json_booking.booking_id;
}
console.log(booking_id);
var order_ids = [];
var arr_order_ids = [];
@@ -656,7 +660,7 @@ function orderItemSplitBillProcess(cnt_items){
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'arr_order_ids': JSON.stringify(arr_order_ids), 'order_items' : JSON.stringify(order_items), 'orders' : ''},
data: {'cashier_type':cashier_type,'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'arr_order_ids': JSON.stringify(arr_order_ids), 'order_items' : JSON.stringify(order_items), 'orders' : ''},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
@@ -689,7 +693,7 @@ function orderSplitBillProcess(cnt_orders){
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders), 'arr_order_ids': []},
data: {'cashier_type':cashier_type,'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders), 'arr_order_ids': []},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);

View File

@@ -156,6 +156,15 @@
<!-- Column Three -->
<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") %>
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<% else %>
<%if @membership.discount && @sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</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" data-toggle="modal" data-target="#voidModal" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
@@ -163,6 +172,38 @@
</div>
</div>
<!-- membership paymentmodal -->
<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"><%= @sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<option value="Cash">Cash</option>
<option value="Credit">Credit</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<!-- membership paymentmodal -->
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -212,6 +253,24 @@
</div>
<script>
$(document).ready(function(){
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
discount="<%= @membership.discount%>"
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
if (discount) {
if(checkReceiptNoInFirstBillData(receipt_no,"")){
$("#pay").show();
}else{
$("#pay").hide();
}
}
}
/* end check first bill or not*/
$(".tables").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/<%= @table.id %>/table_invoice/' + dining_id;
@@ -222,6 +281,68 @@ $(document).ready(function(){
// window.location.href = '/origami/sale/<%= @sale.id %>/payment';
// });
// Print for first bill
$("#first_bill").on('click', function () {
var sale_id = '<%= @sale.id %>';
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
location.reload();
}
});
});
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = '<%= @sale.id %>';
type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
calculate_member_discount(sale_id,"Card");
}else{
calculate_member_discount(sale_id,"Cash");
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
var sale_id = '<%= @sale.id %>';
@@ -261,7 +382,7 @@ $('#void').on('click',function () {
if (isConfirm) {
var sale_id = $('#sale_id').val();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
var ajax_url = "/origami/sale/" + sale_id + '/cashier/void';
$.ajax({
type: 'POST',
url: ajax_url,
@@ -291,7 +412,7 @@ $('#foc').click(function() {
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
url: "/origami/payment/cashier/foc",
data: params,
success:function(result){
if (cash >= 0) {

View File

@@ -12,6 +12,8 @@
<%= f.input :template %>
<%= f.input :font %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<%= f.input :brand_name %>
<%= f.input :printer_type %>
<%= f.input :api_settings %>
<%= f.input :page_width %>
<%= f.input :page_height %>
@@ -61,6 +63,22 @@
</div>
<script type="text/javascript">
$(document).ready(function(){
// if selected printer change call and bind
$("#print_setting_printer_name").on("change", function(){
var printer_name = $(this).val();
$.ajax({
type: "GET",
url: "/get_printer_options/"+printer_name,
success:function(result){
$("#print_setting_brand_name").val(result.model);
$("#print_setting_api_settings").val(result.url);
}
});
});
});
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {

View File

@@ -1,2 +1,2 @@
json.extract! print_setting, :id, :name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies, :created_at, :updated_at
json.extract! print_setting, :id, :name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies, :created_at, :updated_at
json.url print_setting_url(print_setting, format: :json)

View File

@@ -30,6 +30,14 @@
<th><%= t("views.right_panel.detail.printer_name") %></th>
<td><%= @print_setting.printer_name %></td>
</tr>
<tr>
<th><%= t("views.right_panel.detail.brand_name") %></th>
<td><%= @print_setting.brand_name %></td>
</tr>
<tr>
<th><%= t("views.right_panel.detail.printer_type") %></th>
<td><%= @print_setting.printer_type %></td>
</tr>
<tr>
<th><%= t("views.right_panel.detail.font") %></th>
<td><%= @print_setting.font rescue '-' %></td>

View File

@@ -58,14 +58,14 @@
<% 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 %>
<% 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 %>
<% if !sale.status_type %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
@@ -81,8 +81,9 @@
<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 -->
<!-- sub total -->
<!-- end sub total -->
<% end %>
<% end %>
<tr>
<td colspan="3"></td>

View File

@@ -23,31 +23,40 @@
<% 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
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>
<% if !sale.status_type %>
<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><%= sale.unit_price rescue ' ' %></td>
<td><%= sale.grand_total rescue ' ' %></td>
</tr>
<!-- sub total -->
<!-- end sub total -->
<% end %>
<% end %>
<tr>
<td colspan="3"></td>
<td><strong>Total</strong></td>
<td><strong><%= total_qty %></strong></td>
<td><strong><%= total_qty rescue ' ' %></strong></td>
<td></td>
<td><strong><%= grand_total rescue '-' %></strong></td>
<td><strong><%= grand_total rescue ' ' %></strong></td>
</tr>
<% end %>
</tbody>

View File

@@ -18,13 +18,25 @@
<option value="9">Last year</option>
</select>
</div>
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14">Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="">Select Type</option>
<option value="revenue" selected>Revenue Only</option>
<option value="all">All Type</option>
<option value="discount">Discount Only</option>
<option value="void">Void Only</option>
<option value="foc">Foc Only</option>
<option value="other">Other Amount Only</option>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
@@ -52,7 +64,7 @@
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
});
var item = $('#item').val();
var payment_type = $('#payment_type');
@@ -76,17 +88,18 @@
});
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
var sale_type = "<%=params[:sale_type]%>";
$("#sel_sale_type").val(sale_type);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>

View File

@@ -57,8 +57,7 @@
delimiter = ""
end
%>
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_qty = 0 %>
@@ -75,24 +74,29 @@
<% total_item_foc = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% 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 %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
@@ -119,7 +123,12 @@
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue '-' %></td>
<% if sale.status_type != "Discount" %>
<td><%= sale.total_item rescue '-' %></td>
<%else%>
<td><%= sale.total_item*(-1) rescue '-' %></td>
<% end %>
<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>
@@ -130,10 +139,12 @@
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type!="Discount" && (!sale.product_name.include? "FOC")
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC")
sub_qty += sale.total_item
end %>
<% if sale.status_type =="Discount"
sub_qty += sale.total_item*(-1)
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
@@ -151,7 +162,8 @@
<!-- end sub total -->
<% end %>
<!--Other Charges -->
<% if @other_charges.present? %>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
@@ -191,55 +203,38 @@
<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.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.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.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.to_i,delimiter: delimiter) %>
</span>
</td>
</tr>
<% if @type == "other"%>
<% @sale_taxes.each do |tax| %>
<!-- <tr>
<td colspan="5">&nbsp;</td>
<td><%= tax.tax_name %></td>
<td><%= tax.st_amount.round(2) %>
<%total_tax += tax.st_amount%>
</td>
</tr> -->
<% end %>
<tr>
<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.to_i,delimiter:delimiter)%></td>
</tr>
<!-- <tr>
<td colspan="5">&nbsp;</td>
<td>Grand Total</td>
<td><span class="double_underline"><%= @grand_total - @change_amount%></span></td>
</tr> -->
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<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.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<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.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
</tbody>
</table>
</div>

View File

@@ -27,10 +27,22 @@
</tr>
</thead>
<tbody>
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% 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
%>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% count = 0 %>
@@ -42,14 +54,29 @@
<% total_amount = 0 %>
<% discount = 0 %>
<% total_item_foc = 0 %>
<% total_item_dis = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<% if sale.total_item > 0
<!-- all total qty sum -->
<!--
<% 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 %>
-->
<!-- end all total qty -->
<!--
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
-->
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
@@ -58,7 +85,7 @@
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= total %></b>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
@@ -77,95 +104,110 @@
<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>
<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 -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.menu_category_id == key %>
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type!="Discount" && (!sale.product_name.include? "FOC")
sub_qty += sale.total_item
end %>
<% if count == value %>
<tr>
<td colspan="5">&nbsp;</td>
<td colspan="3">&nbsp;</td>
<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"><%= sub_total %></span></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% if sale.status_type === "foc"
total_item_foc += sale.grand_total
end %>
<% if sale.status_type === "Discount"
total_item_dis += sale.grand_total
end %>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<% end %>
<!--Other Charges -->
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item rescue '-' %></td>
<td><%= other.unit_price rescue '-' %></td>
<td><%= other.grand_total rescue '-' %></td>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= other_sub_total %></span></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<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.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<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.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td><%= t("views.right_panel.detail.net_amount") %></td>
<td><span><%= grand_total%></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.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><%= total_item_foc %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= total_item_dis %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.foc_sales") %></td>
<td><span><%= @foc_data %></span></td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= @discount_data %></span></td>
</tr>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<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.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<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.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,366 @@
<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">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_saleitem_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_saleitem_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="table-responsive">
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<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.revenue") %></th>
</tr>
</thead>
<tbody>
<% 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
%>
<% unless @sale_data.blank? %>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% count = 0 %>
<% total_price = 0 %>
<% cate_count = 0 %>
<% acc_count = 0 %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_amount = 0 %>
<% discount = 0 %>
<% total_item_foc = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% @sale_data.each do |sale| %>
<!-- all total qty sum -->
<% 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 %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
<td colspan="4">&nbsp;</td>
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
</td>
</tr>
<% acc_arr.push(sale.account_id) %>
<% 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 %>
<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 -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type!="Discount" && (!sale.product_name.include? "FOC")
sub_qty += sale.total_item
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
<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.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<!--Other Charges -->
<% if @other_charges.present? %>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<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.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<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.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<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.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.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.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.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.to_i,delimiter: delimiter) %>
</span>
</td>
</tr>
<% @sale_taxes.each do |tax| %>
<!-- <tr>
<td colspan="5">&nbsp;</td>
<td><%= tax.tax_name %></td>
<td><%= tax.st_amount.round(2) %>
<%total_tax += tax.st_amount%>
</td>
</tr> -->
<% end %>
<tr>
<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.to_i,delimiter:delimiter)%></td>
</tr>
<!-- <tr>
<td colspan="5">&nbsp;</td>
<td>Grand Total</td>
<td><span class="double_underline"><%= @grand_total - @change_amount%></span></td>
</tr> -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#from').val(from)
search_by_date();
});
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
console.log(check_arr.length)
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var selected = '';
var str = '';
var param_shift = '<%= params[:shift_name]%>';
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
console.log(data)
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
if(param_shift != ''){
if(shift_id == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}
else{
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
});
</script>

View File

@@ -24,7 +24,16 @@
</div>
<div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
<div class="m-b-10 clearfix">
<div class="float-left">
<%= form_tag import_settings_menus_path,class:"col-md-", multipart:true do%>
<%=file_field_tag :file, :class => "img-thumbnail col-md-7" %>
<%=submit_tag "Import",:class => 'btn btn-primary btn-lg waves-effect' %>
<%end%>
</div>
<%= link_to t("views.btn.new"),new_settings_menu_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
<%= link_to "Export", settings_menus_path(format: "xlsx"),:class => 'btn btn-info btn-lg waves-effect float-right m-r-10' %>
</div>
<div class="card">
<table class="table table-striped">

Some files were not shown because too many files have changed in this diff Show More