fixed conflict
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -37,6 +37,7 @@ pickle-email-*.html
|
|||||||
.rbenv-version
|
.rbenv-version
|
||||||
config/deploy/config/*
|
config/deploy/config/*
|
||||||
config/puma.rb
|
config/puma.rb
|
||||||
|
config/shops.json
|
||||||
!/log/.keep
|
!/log/.keep
|
||||||
!/tmp/.keep
|
!/tmp/.keep
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
|||||||
12
Gemfile
12
Gemfile
@@ -1,5 +1,5 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
ruby '2.4.0'
|
||||||
git_source(:github) do |repo_name|
|
git_source(:github) do |repo_name|
|
||||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||||
"https://github.com/#{repo_name}.git"
|
"https://github.com/#{repo_name}.git"
|
||||||
@@ -89,10 +89,10 @@ gem 'cancancan', '~> 1.10'
|
|||||||
# Use Capistrano for deployment
|
# Use Capistrano for deployment
|
||||||
# gem 'capistrano-rails', group: :development
|
# gem 'capistrano-rails', group: :development
|
||||||
|
|
||||||
group :development, :test do
|
#group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug', platform: :mri
|
# gem 'byebug', platform: :mri
|
||||||
end
|
#end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
||||||
@@ -103,6 +103,10 @@ group :development do
|
|||||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||||
gem 'rspec-rails', '~> 3.5'
|
gem 'rspec-rails', '~> 3.5'
|
||||||
gem 'schema_to_scaffold'
|
gem 'schema_to_scaffold'
|
||||||
|
gem 'capistrano'
|
||||||
|
gem 'capistrano-bundler'
|
||||||
|
gem 'capistrano-rails'
|
||||||
|
gem 'capistrano-rbenv', github: "capistrano/rbenv"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|||||||
38
Gemfile.lock
38
Gemfile.lock
@@ -1,3 +1,11 @@
|
|||||||
|
GIT
|
||||||
|
remote: https://github.com/capistrano/rbenv.git
|
||||||
|
revision: c029e4128e4a8f25adda35795f5729bd4f62e51f
|
||||||
|
specs:
|
||||||
|
capistrano-rbenv (2.1.3)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
sshkit (~> 1.3)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@@ -39,12 +47,24 @@ GEM
|
|||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
aescrypt (1.0.0)
|
aescrypt (1.0.0)
|
||||||
|
airbrussh (1.3.0)
|
||||||
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
arel (8.0.0)
|
arel (8.0.0)
|
||||||
bcrypt (3.1.11)
|
bcrypt (3.1.11)
|
||||||
bindex (0.5.0)
|
bindex (0.5.0)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (9.1.0)
|
|
||||||
cancancan (1.17.0)
|
cancancan (1.17.0)
|
||||||
|
capistrano (3.10.1)
|
||||||
|
airbrussh (>= 1.0.0)
|
||||||
|
i18n
|
||||||
|
rake (>= 10.0.0)
|
||||||
|
sshkit (>= 1.9.0)
|
||||||
|
capistrano-bundler (1.3.0)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
sshkit (~> 1.2)
|
||||||
|
capistrano-rails (1.3.1)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
capistrano-bundler (~> 1.1)
|
||||||
carrierwave (1.2.1)
|
carrierwave (1.2.1)
|
||||||
activemodel (>= 4.0.0)
|
activemodel (>= 4.0.0)
|
||||||
activesupport (>= 4.0.0)
|
activesupport (>= 4.0.0)
|
||||||
@@ -128,6 +148,9 @@ GEM
|
|||||||
multi_xml (0.6.0)
|
multi_xml (0.6.0)
|
||||||
mysql2 (0.4.9)
|
mysql2 (0.4.9)
|
||||||
nested_form (0.3.2)
|
nested_form (0.3.2)
|
||||||
|
net-scp (1.2.1)
|
||||||
|
net-ssh (>= 2.6.5)
|
||||||
|
net-ssh (4.2.0)
|
||||||
nio4r (2.1.0)
|
nio4r (2.1.0)
|
||||||
nokogiri (1.8.1)
|
nokogiri (1.8.1)
|
||||||
mini_portile2 (~> 2.3.0)
|
mini_portile2 (~> 2.3.0)
|
||||||
@@ -228,6 +251,9 @@ GEM
|
|||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
|
sshkit (1.15.1)
|
||||||
|
net-scp (>= 1.1.2)
|
||||||
|
net-ssh (>= 2.8.0)
|
||||||
tether-rails (1.4.0)
|
tether-rails (1.4.0)
|
||||||
rails (>= 3.1)
|
rails (>= 3.1)
|
||||||
thor (0.20.0)
|
thor (0.20.0)
|
||||||
@@ -260,8 +286,11 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
aescrypt
|
aescrypt
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
byebug
|
|
||||||
cancancan (~> 1.10)
|
cancancan (~> 1.10)
|
||||||
|
capistrano
|
||||||
|
capistrano-bundler
|
||||||
|
capistrano-rails
|
||||||
|
capistrano-rbenv!
|
||||||
carrierwave (~> 1.0)
|
carrierwave (~> 1.0)
|
||||||
chartkick
|
chartkick
|
||||||
coffee-rails (~> 4.2)
|
coffee-rails (~> 4.2)
|
||||||
@@ -306,5 +335,8 @@ DEPENDENCIES
|
|||||||
web-console (>= 3.3.0)
|
web-console (>= 3.3.0)
|
||||||
whenever
|
whenever
|
||||||
|
|
||||||
|
RUBY VERSION
|
||||||
|
ruby 2.4.0p0
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.0
|
1.16.1
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ ruby 2.4.1p111
|
|||||||
|
|
||||||
Campaign Id => {"campaign_type_id": 1}
|
Campaign Id => {"campaign_type_id": 1}
|
||||||
|
|
||||||
|
java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
|
||||||
|
|
||||||
* ToDo list
|
* ToDo list
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ $(document).on('turbolinks:load', function() {
|
|||||||
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
|
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
|
||||||
var options = "";
|
var options = "";
|
||||||
}else{
|
}else{
|
||||||
var options = data.options;
|
var options = data[field]["options"];
|
||||||
}
|
}
|
||||||
|
|
||||||
var date = new Date(data[field]["created_at"]);
|
var date = new Date(data[field]["created_at"]);
|
||||||
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
|
var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
|
||||||
|
|
||||||
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
|
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
|
||||||
+'<div class="card-block">'
|
+'<div class="card-block">'
|
||||||
@@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() {
|
|||||||
+'<span class="order-qty"> [x'+ data[field]["qty"] +'] </span>'
|
+'<span class="order-qty"> [x'+ data[field]["qty"] +'] </span>'
|
||||||
+'</p>'
|
+'</p>'
|
||||||
|
|
||||||
+'<p class="card-text item-options">'+ options +'</p>'
|
+'<br/><p class="card-text item-options">'+ options +'</p>'
|
||||||
|
|
||||||
+'<span class="card-text">'
|
+'<span class="card-text">'
|
||||||
+'<span class="text-muted">Order at - '
|
+'<span class="text-muted">Order at - '
|
||||||
@@ -223,8 +223,9 @@ $(document).on('turbolinks:load', function() {
|
|||||||
var params = { 'options':options };
|
var params = { 'options':options };
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'POST',
|
||||||
url: '/oqs/print/print/'+assigned_item_id,
|
url: '/oqs/print/print/'+assigned_item_id,
|
||||||
|
data: params,
|
||||||
success: function(data){ }
|
success: function(data){ }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -243,21 +244,4 @@ $(document).on('turbolinks:load', function() {
|
|||||||
success: function(data){ }
|
success: function(data){ }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Qty update for OQS Edit Controller
|
|
||||||
$('#qty-update').on('click', function(){
|
|
||||||
var qty_weight = $("input[name='qty_weight']").val();
|
|
||||||
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 }
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/oqs/' + order_items_id,
|
|
||||||
data: params,
|
|
||||||
success: function(result){
|
|
||||||
alert("Updated!");
|
|
||||||
window.location.href = '/oqs';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,8 +73,9 @@ $(function() {
|
|||||||
}
|
}
|
||||||
//end show list function
|
//end show list function
|
||||||
//click menu sidebar menu category
|
//click menu sidebar menu category
|
||||||
$(".menu_category").on("click", function(){
|
// $(".menu_category").on("click", function(){
|
||||||
var menu_id = $(this).find(".menu-id").text();
|
$(document).on('click', '.menu_category', function(event){
|
||||||
|
var menu_id = $(this).attr("data-id");
|
||||||
var url = "get_menu_category/"+menu_id;
|
var url = "get_menu_category/"+menu_id;
|
||||||
show_menu_item_list(url);
|
show_menu_item_list(url);
|
||||||
});
|
});
|
||||||
@@ -525,7 +526,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (active) {
|
if (active) {
|
||||||
$(this).revoveClass('selected-option');
|
$(this).removeClass('selected-option');
|
||||||
}else{
|
}else{
|
||||||
$(this).addClass('selected-option');
|
$(this).addClass('selected-option');
|
||||||
}
|
}
|
||||||
@@ -855,12 +856,12 @@ $(function() {
|
|||||||
|
|
||||||
$('#'+minus).on("click", function(){
|
$('#'+minus).on("click", function(){
|
||||||
|
|
||||||
var count = parseInt($('#'+id).val());
|
// var count = parseInt($('#'+id).val());
|
||||||
var countEl = document.getElementById(id);
|
// var countEl = document.getElementById(id);
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
count--;
|
count--;
|
||||||
countEl.value = count;
|
$('#'+id).val(count);
|
||||||
|
|
||||||
if (id=="count") {
|
if (id=="count") {
|
||||||
price = $("#unit_price").text();
|
price = $("#unit_price").text();
|
||||||
@@ -918,6 +919,47 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//click menu sidebar menu category
|
||||||
|
|
||||||
|
$(".sub_click").on("click", function(){
|
||||||
|
var menu_id = $(this).attr("data-id");
|
||||||
|
var url = "get_menu_sub_category/"+menu_id;
|
||||||
|
sub_category = $(this).find('.sub_category_list');
|
||||||
|
show_sub_category_list(url,sub_category);
|
||||||
|
});
|
||||||
|
//End menu category Click
|
||||||
|
|
||||||
|
//show menu item list when click menu category
|
||||||
|
function show_sub_category_list(url,sub_category){
|
||||||
|
|
||||||
|
var menu_list = $('.sub_category_list');
|
||||||
|
menu_list.empty();
|
||||||
|
//Start Ajax
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
var sub_category_list = $('.sub_category_list');
|
||||||
|
sub_category_list.empty();
|
||||||
|
data = data.sub_category;
|
||||||
|
|
||||||
|
if (data.length>0) {
|
||||||
|
$(sub_category).removeClass('hidden');
|
||||||
|
for(var i in data) {
|
||||||
|
|
||||||
|
row = '<li class="menu_category fadeInTop animated" data-id="'+data[i].id+'">'
|
||||||
|
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ data[i].name+'</a>'
|
||||||
|
+'</li>' ;
|
||||||
|
$(sub_category).append(row);
|
||||||
|
//end is_sub_item false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//end Ajax
|
||||||
|
}
|
||||||
/* $("input").keypress(function(){
|
/* $("input").keypress(function(){
|
||||||
$("span").text(i += 1);
|
$("span").text(i += 1);
|
||||||
});*/
|
});*/
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ $(document).ready(function() {
|
|||||||
date: false
|
date: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// first input focus for all form
|
|
||||||
$("body").has("form").find("input:first").focus();
|
|
||||||
|
|
||||||
// Image Upload
|
// Image Upload
|
||||||
$("#simple_menu_item_image_path").fileinput({
|
$("#simple_menu_item_image_path").fileinput({
|
||||||
previewFileType: "image",
|
previewFileType: "image",
|
||||||
@@ -107,6 +104,9 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// first input focus for all form
|
||||||
|
$('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus();
|
||||||
|
|
||||||
// $(document).on("focus", "[data-behaviour~='datepicker']", function(e){
|
// $(document).on("focus", "[data-behaviour~='datepicker']", function(e){
|
||||||
// $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
|
// $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
|
||||||
// $('.dropdown-toggle').dropdown();
|
// $('.dropdown-toggle').dropdown();
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ App.order = App.cable.subscriptions.create('BillChannel', {
|
|||||||
disconnected: function() {},
|
disconnected: function() {},
|
||||||
|
|
||||||
received: function(data) {
|
received: function(data) {
|
||||||
$('.table_'+data.table.id).removeClass('blue');
|
if($('.table_'+data.table.id).hasClass('blue')){
|
||||||
$('.table_'+data.table.id).addClass('red');
|
$('.table_'+data.table.id).removeClass('blue');
|
||||||
$('.new_text_'+data.table.id).removeClass('hide')
|
$('.table_'+data.table.id).addClass('red');
|
||||||
|
}else{
|
||||||
|
$('.table_'+data.table.id).removeClass('orange');
|
||||||
|
$('.table_'+data.table.id).addClass('red');
|
||||||
|
}
|
||||||
|
$('.new_text_'+data.table.id).removeClass('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
61
app/assets/javascripts/channels/call_waiter.js
Normal file
61
app/assets/javascripts/channels/call_waiter.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
table = data.table
|
||||||
|
|
||||||
|
// for Notificaiotn message
|
||||||
|
var element = "#notify-wrapper"
|
||||||
|
var placementFrom = "top";
|
||||||
|
var placementAlign = "center";
|
||||||
|
var animateEnter = "";
|
||||||
|
var animateExit = "";
|
||||||
|
var colorName = "alert-warning";
|
||||||
|
var text = " Calling Waiter <br> "+table.name ;
|
||||||
|
|
||||||
|
if (text != null || colorName != null){
|
||||||
|
showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
|
||||||
|
if (colorName === null || colorName === '') { colorName = 'bg-black'; }
|
||||||
|
if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
|
||||||
|
if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
|
||||||
|
var allowDismiss = true;
|
||||||
|
|
||||||
|
$.notify({
|
||||||
|
message: text
|
||||||
|
},
|
||||||
|
{
|
||||||
|
element: element,
|
||||||
|
type: colorName,
|
||||||
|
allow_dismiss: allowDismiss,
|
||||||
|
timer: 200000000000000,
|
||||||
|
placement: {
|
||||||
|
from: placementFrom,
|
||||||
|
align: placementAlign
|
||||||
|
},
|
||||||
|
animate: {
|
||||||
|
enter: animateEnter,
|
||||||
|
exit: animateExit
|
||||||
|
},
|
||||||
|
template: '<div data-notify="container" style="width:180px !important;" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-30" : "") + '" role="alert">' +
|
||||||
|
'<button type="button" aria-hidden="true" class="close notify-close float-right m-l-5 m-t--5" data-notify="dismiss">×</button>' +
|
||||||
|
'<span data-notify="icon"></span> ' +
|
||||||
|
'<span data-notify="title">{1}</span> ' +
|
||||||
|
'<span data-notify="message">{2}</span>' +
|
||||||
|
'<div class="progress" data-notify="progressbar">' +
|
||||||
|
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<a href="{3}" target="{4}" data-notify="url"></a>' +
|
||||||
|
'</div>'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//end Notificaiotn message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
16
app/assets/javascripts/channels/check_in_booking.js
Normal file
16
app/assets/javascripts/channels/check_in_booking.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
if($('.table_'+data.table.id).hasClass('green')){
|
||||||
|
$('.table_'+data.table.id).removeClass('green');
|
||||||
|
$('.table_'+data.table.id).addClass('blue');
|
||||||
|
}
|
||||||
|
$('.new_text_'+data.table.id).removeClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
26
app/assets/javascripts/channels/checkin.js
Normal file
26
app/assets/javascripts/channels/checkin.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
App.order = App.cable.subscriptions.create('CheckinChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
$.each(data.table,function(key,value){
|
||||||
|
if($('.table_'+value.table_id).hasClass('blue')){
|
||||||
|
$('.table_'+value.table_id).removeClass('blue');
|
||||||
|
$('.table_'+value.table_id).addClass('orange');
|
||||||
|
}
|
||||||
|
else if($('.table_'+value.table_id).hasClass('red')){
|
||||||
|
$('.table_'+value.table_id).removeClass('red');
|
||||||
|
$('.table_'+value.table_id).addClass('orange');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.table_'+value.table_id).removeClass('green');
|
||||||
|
$('.table_'+value.table_id).addClass('orange');
|
||||||
|
}
|
||||||
|
$('.new_text_'+value.table_id).removeClass('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
|
|||||||
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
|
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
|
||||||
var options = "";
|
var options = "";
|
||||||
}else{
|
}else{
|
||||||
var options = items.options;
|
var options = items[field]["options"];
|
||||||
}
|
}
|
||||||
//for count
|
//for count
|
||||||
test = document.getElementsByClassName("oqs_count");
|
test = document.getElementsByClassName("oqs_count");
|
||||||
@@ -30,7 +30,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
|
|||||||
//end count
|
//end count
|
||||||
|
|
||||||
var date = new Date(items[field]["created_at"]);
|
var date = new Date(items[field]["created_at"]);
|
||||||
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
|
var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
|
||||||
|
|
||||||
if (oqs_id == items[field]["order_queue_station_id"]) {
|
if (oqs_id == items[field]["order_queue_station_id"]) {
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
|
|||||||
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
|
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
|
||||||
+'</p>'
|
+'</p>'
|
||||||
|
|
||||||
+'<p class="card-text item-options">'+ options +'</p>'
|
+'<br/><p class="card-text item-options">'+ options +'</p>'
|
||||||
|
|
||||||
+'<span class="card-text">'
|
+'<span class="card-text">'
|
||||||
+'<span class="text-muted">Order at - '
|
+'<span class="text-muted">Order at - '
|
||||||
|
|||||||
@@ -143,3 +143,55 @@ $(document).on('turbolinks:load', function() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* start check first bill or not funs: */
|
||||||
|
function checkReceiptNoInFirstBillData(receipt_no,payment) {
|
||||||
|
// localStorage.removeItem('receipt_lists');
|
||||||
|
var status = false;
|
||||||
|
if((receipt_no!=undefined) && (receipt_no!="")){
|
||||||
|
if(localStorage.hasOwnProperty("receipt_lists")===true){
|
||||||
|
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||||
|
if (payment) {
|
||||||
|
var json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||||
|
}else{
|
||||||
|
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
|
}
|
||||||
|
|
||||||
|
if((arr_data.length) > (json_data.length)){
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (payment) {
|
||||||
|
return json_data[0]["payment"];
|
||||||
|
}else{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createReceiptNoInFirstBillData(receipt_no,payment) {
|
||||||
|
var arr_data = [];
|
||||||
|
var json_data = [];
|
||||||
|
if(localStorage.hasOwnProperty("receipt_lists") === true){
|
||||||
|
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||||
|
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||||
|
if (payment) {
|
||||||
|
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
|
jdata.push({'receipt_no':receipt_no,'payment':payment});
|
||||||
|
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
||||||
|
arr_data.push({'receipt_no':receipt_no,'payment':payment});
|
||||||
|
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteReceiptNoInFirstBillData(receipt_no) {
|
||||||
|
if(localStorage.hasOwnProperty("receipt_lists") ===true ){
|
||||||
|
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||||
|
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
|
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* end check first bill or not funs: */
|
||||||
@@ -114,9 +114,11 @@
|
|||||||
.green{
|
.green{
|
||||||
background-color: #009900;
|
background-color: #009900;
|
||||||
}
|
}
|
||||||
.left{
|
|
||||||
|
.left-margin-1 {
|
||||||
margin-left:1px;
|
margin-left:1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom{
|
.bottom{
|
||||||
margin-bottom:1px;
|
margin-bottom:1px;
|
||||||
}
|
}
|
||||||
@@ -149,3 +151,9 @@ nav.pagination .page a:hover,
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Logout Icon*/
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
@@ -100,3 +100,8 @@ select.form-control {
|
|||||||
border-left:1px solid #fff;
|
border-left:1px solid #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Logout Icon*/
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
@@ -69,7 +69,17 @@ section .content{
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border-color: #fff #fff #fff #54A5AF;
|
border-color: #fff #fff #fff #54A5AF;
|
||||||
}
|
}
|
||||||
|
.sub_category_list{
|
||||||
|
background:#fff;
|
||||||
|
margin-top:8px;
|
||||||
|
}
|
||||||
|
.sub_category_list > li{
|
||||||
|
list-style:none;
|
||||||
|
margin-left:-40px;
|
||||||
|
}
|
||||||
|
.sub_category_list > li > a.nav-link{
|
||||||
|
border-bottom:1px solid #eee;
|
||||||
|
}
|
||||||
.custom-modal-dialog {
|
.custom-modal-dialog {
|
||||||
left:auto;
|
left:auto;
|
||||||
right: auto;
|
right: auto;
|
||||||
@@ -158,3 +168,9 @@ section.content{
|
|||||||
.add_icon{
|
.add_icon{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Logout Icon*/
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
@@ -93,3 +93,9 @@ nav.pagination .page a:hover,
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Logout Icon*/
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
@@ -275,3 +275,8 @@ tr.discount-item-row:hover {
|
|||||||
-moz-opacity: 1; /* mozilla */
|
-moz-opacity: 1; /* mozilla */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*Logout Icon*/
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
@@ -262,6 +262,10 @@ select.form-control {
|
|||||||
margin-left:1px;
|
margin-left:1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dtp-date .left{
|
||||||
|
margin-left:0px;
|
||||||
|
}
|
||||||
|
|
||||||
.bottom{
|
.bottom{
|
||||||
margin-bottom:1px;
|
margin-bottom:1px;
|
||||||
}
|
}
|
||||||
@@ -357,3 +361,32 @@ tr.discount-item-row:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* End Payment Page */
|
/* End Payment Page */
|
||||||
|
|
||||||
|
/* Logout Icon */
|
||||||
|
|
||||||
|
i.logout_icon{
|
||||||
|
position: relative;
|
||||||
|
top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End Logout Icon */
|
||||||
|
|
||||||
|
/* Notify */
|
||||||
|
|
||||||
|
#notify-wrapper {
|
||||||
|
position: absolute;
|
||||||
|
top: 55px;
|
||||||
|
left: 10px;
|
||||||
|
z-index: 9999;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-notify="container"] {
|
||||||
|
margin-bottom: 5px !important;
|
||||||
|
margin-left:5px !important;
|
||||||
|
position:relative !important;
|
||||||
|
top: 25% !important;
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End Notify */
|
||||||
|
|||||||
@@ -265,5 +265,13 @@ section.content {
|
|||||||
color: #F44336;
|
color: #F44336;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*notification */
|
||||||
|
.alert {
|
||||||
|
padding: .25rem .25rem !important;
|
||||||
|
}
|
||||||
|
.alert-dismissible .close {
|
||||||
|
padding: 0.5rem 0.44rem;
|
||||||
|
}
|
||||||
/* End Reset Theme */
|
/* End Reset Theme */
|
||||||
/* *************************************************** */
|
/* *************************************************** */
|
||||||
@@ -15,4 +15,9 @@ module ApplicationCable
|
|||||||
class BillChannel < ActionCable::Channel::Base
|
class BillChannel < ActionCable::Channel::Base
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Call Waiter Channel
|
||||||
|
class CallWaiterChannel < ActionCable::Channel::Base
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module ApplicationCable
|
module ApplicationCable
|
||||||
class Connection < ActionCable::Connection::Base
|
class Connection < ActionCable::Connection::Base
|
||||||
def connect
|
def connect
|
||||||
logger.add_tags "ActionCable"
|
logger.add_tags "SX-ActionCable"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
14
app/channels/call_waiter_channel.rb
Normal file
14
app/channels/call_waiter_channel.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class CallWaiterChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "call_waiter_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
end
|
||||||
|
|
||||||
|
def order(message)
|
||||||
|
# ToDo
|
||||||
|
end
|
||||||
|
end
|
||||||
10
app/channels/check_in_booking_channel.rb
Normal file
10
app/channels/check_in_booking_channel.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CheckInBookingChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "check_in_booking_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
end
|
||||||
|
end
|
||||||
10
app/channels/checkin_channel.rb
Normal file
10
app/channels/checkin_channel.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CheckinChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "checkin_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -5,7 +5,8 @@ class Api::BillController < Api::ApiController
|
|||||||
def create
|
def create
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "Order ID or Booking ID is require to request for a bill."
|
@error_message = "Order ID or Booking ID is require to request for a bill."
|
||||||
if ShiftSale.current_shift
|
|
||||||
|
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||||
#create Bill by Booking ID
|
#create Bill by Booking ID
|
||||||
table = 0
|
table = 0
|
||||||
if (params[:booking_id])
|
if (params[:booking_id])
|
||||||
@@ -15,16 +16,18 @@ class Api::BillController < Api::ApiController
|
|||||||
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
|
|
||||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id(cashier_zone.cashier_terminal_id)
|
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||||
get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||||
|
|
||||||
if booking
|
if booking
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier_by_terminal)
|
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier_by_terminal)
|
||||||
|
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
else
|
else
|
||||||
@status = true
|
@status = true
|
||||||
@sale_id = booking.sale_id
|
@sale_id = booking.sale_id
|
||||||
|
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -36,6 +39,11 @@ class Api::BillController < Api::ApiController
|
|||||||
booking = Booking.find_by_sale_id(@sale_id)
|
booking = Booking.find_by_sale_id(@sale_id)
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Bind shift sale id to sale
|
||||||
|
@sale_data.shift_sale_id = shift_by_terminal.id
|
||||||
|
@sale_data.save
|
||||||
|
|
||||||
Promotion.promo_activate(@sale)
|
Promotion.promo_activate(@sale)
|
||||||
|
|
||||||
BillBroadcastJob.perform_later(table)
|
BillBroadcastJob.perform_later(table)
|
||||||
|
|||||||
20
app/controllers/api/call_waiters_controller.rb
Normal file
20
app/controllers/api/call_waiters_controller.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
class Api::CallWaitersController < ActionController::API
|
||||||
|
|
||||||
|
#List all active customers by name
|
||||||
|
def index
|
||||||
|
@table_id = params[:dining_id]
|
||||||
|
@time = params[:time]
|
||||||
|
@table = DiningFacility.find(@table_id)
|
||||||
|
CallWaiterJob.perform_later(@table,@time)
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
# @shop = Shop::ShopDetail
|
||||||
|
# unique_code = "CallWaiterPdf"
|
||||||
|
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
# printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,23 +1,47 @@
|
|||||||
class Api::CheckInProcessController < Api::ApiController
|
class Api::CheckInProcessController < Api::ApiController
|
||||||
|
|
||||||
|
def check_in_time
|
||||||
|
if params[:dining_id]
|
||||||
|
dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
|
booking = dining_facility.get_current_checkout_booking
|
||||||
|
if !booking.nil?
|
||||||
|
|
||||||
|
DiningFacility.check_in_booking(params[:dining_id])
|
||||||
|
|
||||||
|
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||||
|
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
|
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||||
|
alert_time_min = 0
|
||||||
|
if !lookup_checkout_time.nil?
|
||||||
|
if lookup_checkout_time[0][0] == 'min'
|
||||||
|
alert_time_min = (lookup_checkout_time[0][1]).to_i
|
||||||
|
else
|
||||||
|
alert_time_min = 15
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min }
|
||||||
|
else
|
||||||
|
render :json => { :status => false, :error_message => "No current booking!" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def check_in_process
|
def check_in_process
|
||||||
if params[:dining_id]
|
if params[:dining_id]
|
||||||
dining_facility = DiningFacility.find(params[:dining_id])
|
dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
if dining_facility.status == "available"
|
if dining_facility.status == "available"
|
||||||
dining_charge = DiningCharge.select('charge_type','charge_block')
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
.where('dining_facility_id = ?',params[:dining_id])
|
|
||||||
.first()
|
|
||||||
|
|
||||||
checkout_at = Time.now.utc
|
checkout_at = Time.now.utc
|
||||||
|
|
||||||
if !dining_charge.nil?
|
if !lookup_checkout_time.nil?
|
||||||
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
|
if lookup_checkout_time[0][0] == 'hr'
|
||||||
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
|
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
|
||||||
# if dining_charge.charge_type == 'hr'
|
else
|
||||||
checkout_at = checkout_at + hr.hour + min.minutes
|
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
|
||||||
# else
|
end
|
||||||
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
dining_facility.status = "occupied"
|
dining_facility.status = "occupied"
|
||||||
@@ -30,10 +54,10 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||||
:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||||
booking.save!
|
booking.save!
|
||||||
|
|
||||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||||
else
|
else
|
||||||
error_message = "#{dining_facility.type} is not available!"
|
error_message = "#{dining_facility.type} is not available!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
@@ -58,7 +82,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
booking.checkout_at = checkout_at
|
booking.checkout_at = checkout_at
|
||||||
booking.save!
|
booking.save!
|
||||||
|
|
||||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.strftime("%Y-%m-%d %H:%M") }
|
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||||
error_message = "time is required!"
|
error_message = "time is required!"
|
||||||
render :json => { :status => false, :error_message => error_message }
|
render :json => { :status => false, :error_message => error_message }
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
def lookup_domain
|
def lookup_domain
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
if request.subdomain.present? && request.subdomain != "www"
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase
|
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||||
|
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||||
if (!@license.nil?)
|
if (!@license.nil?)
|
||||||
# logger.info "Location - " + @license.name
|
# logger.info "Location - " + @license.name
|
||||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
@@ -37,29 +38,30 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
# check for license file
|
# check for license file
|
||||||
if check_license
|
# if check_license
|
||||||
current_license(ENV["SX_PROVISION_URL"])
|
# current_license(ENV["SX_PROVISION_URL"])
|
||||||
end
|
# else
|
||||||
|
# redirect_to activate_path
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_license(url)
|
def current_license(url)
|
||||||
@license = License.new(url)
|
@license = License.new(url)
|
||||||
|
flag = @license.detail_with_local_file()
|
||||||
if (@license.detail_with_local_file() == true)
|
if (flag == 0)
|
||||||
puts "RUN SAY BYAR"
|
flash[:notice] = 'Expired or No License!'
|
||||||
|
elsif (flag == 2)
|
||||||
|
flash[:notice] = 'Expiring! Please, License extend...'
|
||||||
else
|
else
|
||||||
return nil
|
puts "RUN SAY BYAR"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_license(url, lookup)
|
def cache_license(url, lookup)
|
||||||
@license = License.new(url, lookup)
|
@license = License.new(url, lookup)
|
||||||
# Export for Key
|
|
||||||
aes = MyAesCrypt.new
|
|
||||||
aes_key, aes_iv = aes.export_key(lookup)
|
|
||||||
|
|
||||||
if (@license.detail_with_local_cache(lookup, aes_key, aes_iv) == true)
|
if (@license.detail_with_local_cache(lookup) == true)
|
||||||
return @license
|
return @license
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
@@ -109,9 +111,8 @@ class ApplicationController < ActionController::Base
|
|||||||
def check_license
|
def check_license
|
||||||
if License.check_license_file
|
if License.check_license_file
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
redirect_to install_path
|
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class BaseController < ActionController::Base
|
class BaseController < ActionController::Base
|
||||||
layout "installation"
|
layout "installation"
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class BaseOrigamiController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "origami"
|
layout "origami"
|
||||||
|
|
||||||
|
# before_action :checkin_process
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
@@ -13,4 +15,7 @@ class BaseOrigamiController < ActionController::Base
|
|||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def checkin_process
|
||||||
|
# CheckinJob.set(wait: 1.minute).perform_later()
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
@response = Customer.get_membership_transactions(@customer)
|
@response = Customer.get_membership_transactions(@customer)
|
||||||
puts @response.to_json
|
|
||||||
|
Rails.logger.debug "get membership transactions response"
|
||||||
|
Rails.logger.debug @response.to_json
|
||||||
# @response = ""
|
# @response = ""
|
||||||
#end customer amount
|
#end customer amount
|
||||||
|
|
||||||
@@ -156,7 +158,8 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = {"status" => false, "message" => "Can't open membership server "}
|
response = {"status" => false, "message" => "Can't open membership server "}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "--------------Create Member---------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
customer = Customer.find(@crm_customers.customer_id)
|
customer = Customer.find(@crm_customers.customer_id)
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
@@ -235,7 +238,7 @@ end
|
|||||||
id = @crm_customer.membership_id
|
id = @crm_customer.membership_id
|
||||||
member_group_id = params[:member_group_id]
|
member_group_id = params[:member_group_id]
|
||||||
|
|
||||||
if id.nil? && !member_group_id.nil?
|
if !id.present? && !member_group_id.nil?
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
@@ -277,10 +280,9 @@ end
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false}
|
response = { status: false}
|
||||||
end
|
end
|
||||||
puts "ssssssss"
|
|
||||||
puts response.to_json
|
|
||||||
customer = Customer.find(@crm_customer.customer_id)
|
customer = Customer.find(@crm_customer.customer_id)
|
||||||
|
Rails.logger.debug "--------Update Member response -------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
@@ -337,10 +339,8 @@ end
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false}
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "--------Update Member response -------"
|
||||||
puts "ssssssss"
|
Rails.logger.debug response.to_json
|
||||||
puts response.to_json
|
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
customer = Customer.find(@crm_customer.customer_id)
|
customer = Customer.find(@crm_customer.customer_id)
|
||||||
# Check membership id and bind to user
|
# Check membership id and bind to user
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ class HomeController < ApplicationController
|
|||||||
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@employees = Employee.all_emp_except_waiter.order("name asc")
|
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||||
|
@employees = Employee.all.order("name asc")
|
||||||
@login_form = LoginForm.new()
|
@login_form = LoginForm.new()
|
||||||
render "layouts/login_dashboard", layout: false
|
render "layouts/login_dashboard", layout: false
|
||||||
end
|
end
|
||||||
@@ -45,7 +46,7 @@ class HomeController < ApplicationController
|
|||||||
elsif @employee.role == "manager"
|
elsif @employee.role == "manager"
|
||||||
session[:session_token] = @employee.token_session
|
session[:session_token] = @employee.token_session
|
||||||
redirect_to dashboard_path
|
redirect_to dashboard_path
|
||||||
elsif @employee.role == "supervisor"
|
elsif @employee.role == "supervisor" || @employee.role == "waiter"
|
||||||
session[:session_token] = @employee.token_session
|
session[:session_token] = @employee.token_session
|
||||||
redirect_to origami_root_path
|
redirect_to origami_root_path
|
||||||
elsif @employee.role == "account"
|
elsif @employee.role == "account"
|
||||||
@@ -72,7 +73,8 @@ class HomeController < ApplicationController
|
|||||||
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
||||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||||
# .sum(:grand_total)
|
# .sum(:grand_total)
|
||||||
@employee_sales = Sale.employee_sales(today).sum(:grand_total)
|
@employee_sales = Sale.employee_sales(today)
|
||||||
|
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||||
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||||
|
|
||||||
@total_sale = Sale.total_sale(today)
|
@total_sale = Sale.total_sale(today)
|
||||||
@@ -86,10 +88,10 @@ class HomeController < ApplicationController
|
|||||||
@total_payment_methods.each do |payment|
|
@total_payment_methods.each do |payment|
|
||||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||||
pay = Sale.payment_sale('card', today)
|
pay = Sale.payment_sale('card', today)
|
||||||
@sale_data.push({'card' => pay})
|
@sale_data.push({'card' => pay.payment_amount})
|
||||||
else
|
else
|
||||||
pay = Sale.payment_sale(payment.payment_method, today)
|
pay = Sale.payment_sale(payment.payment_method, today)
|
||||||
@sale_data.push({payment.payment_method => pay})
|
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@summ_sale = Sale.summary_sale_receipt(today)
|
@summ_sale = Sale.summary_sale_receipt(today)
|
||||||
|
|||||||
@@ -1,42 +1,77 @@
|
|||||||
class InstallController < BaseController
|
class InstallController < BaseController
|
||||||
|
skip_before_action :verify_authenticity_token
|
||||||
|
# before_action :check_license
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def activate
|
||||||
|
flag = "<%= ENV['AES_IV'] %>"
|
||||||
|
key_base = "<%= ENV['secret_key_base'] %>"
|
||||||
|
|
||||||
restaurant = params[:restaurant_name]
|
restaurant = params[:restaurant_name]
|
||||||
license_key = params[:license_key]
|
license_key = params[:license_key]
|
||||||
admin_user = params[:admin_user]
|
# admin_user = params[:admin_user]
|
||||||
admin_password = params[:admin_password]
|
# admin_password = params[:admin_password]
|
||||||
|
db_host = params[:db_host]
|
||||||
|
db_schema = params[:db_schema]
|
||||||
|
db_user = params[:db_user]
|
||||||
|
db_password = params[:db_password]
|
||||||
|
phrase = license_key
|
||||||
|
|
||||||
|
# Check Exists IV
|
||||||
|
# if flag == "<%= ENV['AES_IV'] %>"
|
||||||
|
# # Export for Key
|
||||||
|
# aes = MyAesCrypt.new
|
||||||
|
# aes_key, aes_iv = aes.export_key(phrase)
|
||||||
|
# else
|
||||||
|
# aes_key = ENV["AES_KEY"]
|
||||||
|
# aes_iv = ENV["AES_IV"]
|
||||||
|
# end
|
||||||
|
|
||||||
|
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||||
|
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||||
|
if response[:status]
|
||||||
|
redirect_to root_url, notice: response["message"]
|
||||||
|
else
|
||||||
|
redirect_to activate_path, notice: response["message"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lookup_domain
|
def check_license
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
if License.check_license_file
|
||||||
@license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
redirect_to root_url
|
||||||
if (!@license.nil?)
|
|
||||||
# logger.info "Location - " + @license.name
|
|
||||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
|
||||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
|
||||||
else
|
|
||||||
# reconnect_default_db
|
|
||||||
logger.info 'License is nil'
|
|
||||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
|
||||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_license(url, key)
|
# def lookup_domain
|
||||||
@license = License.new(url, key)
|
# if request.subdomain.present? && request.subdomain != "www"
|
||||||
|
# @license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
||||||
|
# if (!@license.nil?)
|
||||||
|
# # logger.info "Location - " + @license.name
|
||||||
|
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
|
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||||
|
# else
|
||||||
|
# # reconnect_default_db
|
||||||
|
# logger.info 'License is nil'
|
||||||
|
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||||
|
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
##creating md5 hash
|
# def current_license(url, key)
|
||||||
md5_hostname = Digest::MD5.new
|
# @license = License.new(url, key)
|
||||||
md5key = md5_hostname.update(request.host)
|
|
||||||
if (@license.detail_with_local_cache(key, md5key.to_s) == true)
|
|
||||||
#if (@license.detail == true)
|
|
||||||
|
|
||||||
return @license
|
# ##creating md5 hash
|
||||||
else
|
# md5_hostname = Digest::MD5.new
|
||||||
return nil
|
# md5key = md5_hostname.update(request.host)
|
||||||
end
|
# if (@license.detail_with_local_cache(key, md5key.to_s) == true)
|
||||||
end
|
# #if (@license.detail == true)
|
||||||
|
|
||||||
|
# return @license
|
||||||
|
# else
|
||||||
|
# return nil
|
||||||
|
# end
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Inventory::InventoryController < BaseInventoryController
|
class Inventory::InventoryController < BaseInventoryController
|
||||||
|
load_and_authorize_resource
|
||||||
def index
|
def index
|
||||||
@products = InventoryDefinition.all.active.order('created_at desc')
|
@products = InventoryDefinition.all.active.order('created_at desc')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class Oqs::EditController < BaseOqsController
|
|||||||
def index
|
def index
|
||||||
assigned_item_id = params[:id]
|
assigned_item_id = params[:id]
|
||||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_code='#{ assigned_item.item_code }'");
|
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'");
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -17,7 +17,7 @@ class Oqs::EditController < BaseOqsController
|
|||||||
order_item.save
|
order_item.save
|
||||||
|
|
||||||
# print
|
# print
|
||||||
assigned_item = AssignedOrderItem.find_by_item_code(order_item.item_code)
|
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
|
||||||
# order queue stations
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
|
|
||||||
@@ -25,6 +25,6 @@ class Oqs::EditController < BaseOqsController
|
|||||||
|
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_item(print_settings, oqs,assigned_item.order_id, assigned_item.item_code, print_status=" (Edited)" )
|
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Oqs::PrintController < ApplicationController
|
|||||||
|
|
||||||
# order queue stations
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
|
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||||
|
|
||||||
# Check Printed
|
# Check Printed
|
||||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||||
@@ -16,7 +17,7 @@ class Oqs::PrintController < ApplicationController
|
|||||||
# print when complete click
|
# print when complete click
|
||||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, assigned_item.instance_code, print_status, options )
|
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
|
||||||
|
|
||||||
# update print status for completed same order items
|
# update print status for completed same order items
|
||||||
assigned_items.each do |ai|
|
assigned_items.each do |ai|
|
||||||
|
|||||||
@@ -44,6 +44,17 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def get_menu_sub_category ()
|
||||||
|
id = params[:id]
|
||||||
|
if (id)
|
||||||
|
#Pull this menu
|
||||||
|
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||||
|
# puts @menu.menu_items[1].item_attributes.to_json
|
||||||
|
return @sub_menu
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_all_product()
|
def get_all_product()
|
||||||
@product = Product.all
|
@product = Product.all
|
||||||
end
|
end
|
||||||
@@ -58,9 +69,6 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
|||||||
items_arr.push(items)
|
items_arr.push(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
puts "sssssssssss"
|
|
||||||
puts params[:customer_id]
|
|
||||||
puts params.to_json
|
|
||||||
# begin
|
# begin
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
class Origami::CheckInProcessController < BaseOrigamiController
|
class Origami::CheckInProcessController < BaseOrigamiController
|
||||||
|
|
||||||
def check_in_process
|
def check_in_process
|
||||||
dining_charge = DiningCharge.select('charge_type','charge_block')
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
.where('dining_facility_id = ?',params[:dining_id])
|
|
||||||
.first()
|
|
||||||
|
|
||||||
checkout_at = Time.now.utc
|
checkout_at = Time.now.utc
|
||||||
|
|
||||||
if !dining_charge.nil?
|
if !lookup_checkout_time.nil?
|
||||||
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
|
if lookup_checkout_time[0][0] == 'hr'
|
||||||
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
|
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
|
||||||
# if dining_charge.charge_type == 'hr'
|
else
|
||||||
checkout_at = checkout_at + hr.hour + min.minutes
|
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
|
||||||
# else
|
end
|
||||||
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
@dining_facility = DiningFacility.find(params[:dining_id])
|
@dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
@dining_facility.status = "occupied"
|
@dining_facility.status = "occupied"
|
||||||
@@ -27,7 +22,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||||
:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign" })
|
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||||
@booking.save!
|
@booking.save!
|
||||||
|
|
||||||
respond = {:status => 'ok'}
|
respond = {:status => 'ok'}
|
||||||
|
|||||||
@@ -4,11 +4,20 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
# limit visa_amount
|
# limit visa_amount
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@creditcount = 0
|
@creditcount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "visa"
|
if sale_payment.payment_method == "creditnote"
|
||||||
@creditcount = @creditcount + sale_payment.payment_amount
|
@creditcount = @creditcount + sale_payment.payment_amount
|
||||||
else
|
else
|
||||||
others = others + sale_payment.payment_amount
|
others = others + sale_payment.payment_amount
|
||||||
@@ -21,6 +30,16 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
|||||||
cash = params[:amount]
|
cash = params[:amount]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
if(Sale.exists?(sale_id))
|
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)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote")
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||||
# sale.save
|
# sale.save
|
||||||
if discount_items.length > 0
|
if discount_items.length > 0
|
||||||
puts discount_items.to_json
|
|
||||||
puts "dddddddddddd"
|
|
||||||
|
|
||||||
#save sale item for discount
|
#save sale item for discount
|
||||||
discount_items.each do |di|
|
discount_items.each do |di|
|
||||||
@@ -159,11 +157,15 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
is_card = params[:is_card]
|
is_card = params[:is_card]
|
||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
|
if is_card == 'true'
|
||||||
|
is_card = true
|
||||||
|
else is_card.to_s == 'false'
|
||||||
|
is_card = false
|
||||||
|
end
|
||||||
# Check for Card Payment
|
# Check for Card Payment
|
||||||
is_card_payment = SaleItem.get_sale_payments_by_card(sale.sale_payments)
|
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
|
||||||
|
|
||||||
if is_card_payment != true
|
# if is_card != "true"
|
||||||
account_types = Account.where("discount=?",true)
|
account_types = Account.where("discount=?",true)
|
||||||
table_id = sale.bookings[0].dining_facility_id
|
table_id = sale.bookings[0].dining_facility_id
|
||||||
table_type = DiningFacility.find(table_id).type
|
table_type = DiningFacility.find(table_id).type
|
||||||
@@ -180,7 +182,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
generic_customer_id = sale.customer.membership_id
|
generic_customer_id = sale.customer.membership_id
|
||||||
receipt_no = sale.receipt_no
|
receipt_no = sale.receipt_no
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
@@ -189,12 +190,13 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
account_no = sale.customer.paypar_account_no rescue nil
|
||||||
|
|
||||||
# Check for items for Paypar Cloud
|
# Check for items for Paypar Cloud
|
||||||
if acc_prices.length > 0
|
if acc_prices.length > 0
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => { account_no: nil,
|
:body => { account_no: account_no,
|
||||||
generic_customer_id:generic_customer_id ,
|
generic_customer_id:generic_customer_id ,
|
||||||
campaign_type_id: campaign_type_id,
|
campaign_type_id: campaign_type_id,
|
||||||
receipt_no: receipt_no,
|
receipt_no: receipt_no,
|
||||||
@@ -221,8 +223,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
else
|
else
|
||||||
response = {"status": false, "message": "You have no selected discount item" }
|
response = {"status": false, "message": "You have no selected discount item" }
|
||||||
end
|
end
|
||||||
puts "discountttttttttttt"
|
Rails.logger.debug "-------------- Member Discount Osaka ---------"
|
||||||
puts response.to_json
|
Rails.logger.debug response.to_json
|
||||||
# Re-calc All Amount in Sale
|
# Re-calc All Amount in Sale
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
discount_amount = response["discount_earned"]
|
discount_amount = response["discount_earned"]
|
||||||
@@ -239,7 +241,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
|
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
|
|
||||||
end #end Is Card Payment
|
# end #end Is Card Payment
|
||||||
end
|
end
|
||||||
|
|
||||||
#discount for selected order
|
#discount for selected order
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@rooms = Room.all.active.order('status desc')
|
@rooms = Room.all.active.order('status desc')
|
||||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||||
@orders = Order.all.order('date desc')
|
@orders = Order.all.order('date desc')
|
||||||
@shop = Shop.find_by_id(1)
|
@shop = Shop::ShopDetail
|
||||||
|
|
||||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
end
|
end
|
||||||
@@ -22,6 +22,10 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
|
|
||||||
|
@shop = Shop::ShopDetail
|
||||||
|
@membership = MembershipSetting::MembershipSetting
|
||||||
|
@payment_methods = PaymentMethodSetting.all
|
||||||
|
|
||||||
@dining.bookings.active.each do |booking|
|
@dining.bookings.active.each do |booking|
|
||||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||||
@order_items = Array.new
|
@order_items = Array.new
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
class Origami::InDutiesController < BaseOrigamiController
|
class Origami::InDutiesController < BaseOrigamiController
|
||||||
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
|
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
|
||||||
|
|
||||||
# GET /in_duties
|
# GET /in_duties
|
||||||
# GET /in_duties.json
|
# GET /in_duties.json
|
||||||
def index
|
def index
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@jcbcount = 0
|
@jcbcount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "jcb"
|
if sale_payment.payment_method == "jcb"
|
||||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||||
@@ -26,6 +35,16 @@ class Origami::JcbController < BaseOrigamiController
|
|||||||
cash = params[:amount]
|
cash = params[:amount]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
if(Sale.exists?(sale_id))
|
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)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@mastercount = 0
|
@mastercount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "master"
|
if sale_payment.payment_method == "master"
|
||||||
@mastercount = @mastercount + sale_payment.payment_amount
|
@mastercount = @mastercount + sale_payment.payment_amount
|
||||||
@@ -25,6 +34,16 @@ class Origami::MasterController < BaseOrigamiController
|
|||||||
cash = params[:amount]
|
cash = params[:amount]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
if(Sale.exists?(sale_id))
|
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)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
@mpucount = 0
|
@mpucount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "mpu"
|
if sale_payment.payment_method == "mpu"
|
||||||
@mpucount = @mpucount + sale_payment.payment_amount
|
@mpucount = @mpucount + sale_payment.payment_amount
|
||||||
@@ -26,6 +34,16 @@ class Origami::MpuController < BaseOrigamiController
|
|||||||
cash = params[:amount]
|
cash = params[:amount]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
if(Sale.exists?(sale_id))
|
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)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
sale_item.qty = 1
|
sale_item.qty = 1
|
||||||
sale_item.unit_price = di["price"]
|
sale_item.unit_price = di["price"]
|
||||||
sale_item.taxable_price = di["price"] * 1
|
sale_item.taxable_price = di["price"] * 1
|
||||||
sale_item.is_taxable = 1
|
sale_item.is_taxable = di["is_taxable"]
|
||||||
sale_item.account_id = 0
|
sale_item.account_id = 0
|
||||||
|
|
||||||
sale_item.price = di["price"] * 1
|
sale_item.price = di["price"] * 1
|
||||||
|
|||||||
@@ -24,13 +24,30 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
# Print for First Bill to Customer
|
# Print for First Bill to Customer
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
#shop detail
|
#shop detail
|
||||||
shop_details = Shop.find(1)
|
shop_details = Shop::ShopDetail
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
customer= Customer.find(sale_data.customer_id)
|
customer = Customer.find(sale_data.customer_id)
|
||||||
|
|
||||||
|
# rounding adjustment
|
||||||
|
if shop_details.is_rounding_adj
|
||||||
|
a = sale_data.grand_total % 25 # Modulus
|
||||||
|
b = sale_data.grand_total / 25 # Division
|
||||||
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
|
#calculate rounding if modulus is zero or not zero and division are not even
|
||||||
|
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||||
|
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||||
|
rounding_adj = new_total-sale_data.grand_total
|
||||||
|
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end rounding adjustment
|
||||||
|
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
if customer.membership_id != nil && rebate
|
if customer.membership_id != nil && rebate
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
|
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
|
current_balance = 0
|
||||||
end
|
end
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
@@ -44,7 +61,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
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")
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -54,6 +71,22 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
|
shop_details = Shop::ShopDetail
|
||||||
|
|
||||||
|
# rounding adjustment
|
||||||
|
if shop_details.is_rounding_adj
|
||||||
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
|
b = saleObj.grand_total / 25 # Division
|
||||||
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
|
#calculate rounding if modulus is zero or not zero and division are not even
|
||||||
|
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||||
|
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
|
||||||
|
end
|
||||||
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||||
|
|
||||||
@@ -76,13 +109,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
#shop detail
|
|
||||||
shop_details = Shop.find(1)
|
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
if customer.membership_id != nil && rebate
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||||
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
@@ -92,7 +126,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
|
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -114,6 +148,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@accountable_type = ''
|
@accountable_type = ''
|
||||||
@table_no = ''
|
@table_no = ''
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(@sale_data.customer_id)
|
@customer = Customer.find(@sale_data.customer_id)
|
||||||
accounts = @customer.tax_profiles
|
accounts = @customer.tax_profiles
|
||||||
@@ -127,7 +169,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
# get member information
|
# get member information
|
||||||
if @customer.membership_id != nil && rebate
|
if @customer.membership_id != nil && rebate
|
||||||
response = Customer.get_member_account(@customer)
|
response = Customer.get_member_account(@customer)
|
||||||
puts response.to_json
|
|
||||||
if response["status"]==true
|
if response["status"]==true
|
||||||
response["account_data"].each do |res|
|
response["account_data"].each do |res|
|
||||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||||
@@ -191,12 +232,13 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
#shop detail
|
#shop detail
|
||||||
shop_details = Shop.find(1)
|
shop_details = Shop::ShopDetail
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
if customer.membership_id != nil && rebate
|
if customer.membership_id != nil && rebate
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||||
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
end
|
end
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
@@ -206,7 +248,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
|
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance)
|
||||||
end
|
end
|
||||||
|
|
||||||
def foc
|
def foc
|
||||||
@@ -215,6 +257,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
sub_total = params[:sub_total]
|
sub_total = params[:sub_total]
|
||||||
member_info = nil
|
member_info = nil
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
|
current_balance = nil
|
||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
@@ -240,7 +283,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
customer= Customer.find(saleObj.customer_id)
|
customer= Customer.find(saleObj.customer_id)
|
||||||
|
|
||||||
#shop detail
|
#shop detail
|
||||||
shop_details = Shop.find(1)
|
shop_details = Shop::ShopDetail
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
@@ -249,7 +292,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = 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")
|
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -259,14 +302,15 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@shop = Shop.find_by_id(1)
|
@shop = Shop.find_by_id(1)
|
||||||
|
|
||||||
if @shop.is_rounding_adj
|
if @shop.is_rounding_adj
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
else
|
b = saleObj.grand_total / 25 # Division
|
||||||
new_total = saleObj.grand_total
|
#not calculate rounding if modulus is 0 and division is even
|
||||||
|
#calculate rounding if modulus is zero or not zero and division are not even
|
||||||
|
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
@@ -6,6 +6,15 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
|||||||
payment_method = "paypar"
|
payment_method = "paypar"
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(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
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
|
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
|
||||||
if status == true
|
if status == true
|
||||||
|
|||||||
@@ -5,76 +5,65 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
|||||||
@membership_rebate_balance=0
|
@membership_rebate_balance=0
|
||||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
|
||||||
# limit redeem_amount
|
@shop = Shop::ShopDetail
|
||||||
# rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
|
if @shop.is_rounding_adj
|
||||||
# nonrebate_prices = sale_data.total_amount - rebate_prices
|
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||||
# @payparcount = 0
|
|
||||||
# others = 0
|
|
||||||
# sale_data.sale_payments.each do |sale_payment|
|
|
||||||
# if sale_payment.payment_method == "paypar"
|
|
||||||
# @payparcount = @payparcount + sale_payment.payment_amount
|
|
||||||
# else
|
|
||||||
# others = others + sale_payment.payment_amount
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
|
|
||||||
# if non_rebate_exceed < 0
|
|
||||||
# @redeem_prices = rebate_prices - @payparcount
|
|
||||||
# else
|
|
||||||
# @redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
|
|
||||||
# end
|
|
||||||
|
|
||||||
@payparcount = 0
|
|
||||||
others = 0
|
|
||||||
sale_data.sale_payments.each do |sale_payment|
|
|
||||||
if sale_payment.payment_method == "paypar"
|
|
||||||
@payparcount = @payparcount + sale_payment.payment_amount
|
|
||||||
else
|
else
|
||||||
others = others + sale_payment.payment_amount
|
new_total = sale_data.grand_total
|
||||||
end
|
end
|
||||||
end
|
@rounding_adj = new_total-sale_data.grand_total
|
||||||
@redeem_prices = sale_data.grand_total - @payparcount -others
|
|
||||||
|
@payparcount = 0
|
||||||
|
others = 0
|
||||||
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
|
if sale_payment.payment_method == "paypar"
|
||||||
|
@payparcount = @payparcount + sale_payment.payment_amount
|
||||||
|
else
|
||||||
|
others = others + sale_payment.payment_amount
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@redeem_prices = sale_data.grand_total - @payparcount -others
|
||||||
|
|
||||||
|
|
||||||
if sale_data
|
if sale_data
|
||||||
if sale_data.customer_id
|
if sale_data.customer_id
|
||||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||||
if customer_data
|
if customer_data
|
||||||
@membership_id = customer_data.membership_id
|
@membership_id = customer_data.membership_id
|
||||||
if !@membership_id.nil?
|
if !@membership_id.nil?
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
if membership_setting.gateway_url
|
if membership_setting.gateway_url
|
||||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||||
if member_actions.gateway_url
|
if member_actions.gateway_url
|
||||||
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
|
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
|
||||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||||
merchant_uid= member_actions.merchant_account_id
|
merchant_uid= member_actions.merchant_account_id
|
||||||
auth_token = member_actions.auth_token.to_s
|
auth_token = member_actions.auth_token.to_s
|
||||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
@membership_rebate_balance=membership_data["balance"]
|
@membership_rebate_balance=membership_data["balance"]
|
||||||
@out = true, @membership_rebate_balance,@membership_id
|
@out = true, @membership_rebate_balance,@membership_id
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out =false,0
|
@out =false,0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false,0
|
@out = false,0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
@out = false, 0
|
@out = false, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ class Origami::RoomsController < BaseOrigamiController
|
|||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
|
|
||||||
|
@shop = Shop::ShopDetail
|
||||||
|
@membership = MembershipSetting::MembershipSetting
|
||||||
|
@payment_methods = PaymentMethodSetting.all
|
||||||
|
|
||||||
@room.bookings.active.each do |booking|
|
@room.bookings.active.each do |booking|
|
||||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||||
@order_items = Array.new
|
@order_items = Array.new
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem = saleitemObj.dup
|
@newsaleitem = saleitemObj.dup
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
@newsaleitem.qty = saleitemObj.qty * -1
|
@newsaleitem.qty = saleitemObj.qty * -1
|
||||||
@newsaleitem.unit_price = saleitemObj.unit_price * -1
|
@newsaleitem.unit_price = saleitemObj.unit_price * 1
|
||||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||||
@newsaleitem.price = saleitemObj.price * -1
|
@newsaleitem.price = saleitemObj.price * -1
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||||
@orders = Order.all.order('date desc')
|
@orders = Order.all.order('date desc')
|
||||||
@sale = Sale.find(params[:sale_id])
|
@sale = Sale.find(params[:sale_id])
|
||||||
|
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||||
|
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||||
|
@table_id = Booking.find(@booking).dining_facility_id
|
||||||
|
@dining = DiningFacility.find(@table_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_existing_invoice
|
def add_to_existing_invoice
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@visacount = 0
|
@visacount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "visa"
|
if sale_payment.payment_method == "visa"
|
||||||
@visacount = @visacount + sale_payment.payment_amount
|
@visacount = @visacount + sale_payment.payment_amount
|
||||||
@@ -25,6 +34,17 @@ class Origami::VisaController < BaseOrigamiController
|
|||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(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)
|
||||||
|
#end rounding adjustment
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
|
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,12 +8,19 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
sale = Sale.find_by_sale_id(sale_id)
|
sale = Sale.find_by_sale_id(sale_id)
|
||||||
|
|
||||||
# update count for shift sale
|
# update count for shift sale
|
||||||
# if(sale.sale_status == "completed")
|
if(sale.sale_status == "completed")
|
||||||
if sale.shift_sale_id != nil
|
if sale.shift_sale_id != nil
|
||||||
shift = ShiftSale.find(sale.shift_sale_id)
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
shift.calculate(sale_id, "void")
|
shift.calculate(sale_id, "void")
|
||||||
end
|
end
|
||||||
# end
|
else
|
||||||
|
# void before sale payment complete
|
||||||
|
if sale.shift_sale_id != nil
|
||||||
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
|
shift.total_void = shift.total_void + sale.grand_total
|
||||||
|
shift.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sale.payment_status = 'void'
|
sale.payment_status = 'void'
|
||||||
sale.sale_status = 'void'
|
sale.sale_status = 'void'
|
||||||
@@ -73,6 +80,7 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
if customer.membership_id != nil && rebate
|
if customer.membership_id != nil && rebate
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||||
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
end
|
end
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
@@ -81,7 +89,7 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
discount_price_by_accounts = SaleItem.get_discount_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 = 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")
|
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)
|
||||||
|
|
||||||
#end print
|
#end print
|
||||||
|
|
||||||
@@ -94,5 +102,4 @@ class Origami::VoidController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -7,6 +7,15 @@ class Origami::VoucherController < BaseOrigamiController
|
|||||||
total = sale_data.grand_total
|
total = sale_data.grand_total
|
||||||
@vouchercount = 0
|
@vouchercount = 0
|
||||||
others = 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|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
if sale_payment.payment_method == "voucher"
|
if sale_payment.payment_method == "voucher"
|
||||||
@vouchercount = @vouchercount + sale_payment.payment_amount
|
@vouchercount = @vouchercount + sale_payment.payment_amount
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ class Reports::PaymentMethodController < BaseReportController
|
|||||||
end
|
end
|
||||||
@payment_type = params[:payment_type]
|
@payment_type = params[:payment_type]
|
||||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
|
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
|
||||||
puts @pyament_method.to_json
|
|
||||||
puts "sssssssssssss"
|
|
||||||
@from = from
|
@from = from
|
||||||
@to = to
|
@to = to
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ authorize_resource :class => false
|
|||||||
payment_type = params[:payment_type]
|
payment_type = params[:payment_type]
|
||||||
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
|
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
|
||||||
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
|
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
|
||||||
|
@tax_profiles = TaxProfile.order('order_by asc')
|
||||||
@from = from
|
@from = from
|
||||||
@to = to
|
@to = to
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ class Reports::SaleitemController < BaseReportController
|
|||||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@sale_data, @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)
|
@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)
|
||||||
puts @sale_data.to_json
|
|
||||||
puts "SSSSSSSSSSS"
|
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||||
|
|
||||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ class Settings::MenuItemInstancesController < ApplicationController
|
|||||||
|
|
||||||
def get_instance
|
def get_instance
|
||||||
@id = MenuItemInstance.find(params[:id])
|
@id = MenuItemInstance.find(params[:id])
|
||||||
puts "iddddddddd"
|
|
||||||
puts @id.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /settings/menu_item_instances/1/edit
|
# GET /settings/menu_item_instances/1/edit
|
||||||
@@ -67,12 +65,13 @@ class Settings::MenuItemInstancesController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @settings_menu_item_instances.save
|
if @settings_menu_item_instances.save
|
||||||
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
|
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split(" ")
|
||||||
@settings_menu_item_instances.save
|
@settings_menu_item_instances.save
|
||||||
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' }
|
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' }
|
||||||
format.json { render :show, status: :created, location: @settings_menu_item_instances }
|
format.json { render :show, status: :created, location: @settings_menu_item_instances }
|
||||||
else
|
else
|
||||||
format.html { render :new }
|
flash[:instance_code_error] = @settings_menu_item_instances.errors
|
||||||
|
format.html { redirect_to new_settings_simple_menu_item_menu_item_instance_path }
|
||||||
format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity }
|
format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -105,9 +104,9 @@ class Settings::MenuItemInstancesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
||||||
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
|
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
|
||||||
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
|
#@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
|
||||||
|
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split(" ")
|
||||||
@settings_menu_item_instances.save
|
@settings_menu_item_instances.save
|
||||||
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' }
|
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' }
|
||||||
format.json { render :show, status: :ok, location: @settings_menu_item_instances }
|
format.json { render :show, status: :ok, location: @settings_menu_item_instances }
|
||||||
@@ -154,6 +153,9 @@ class Settings::MenuItemInstancesController < ApplicationController
|
|||||||
else
|
else
|
||||||
@item = MenuItem.find(params[:set_menu_item_id])
|
@item = MenuItem.find(params[:set_menu_item_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# To Only show in Menu item selected attrs
|
||||||
|
@item.item_attributes = MenuItemAttribute.where(id: @item.item_attributes).select("id, name").map { |e| [e.name, e.id] }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
|
|||||||
@@ -29,8 +29,12 @@ class Settings::PromotionsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@promotion = Promotion.new(promotion_params)
|
@promotion = Promotion.new(promotion_params)
|
||||||
@promotion.created_by = current_login_employee.id
|
@promotion.created_by = current_login_employee.id
|
||||||
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
if !@promotion.promo_start_hour.nil?
|
||||||
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
@promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||||
|
end
|
||||||
|
if !@promotion.promo_end_hour.nil?
|
||||||
|
@promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30)
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @promotion.save
|
if @promotion.save
|
||||||
promo_pros = @promotion.promotion_products
|
promo_pros = @promotion.promotion_products
|
||||||
@@ -95,16 +99,23 @@ class Settings::PromotionsController < ApplicationController
|
|||||||
|
|
||||||
def find_parent_item
|
def find_parent_item
|
||||||
res = []
|
res = []
|
||||||
item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
arr_inst = []
|
||||||
if item.nil?
|
item_inst = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
|
||||||
|
if item_inst.nil?
|
||||||
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
|
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
|
||||||
res.push(product.name)
|
res.push(product.name)
|
||||||
res.push(product.item_code)
|
res.push(product.item_code)
|
||||||
else
|
else
|
||||||
# menu_item = item.menu_item.pluck(:name,:item_code)
|
# menu_item = item_inst.menu_item.pluck(:name,:item_code)
|
||||||
res.push(item.item_instance_name)
|
# res.push(item_inst.item_instance_name)
|
||||||
res.push(item.menu_item.item_code)
|
# res.push(item_inst.menu_item.item_code)
|
||||||
|
item_inst.menu_item.menu_item_instances.each do |inst|
|
||||||
|
arr_inst.push({inst.item_instance_code => inst.item_instance_name})
|
||||||
|
end
|
||||||
|
res.push({item_inst.menu_item.item_code => arr_inst})
|
||||||
end
|
end
|
||||||
|
puts "res"
|
||||||
|
p res
|
||||||
render json: res
|
render json: res
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -141,6 +141,6 @@ class Settings::SetMenuItemsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def settings_menu_item_params
|
def settings_menu_item_params
|
||||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
|
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -157,6 +157,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def settings_menu_item_params
|
def settings_menu_item_params
|
||||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
|
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
35
app/controllers/sym_control_controller.rb
Normal file
35
app/controllers/sym_control_controller.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
class SymControlController < BaseController
|
||||||
|
skip_before_action :verify_authenticity_token
|
||||||
|
|
||||||
|
def run
|
||||||
|
sym_path = "/home/yan/symmetric/"
|
||||||
|
check_sym_proc_str = `#{"service SymmetricDS status"}`
|
||||||
|
# Check Sym Installed
|
||||||
|
# if sym_install_status[1] == "false"
|
||||||
|
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
||||||
|
# end
|
||||||
|
|
||||||
|
if check_sym_proc_str.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
|
||||||
|
# Create Sym Table
|
||||||
|
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
|
||||||
|
if check_sym_table
|
||||||
|
sym_sql = Rails.root + "db/sym_master.sql"
|
||||||
|
|
||||||
|
if File.exist? (sym_sql)
|
||||||
|
# Import Sym Sql to db and start sym
|
||||||
|
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
|
||||||
|
stop_sym = system("service SymmetricDS stop")
|
||||||
|
run_sym = system("service SymmetricDS start")
|
||||||
|
if run_sym
|
||||||
|
render :text => "<h1>Success!</h1>"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :text => "<h1>Sym Sql file not found!</h1>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render :text => "<h1>Sym not running!</h1>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -4,7 +4,7 @@ class Transactions::BookingsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
filter = params[:filter]
|
filter = params[:receipt_no]
|
||||||
from = params[:from]
|
from = params[:from]
|
||||||
to = params[:to]
|
to = params[:to]
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class Transactions::CreditNotesController < ApplicationController
|
|||||||
to = params[:to]
|
to = params[:to]
|
||||||
|
|
||||||
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
||||||
@credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
@credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
||||||
|
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
|
||||||
else
|
else
|
||||||
sale = Sale.search_credit_sales(customer,filter,from,to)
|
sale = Sale.search_credit_sales(customer,filter,from,to)
|
||||||
if sale.count > 0
|
if sale.count > 0
|
||||||
|
|||||||
@@ -3,16 +3,13 @@ class Transactions::OrdersController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
|
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
count = params[:count]
|
|
||||||
from = params[:from]
|
from = params[:from]
|
||||||
to = params[:to]
|
to = params[:to]
|
||||||
|
|
||||||
if filter.nil? && from.nil? && to.nil? && count.nil?
|
if filter.nil? && from.nil? && to.nil?
|
||||||
orders = Order.order("order_id desc")
|
orders = Order.order("order_id desc")
|
||||||
|
|
||||||
else
|
else
|
||||||
orders = Order.search(filter,from,to,count)
|
orders = Order.search(filter,from,to)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if !orders.nil?
|
if !orders.nil?
|
||||||
|
|||||||
8
app/jobs/call_waiter_job.rb
Normal file
8
app/jobs/call_waiter_job.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class CallWaiterJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(table,time)
|
||||||
|
ActionCable.server.broadcast "call_waiter_channel",table: table,time:time
|
||||||
|
# Rails.logger.debug "Testing: I'm performing my job with arguments: #{table}"
|
||||||
|
end
|
||||||
|
end
|
||||||
9
app/jobs/check_in_booking_job.rb
Normal file
9
app/jobs/check_in_booking_job.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CheckInBookingJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(table)
|
||||||
|
ActionCable.server.broadcast "check_in_booking_channel",table: table
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
12
app/jobs/checkin_job.rb
Normal file
12
app/jobs/checkin_job.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class CheckinJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def self.perform()
|
||||||
|
table = DiningFacility.get_checkin_booking
|
||||||
|
if table.length > 0
|
||||||
|
ActionCable.server.broadcast "checkin_channel",table: table
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
@@ -4,8 +4,7 @@ class OrderQueueProcessorJob < ApplicationJob
|
|||||||
def perform(order_id, table_id)
|
def perform(order_id, table_id)
|
||||||
# Do something later
|
# Do something later
|
||||||
#Order ID
|
#Order ID
|
||||||
|
order = Order.find(order_id)
|
||||||
order = Order.find(order_id)
|
|
||||||
|
|
||||||
#Execute orders and send to order stations
|
#Execute orders and send to order stations
|
||||||
if order
|
if order
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ class Ability
|
|||||||
can :manage, TaxProfile
|
can :manage, TaxProfile
|
||||||
can :manage, PrintSetting
|
can :manage, PrintSetting
|
||||||
can :manage, Account
|
can :manage, Account
|
||||||
can :manage, Commission
|
|
||||||
can :manage, Commissioner
|
|
||||||
can :manage, Promotion
|
|
||||||
can :manage, Product
|
|
||||||
|
|
||||||
|
|
||||||
can :manage, Order
|
can :manage, Order
|
||||||
can :manage, Booking
|
can :manage, Booking
|
||||||
@@ -46,6 +41,13 @@ class Ability
|
|||||||
can :index, :credit_payment
|
can :index, :credit_payment
|
||||||
can :index, :void_sale
|
can :index, :void_sale
|
||||||
|
|
||||||
|
can :show, :dailysale
|
||||||
|
can :show, :saleitem
|
||||||
|
can :show, :receipt_no
|
||||||
|
can :show, :shiftsale
|
||||||
|
can :show, :credit_payment
|
||||||
|
can :show, :void_sale
|
||||||
|
|
||||||
can :get_customer, Customer
|
can :get_customer, Customer
|
||||||
can :add_customer, Customer
|
can :add_customer, Customer
|
||||||
can :update_sale_by_customer, Customer
|
can :update_sale_by_customer, Customer
|
||||||
@@ -79,6 +81,13 @@ class Ability
|
|||||||
|
|
||||||
can :overall_void, :void
|
can :overall_void, :void
|
||||||
|
|
||||||
|
can :manage, Commission
|
||||||
|
can :manage, Commissioner
|
||||||
|
can :manage, Promotion
|
||||||
|
can :manage, Product
|
||||||
|
|
||||||
|
can :manage, Inventory
|
||||||
|
|
||||||
elsif user.role == "cashier"
|
elsif user.role == "cashier"
|
||||||
|
|
||||||
# can :overall_void, :void
|
# can :overall_void, :void
|
||||||
@@ -113,6 +122,11 @@ class Ability
|
|||||||
|
|
||||||
can :manage, DiningQueue
|
can :manage, DiningQueue
|
||||||
|
|
||||||
|
can :manage, Commission
|
||||||
|
can :manage, Commissioner
|
||||||
|
can :manage, Promotion
|
||||||
|
can :manage, Product
|
||||||
|
|
||||||
elsif user.role == "account"
|
elsif user.role == "account"
|
||||||
|
|
||||||
can :index, :dailysale
|
can :index, :dailysale
|
||||||
@@ -121,6 +135,12 @@ class Ability
|
|||||||
can :index, :shiftsale
|
can :index, :shiftsale
|
||||||
can :index, :credit_payment
|
can :index, :credit_payment
|
||||||
can :index, :void_sale
|
can :index, :void_sale
|
||||||
|
can :show, :dailysale
|
||||||
|
can :show, :saleitem
|
||||||
|
can :show, :receipt_no
|
||||||
|
can :show, :shiftsale
|
||||||
|
can :show, :credit_payment
|
||||||
|
can :show, :void_sale
|
||||||
|
|
||||||
elsif user.role == "supervisor"
|
elsif user.role == "supervisor"
|
||||||
|
|
||||||
@@ -148,6 +168,12 @@ class Ability
|
|||||||
can :show, :payment
|
can :show, :payment
|
||||||
can :reprint, :payment
|
can :reprint, :payment
|
||||||
can :rounding_adj, :payment
|
can :rounding_adj, :payment
|
||||||
|
|
||||||
|
can :manage, Commission
|
||||||
|
can :manage, Commissioner
|
||||||
|
can :manage, Promotion
|
||||||
|
can :manage, Product
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ class Customer < ApplicationRecord
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false, message: "Can't connect server"}
|
response = { status: false, message: "Can't connect server"}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "--------Get Member Account response -------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -131,6 +132,8 @@ class Customer < ApplicationRecord
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false, message: "Can't connect server"}
|
response = { status: false, message: "Can't connect server"}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "--------Update Membership response -------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
||||||
end
|
end
|
||||||
@@ -142,6 +145,10 @@ class Customer < ApplicationRecord
|
|||||||
sales.each do |sale|
|
sales.each do |sale|
|
||||||
if sale.customer.membership_id
|
if sale.customer.membership_id
|
||||||
response = self.rebat(Sale.find(sale.sale_id))
|
response = self.rebat(Sale.find(sale.sale_id))
|
||||||
|
#record an payment in sale-audit
|
||||||
|
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} "
|
||||||
|
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
status = sale.update_attributes(rebate_status: "true")
|
status = sale.update_attributes(rebate_status: "true")
|
||||||
end
|
end
|
||||||
@@ -184,12 +191,17 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
# Control for Paypar Cloud
|
# Control for Paypar Cloud
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
|
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,
|
||||||
receipt_no: receipt_no,auth_token:auth_token}.to_json,
|
total_sale_transaction_amount: sObj.grand_total,
|
||||||
:headers => {
|
merchant_uid:merchant_uid,
|
||||||
'Content-Type' => 'application/json',
|
total_amount: total_amount,
|
||||||
'Accept' => 'application/json; version=2'
|
campaign_type_id: campaign_type_id,
|
||||||
}, :timeout => 10)
|
receipt_no: receipt_no,
|
||||||
|
auth_token:auth_token}.to_json,
|
||||||
|
:headers => {
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Accept' => 'application/json; version=2'
|
||||||
|
}, :timeout => 10)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { "status": false , "message": "Connect To" }
|
response = { "status": false , "message": "Connect To" }
|
||||||
|
|
||||||
@@ -202,6 +214,8 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
return response
|
return response
|
||||||
|
Rails.logger.debug "--------Update Rebate response -------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -236,6 +250,8 @@ class Customer < ApplicationRecord
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false, message: "Can't connect server"}
|
response = { status: false, message: "Can't connect server"}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "--------Search Paypar Account No response -------"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
return response
|
return response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_current_checkout_booking
|
def get_current_checkout_booking
|
||||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is not null and checkout_by is null").limit(1)
|
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||||
if booking.count > 0 then
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
else
|
else
|
||||||
@@ -78,19 +78,75 @@ class DiningFacility < ApplicationRecord
|
|||||||
def get_checkout_booking
|
def get_checkout_booking
|
||||||
booking = self.get_current_checkout_booking
|
booking = self.get_current_checkout_booking
|
||||||
if booking
|
if booking
|
||||||
|
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||||
|
free_time_min = 0
|
||||||
|
if !lookup_checkout_time.nil?
|
||||||
|
if lookup_checkout_time[0][0] == 'min'
|
||||||
|
free_time_min = (lookup_checkout_time[0][1]).to_i
|
||||||
|
else
|
||||||
|
free_time_min = 15
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
now = Time.now.utc
|
now = Time.now.utc
|
||||||
hr = (now.strftime("%H").to_i).to_int
|
hr = (now.strftime("%H").to_i).to_int
|
||||||
min = (now.strftime("%M").to_i).to_int
|
min = (now.strftime("%M").to_i).to_int
|
||||||
|
if !booking.checkout_at.nil?
|
||||||
checkout_at = booking.checkout_at.utc
|
checkout_at = booking.checkout_at.utc
|
||||||
|
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
|
||||||
checkout_at = checkout_at - hr.hour
|
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
|
||||||
checkout_at = checkout_at - min.minutes
|
checkout_at_min -= min
|
||||||
checkout_at = checkout_at.utc.strftime("%M").to_i
|
if (checkout_at_hr < hr)
|
||||||
|
return booking
|
||||||
if checkout_at <= 15
|
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
||||||
return booking
|
return booking
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_checkin_booking
|
||||||
|
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||||
|
arr_booking = Array.new
|
||||||
|
if bookings
|
||||||
|
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||||
|
free_time_min = 0
|
||||||
|
if !lookup_checkout_time.nil?
|
||||||
|
if lookup_checkout_time[0][0] == 'min'
|
||||||
|
free_time_min = (lookup_checkout_time[0][1]).to_i
|
||||||
|
else
|
||||||
|
free_time_min = 15
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bookings.each do |booking|
|
||||||
|
now = Time.now.utc
|
||||||
|
hr = (now.strftime("%H").to_i).to_int
|
||||||
|
min = (now.strftime("%M").to_i).to_int
|
||||||
|
if !booking.checkout_at.nil?
|
||||||
|
checkout_at = booking.checkout_at.utc
|
||||||
|
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
|
||||||
|
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
|
||||||
|
checkout_at_min -= min
|
||||||
|
if (checkout_at_hr < hr)
|
||||||
|
arr_booking.push({'table_id' => booking.dining_facility_id})
|
||||||
|
elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
|
||||||
|
arr_booking.push({'table_id' => booking.dining_facility_id})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return arr_booking
|
||||||
|
end
|
||||||
|
|
||||||
|
#send order items and send to order queue
|
||||||
|
def self.check_in_booking(table_id)
|
||||||
|
table = DiningFacility.find(table_id)
|
||||||
|
#Send to background job for processing
|
||||||
|
CheckInBookingJob.perform_later(table)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,127 +18,122 @@ class License
|
|||||||
if (server != "")
|
if (server != "")
|
||||||
self.class.base_uri server
|
self.class.base_uri server
|
||||||
end
|
end
|
||||||
|
|
||||||
# @secret = ENV["aes_key"]
|
|
||||||
# @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def shop_code
|
# For Cloud
|
||||||
if ( self.subdomain.length > 3)
|
def detail_with_local_cache(lookup)
|
||||||
return self.subdomain[0,3].upcase
|
aes = MyAesCrypt.new
|
||||||
else
|
aes_key, aes_iv = aes.export_to_file(lookup)
|
||||||
return self.subdomain.upcase
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def detail_with_local_cache(lookup, key, iv)
|
|
||||||
##Check from local redis - if available load local otherwise get from remote
|
##Check from local redis - if available load local otherwise get from remote
|
||||||
cache_key = "#{lookup}:license:#{key}:hostname"
|
cache_key = "#{lookup}:license:#{aes_key}:hostname"
|
||||||
|
|
||||||
# No Needs for current
|
|
||||||
# @secret = key
|
|
||||||
|
|
||||||
cache_license = nil
|
cache_license = nil
|
||||||
|
|
||||||
##Get redis connection from connection pool
|
##Get redis connection from connection pool
|
||||||
Redis.current do |conn|
|
redis = Redis.new
|
||||||
cache_license = conn.get(cache_key)
|
cache_license = redis.get(cache_key)
|
||||||
end
|
|
||||||
|
|
||||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||||
if cache_license.nil?
|
if cache_license.nil?
|
||||||
##change the d/e key
|
##change the d/e key
|
||||||
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
# @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
||||||
@params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} }
|
@params = { query: { lookup_type: self.server_mode, lookup: lookup, iv_key: aes_iv} }
|
||||||
response = self.class.get("/subdomain", @params)
|
response = self.class.get("/subdomain", @params)
|
||||||
@license = response.parsed_response
|
@license = response.parsed_response
|
||||||
|
|
||||||
if (@license["status"] == true)
|
if (@license["status"] == true)
|
||||||
|
assign(aes_key, aes_iv)
|
||||||
assign()
|
|
||||||
|
|
||||||
Rails.logger.info "License - " + response.parsed_response.to_s
|
Rails.logger.info "License - " + response.parsed_response.to_s
|
||||||
|
|
||||||
Redis.current do |conn|
|
redis = Redis.new
|
||||||
##Remote - store the remote response in local redis cache
|
redis.set(cache_key, Marshal.dump(@license))
|
||||||
conn.set(cache_key, Marshal.dump(@license))
|
# redis.sadd("License:cache:keys", cache_key)
|
||||||
##ADD to List to remove later
|
# Redis.current do |conn|
|
||||||
conn.sadd("License:cache:keys", cache_key)
|
# ##Remote - store the remote response in local redis cache
|
||||||
end
|
# conn.set(cache_key, Marshal.dump(@license))
|
||||||
|
# ##ADD to List to remove later
|
||||||
|
# conn.sadd("License:cache:keys", cache_key)
|
||||||
|
# end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@license = Marshal.load(cache_license)
|
||||||
|
assign(aes_key, aes_iv)
|
||||||
Rails.logger.info 'API License'
|
Rails.logger.info 'API License'
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# For Local System
|
||||||
def detail_with_local_file()
|
def detail_with_local_file()
|
||||||
has_license = true #verify_license()
|
renewal_date_str = read_license("renewable_date")
|
||||||
|
|
||||||
if has_license
|
if check_expiring(renewal_date_str)
|
||||||
# puts "VERIFIED"
|
# return for all ok
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
has_license = verify_license()
|
||||||
|
|
||||||
|
if has_license
|
||||||
|
# return for expiring
|
||||||
|
return 2
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# if cache_license.nil?
|
|
||||||
# ##change the d/e key
|
|
||||||
# @params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} }
|
|
||||||
|
|
||||||
# response = self.class.get("/request_license", @params)
|
|
||||||
# @license = response.parsed_response
|
|
||||||
|
|
||||||
# if (@license["status"] == true)
|
|
||||||
|
|
||||||
# assign()
|
|
||||||
|
|
||||||
# Rails.logger.info "License - " + response.parsed_response.to_s
|
|
||||||
|
|
||||||
# Redis.current do |conn|
|
|
||||||
# ##Remote - store the remote response in local redis cache
|
|
||||||
# conn.set(cache_key, Marshal.dump(@license))
|
|
||||||
# ##ADD to List to remove later
|
|
||||||
# conn.sadd("License:cache:keys", cache_key)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# return true
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Rails.logger.info 'API License'
|
|
||||||
|
|
||||||
# else
|
|
||||||
# @license = Marshal.load(cache_license) if cache_license
|
|
||||||
|
|
||||||
# Rails.logger.info 'Cache License'
|
|
||||||
|
|
||||||
# if (@license["status"] == true)
|
|
||||||
# assign()
|
|
||||||
# return true
|
|
||||||
# end
|
|
||||||
# end
|
# end
|
||||||
# return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def detail
|
# License Activation
|
||||||
response = self.class.get("/subdomain", @options)
|
def license_activate (shop, license_key, db_host, db_schema, db_user, db_password)
|
||||||
@license = response.parsed_response
|
aes = MyAesCrypt.new
|
||||||
|
aes_key, aes_iv = aes.export_key(license_key)
|
||||||
|
|
||||||
Rails.logger.debug "License - " + response.parsed_response.to_s
|
@params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } }
|
||||||
|
response = self.class.get("/activate", @params)
|
||||||
|
@activate = response.parsed_response
|
||||||
|
|
||||||
|
if (@activate["status"])
|
||||||
|
##Check from local redis - if available load local otherwise get from remote
|
||||||
|
cache_key = "shop:#{@activate["shop_name"]}"
|
||||||
|
|
||||||
if (@license["status"] == true)
|
cache_license = nil
|
||||||
assign()
|
|
||||||
|
|
||||||
return true
|
##Get redis connection from connection pool
|
||||||
end
|
redis = Redis.new
|
||||||
|
cache_license = redis.get(cache_key)
|
||||||
|
|
||||||
return false
|
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||||
|
|
||||||
|
if cache_license.nil?
|
||||||
|
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
|
||||||
|
redis = Redis.new
|
||||||
|
redis.set(cache_key, Marshal.dump(cache))
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.logger.info "License - " + response.parsed_response.to_s
|
||||||
|
|
||||||
|
response = create_license_file(@activate)
|
||||||
|
if(response[:status])
|
||||||
|
sym_path = "/home/yan/symmetric/"
|
||||||
|
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
|
||||||
|
if(response[:status])
|
||||||
|
response = run_symmetric(sym_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
|
||||||
|
end
|
||||||
|
return response
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_license
|
def verify_license
|
||||||
api_token = read_license("api_token")
|
api_token = read_license_no_decrypt("api_token")
|
||||||
@options = { query: {lookup_type: "application", token: api_token} }
|
@params = { query: {lookup_type: "application", api_token: api_token} }
|
||||||
response = self.class.get("/verify", @options)
|
response = self.class.get("/verify", @params)
|
||||||
@varified = response.parsed_response
|
@varified = response.parsed_response
|
||||||
|
|
||||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
||||||
@@ -152,38 +147,23 @@ class License
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_remote_license(license_key)
|
# Check Expired before 30 days
|
||||||
# @options = { query: {device: "cloud", key: license_key, skey: @secret, token: Rails.application.secrets.provision_key} }
|
def check_expiring(renewal_date_str)
|
||||||
@options = { query: {lookup_type: "application", encrypted_key: @secret, token: SECRETS_CONFIG['provision_key']} }
|
if !renewal_date_str.empty?
|
||||||
response = self.class.get("/license", @options)
|
renewal_date = DateTime.parse(renewal_date_str)
|
||||||
|
renewal_date > Date.today.advance(:days => 30)
|
||||||
@license = response.parsed_response
|
|
||||||
|
|
||||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
|
||||||
if (@license["status"])
|
|
||||||
assign()
|
|
||||||
end
|
end
|
||||||
return @license["status"]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_by_api_token(api_token)
|
# Check License expired date from PROVISION SERVER
|
||||||
@options = { query: {device: "SX", api_token: api_token, skey: @secret, token: SECRETS_CONFIG['provision_key']} }
|
def check_expired(renewal_date_str)
|
||||||
response = self.class.get("/verify", @options)
|
expired_date_str = read_license("renewable_date")
|
||||||
|
renewal_date = DateTime.parse(renewal_date_str)
|
||||||
|
|
||||||
@license = response.parsed_response
|
if(renewal_date_str != expired_date_str)
|
||||||
|
update_license("renewable_date", renewal_date_str)
|
||||||
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
|
|
||||||
if (@license["status"])
|
|
||||||
assign()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return @license["status"]
|
|
||||||
end
|
|
||||||
#Load License is remove from the cloud license because - this license is must be validated against subdmain instead of license.data from file.
|
|
||||||
|
|
||||||
|
|
||||||
def check_expired(renewal_date)
|
|
||||||
if (renewal_date < Date.today)
|
if (renewal_date < Date.today)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
@@ -191,67 +171,259 @@ class License
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check License File exists
|
||||||
def self.check_license_file
|
def self.check_license_file
|
||||||
return File.exist?("config/license.yml")
|
return File.exist?("config/license.yml")
|
||||||
end
|
end
|
||||||
|
|
||||||
# read line by key for license file
|
# read line by key for license file
|
||||||
def read_license(key)
|
def read_license(key_name)
|
||||||
|
decrypted_line = ""
|
||||||
|
key, iv = get_redis_key()
|
||||||
|
|
||||||
|
if File.exist?("config/license.yml")
|
||||||
|
File.open("config/license.yml").each do |line|
|
||||||
|
if line.include? (key_name)
|
||||||
|
decrypted_line_array = line.split(": ")
|
||||||
|
decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return decrypted_line
|
||||||
|
end
|
||||||
|
|
||||||
|
# read line by key for license file without decrypt
|
||||||
|
def read_license_no_decrypt(key)
|
||||||
decrypted_line = ""
|
decrypted_line = ""
|
||||||
if File.exist?("config/license.yml")
|
if File.exist?("config/license.yml")
|
||||||
File.open("config/license.yml").each do |line|
|
File.open("config/license.yml").each do |line|
|
||||||
if line.include? (key)
|
if line.include? (key)
|
||||||
decrypted_line_array = line.split(":")
|
decrypted_line_array = line.split(": ")
|
||||||
decrypted_line = AESCrypt.decrypt(decrypted_line_array[1])
|
decrypted_line = decrypted_line_array[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return decrypted_line
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
# Update license file for line
|
||||||
def assign
|
def update_license(content, new_content)
|
||||||
# self.name = @license["name"]
|
key, iv = get_redis_key()
|
||||||
# self.address_1 = @license["address_1"]
|
|
||||||
# self.address_2 = @license["address_2"]
|
|
||||||
# self.township = @license["township"]
|
|
||||||
# self.city = @license["city"]
|
|
||||||
# self.country = @license["country"]
|
|
||||||
# self.email = @license["email"]
|
|
||||||
# self.phone = @license["phone"]
|
|
||||||
# self.fax = @license["fax"]
|
|
||||||
# self.logo = @license["logo"]
|
|
||||||
# self.localhost_address = @license["localhost_address"]
|
|
||||||
# self.subdomain = @license["subdomain"]
|
|
||||||
# self.plan_activation_date = Date.parse(@license["plan_activation_date"])
|
|
||||||
# self.plan_next_renewal_date = Date.parse(@license["plan_next_renewal_date"])
|
|
||||||
|
|
||||||
## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d")
|
if !new_content.include? "=="
|
||||||
## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d")
|
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
|
||||||
|
|
||||||
|
|
||||||
# self.plan_max_products = @license["plan_max_products"].to_i
|
|
||||||
# self.plan_max_customers = @license["plan_max_customers"].to_i
|
|
||||||
# self.plan_active_connections = @license["plan_active_connections"].to_i
|
|
||||||
salt = @license["secret_key"]
|
|
||||||
|
|
||||||
if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
|
|
||||||
self.dbhost = AESCrypt.decrypt(@license["dbhost"], salt)
|
|
||||||
self.dbschema = AESCrypt.decrypt(@license["dbschema"], salt)
|
|
||||||
self.dbusername = AESCrypt.decrypt(@license["dbusername"], salt)
|
|
||||||
self.dbpassword = AESCrypt.decrypt(@license["dbpassword"], salt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# self.exchange_unqiue_id = @license["exchange_unqiue_id"]
|
content_str = read_license_no_decrypt(content)
|
||||||
|
if File.exist?("config/license.yml")
|
||||||
|
file_str = File.read("config/license.yml")
|
||||||
|
new_file_str = file_str.gsub(content_str, encode_str(crypted_str))
|
||||||
|
|
||||||
# self.localqueue_host= @license["localqueue_host"]
|
# To write changes to the file, use:
|
||||||
# self.localqueue_user= @license["localqueue_user"]
|
File.open("config/license.yml", "w") {|file| file.puts new_file_str }
|
||||||
# self.localqueue_password= @license["localqueue_password"]
|
|
||||||
|
|
||||||
# self.remotequeue_host = @license["remotequeue_host"]
|
# File.open("config/license.yml").each do |line|
|
||||||
# self.remotequeue_user = @license["remotequeue_user"]
|
# new_file_str = line.gsub(content, crypted_str)
|
||||||
# self.remotequeue_password = @license["remotequeue_password"]
|
# f.put
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def get_redis_key
|
||||||
|
iv = ""
|
||||||
|
key = ""
|
||||||
|
shop = read_license_no_decrypt("shop_name")
|
||||||
|
##Check from local redis - if available load local otherwise get from remote
|
||||||
|
cache_key = "shop:#{shop.chomp}"
|
||||||
|
|
||||||
|
cache_shop = nil
|
||||||
|
|
||||||
|
##Get redis connection from connection pool
|
||||||
|
redis = Redis.new
|
||||||
|
cache_shop = redis.get(cache_key)
|
||||||
|
|
||||||
|
if !cache_shop.nil?
|
||||||
|
@shop = Marshal.load(cache_shop)
|
||||||
|
key = @shop["key"]
|
||||||
|
iv = @shop["iv"]
|
||||||
|
end
|
||||||
|
return key, iv
|
||||||
|
end
|
||||||
|
|
||||||
|
def encode_str(str)
|
||||||
|
return Base64.encode64(str)
|
||||||
|
end
|
||||||
|
|
||||||
|
def decode_str(str)
|
||||||
|
return Base64.decode64(str)
|
||||||
|
end
|
||||||
|
|
||||||
|
# License File Creation
|
||||||
|
def create_license_file(response_data)
|
||||||
|
if File.exist?("config/license.yml")
|
||||||
|
delete_license_file
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
# Licese File Creation
|
||||||
|
File.open("config/license.yml", "w") do |f|
|
||||||
|
f.puts("iv_key: #{response_data['iv_key']}")
|
||||||
|
f.puts("shop_name: #{response_data['shop_name']}")
|
||||||
|
f.puts("email: #{response_data['email']}")
|
||||||
|
f.puts("telephone: #{response_data['telephone']}")
|
||||||
|
f.puts("fax: #{response_data['fax']}")
|
||||||
|
f.puts("address: #{response_data['address']}")
|
||||||
|
f.puts("dbhost: #{response_data['dbhost']}")
|
||||||
|
f.puts("dbschema: #{response_data['dbschema']}")
|
||||||
|
f.puts("dbusername: #{response_data['dbusername']}")
|
||||||
|
f.puts("dbpassword: #{response_data['dbpassword']}")
|
||||||
|
f.puts("api_token: #{response_data['api_token']}")
|
||||||
|
f.puts("app_token: #{response_data['app_token']}")
|
||||||
|
f.puts("plan_sku: #{response_data['plan_sku']}")
|
||||||
|
f.puts("renewable_date: #{response_data['renewable_date']}")
|
||||||
|
f.puts("plan_name: #{response_data['plan_name']}")
|
||||||
|
end
|
||||||
|
rescue IOError
|
||||||
|
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||||
|
end
|
||||||
|
response = { "status": true, "message": "Success Activation. License also created."}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Symmetric Configuration
|
||||||
|
def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password)
|
||||||
|
if File.directory? (sym_location)
|
||||||
|
begin
|
||||||
|
# sx properties create
|
||||||
|
f = File.open(sym_location + "engines/sx.properties", "w")
|
||||||
|
f.write("engine.name=sx\n")
|
||||||
|
f.write("db.driver=com.mysql.jdbc.Driver\n")
|
||||||
|
f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n")
|
||||||
|
f.write("db.user=#{db_user}\n")
|
||||||
|
f.write("db.password=#{db_password}\n")
|
||||||
|
f.write("registration.url=\n")
|
||||||
|
f.write("sync.url=http://#{db_host}:31415/sync/sx\n")
|
||||||
|
f.write("group.id=sx\n")
|
||||||
|
f.write("external.id=000\n")
|
||||||
|
f.write("job.purge.period.time.ms=7200000\n")
|
||||||
|
f.write("job.routing.period.time.ms=5000\n")
|
||||||
|
f.write("job.push.period.time.ms=10000\n")
|
||||||
|
f.write("job.pull.period.time.ms=10000\n")
|
||||||
|
f.write("initial.load.create.first=true\n")
|
||||||
|
f.write("initial.load.use.extract.job.enabled=true\n")
|
||||||
|
f.close
|
||||||
|
|
||||||
|
# read from license file
|
||||||
|
shop_name = read_license_no_decrypt("shop_name")
|
||||||
|
dbhost = read_license("dbhost")
|
||||||
|
dbschema = read_license("dbschema")
|
||||||
|
dbusername = read_license("dbusername")
|
||||||
|
dbpassword = read_license("dbpassword")
|
||||||
|
|
||||||
|
# shop properties create
|
||||||
|
f = File.open(sym_location + "engines/#{shop_name}.properties", "w")
|
||||||
|
f.write("engine.name=#{shop_name}\n")
|
||||||
|
f.write("db.driver=com.mysql.jdbc.Driver\n")
|
||||||
|
f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n")
|
||||||
|
f.write("db.user=#{dbusername}\n")
|
||||||
|
f.write("db.password=#{dbpassword}\n")
|
||||||
|
f.write("registration.url=http://#{db_host}:31415/sync/sx\n")
|
||||||
|
f.write("group.id=store\n")
|
||||||
|
f.write("external.id=001\n")
|
||||||
|
f.write("job.routing.period.time.ms=5000\n")
|
||||||
|
f.write("job.push.period.time.ms=10000\n")
|
||||||
|
f.write("job.pull.period.time.ms=10000\n")
|
||||||
|
# f.write("initial.load.create.first=true\n")
|
||||||
|
# f.write("initial.load.use.extract.job.enabled=true\n")
|
||||||
|
f.close
|
||||||
|
rescue IOError
|
||||||
|
response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"}
|
||||||
|
end
|
||||||
|
response = { "status": true, "message": "Success Activation. License also created."}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Run Symmetric
|
||||||
|
def run_symmetric(sym_path)
|
||||||
|
# check_sym_proc_str = `#{sym_path + "bin/sym_service status"}`
|
||||||
|
# check_sym_proc_str = check_sym_proc_str.split("\n")
|
||||||
|
# sym_install_status = check_sym_proc_str[0].split(": ")
|
||||||
|
|
||||||
|
check_sym_proc_str = `#{"service SymmetricDS status"}`
|
||||||
|
|
||||||
|
# Check Sym Installed
|
||||||
|
# if sym_install_status[1] == "false"
|
||||||
|
# response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"}
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Run Sym Service
|
||||||
|
sym_run_status = check_sym_running(check_sym_proc_str, sym_path)
|
||||||
|
if sym_run_status
|
||||||
|
# Create Sym Table
|
||||||
|
check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables")
|
||||||
|
if check_sym_table
|
||||||
|
sym_sql = Rails.root + "db/sym_master.sql"
|
||||||
|
|
||||||
|
if File.exist? (sym_sql)
|
||||||
|
# Import Sym Sql to db and start sym
|
||||||
|
run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s)
|
||||||
|
stop_sym = system("service SymmetricDS stop")
|
||||||
|
run_sym = system("service SymmetricDS start")
|
||||||
|
if run_sym
|
||||||
|
response = { "status": true, "message": "Activation is success and Configuration done..."}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check Symmetric Running
|
||||||
|
def check_sym_running(status, sym_path)
|
||||||
|
# Run Sym Service
|
||||||
|
# if status.include? "Server is already running"
|
||||||
|
# return true
|
||||||
|
# elsif status.include? "false"
|
||||||
|
# sym_start_str = `#{sym_path + "bin/sym_service start"}`
|
||||||
|
# if sym_start_str.include? "Started"
|
||||||
|
# return true
|
||||||
|
# else
|
||||||
|
# check_sym_running(sym_start_status[0])
|
||||||
|
# end
|
||||||
|
# else
|
||||||
|
# return true
|
||||||
|
# end
|
||||||
|
|
||||||
|
if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running"
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Delete License File
|
||||||
|
def delete_license_file
|
||||||
|
File.delete("config/license.yml") if File.exist?("config/license.yml")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Assign db info for Cloud
|
||||||
|
def assign(aes_key, aes_iv)
|
||||||
|
key = Base64.decode64(aes_key)
|
||||||
|
iv = Base64.decode64(aes_iv)
|
||||||
|
|
||||||
|
if (@license["dbhost"] || @license["dbschema"] || @license["dbusername"] || @license["dbpassword"] )
|
||||||
|
host = Base64.decode64(@license["dbhost"])
|
||||||
|
dbschema = Base64.decode64(@license["dbschema"])
|
||||||
|
dbusername = Base64.decode64(@license["dbusername"])
|
||||||
|
dbpassword = Base64.decode64(@license["dbpassword"])
|
||||||
|
|
||||||
|
self.dbhost = AESCrypt.decrypt_data(host, key, iv, ENV['CIPHER_TYPE'])
|
||||||
|
self.dbschema = AESCrypt.decrypt_data(dbschema, key, iv, ENV['CIPHER_TYPE'])
|
||||||
|
self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE'])
|
||||||
|
self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE'])
|
||||||
|
end
|
||||||
|
|
||||||
# self.api_token = @license["api_token"]
|
|
||||||
# self.app_token = @license["app_token"]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
class MembershipSetting < ApplicationRecord
|
class MembershipSetting < ApplicationRecord
|
||||||
|
MembershipSetting = MembershipSetting.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class MenuItem < ApplicationRecord
|
|||||||
has_many :menu_item_sets
|
has_many :menu_item_sets
|
||||||
has_many :item_sets, through: :menu_item_sets
|
has_many :item_sets, through: :menu_item_sets
|
||||||
|
|
||||||
validates_presence_of :item_code, :name, :type, :min_qty, :taxable,:account_id
|
validates_presence_of :item_code, :name, :type, :min_qty,:account_id
|
||||||
validates_uniqueness_of :item_code
|
validates_uniqueness_of :item_code
|
||||||
|
|
||||||
default_scope { order('item_code asc') }
|
default_scope { order('item_code asc') }
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ class MenuItemInstance < ApplicationRecord
|
|||||||
has_many :menu_instance_item_sets
|
has_many :menu_instance_item_sets
|
||||||
has_many :item_sets, through: :menu_instance_item_sets
|
has_many :item_sets, through: :menu_instance_item_sets
|
||||||
# before_create :generate_menu_item_instance_code
|
# before_create :generate_menu_item_instance_code
|
||||||
validates_presence_of :item_instance_code
|
# validates_presence_of :item_instance_code
|
||||||
# validates_uniqueness_of :item_instance_code
|
|
||||||
|
validates_uniqueness_of :item_instance_code
|
||||||
|
|
||||||
def self.findParentCategory(item)
|
def self.findParentCategory(item)
|
||||||
if item.menu_category_id
|
if item.menu_category_id
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
require 'openssl'
|
||||||
|
require 'base64'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
class MyAesCrypt
|
class MyAesCrypt
|
||||||
@cipher = ""
|
@cipher = ""
|
||||||
|
|
||||||
@@ -7,14 +11,51 @@ class MyAesCrypt
|
|||||||
|
|
||||||
def export_key(passphrase)
|
def export_key(passphrase)
|
||||||
# We want a 256 bit key symetric key based on passphrase
|
# We want a 256 bit key symetric key based on passphrase
|
||||||
|
# for cloud is lookup
|
||||||
|
# for local is license_key
|
||||||
|
# iv_salt = passphrase+"c2l"
|
||||||
|
passphrase = passphrase + ENV['SX_KEY']
|
||||||
|
passphrase = passphrase.gsub(".","_")
|
||||||
digest = Digest::SHA256.new
|
digest = Digest::SHA256.new
|
||||||
key = digest.update(passphrase)
|
key_digest = digest.update(passphrase)
|
||||||
key = digest.digest
|
key = key_digest.digest
|
||||||
ENV['AES_KEY'] = cipher_key = key # stores the key in key, and also sets the generated key on the @cipher
|
|
||||||
ENV['AES_IV'] = cipher_iv = @cipher.random_iv # stores the iv in iv, and also sets the generated iv on the @cipher
|
# iv = iv_digest.digest
|
||||||
|
ENV['AES_KEY'] = cipher_key = Base64.encode64(key) # stores the key in key, and also sets the generated key on the @cipher
|
||||||
|
ENV['AES_IV'] = cipher_iv = Base64.encode64(@cipher.random_iv) # stores the iv in iv, and also sets the generated iv on the @cipher
|
||||||
return cipher_key, cipher_iv
|
return cipher_key, cipher_iv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def export_to_file(passphrase)
|
||||||
|
file_path = "config/shops.json"
|
||||||
|
aes_key, aes_iv = export_key(passphrase)
|
||||||
|
tmpHash = {
|
||||||
|
"lookup" => passphrase,
|
||||||
|
"value" =>
|
||||||
|
{
|
||||||
|
"key" => aes_key,
|
||||||
|
"iv" => aes_iv
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shop_data = File.read(file_path)
|
||||||
|
|
||||||
|
shop_json = JSON.parse(shop_data)
|
||||||
|
shop_json["data"].each do |j|
|
||||||
|
if j["lookup"] == passphrase
|
||||||
|
return j["value"]["key"], j["value"]["iv"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shop_json["data"] << tmpHash
|
||||||
|
|
||||||
|
File.open(file_path, "w") { |io|
|
||||||
|
io.puts JSON.pretty_generate(shop_json)
|
||||||
|
}
|
||||||
|
|
||||||
|
return aes_key, aes_iv
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def encrypt(data)
|
def encrypt(data)
|
||||||
cipher.encrypt
|
cipher.encrypt
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
|
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
|
||||||
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
||||||
self.employee_name)
|
self.employee_name, menu_item[:taxable])
|
||||||
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
@@ -363,18 +363,18 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search(filter,from,to,count)
|
def self.search(filter,from,to)
|
||||||
if count.to_i > 0
|
if filter.blank?
|
||||||
item_count = "and item_count = '#{count}'"
|
keyword = ''
|
||||||
else
|
else
|
||||||
item_count = ''
|
keyword = "order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%"
|
||||||
end
|
end
|
||||||
if from.present? && to.present?
|
|
||||||
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to)
|
if from.present? && to.present?
|
||||||
elsif !from.present? && !to.present? && count.present?
|
order = Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
|
||||||
Order.where("item_count = '#{count}'")
|
query = order.where(keyword)
|
||||||
else
|
else
|
||||||
Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class OrderItem < ApplicationRecord
|
|||||||
# option_values : [],
|
# option_values : [],
|
||||||
# sub_order_items : [],
|
# sub_order_items : [],
|
||||||
# }
|
# }
|
||||||
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
|
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by, taxable)
|
||||||
|
|
||||||
orderitem = OrderItem.create do |oitem|
|
orderitem = OrderItem.create do |oitem|
|
||||||
oitem.order_id = order_id
|
oitem.order_id = order_id
|
||||||
@@ -31,6 +31,7 @@ class OrderItem < ApplicationRecord
|
|||||||
oitem.account_id = account_id
|
oitem.account_id = account_id
|
||||||
oitem.qty = qty
|
oitem.qty = qty
|
||||||
oitem.price = price
|
oitem.price = price
|
||||||
|
oitem.taxable = taxable
|
||||||
oitem.options = options
|
oitem.options = options
|
||||||
oitem.set_menu_items = set_menu_items
|
oitem.set_menu_items = set_menu_items
|
||||||
oitem.item_order_by = item_order_by #person who order this. * If emenu - it will be login user on the app
|
oitem.item_order_by = item_order_by #person who order this. * If emenu - it will be login user on the app
|
||||||
|
|||||||
@@ -116,13 +116,13 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Print order_item in 1 slip per item
|
#Print order_item in 1 slip per item
|
||||||
def print_slip_item(oqs, assigned_order_item)
|
def print_slip_item(oqs, assigned_item)
|
||||||
unique_code="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
|
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||||
# print when complete click
|
# print when complete click
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, item.item_code, print_status="" )
|
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
|
||||||
|
|
||||||
# update print status for completed same order items
|
# update print status for completed same order items
|
||||||
assigned_order_item.each do |ai|
|
assigned_order_item.each do |ai|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class PrintSetting < ApplicationRecord
|
class PrintSetting < ApplicationRecord
|
||||||
# validations
|
# validations
|
||||||
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height
|
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||||
|
|
||||||
def print_order_item(print_settings,oqs,order_id, item_code, print_status, options="")
|
def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, options="")
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
# Must be one print
|
||||||
|
if print_settings.print_copies == 0
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
|
end
|
||||||
|
|
||||||
filename = "tmp/order_item.pdf"
|
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
||||||
|
|
||||||
|
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||||
|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
# if order_item[0].price != 0
|
# if order_item[0].price != 0
|
||||||
@@ -14,12 +20,13 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
@@ -30,41 +37,50 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
order=print_query('order_summary', order_id)
|
# Must be one print
|
||||||
|
if print_settings.print_copies == 0
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
order=print_query('order_summary', order_id)
|
||||||
# For Print Per Item
|
# For Print Per Item
|
||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
order.each do|odi|
|
|
||||||
filename = "tmp/order_item.pdf"
|
order_items.each do|odi|
|
||||||
|
odi_item=print_query('order_item', odi.order_items_id)
|
||||||
|
filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||||
# For Item Options
|
# For Item Options
|
||||||
options = odi.options == "[]"? "" : odi.options
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
#if odi.price != 0
|
#if odi.price != 0
|
||||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name)
|
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
|
||||||
# pdf.render_file "tmp/order_item.pdf"
|
# pdf.render_file "tmp/order_item.pdf"
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
filename = "tmp/order_summary.pdf"
|
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -72,11 +88,17 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
# Print for orders in booking
|
# Print for orders in booking
|
||||||
def print_booking_summary(print_settings,oqs, booking_id, print_status)
|
def print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||||
|
# Must be one print
|
||||||
|
if print_settings.print_copies == 0
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
|
end
|
||||||
|
|
||||||
order=print_query('booking_summary', booking_id)
|
order=print_query('booking_summary', booking_id)
|
||||||
# For Print Per Item
|
# For Print Per Item
|
||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
order.each do|odi|
|
order.each do|odi|
|
||||||
filename = "tmp/order_item.pdf"
|
filename = "tmp/order_item_#{booking_id}" + ".pdf"
|
||||||
# For Item Options
|
# For Item Options
|
||||||
options = odi.options == "[]"? "" : odi.options
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
|
||||||
@@ -89,25 +111,29 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
|
|
||||||
#For print copy
|
#For print copy
|
||||||
pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
filename = "tmp/booking_summary.pdf"
|
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
|
|
||||||
#For print copy
|
#For print copy
|
||||||
pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -123,7 +149,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
left join customers as cus ON cus.customer_id = orders.customer_id
|
||||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
left join menu_items as item ON item.item_code = order_items.item_code")
|
||||||
.where("order_items.item_instance_code = '#{ id }'")
|
.where("order_items.order_items_id = '#{ id }'")
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
elsif type == "order_summary"
|
elsif type == "order_summary"
|
||||||
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
def print(file_path,printer_destination = nil )
|
def print(file_path,printer_destination = nil )
|
||||||
|
|
||||||
if printer_destination.nil?
|
if printer_destination.nil?
|
||||||
printer_destination = self.printer_destination
|
printer_destination = self.printer_destination
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,15 +65,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status)
|
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)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#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)
|
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)
|
||||||
|
|
||||||
# print as print copies in printer setting
|
# print as print copies in printer setting
|
||||||
count = printer_settings.print_copies
|
count = printer_settings.print_copies
|
||||||
|
|
||||||
|
# override print copies for print worker loop
|
||||||
|
print_settings.print_copies = 1
|
||||||
|
print_settings.save!
|
||||||
begin
|
begin
|
||||||
if count == 1
|
if count == 1
|
||||||
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf"
|
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||||
@@ -100,7 +104,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
pdf = QueueNoPdf.new(printer_settings,queue)
|
pdf = QueueNoPdf.new(printer_settings,queue)
|
||||||
pdf.render_file "tmp/print_queue_no.pdf"
|
pdf.render_file "tmp/print_queue_no.pdf"
|
||||||
self.print("tmp/print_queue_no.pdf")
|
self.print("tmp/print_queue_no.pdf")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
pdf.render_file "tmp/print_crm_order.pdf"
|
pdf.render_file "tmp/print_crm_order.pdf"
|
||||||
self.print("tmp/print_crm_order.pdf")
|
self.print("tmp/print_crm_order.pdf")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#Queue No Print
|
||||||
|
def print_call_waiter(printer_settings,table,time,shop_detail)
|
||||||
|
#Use CUPS service
|
||||||
|
#Generate PDF
|
||||||
|
#Print
|
||||||
|
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
||||||
|
pdf.render_file "tmp/print_call_waiter.pdf"
|
||||||
|
self.print("tmp/print_call_waiter.pdf")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -225,7 +225,11 @@ class Sale < ApplicationRecord
|
|||||||
puts "item.sales_item_id ddd"
|
puts "item.sales_item_id ddd"
|
||||||
puts item.sale_item_id
|
puts item.sale_item_id
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
total_taxable = total_taxable + item.taxable_price
|
|
||||||
|
# only calc tax when true
|
||||||
|
if(item.is_taxable)
|
||||||
|
total_taxable = total_taxable + item.taxable_price
|
||||||
|
end
|
||||||
# total_taxable = total_taxable + (item.taxable_price * item.qty)
|
# total_taxable = total_taxable + (item.taxable_price * item.qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -287,7 +291,11 @@ class Sale < ApplicationRecord
|
|||||||
if item.remark != 'void' && item.remark != 'foc'
|
if item.remark != 'void' && item.remark != 'foc'
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
total_taxable = total_taxable + item.price
|
|
||||||
|
# only calc tax when true
|
||||||
|
if(item.is_taxable)
|
||||||
|
total_taxable = total_taxable + item.taxable_price
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -449,7 +457,7 @@ class Sale < ApplicationRecord
|
|||||||
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
|
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
|
||||||
query = sale.where(keyword)
|
query = sale.where(keyword)
|
||||||
else
|
else
|
||||||
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
|
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -519,10 +527,10 @@ def self.daily_sales_list(from,to)
|
|||||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
|
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||||
.joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id")
|
.joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||||
.where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0", 'completed', from, to)
|
.where("sale_status = ? AND sales.receipt_date between ? and ? ", 'completed', from, to)
|
||||||
.group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
.group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
||||||
|
|
||||||
daily_total = Array.new
|
daily_total = Array.new
|
||||||
@@ -562,7 +570,7 @@ def self.daily_sales_list(from,to)
|
|||||||
:grand_total => grand_total,
|
:grand_total => grand_total,
|
||||||
:old_grand_total => old_grand_total,
|
:old_grand_total => old_grand_total,
|
||||||
:void_amount => void_amount,
|
:void_amount => void_amount,
|
||||||
:rounding_adj => sale.rounding_adj}
|
:rounding_adj => sale.rounding_adj}
|
||||||
daily_total.push(total)
|
daily_total.push(total)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -591,11 +599,40 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shiftsales(from,to,shift)
|
def self.get_by_shiftsales(from,to,shift)
|
||||||
if !shift.blank?
|
if !shift.blank?
|
||||||
ShiftSale.where("id =?",shift.id)
|
query = ShiftSale.where("shift_sales.id =?",shift.id)
|
||||||
else
|
else
|
||||||
ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
|
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shift_sale_data = Hash.new
|
||||||
|
|
||||||
|
query.each do |shift_sale|
|
||||||
|
foc = 0
|
||||||
|
foc_data = Sale.select("SUM(sp.payment_amount) as foc_sales")
|
||||||
|
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
||||||
|
.where("sales.shift_sale_id=? and sp.payment_method='foc'",shift_sale.id)
|
||||||
|
.first()
|
||||||
|
|
||||||
|
if !foc_data.foc_sales.nil? && foc_data.foc_sales > 0
|
||||||
|
shift_sale.other_sales -= foc_data.foc_sales
|
||||||
|
foc = foc_data.foc_sales
|
||||||
|
end
|
||||||
|
|
||||||
|
shift_sale_data[shift_sale.id] = {
|
||||||
|
:cashier_terminal_name => shift_sale.cashier_terminal.name,
|
||||||
|
:employee_name => shift_sale.employee.name,
|
||||||
|
:shift_started_at => shift_sale.shift_started_at,
|
||||||
|
:shift_closed_at => shift_sale.shift_closed_at,
|
||||||
|
:cash_sales => shift_sale.cash_sales,
|
||||||
|
:credit_sales => shift_sale.credit_sales,
|
||||||
|
:other_sales => shift_sale.other_sales.to_f,
|
||||||
|
:foc_sales => foc,
|
||||||
|
:grand_total => shift_sale.grand_total
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return shift_sale_data.values
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shift_sale(from,to,status)
|
def self.get_by_shift_sale(from,to,status)
|
||||||
@@ -608,41 +645,38 @@ def self.get_by_shift_sale(from,to,status)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_item_query()
|
def self.get_item_query()
|
||||||
# query = SaleItem.select("acc.title as account_name,account_id, item_instance_code as item_code, " +
|
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||||
# "SUM(qty * unit_price) as grand_total,SUM(qty) as total_item," +
|
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||||
# " unit_price as unit_price,product_name as product_name, 'cat' as" +
|
"i.remark as status_type,"+
|
||||||
# " menu_category_name,'test' as menu_category_id ")
|
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" +
|
||||||
|
" menu_category_name,mc.id as menu_category_id ")
|
||||||
|
|
||||||
# query = query.joins("JOIN sales s ON s.sale_id = sale_items.sale_id" +
|
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||||
# " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
" JOIN menu_item_instances mii ON i.item_instance_code = mii.item_instance_code" +
|
||||||
# # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||||
|
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" +
|
||||||
|
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||||
|
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||||
|
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||||
|
# query = query.where("i.item_instance_code IS NOT NULL")
|
||||||
|
query = query.group("i.product_name").order("mi.account_id desc")
|
||||||
|
end
|
||||||
|
|
||||||
# query = query.joins(" JOIN accounts acc ON acc.id = account_id")
|
def self.get_other_charges()
|
||||||
# query = query.where("item_instance_code is not NULL")
|
query = Sale.select("i.account_id as account_id, " +
|
||||||
# query = query.group("item_instance_code").order("account_id")
|
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
|
"i.remark as status_type,"+
|
||||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code, " +
|
" i.unit_price as unit_price,i.product_name as product_name")
|
||||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||||
"i.remark as status_type,"+
|
query = query.where("i.item_instance_code IS NULL AND i.product_code = 'Other Charges'")
|
||||||
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" +
|
query = query.group("i.sale_item_id")
|
||||||
" menu_category_name,mc.id as menu_category_id ")
|
|
||||||
|
|
||||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
|
||||||
" JOIN menu_item_instances mii ON i.item_instance_code = mii.item_instance_code" +
|
|
||||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
|
||||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" +
|
|
||||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
|
||||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
|
||||||
|
|
||||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
|
||||||
query = query.where("i.item_instance_code IS NOT NULL")
|
|
||||||
query = query.group("i.product_name").order("mi.account_id, mi.menu_category_id")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||||
|
|
||||||
query = self.get_item_query()
|
query = self.get_item_query()
|
||||||
|
|
||||||
discount_query = 0
|
discount_query = 0
|
||||||
total_card_amount = 0
|
total_card_amount = 0
|
||||||
total_cash_amount = 0
|
total_cash_amount = 0
|
||||||
@@ -650,10 +684,13 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
|||||||
total_foc_amount = 0
|
total_foc_amount = 0
|
||||||
total_grand_total = 0
|
total_grand_total = 0
|
||||||
|
|
||||||
|
other_charges = self.get_other_charges()
|
||||||
|
|
||||||
if shift.present?
|
if shift.present?
|
||||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||||
|
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||||
@@ -671,8 +708,9 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
|||||||
### => get all sales range in shift_sales
|
### => get all sales range in shift_sales
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||||
|
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||||
@@ -685,12 +723,14 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
|||||||
total_credit_amount += s_c.credit_amount.to_f
|
total_credit_amount += s_c.credit_amount.to_f
|
||||||
total_foc_amount += s_c.foc_amount.to_f
|
total_foc_amount += s_c.foc_amount.to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||||
|
|
||||||
else
|
else
|
||||||
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||||
|
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||||
@@ -707,7 +747,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
return query,other_charges, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
|
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
|
||||||
@@ -724,23 +764,19 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
|
|||||||
|
|
||||||
query = Sale.all
|
query = Sale.all
|
||||||
if shift.present?
|
if shift.present?
|
||||||
|
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sales.payment_status= 'paid' and sale_payments.payment_amount != 0", shift.to_a)
|
||||||
query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
|
||||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||||
.group("sales.sale_id")
|
.group("sales.sale_id")
|
||||||
|
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
|
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.payment_status= 'paid' and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||||
query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a)
|
|
||||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||||
.group("sales.sale_id")
|
.group("sales.sale_id")
|
||||||
|
|
||||||
else
|
else
|
||||||
|
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sales.payment_status= 'paid' and sale_payments.payment_amount != 0",from,to)
|
||||||
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
|
|
||||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||||
.group("sales.sale_id")
|
.group("sales.sale_id")
|
||||||
end
|
end
|
||||||
|
return query
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
|
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
|
||||||
@@ -795,27 +831,28 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
|
|||||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||||
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift.to_a)
|
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift.to_a)
|
||||||
.group("sale_taxes.tax_name")
|
.group("sale_taxes.tax_name")
|
||||||
.order("sale_taxes.sale_tax_id asc")
|
.order("sale_taxes.tax_name desc")
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||||
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift_sale_range.to_a)
|
.where("sales.shift_sale_id in (?) and sale_status= 'completed'", shift_sale_range.to_a)
|
||||||
.group("sale_taxes.tax_name")
|
.group("sale_taxes.tax_name")
|
||||||
.order("sale_taxes.sale_tax_id asc")
|
.order("sale_taxes.tax_name desc")
|
||||||
else
|
else
|
||||||
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||||
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
|
||||||
.where("sales.receipt_date between ? and ? and sale_status= 'completed'", from,to)
|
.where("sales.receipt_date between ? and ? and sale_status= 'completed'", from,to)
|
||||||
.group("sale_taxes.tax_name")
|
.group("sale_taxes.tax_name")
|
||||||
.order("sale_taxes.sale_tax_id asc")
|
.order("sale_taxes.tax_name desc")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
|
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
|
||||||
|
|
||||||
sale_payment = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
|
sale_payment = SalePayment.select("s.amount_changed as change_amount,s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
|
||||||
s.cashier_name as cashier_name")
|
s.cashier_name as cashier_name")
|
||||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.order('s.receipt_no DESC')
|
||||||
|
|
||||||
payments_total = SalePayment.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
payments_total = SalePayment.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||||
@@ -824,6 +861,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
|||||||
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
|
||||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='cash') then sales.amount_changed else 0 end) as total_change_amount,
|
||||||
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
|
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
|
||||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||||
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
||||||
@@ -875,7 +913,7 @@ end
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
def grand_total_after_rounding
|
def grand_total_after_rounding
|
||||||
return self.old_grand_total.to_f + self.rounding_adjustment.to_f
|
return self.grand_total.to_f + self.rounding_adjustment.to_f
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_cash_amount
|
def get_cash_amount
|
||||||
@@ -941,16 +979,16 @@ end
|
|||||||
def self.hourly_sales(today)
|
def self.hourly_sales(today)
|
||||||
query= Sale.select("grand_total")
|
query= Sale.select("grand_total")
|
||||||
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
.group("date_format(receipt_date, '%I %p')")
|
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
|
||||||
|
.order('receipt_date')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.employee_sales(today)
|
def self.employee_sales(today)
|
||||||
query = Sale.select("e.name as employee_name,grand_total")
|
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
|
||||||
.where('sales.payment_status="paid" and sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
||||||
.joins("join employees e on e.id=sales.cashier_id")
|
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
|
||||||
.joins("join sale_payments sp on sp.sale_id=sales.sale_id")
|
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb') THEN 'card' ELSE sp.payment_method END)","e.name")
|
||||||
.group("sp.payment_method","e.name")
|
.order("e.name")
|
||||||
.order('e.name')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_sale(today)
|
def self.total_sale(today)
|
||||||
@@ -1000,24 +1038,31 @@ end
|
|||||||
else
|
else
|
||||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
end
|
end
|
||||||
query.sum("sp.payment_amount")
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_customer(today)
|
def self.total_customer(today)
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_cus")
|
dinein_cnt = self.total_dinein(today)
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
takeaway_cnt = self.total_takeaway(today)
|
||||||
.first()
|
membership_cnt = self.total_membership(today)
|
||||||
|
|
||||||
|
total_cus = 0
|
||||||
|
if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
|
||||||
|
total_cus = dinein_cnt.total_dinein_cus.to_int + takeaway_cnt.total_take_cus.to_int + membership_cnt.total_memb_cus.to_int
|
||||||
|
end
|
||||||
|
|
||||||
|
return total_cus
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_dinein(today)
|
def self.total_dinein(today)
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_dinein_cus")
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_takeaway(today)
|
def self.total_takeaway(today)
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_take_cus")
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
@@ -1026,12 +1071,12 @@ end
|
|||||||
def self.total_membership(today)
|
def self.total_membership(today)
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is not null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
|
||||||
.first()
|
.first()
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_other_customer(today)
|
def self.total_other_customer(today)
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_cus")
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
@@ -1062,16 +1107,16 @@ end
|
|||||||
def self.top_items(today)
|
def self.top_items(today)
|
||||||
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
.group("a.product_code")
|
.group("a.product_code")
|
||||||
.order("SUM(a.price) DESC")
|
.order("SUM(a.qty) DESC")
|
||||||
.first()
|
.first()
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_foc_items(today)
|
def self.total_foc_items(today)
|
||||||
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.where("sales.sale_status = 'completed' and a.remark='foc' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
.count()
|
.sum("a.qty")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -78,6 +78,36 @@ class SaleAudit < ApplicationRecord
|
|||||||
sale_audit.save!
|
sale_audit.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.record_paymal(sale_id, remark, action_by)
|
||||||
|
sale_audit = SaleAudit.new()
|
||||||
|
sale_audit.sale_id = sale_id
|
||||||
|
sale_audit.action = "PAYMAL"
|
||||||
|
sale_audit.action_at = DateTime.now.utc
|
||||||
|
sale_audit.action_by = action_by
|
||||||
|
sale_audit.remark = remark
|
||||||
|
sale_audit.approved_by = Time.now
|
||||||
|
sale_audit.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.paymal_search(sale_id)
|
||||||
|
paymal = SaleAudit.where("sale_id =? and action = 'PAYMAL'",sale_id)
|
||||||
|
remark = paymal[0].remark.split("}")
|
||||||
|
response = "["+remark[0]+'}]'
|
||||||
|
response = JSON.parse(response)
|
||||||
|
puts response
|
||||||
|
if response[0]["status"] == true
|
||||||
|
if response[0]["current_rebate_amount"].present?
|
||||||
|
amount = response[0]["current_rebate_amount"]
|
||||||
|
else
|
||||||
|
amount = response[0]["current_balance_amount"]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
amount = nil
|
||||||
|
end
|
||||||
|
return amount
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
|
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
|
||||||
|
|||||||
@@ -27,27 +27,32 @@ class SaleItem < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
||||||
sale_item = SaleItem.new
|
# Original Item to add remark
|
||||||
sale_item.product_code = item.product_code
|
item.remark = type
|
||||||
sale_item.product_name = item.product_name + "(#{type})"
|
item.save
|
||||||
sale_item.product_alt_name = item.product_alt_name
|
|
||||||
sale_item.account_id = item.account_id
|
|
||||||
sale_item.remark = type
|
|
||||||
if type == "foc" || type == "promotion" || type == "void"
|
|
||||||
sale_item.qty = qty * (-1)
|
|
||||||
else
|
|
||||||
sale_item.qty = qty
|
|
||||||
end
|
|
||||||
|
|
||||||
sale_item.unit_price = item_price # * (-1)
|
sale_item = SaleItem.new
|
||||||
sale_item.taxable_price = (price) * (-1)
|
sale_item.product_code = item.product_code
|
||||||
sale_item.price = (price) * (-1)
|
sale_item.item_instance_code = item.item_instance_code
|
||||||
|
sale_item.product_name = item.product_name + " (#{type.upcase})"
|
||||||
|
sale_item.product_alt_name = item.product_alt_name
|
||||||
|
sale_item.account_id = item.account_id
|
||||||
|
sale_item.remark = type
|
||||||
|
if type == "foc" || type == "promotion" || type == "void"
|
||||||
|
sale_item.qty = qty * (-1)
|
||||||
|
else
|
||||||
|
sale_item.qty = qty
|
||||||
|
end
|
||||||
|
|
||||||
sale_item.is_taxable = 1
|
sale_item.unit_price = item_price # * (-1)
|
||||||
sale_item.sale_id = sale_id
|
sale_item.taxable_price = (price) * (-1)
|
||||||
sale_item.save
|
sale_item.price = (price) * (-1)
|
||||||
sale = Sale.find(sale_id)
|
|
||||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
sale_item.is_taxable = 1
|
||||||
|
sale_item.sale_id = sale_id
|
||||||
|
sale_item.save
|
||||||
|
sale = Sale.find(sale_id)
|
||||||
|
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_order_items_details(sale_id)
|
def self.get_order_items_details(sale_id)
|
||||||
@@ -94,9 +99,9 @@ class SaleItem < ApplicationRecord
|
|||||||
discount_account = {:name => a.title, :price => 0}
|
discount_account = {:name => a.title, :price => 0}
|
||||||
|
|
||||||
# Check for actual sale items
|
# Check for actual sale items
|
||||||
sale_items.where("is_taxable = false AND remark = 'Discount'").find_each do |si|
|
sale_items.where("remark = 'Discount'").find_each do |si|
|
||||||
if si.account_id == a.id
|
if si.account_id == a.id
|
||||||
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (-1)
|
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
discount_accounts.push(discount_account)
|
discount_accounts.push(discount_account)
|
||||||
@@ -145,17 +150,6 @@ class SaleItem < ApplicationRecord
|
|||||||
return price,type
|
return price,type
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for Card Payment
|
|
||||||
def self.get_sale_payments_by_card(sale_payments)
|
|
||||||
|
|
||||||
# Check for Card Payment
|
|
||||||
sale_payments.each do |sp|
|
|
||||||
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master"
|
|
||||||
return true;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
# def self.get_overall_discount(sale_id)
|
# def self.get_overall_discount(sale_id)
|
||||||
# price = 0.0
|
# price = 0.0
|
||||||
# item=SaleItem.where("product_code=?", sale_id)
|
# item=SaleItem.where("product_code=?", sale_id)
|
||||||
@@ -170,6 +164,5 @@ class SaleItem < ApplicationRecord
|
|||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ class SalePayment < ApplicationRecord
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { status: false}
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
Rails.logger.debug "Get Paypar Account "
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
return response;
|
return response;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -151,19 +153,40 @@ class SalePayment < ApplicationRecord
|
|||||||
else
|
else
|
||||||
response =false;
|
response =false;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Rails.logger.debug "Redeem response"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check for Card Payment
|
||||||
|
def self.get_sale_payments_by_card(sale_payments)
|
||||||
|
# Check for Card Payment
|
||||||
|
sale_payments.each do |sp|
|
||||||
|
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master"
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def cash_payment
|
def cash_payment
|
||||||
|
status = false
|
||||||
|
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
|
||||||
|
if sale_payments_data.nil?
|
||||||
|
status = true
|
||||||
|
end
|
||||||
|
|
||||||
payment_status = false
|
payment_status = false
|
||||||
self.payment_method = "cash"
|
self.payment_method = "cash"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
sale_update_payment_status(self.received_amount)
|
|
||||||
|
sale_update_payment_status(self.received_amount,status)
|
||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -171,7 +194,7 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
# add to sale item with foc
|
# add to sale item with foc
|
||||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
|
||||||
|
|
||||||
sale_items.each do|item|
|
sale_items.each do|item|
|
||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
@@ -203,14 +226,12 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
def external_terminal_card_payment(method)
|
def external_terminal_card_payment(method)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
self.payment_method = method
|
self.payment_method = method
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
self.payment_reference = self.card_payment_reference
|
self.payment_reference = self.card_payment_reference
|
||||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_method = self.save!
|
payment_method = self.save!
|
||||||
|
|
||||||
sale_update_payment_status(self.received_amount)
|
sale_update_payment_status(self.received_amount)
|
||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
@@ -255,6 +276,10 @@ class SalePayment < ApplicationRecord
|
|||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
||||||
|
|
||||||
|
#record an payment in sale-audit
|
||||||
|
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||||
|
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||||
|
|
||||||
if membership_data["status"]==true
|
if membership_data["status"]==true
|
||||||
self.payment_method = "paypar"
|
self.payment_method = "paypar"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
@@ -272,7 +297,7 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sale_update_payment_status(paid_amount)
|
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||||
#update amount_outstanding
|
#update amount_outstanding
|
||||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||||
self.sale.save!
|
self.sale.save!
|
||||||
@@ -305,9 +330,13 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
self.sale.sale_status = "completed"
|
self.sale.sale_status = "completed"
|
||||||
|
|
||||||
if MembershipSetting.find_by_rebate(1) && is_foc == 0
|
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
|
||||||
response = rebat(sObj)
|
response = rebat(sObj)
|
||||||
|
|
||||||
|
#record an payment in sale-audit
|
||||||
|
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||||
|
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||||
|
|
||||||
if !response.nil?
|
if !response.nil?
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
self.sale.rebate_status = 'true'
|
self.sale.rebate_status = 'true'
|
||||||
@@ -328,7 +357,9 @@ class SalePayment < ApplicationRecord
|
|||||||
self.sale.save!
|
self.sale.save!
|
||||||
table_update_status(sObj)
|
table_update_status(sObj)
|
||||||
|
|
||||||
if paid_amount != "0.0"
|
if check_foc
|
||||||
|
update_shift
|
||||||
|
elsif paid_amount != "0.0"
|
||||||
update_shift
|
update_shift
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -341,12 +372,18 @@ class SalePayment < ApplicationRecord
|
|||||||
shift.update(self.sale)
|
shift.update(self.sale)
|
||||||
self.sale.shift_sale_id = shift.id
|
self.sale.shift_sale_id = shift.id
|
||||||
self.sale.save
|
self.sale.save
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_shift
|
||||||
|
shift.update(self.sale)
|
||||||
|
self.sale.shift_sale_id = shift.id
|
||||||
|
self.sale.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def table_update_status(sale_obj)
|
def table_update_status(sale_obj)
|
||||||
status = true
|
status = true
|
||||||
booking = Booking.find_by_sale_id(sale_obj.id)
|
booking = Booking.find_by_sale_id(sale_obj.id)
|
||||||
|
|
||||||
if booking
|
if booking
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = DiningFacility.find(booking.dining_facility_id)
|
||||||
bookings = table.bookings
|
bookings = table.bookings
|
||||||
@@ -355,12 +392,15 @@ class SalePayment < ApplicationRecord
|
|||||||
if tablebooking.sale_id
|
if tablebooking.sale_id
|
||||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
|
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
|
||||||
status = false
|
status = false
|
||||||
|
else
|
||||||
|
status = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
status = false
|
status = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if status
|
if status
|
||||||
table.status = "available"
|
table.status = "available"
|
||||||
table.save
|
table.save
|
||||||
@@ -388,6 +428,7 @@ class SalePayment < ApplicationRecord
|
|||||||
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
||||||
overall_dis = sObj.total_discount
|
overall_dis = sObj.total_discount
|
||||||
|
|
||||||
|
if credit != 1
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
|
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
|
||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
@@ -416,89 +457,93 @@ class SalePayment < ApplicationRecord
|
|||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
end
|
end
|
||||||
redeem_amount = payparcost + overall_dis
|
|
||||||
|
|
||||||
total_percentage = 0
|
redeem_amount = payparcost + overall_dis
|
||||||
|
|
||||||
type_arr = []
|
total_percentage = 0
|
||||||
# Check for present response fields
|
|
||||||
if response["membership_campaign_data"].present?
|
|
||||||
response["membership_campaign_data"].each do |a|
|
|
||||||
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
|
|
||||||
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
|
|
||||||
|
|
||||||
type_arr.push(data)
|
type_arr = []
|
||||||
end
|
Rails.logger.debug "Get Member Campaign"
|
||||||
end
|
Rails.logger.debug response.to_json
|
||||||
|
# Check for present response fields
|
||||||
rebate_arr =[]
|
if response["membership_campaign_data"].present?
|
||||||
campaign_method.each do |a|
|
response["membership_campaign_data"].each do |a|
|
||||||
data = {:type => a[:type], :amount => a[:amount]}
|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
|
||||||
type_arr.each do |si|
|
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
|
||||||
if si[:type] == a[:type]
|
|
||||||
if credit == 1
|
|
||||||
data[:amount] = 0
|
|
||||||
else
|
|
||||||
amount = (redeem_amount / total_percentage)*si[:percentage]
|
|
||||||
actual = a[:amount] - amount
|
|
||||||
data[:amount] = actual
|
|
||||||
end
|
|
||||||
|
|
||||||
|
type_arr.push(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rebate_arr.push(data)
|
|
||||||
end
|
|
||||||
|
|
||||||
total_amount = rebate_prices - payparcost - overall_dis
|
rebate_arr =[]
|
||||||
|
campaign_method.each do |a|
|
||||||
|
data = {:type => a[:type], :amount => a[:amount]}
|
||||||
|
type_arr.each do |si|
|
||||||
|
if si[:type] == a[:type]
|
||||||
|
if credit == 1
|
||||||
|
data[:amount] = 0
|
||||||
|
else
|
||||||
|
amount = (redeem_amount / total_percentage)*si[:percentage]
|
||||||
|
actual = a[:amount] - amount
|
||||||
|
data[:amount] = actual
|
||||||
|
end
|
||||||
|
|
||||||
if credit == 1
|
end
|
||||||
total_amount = 0
|
end
|
||||||
end
|
rebate_arr.push(data)
|
||||||
if total_amount >= 0
|
end
|
||||||
receipt_no = sObj.receipt_no
|
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
total_amount = rebate_prices - payparcost - overall_dis
|
||||||
memberaction = MembershipAction.find_by_membership_type("rebate")
|
|
||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
if credit == 1
|
||||||
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
total_amount = 0
|
||||||
auth_token = memberaction.auth_token.to_s
|
end
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
|
||||||
|
if total_amount >= 0
|
||||||
# Control for Paypar Cloud
|
receipt_no = sObj.receipt_no
|
||||||
begin
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
response = HTTParty.post(url,
|
memberaction = MembershipAction.find_by_membership_type("rebate")
|
||||||
:body => {
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
generic_customer_id:generic_customer_id ,
|
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
||||||
total_sale_transaction_amount: sObj.grand_total,
|
auth_token = memberaction.auth_token.to_s
|
||||||
merchant_uid:merchant_uid,
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
total_amount: total_amount,
|
|
||||||
campaign_type_id: campaign_type_id,
|
# Control for Paypar Cloud
|
||||||
receipt_no: receipt_no,
|
begin
|
||||||
campaign_method: rebate_arr.to_json,
|
response = HTTParty.post(url,
|
||||||
auth_token:auth_token
|
:body => {
|
||||||
}.to_json,
|
generic_customer_id:generic_customer_id ,
|
||||||
:headers => {
|
total_sale_transaction_amount: sObj.grand_total,
|
||||||
'Content-Type' => 'application/json',
|
merchant_uid:merchant_uid,
|
||||||
'Accept' => 'application/json; version=2'
|
total_amount: total_amount,
|
||||||
}, :timeout => 10)
|
campaign_type_id: campaign_type_id,
|
||||||
rescue Net::OpenTimeout
|
receipt_no: receipt_no,
|
||||||
response = { "status": false , "message": "Connect To" }
|
campaign_method: rebate_arr.to_json,
|
||||||
rescue OpenURI::HTTPError
|
auth_token:auth_token
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
}.to_json,
|
||||||
|
:headers => {
|
||||||
rescue SocketError
|
'Content-Type' => 'application/json',
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
'Accept' => 'application/json; version=2'
|
||||||
|
}, :timeout => 10)
|
||||||
|
rescue Net::OpenTimeout
|
||||||
|
response = { "status": false , "message": "Connect To" }
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
|
end
|
||||||
|
Rails.logger.debug "Rebage Response"
|
||||||
|
Rails.logger.debug response.to_json
|
||||||
|
return response
|
||||||
end
|
end
|
||||||
return response
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
response = { "status": "no_member", "message": "Not membership"}
|
response = { "status": "no_member", "message": "Not membership"}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ class ShiftSale < ApplicationRecord
|
|||||||
self.total_taxes = self.total_taxes + saleobj.total_tax
|
self.total_taxes = self.total_taxes + saleobj.total_tax
|
||||||
self.grand_total = self.grand_total + saleobj.grand_total
|
self.grand_total = self.grand_total + saleobj.grand_total
|
||||||
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
self.cash_sales = self.cash_sales.to_f + cash.to_f
|
||||||
self.credit_sales = self.credit_sales.to_i + credit.to_f
|
self.credit_sales = self.credit_sales.to_f + credit.to_f
|
||||||
self.other_sales = self.other_sales.to_i + other_sales.to_f
|
self.other_sales = self.other_sales.to_f + other_sales.to_f
|
||||||
self.nett_sales = self.nett_sales + (saleobj.total_amount.to_f - self.total_discounts) #self.grand_total.to_i - self.commercial_taxes
|
self.nett_sales = self.nett_sales + (saleobj.total_amount.to_f - saleobj.total_discount) #self.grand_total.to_f - self.commercial_taxes
|
||||||
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
|
self.commercial_taxes = self.commercial_taxes.to_f + tax.to_f
|
||||||
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
|
||||||
self.total_receipt = self.total_receipt + 1
|
self.total_receipt = self.total_receipt + 1
|
||||||
if saleobj.customer.customer_type == "Dinein"
|
if saleobj.customer.customer_type == "Dinein"
|
||||||
@@ -79,10 +79,10 @@ class ShiftSale < ApplicationRecord
|
|||||||
self.total_taxes = self.total_taxes - saleobj.total_tax
|
self.total_taxes = self.total_taxes - saleobj.total_tax
|
||||||
self.grand_total = self.grand_total - saleobj.grand_total
|
self.grand_total = self.grand_total - saleobj.grand_total
|
||||||
self.cash_sales = self.cash_sales.to_f - cash.to_f
|
self.cash_sales = self.cash_sales.to_f - cash.to_f
|
||||||
self.credit_sales = self.credit_sales.to_i - credit.to_f
|
self.credit_sales = self.credit_sales.to_f - credit.to_f
|
||||||
self.other_sales = self.other_sales.to_i - other_sales.to_f
|
self.other_sales = self.other_sales.to_f - other_sales.to_f
|
||||||
self.nett_sales = self.nett_sales - (saleobj.total_amount.to_f - self.total_discounts) #self.grand_total.to_i - self.commercial_taxes
|
self.nett_sales = self.nett_sales - (saleobj.total_amount.to_f - self.total_discounts) #self.grand_total.to_i - self.commercial_taxes
|
||||||
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
|
self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f
|
||||||
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
|
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
|
||||||
self.total_void = self.total_void + saleobj.grand_total
|
self.total_void = self.total_void + saleobj.grand_total
|
||||||
if saleobj.customer.customer_type == "Dinein"
|
if saleobj.customer.customer_type == "Dinein"
|
||||||
@@ -121,7 +121,7 @@ class ShiftSale < ApplicationRecord
|
|||||||
"JOIN accounts acc ON acc.id = i.account_id" +
|
"JOIN accounts acc ON acc.id = i.account_id" +
|
||||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||||
if type == 'discount'
|
if type == 'discount'
|
||||||
query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.is_taxable = false and i.remark = 'Discount'", shift.id)
|
query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.remark = 'Discount'", shift.id)
|
||||||
.group("acc.title").order("acc.id")
|
.group("acc.title").order("acc.id")
|
||||||
else
|
else
|
||||||
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
|
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
class Shop < ApplicationRecord
|
class Shop < ApplicationRecord
|
||||||
|
ShopDetail = Shop.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|||||||
71
app/pdf/call_waiter_pdf.rb
Normal file
71
app/pdf/call_waiter_pdf.rb
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
class CallWaiterPdf < Prawn::Document
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
|
def initialize(printer_settings, table,time,shop_detail)
|
||||||
|
self.page_width = printer_settings.page_width
|
||||||
|
self.page_height = printer_settings.page_height
|
||||||
|
self.margin = 5
|
||||||
|
self.price_width = 35
|
||||||
|
self.qty_width = 20
|
||||||
|
self.total_width = 35
|
||||||
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
|
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if printer_settings.font != ""
|
||||||
|
font_families.update("#{printer_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{printer_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
|
||||||
|
self.header_font_size = 10
|
||||||
|
self.item_font_size = 8
|
||||||
|
|
||||||
|
header( shop_detail.name, printer_settings.name)
|
||||||
|
|
||||||
|
call_waiter(table)
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
# date_info(queue)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_name, name)
|
||||||
|
text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
text "#{name}", :size => self.header_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
|
||||||
|
def call_waiter (table)
|
||||||
|
move_down 3
|
||||||
|
text "Table Name : #{table.name}",:align => :center
|
||||||
|
end
|
||||||
|
|
||||||
|
# def date_info(queue)
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
# text "Date:", :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
# bounding_box([self.label_width,y_position], :width => self.item_width) do
|
||||||
|
# text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
|
||||||
|
# end
|
||||||
|
|
||||||
|
# move_down 5
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -5,7 +5,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
self.price_width = 40
|
self.price_width = 60
|
||||||
self.qty_width = 20
|
self.qty_width = 20
|
||||||
self.total_width = 40
|
self.total_width = 40
|
||||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
@@ -133,7 +133,6 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{shift_sale.cash_in}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.cash_in}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Cash Out:", :size => self.item_font_size, :align => :right
|
text "Cash Out:", :size => self.item_font_size, :align => :right
|
||||||
@@ -142,26 +141,11 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{shift_sale.cash_out}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.cash_out}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Net Sales:", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{shift_sale.nett_sales}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Total Tax :", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 7
|
move_down 7
|
||||||
|
|
||||||
|
@total_foc = 0
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||||
@@ -180,14 +164,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
#start other payment details
|
#start other payment details
|
||||||
if shift_sale.other_sales > 0
|
if shift_sale.other_sales > 0
|
||||||
other_payment.each do |other|
|
other_payment.each do |other|
|
||||||
y_position = cursor
|
@total_foc = other.foc_amount.round(2)
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Other Payment Details", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||||
@@ -204,14 +181,6 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Master Payment :", :size => self.item_font_size, :align => :right
|
text "Master Payment :", :size => self.item_font_size, :align => :right
|
||||||
@@ -220,6 +189,14 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Reedem Payment :", :size => self.item_font_size, :align => :right
|
text "Reedem Payment :", :size => self.item_font_size, :align => :right
|
||||||
@@ -227,15 +204,6 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "FOC :", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{other.foc_amount.round(2)}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -247,30 +215,63 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.total_rounding.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.grand_total.round(2)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
# end other payment details
|
# end other payment details
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 7
|
move_down 7
|
||||||
#start total amount by Account Like Food / Beverage /..
|
|
||||||
total_amount_by_account.each do |amount|
|
#start service charges and commercial tax
|
||||||
|
sale_taxes.each do |tax|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right
|
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
|
text "#{tax.st_amount.round(2)}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#end total amount by Account
|
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Total Sale :", :size => self.item_font_size, :align => :right
|
text "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{shift_sale.nett_sales}", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
#end for service charges and commercial tax
|
||||||
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Total Sale :", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 7
|
move_down 7
|
||||||
@@ -304,7 +305,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
|
text "Total Discount :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{@overall}", :size => self.item_font_size, :align => :right
|
text "#{@overall}", :size => self.item_font_size, :align => :right
|
||||||
@@ -312,39 +313,58 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Total Discount Amount :", :size => self.item_font_size, :align => :right
|
text "Total FOC :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
|
text "(#{@total_foc})", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Void :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Grand Total :", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 7
|
move_down 7
|
||||||
|
|
||||||
sale_taxes.each do |tax|
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_amount_by_account.each do |amount|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{tax.st_amount.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Rounding Adjustment :", :size => self.item_font_size, :align => :right
|
text "Total Dine-in Count :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{shift_sale.total_rounding.round(2)}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
y_position = cursor
|
|
||||||
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
text "Grand Total :", :size => self.item_font_size, :align => :right
|
text "Total Takeaway Count :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -355,31 +375,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
|
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
|
|
||||||
y_position = cursor
|
move_down 5
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Dining Count :", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Takeaway Count :", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
|
||||||
text "Total Void:", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
|
||||||
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
move_down 5
|
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 5
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class OrderItemPdf < Prawn::Document
|
|||||||
|
|
||||||
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 3
|
||||||
|
|
||||||
#order_info
|
#order_info
|
||||||
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
|
||||||
@@ -56,13 +56,13 @@ class OrderItemPdf < Prawn::Document
|
|||||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 2
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||||
@@ -105,18 +105,22 @@ class OrderItemPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
if alt_name
|
if alt_name
|
||||||
move_down 4
|
if !(order_item.alt_name).empty?
|
||||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
move_down 4
|
||||||
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
if !options.empty?
|
||||||
|
move_down 5
|
||||||
|
|
||||||
# add option
|
# add option
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
text "#{options}", :size => self.item_font_size,:align => :left
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|||||||
129
app/pdf/order_item_slim_pdf.rb
Normal file
129
app/pdf/order_item_slim_pdf.rb
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
class OrderItemSlimPdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
|
def initialize(print_settings,order_item_slim, print_status, options, alt_name)
|
||||||
|
self.page_width = print_settings.page_width
|
||||||
|
self.page_height = print_settings.page_height
|
||||||
|
self.margin = 0
|
||||||
|
self.price_width = 40 # No Need for item
|
||||||
|
self.qty_width = 40
|
||||||
|
self.total_width = 40 # No Need for item
|
||||||
|
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
|
self.label_width=90
|
||||||
|
|
||||||
|
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if print_settings.font != ""
|
||||||
|
font_families.update("#{print_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{print_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
|
||||||
|
self.header_font_size = 11
|
||||||
|
self.item_font_size = 9
|
||||||
|
else
|
||||||
|
self.header_font_size = 12
|
||||||
|
self.item_font_size = 10
|
||||||
|
end
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
#font "public/fonts/Chinese.ttf"
|
||||||
|
|
||||||
|
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
#order_info
|
||||||
|
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
|
||||||
|
|
||||||
|
# order items slim
|
||||||
|
order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order Information to PDF
|
||||||
|
def order_info(order_no, order_by, order_at)
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
move_down 3
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order items to PDF
|
||||||
|
def order_items_slim(order_item_slim, options, alt_name, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
#Add Order Item
|
||||||
|
add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||||
|
|
||||||
|
dash(1, :space => 1, :phase => 1)
|
||||||
|
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||||
|
move_down 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add order items slim under order info
|
||||||
|
def add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||||
|
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# if alt_name
|
||||||
|
# if !(order_item_slim.alt_name).empty?
|
||||||
|
# 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
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
if !options.empty?
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
# add option
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
end
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -122,19 +122,21 @@ class OrderSummaryPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
if alt_name
|
if alt_name
|
||||||
move_down 4
|
if !(odi.alt_name).empty?
|
||||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
move_down 4
|
||||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
|
||||||
|
|
||||||
# add option
|
# add option
|
||||||
options = odi.options == "[]"? "" : odi.options
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
|
||||||
if options != ""
|
if options != ""
|
||||||
|
move_down 5
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width => self.item_width) do
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
text "#{options}", :size => self.item_font_size,:align => :left
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
|||||||
155
app/pdf/order_summary_slim_pdf.rb
Normal file
155
app/pdf/order_summary_slim_pdf.rb
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
class OrderSummarySlimPdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||||
|
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
|
||||||
|
self.page_width = print_settings.page_width
|
||||||
|
self.page_height = print_settings.page_height
|
||||||
|
self.margin = 0
|
||||||
|
self.price_width = 40 # No Need for item
|
||||||
|
self.qty_width = 40
|
||||||
|
self.total_width = 40 # No Need for item
|
||||||
|
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
|
self.label_width=90
|
||||||
|
|
||||||
|
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if print_settings.font != ""
|
||||||
|
font_families.update("#{print_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{print_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{print_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
|
||||||
|
self.header_font_size = 11
|
||||||
|
self.item_font_size = 9
|
||||||
|
else
|
||||||
|
self.header_font_size = 12
|
||||||
|
self.item_font_size = 10
|
||||||
|
end
|
||||||
|
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
|
||||||
|
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
#order_info
|
||||||
|
order_info(order[0].order_id, order[0].order_by,order[0].order_at)
|
||||||
|
|
||||||
|
# order items
|
||||||
|
if order_items == nil
|
||||||
|
order_items(order, alt_name, print_settings.precision)
|
||||||
|
else
|
||||||
|
order_items(order_items, alt_name, print_settings.precision)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order Information to PDF
|
||||||
|
def order_info(order_no, order_by, order_at)
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Write Order items to PDF
|
||||||
|
def order_items(order_item, alt_name, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "Item", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||||
|
text "Qty", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
#Add Order Item
|
||||||
|
add_order_items(order_item, alt_name, precision)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add order items under order info
|
||||||
|
def add_order_items(order_item, alt_name, precision)
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
order_item.each do|odi|
|
||||||
|
# check for item not to show
|
||||||
|
# if odi.price != 0
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||||
|
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if alt_name
|
||||||
|
if !(odi.alt_name).empty?
|
||||||
|
move_down 1
|
||||||
|
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||||
|
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# add option
|
||||||
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
|
||||||
|
if options != ""
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width) do
|
||||||
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 1
|
||||||
|
|
||||||
|
dash(1, :space => 1, :phase => 1)
|
||||||
|
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||||
|
move_down 1
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
class ReceiptBillPdf < Prawn::Document
|
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
|
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
|
||||||
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)
|
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)
|
||||||
self.page_width = printer_settings.page_width
|
self.page_width = printer_settings.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.margin = 5
|
self.margin = 0
|
||||||
self.price_width = 40
|
self.price_width = 60
|
||||||
self.qty_width = 20
|
self.qty_width = 25
|
||||||
self.total_width = 40
|
self.total_width = 60
|
||||||
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
|
||||||
self.item_height = 15
|
self.item_height = 15
|
||||||
self.item_description_width = (self.page_width-20) / 2
|
self.item_description_width = (self.page_width-5) / 2
|
||||||
self.label_width = 100
|
self.label_width = 100
|
||||||
|
|
||||||
self.description_width = 150
|
self.description_width = 150
|
||||||
@@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
#setting page margin and width
|
#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])
|
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
|
||||||
|
end
|
||||||
|
|
||||||
# db font setup
|
# db font setup
|
||||||
if printer_settings.font != ""
|
if printer_settings.font != ""
|
||||||
font_families.update("#{printer_settings.font}" => {
|
font_families.update("#{printer_settings.font}" => {
|
||||||
@@ -55,7 +60,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
|
|
||||||
if member_info != nil
|
if member_info != nil
|
||||||
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter)
|
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
|
||||||
end
|
end
|
||||||
|
|
||||||
customer(customer_name)
|
customer(customer_name)
|
||||||
@@ -74,7 +79,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def header (shop_details)
|
def header (shop_details)
|
||||||
move_down 7
|
move_down 5
|
||||||
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
move_down 5
|
move_down 5
|
||||||
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
@@ -124,15 +129,27 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def line_items(sale_items,precision,delimiter)
|
def line_items(sale_items,precision,delimiter)
|
||||||
|
if precision.to_i > 0
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
|
item_label_qty_end_width = self.qty_width + 4
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 10
|
||||||
|
item_label_total_end_width = self.total_width + 9
|
||||||
|
else
|
||||||
|
self.item_width = self.item_width.to_i + 8
|
||||||
|
item_label_qty_front_width = (self.item_width+self.price_width) + 8
|
||||||
|
item_label_qty_end_width = self.qty_width + 7
|
||||||
|
item_label_total_front_width = (self.item_width+self.price_width) + 5
|
||||||
|
item_label_total_end_width = self.total_width + 4
|
||||||
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down 5
|
move_down 5
|
||||||
pad_top(15) {
|
pad_top(15) {
|
||||||
# @item_width.to_i + @half_qty.to_i
|
# @item_width.to_i + @half_qty.to_i
|
||||||
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||||
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
}
|
}
|
||||||
move_down -5
|
move_down -5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
@@ -140,7 +157,19 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_line_item_row(sale_items,precision,delimiter)
|
def add_line_item_row(sale_items,precision,delimiter)
|
||||||
item_name_width = (self.item_width+self.price_width)
|
if precision.to_i > 0
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = (self.item_width+self.price_width) + 5
|
||||||
|
item_qty_end_width = self.qty_width + 4
|
||||||
|
item_total_front_width = item_name_width + 10
|
||||||
|
item_total_end_width = self.total_width + 9
|
||||||
|
else
|
||||||
|
item_name_width = (self.item_width+self.price_width)
|
||||||
|
item_qty_front_width = item_name_width + 8
|
||||||
|
item_qty_end_width = self.qty_width + 7
|
||||||
|
item_total_front_width = item_name_width + 5
|
||||||
|
item_total_end_width = self.total_width + 4
|
||||||
|
end
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
move_down 5
|
move_down 5
|
||||||
sub_total = 0.0
|
sub_total = 0.0
|
||||||
@@ -162,8 +191,8 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
|
||||||
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||||
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||||
}
|
}
|
||||||
move_down 5
|
move_down 5
|
||||||
end
|
end
|
||||||
@@ -254,7 +283,8 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 5
|
||||||
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method").where('sale_id = ?', sale_data.sale_id).group("payment_method")
|
||||||
|
sale_payments.each do |payment|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
if payment.payment_method == "paypar"
|
if payment.payment_method == "paypar"
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
@@ -285,7 +315,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
# show member information
|
# show member information
|
||||||
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter)
|
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
|
||||||
if rebate_amount != nil
|
if rebate_amount != nil
|
||||||
if rebate_amount["status"] == true
|
if rebate_amount["status"] == true
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
@@ -293,6 +323,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
balance = 0
|
balance = 0
|
||||||
rebate_balance =0
|
rebate_balance =0
|
||||||
redeem = 0
|
redeem = 0
|
||||||
|
redeem_count = 0
|
||||||
rebate_amount["data"].each do |res|
|
rebate_amount["data"].each do |res|
|
||||||
total = total + res["balance"]
|
total = total + res["balance"]
|
||||||
#total redeem amount
|
#total redeem amount
|
||||||
@@ -317,7 +348,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
end
|
end
|
||||||
# Total Rebate Amount if birthday
|
# Total Rebate Amount if birthday
|
||||||
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate"
|
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
|
||||||
rebate_balance = rebate_balance + res["deposit"]
|
rebate_balance = rebate_balance + res["deposit"]
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -331,29 +362,24 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
#end Total rebate if birthday
|
#end Total rebate if birthday
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
|
||||||
y_position = cursor
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
|
||||||
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
|
||||||
end
|
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
|
||||||
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if redeem == 0
|
|
||||||
old = total - rebate_balance
|
|
||||||
else
|
|
||||||
old = balance + redeem
|
|
||||||
end
|
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
text "Old Balance", :size => self.item_font_size,:align => :left
|
text "Redeem Amount", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
if current_balance != nil
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "Old Balance", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -367,7 +393,6 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
total_balance = total_balance + res["balance"]
|
total_balance = total_balance + res["balance"]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
move_down 5
|
move_down 5
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
@@ -441,6 +466,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
move_down 73
|
move_down 73
|
||||||
text "Approved By" , :size => self.item_font_size,:align => :center
|
text "Approved By" , :size => self.item_font_size,:align => :center
|
||||||
end
|
end
|
||||||
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if sale_data.payment_status == "foc"
|
if sale_data.payment_status == "foc"
|
||||||
@@ -472,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
|
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|||||||
6
app/views/api/call_waiters/index.json.jbuilder
Normal file
6
app/views/api/call_waiters/index.json.jbuilder
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
if (@table)
|
||||||
|
json.table_id @table.id
|
||||||
|
json.name @table.name
|
||||||
|
json.type @table.type
|
||||||
|
json.time @time
|
||||||
|
end
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user