fixed conflit

This commit is contained in:
NyanLinHtut
2019-12-13 10:09:25 +06:30
317 changed files with 17947 additions and 3204 deletions

View File

@@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDaDCCAlACCQCMa8dYfX0ohTANBgkqhkiG9w0BAQsFADB2MQswCQYDVQQGEwJZ
RzELMAkGA1UECAwCWUcxCzAJBgNVBAcMAllHMQwwCgYDVQQKDANDMkwxCjAIBgNV
BAsMATMxCzAJBgNVBAMMAlNYMSYwJAYJKoZIhvcNAQkBFhdud2VuaS5hdW5nQGNv
ZGUybGFiLmNvbTAeFw0xOTExMjYwNTM0NTNaFw0yMDExMjUwNTM0NTNaMHYxCzAJ
BgNVBAYTAllHMQswCQYDVQQIDAJZRzELMAkGA1UEBwwCWUcxDDAKBgNVBAoMA0My
TDEKMAgGA1UECwwBMzELMAkGA1UEAwwCU1gxJjAkBgkqhkiG9w0BCQEWF253ZW5p
LmF1bmdAY29kZTJsYWIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAzjshIBw0Dnv4nFxBBtDd6TbcIR9GGndM7aKOr8yZBv7qKiRoFr9vtT/M1JZh
MO2G0DxvH9BjR1oVWNuAOBx7JUf9wweZ0ntaYT+kPen66LqTn5gFfCAJ+EAzIvaq
s2zlWB8Opl1kahW3LDLngmJGQPBTXO5UVfZHcxgyEGa4b+KdG9s8xqIC4HpvEOST
JmtZiuk/f/9tD7TqWhLsm/Aaw851/6kNjwZJYLbb/Trw8p04iLyyFl1yxVGQLfKB
uoT9tZizPJwZpxCPcvfk2aea0tO+tzBGvtC0VxIUGmBtsZyexVKj/dRuxYhYhFiT
m+0LXyBVyBU5tnuSlvTTM6Qy+wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBUS4G7
xFFlR7Jy1pru4sBMJk11r1pXjUU4lW8bgR1GYC/truda9JyIYlsnrpb+AkhKC1wT
cDufZs+mciN9u8K0eBSdwcAE+m1mSxa1AZbRLyXb9JxWEYmY53K/ktocQloBM3id
sNZQpsSsqZ4DEuaIzgc3A8C+bQbKi1/P2vo12quzGqebIryvy5QPXpi47ECmSGqW
mIBLhPoy3gzm6PamdY+0z+nKGTdAPS15tTpYsfRA3u54fiavluJYNRV2cFYlGPsS
6YmcQNV1R+ONfjaPCqH24/NNVgeeaKzb6uGIpgOfB2cb8aXjTDVUT0qVgJ3S9M4p
HflFmRqebVXhDDiE
-----END CERTIFICATE-----

View File

@@ -1,28 +0,0 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOOyEgHDQOe/ic
XEEG0N3pNtwhH0Yad0ztoo6vzJkG/uoqJGgWv2+1P8zUlmEw7YbQPG8f0GNHWhVY
24A4HHslR/3DB5nSe1phP6Q96froupOfmAV8IAn4QDMi9qqzbOVYHw6mXWRqFbcs
MueCYkZA8FNc7lRV9kdzGDIQZrhv4p0b2zzGogLgem8Q5JMma1mK6T9//20PtOpa
Euyb8BrDznX/qQ2PBklgttv9OvDynTiIvLIWXXLFUZAt8oG6hP21mLM8nBmnEI9y
9+TZp5rS0763MEa+0LRXEhQaYG2xnJ7FUqP91G7FiFiEWJOb7QtfIFXIFTm2e5KW
9NMzpDL7AgMBAAECggEABCQj0iU+1lue7mTb2WswSZKUcQXTvoxOuybcfqM5H27W
/OmmPW6yq40Qa+RpJzZd0qikApuIotIoQ5SEypunzWPYsKXibNuVQQaqIaQlKa81
b6r50ThDevyvCjCx1NCG+nIFNUoCzi6JcxXCmFeo2Xz574/JmcBMRv9hYfruETEO
g5KvR+bhymaDGgKPoIgro2ar3DjKYMuWwaHJQClx3laYPIgnyGFvmTG/if5UykF4
oTDnjVYkWqw8XOvsL5WhDBGbTq/f1jB7IjfIt1+pV51synVsa/zGNe3jQstCNBX0
LK+7k8ub6v3jg2ZU0xx7z+hPuOIwz9HLjVEMfZWZwQKBgQDrSmJfbb7FMrPMKeaU
TEX6+fJRQkfgUdtfx8MK5PytV4WzkHOyJ2ankkpyh5TQG77MUzubfGPmg5nBT2+I
TEZO8rH83nOvMKLmXoPp0TvyBxGt0OqBb6RE+mc5rQmPk4lEtUq+i0L+/fB4RYMe
CZgn8pjuvBi+4oQOiQPSl+SwuQKBgQDgYffroNTn1i3VYNU3DYp9xjSLor7TPdsv
S2Xi5FXaZr9PcXdviBE9siY9KEBuiWVA5Q9Wv8XdBbA26VmEzyf+k7KzMr4Z6k5H
SlqClr4AFes6KYmvP2DrVaUsxlUeDO0saxahEK8PkMYTWbWDTAv0d2YD/mLcesEr
haeCCpyfUwKBgQCVCUDWgYVdE4ifwcq0FLwfBUNgBUPR6wex267Hr9P9WHrwCoe+
SQbVDezqLscsKuboNbCEBH6i/KjfsZlMFERUrZXgPme4iG4mzadw63+1BpVELBje
dADxUEsiVWDA+Qrx4oO9vihprCAtjppG5HzkkN4eGjbycjiDnHY3Zs8MwQKBgAqS
kyv3GBEUdnRna6R8btoeTLuHn5Y0g+9mjhZyy9jOnpUPs6D9uFI/4q1fCCotLygv
otljj98qNXNg62bmm+vS6ciny21NLQMO7dTZZXp7jenfqy0mv1pXXsENV1VjJonB
Qf+02YrSN4MR5wuYubd7KMNnaSEaZ5+1XH80IM0hAoGBAJfHi94ZzPW2PDQr1GIm
CS0O0cHjQNI2+5Yde2U+WuXh/U2rMyB9iTyImqw/weTVFXS2AiRmss7CBTpIxhCP
1gVoNcRRfU7kmuiBXthgB/BuhSdeh/OQo7e9pKiNqoieMO+j8ocyvbMi8NSUl7pK
P9O47XLOplsft4lXqG6gkn8C
-----END PRIVATE KEY-----

View File

@@ -1,15 +1,20 @@
FROM ruby:2.4.1 FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs RUN apt-get update -qq && apt-get install -y build-essential libmariadb-dev libcups2-dev libpq-dev nodejs tzdata
RUN mkdir /sxrestaurant RUN mkdir /sxrestaurant
RUN mkdir -p /sxrestaurant/tmp/puma RUN mkdir -p /sxrestaurant/tmp/puma
ENV RAILS_ENV staging ENV RAILS_ENV production
ENV RACK_ENV staging ENV RACK_ENV production
WORKDIR /sxrestaurant WORKDIR /sxrestaurant
COPY Gemfile /sxrestaurant/Gemfile #RUN gem install bundler
COPY Gemfile.lock /sxrestaurant/Gemfile.lock #COPY Gemfile /sxrestaurant/Gemfile
RUN bundle install --without development test #COPY Gemfile.lock /sxrestaurant/Gemfile.lock
#RUN bundle install --without development test
RUN echo "Asia/Rangoon" > /etc/timezone RUN echo "Asia/Rangoon" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata RUN dpkg-reconfigure -f noninteractive tzdata
RUN date
COPY . /sxrestaurant COPY . /sxrestaurant
RUN gem install bundler
#RUN bundle update --bundler
RUN bundle install --without development test
RUN bundle exec rake assets:precompile RUN bundle exec rake assets:precompile
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

19
Dockerfile.backup Normal file
View File

@@ -0,0 +1,19 @@
FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
RUN mkdir /sxrestaurant
RUN mkdir -p /sxrestaurant/tmp/puma
ENV RAILS_ENV production
ENV RACK_ENV production
WORKDIR /sxrestaurant
#RUN gem install bundler
#COPY Gemfile /sxrestaurant/Gemfile
#COPY Gemfile.lock /sxrestaurant/Gemfile.lock
#RUN bundle install --without development test
RUN echo "Asia/Rangoon" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
COPY . /sxrestaurant
RUN gem install bundler
#RUN bundle update --bundler
RUN bundle install --without development test
RUN bundle exec rake assets:precompile
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

View File

@@ -1,6 +1,9 @@
source 'https://rubygems.org' source 'https://rubygems.org'
# ruby '2.4.1'
#ruby '2.5.0'
#ruby '2.5.7'
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?("/")
@@ -40,6 +43,9 @@ gem 'material_icons'
gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2' gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2'
gem 'rack-cors' gem 'rack-cors'
# Multi-tenancy for shops
gem 'acts_as_tenant'
# image upload # image upload
gem 'carrierwave', '~> 1.0' gem 'carrierwave', '~> 1.0'
gem 'mini_magick' gem 'mini_magick'

View File

@@ -46,6 +46,9 @@ GEM
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts_as_tenant (0.4.4)
rails (>= 4.0)
request_store (>= 1.0.5)
aescrypt (1.0.0) aescrypt (1.0.0)
airbrussh (1.4.0) airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0) sshkit (>= 1.6.1, != 1.7.0)
@@ -219,6 +222,8 @@ GEM
rb-inotify (0.10.0) rb-inotify (0.10.0)
ffi (~> 1.0) ffi (~> 1.0)
redis (3.3.5) redis (3.3.5)
request_store (1.4.1)
rack (>= 1.4)
roo (1.13.2) roo (1.13.2)
nokogiri nokogiri
rubyzip rubyzip
@@ -271,8 +276,7 @@ GEM
activemodel (>= 5.0) activemodel (>= 5.0)
spreadsheet (1.2.5) spreadsheet (1.2.5)
ruby-ole (>= 1.0) ruby-ole (>= 1.0)
spring (2.0.2) spring (2.1.0)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1) spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0) listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0) spring (>= 1.2, < 3.0)
@@ -316,6 +320,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
acts_as_tenant
aescrypt aescrypt
axlsx (= 2.0.1) axlsx (= 2.0.1)
axlsx_rails axlsx_rails

View File

@@ -279,6 +279,15 @@ For Food Court Settings On/Off
** '0' means can not use food court and '1' means can use food court ** ** '0' means can not use food court and '1' means can use food court **
=> settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' } => settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' }
For Number Formats
Precision
=> settings/lookups => { lookup_type: number_format, name: precision, value: {0..2} }
Delimiter
=> settings/lookups => { lookup_type: number_format, name: delimiter, value: { ',', '\u0020', '', ... }
Strip insignificant zeros
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
/* Customer Types in lookups */ /* Customer Types in lookups */
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein } 1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway } 2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }

View File

@@ -623,7 +623,7 @@ $(function() {
row = "<h5>"+attributes[field]["type"]+"</h5>"; row = "<h5>"+attributes[field]["type"]+"</h5>";
$(value).each(function(i){ $(value).each(function(i){
disabled = "" disabled = "false";
status =""; status ="";
if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){ if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
status = "selected-attribute"; status = "selected-attribute";
@@ -1041,7 +1041,12 @@ $(function() {
}else if(result.data == 'OK'){ }else if(result.data == 'OK'){
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text(); window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
}else{ }else{
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"; if(result.current_user_role == 'foodcourt_cashier'){
window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment";
}
else{
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment";
}
} }
} }
} }

View File

@@ -135,7 +135,7 @@ $(document).ready(function() {
// var method = $(this).attr('data-method'); // var method = $(this).attr('data-method');
// var url = $(this).attr('data-ref'); // var url = $(this).attr('data-ref');
// var html_text = $(this).siblings( "#delete_text" ).html(); // var html_text = $(this).siblings( "#delete_text" ).html();
// //var page = url.substring(url.lastIndexOf('/') + 1); // //var page = url.substring(url.lastIndexOf('/') + 1);
// swal({ // swal({
// title: "Confirmation", // title: "Confirmation",
// text: html_text, // text: html_text,
@@ -147,11 +147,11 @@ $(document).ready(function() {
// if (isConfirm) { // if (isConfirm) {
// $.ajax({ // $.ajax({
// type: method, // type: method,
// url: url , // url: url ,
// success: function(data) { // success: function(data) {
// location.href = data.url; // location.href = data.url;
// } // }
// }); // });
// } else { // } else {
// swal("Cancelled", "Your imaginary file is safe :)", "error"); // swal("Cancelled", "Your imaginary file is safe :)", "error");
// } // }
@@ -167,7 +167,7 @@ $(document).ready(function() {
var text = $("#notify_message").attr('data-message'); var text = $("#notify_message").attr('data-message');
if (text != null || colorName != null){ if (text != null || colorName != null){
showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit); showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit);
} }
function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) { function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
@@ -222,8 +222,8 @@ function audioPlayBackground(shop_code,audio){
function getOnlineOrderCount(){ function getOnlineOrderCount(){
var count = 0; var count = 0;
//Start Ajax //Start Ajax
$.ajax({ $.ajax({
async: false, async: false,
type: "GET", type: "GET",
url: "/origami/get_order_info", url: "/origami/get_order_info",
dataType: "json", dataType: "json",
@@ -234,8 +234,8 @@ function getOnlineOrderCount(){
} }
} }
}); });
//end Ajax //end Ajax
// alert(count); // alert(count);
return count; return count;
} }
/* online order count*/ /* online order count*/

View File

@@ -0,0 +1,186 @@
//= require jquery
//= require tether
//= require jquery_ujs
//= require bootstrap/js/popper.min
//= require bootstrap/js/bootstrap-material-design.min
//= require momentjs/moment
//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker
//= require jquery-slimscroll/jquery.slimscroll.js
//= require bootstrap-notify/bootstrap-notify.js
//= require node-waves/waves.js
//= require sweetalert/sweetalert.min.js
//= require fileinput.min
//= require cable
//= require turbolinks
//= require BSBMaterial/turbolink_admin.js
//= require BSBMaterial/demo.js
/* Constant Varaibles */
_CREDIT_PAYMENTS_ = "/&nbsp;&nbsp;&nbsp;CREDIT PAYMENTS";
_CUSTOMERS_ = "/&nbsp;&nbsp;&nbsp;CUSTOMERS";
_DISCOUNTS_ = "/&nbsp;&nbsp;&nbsp;DISCOUNTS";
_IN_DUTIES_ = "/&nbsp;&nbsp;&nbsp;IN DUTIES";
_JCB_ = "/&nbsp;&nbsp;&nbsp;JCB PAYMENT";
_MASTER_ = "/&nbsp;&nbsp;&nbsp;MASTER PAYMENT";
_MPU_ = "/&nbsp;&nbsp;&nbsp;MPU PAYMENT";
_ALIPAY_ = "/&nbsp;&nbsp;&nbsp;Alipay";
_JUNCTIONPAY_ = "/&nbsp;&nbsp;&nbsp;JunctionPay";
_PAYMAL_ = "/&nbsp;&nbsp;&nbsp;PAYMAL";
_DINGA_ = "/&nbsp;&nbsp;&nbsp;DINGA PAYMENT";
_GIFT_VOUCHER_ = "/&nbsp;&nbsp;&nbsp;GIFT VOUCHER";
_OTHER_CHARGES_ = "/&nbsp;&nbsp;&nbsp;CHARGES";
_OTHER_PAYMENTS_ = "/&nbsp;&nbsp;&nbsp;OTHER PAYMENT";
_PAYMENTS_ = "/&nbsp;&nbsp;&nbsp;PAYMENT";
_PAYPAR_PAYMENT_ = "/&nbsp;&nbsp;&nbsp;PAYPAR PAYMENT";
_COMMISSIONS_ = "/&nbsp;&nbsp;&nbsp;COMMISSIONS";
_REDEEM_PAYMENT_ = "/&nbsp;&nbsp;&nbsp;REDEEM PAYMENT";
_SALE_EDIT_ = "/&nbsp;&nbsp;&nbsp;SALE EDIT";
_SPLIT_BILL_ = "/&nbsp;&nbsp;&nbsp;SPLIT BILL";
_UNION_ = "/&nbsp;&nbsp;&nbsp;UNION PAYMENT";
_VISA_ = "/&nbsp;&nbsp;&nbsp;VISA PAYMENT";
_VOUCHER_ = "/&nbsp;&nbsp;&nbsp;VOUCHER";
_SURVEY_ = "/&nbsp;&nbsp;&nbsp;SURVEY";
/* Constant Varaibles */
$(document).on('turbolinks:load', function() {
$("#customer_image_path").fileinput({
previewFileType: "image",
allowedFileExtensions: ["jpg", "gif", "png"],
browseClass: "btn btn-success",
browseLabel: "Pick Image",
browseIcon: "<i class=\"fa fa-image\"></i> ",
removeClass: "btn btn-danger",
removeLabel: "Delete",
removeIcon: "<i class=\"fa fa-trash\"></i> ",
showUpload: false,
// uploadClass: "btn btn-info",
// uploadLabel: "Upload",
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
previewTemplates: {
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
'</div>\n',
}
});
$('.datetimepicker').bootstrapMaterialDatePicker({
format: 'DD-MM-YYYY - HH:mm',
clearButton: true,
weekStart: 1
});
$('.datepicker').bootstrapMaterialDatePicker({
format: 'DD-MM-YYYY',
clearButton: true,
weekStart: 1,
time: false
});
$('.timepicker').bootstrapMaterialDatePicker({
format: 'HH:mm',
clearButton: true,
date: false
});
// For selected order return
var order_status = "";
order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim();
$(document).on('click', '.access_modal', function(event){
type = $(this).data("type");
$(".ok").attr("data-action",type);
$('#AccessCodeModal').modal('show');
});
$(document).on('click', '.access_number', function(event){
if(event.handled !== true) {
var original_value = $('#access_code').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value){
$('#access_code').val(original_value + input_value);
}else{
$('#access_code').val(original_value + input_value);
}
break;
case 'ok':
var type = $(this).attr("data-action");
code = $('#access_code').val();
check_emp_access_code(code,type)
break;
case 'clr':
$('#access_code').val("");
break;
}
event.handled = true;
} else {
return false;
}
});
});
function setHeaderBreadCrumb(params){
$("#others_payment").html(params);
}
//show hide nav bar for webview
function showHideNavbar(webview,page){
if(webview){
$("nav.navbar").addClass("hidden");
$("section").addClass("section-margin");
$(".page-loader-wrapper").addClass("hidden");
if(page!=undefined){
$("#back").hide();
}
}else{
$("nav.navbar").removeClass("hidden");
$("section").removeClass("section-margin");
$(".page-loader-wrapper").removeClass("hidden");
if(page!=undefined){
$("#back").show();
}
}
}
function createAccessCode(code) {
localStorage.setItem("access_code",code);
}
function check_emp_access_code(access_code,type) {
var url = "/foodcourt/check_emp_access_code/" + access_code ;
$.ajax({
type: 'POST',
url: url,
data: {},
success: function (result) {
if (result.status == true) {
createAccessCode(code);
if (type == "edit") {
var dining_id = $('#dining').text();
var sale_id = $('#sale_id').text();
if (dining_id) {
window.location.href = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/food_court/edit";
}else{
window.location.href = "/foodcourt/table/sale/" + sale_id + "/food_court/edit";
}
}else if(type == "void"){
$('#AccessCodeModal').modal('hide');
$('#voidModal').modal('show');
}else if(type == "waste") {
waste_and_spoilage("waste")
}else if(type == "spoile") {
waste_and_spoilage("spoile")
}else if(type == "foc"){
$('#AccessCodeModal').modal('hide');
$('#focModal').modal('show');
}
}else{
swal("Oops",result.message,"warning");
}
}
});
}

View File

@@ -0,0 +1,729 @@
@import "material_icons";
@import "tether";
@import "bootstrap/css/bootstrap-material-design.min";
@import "node-waves/waves";
@import "animate-css/animate";
@import "sweetalert/sweetalert.css";
@import "multi-select/css/multi-select.css";
@import "bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker";
@import "morrisjs/morris";
@import "BSBMaterial/style";
@import "BSBMaterial/themes/all-themes";
@import "reset";
@import "fileinput.min";
/* Reset */
.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto, .col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-auto {
padding-left: 5px;
padding-right: 5px;
}
.col-lg-1, .col-md-1, .col-sm-1,col-xl-1{
padding-left: 1px ;
padding-right: 1px ;
}
.ls-closed section.content {
margin-left: 5px;
}
section.content {
margin: 70px 5px 0 225px;
}
.table {
margin-bottom: 0px;
}
select.form-control {
height: inherit !important;
}
.form-horizontal .form-group {
margin-right: 0px !important;
}
.card-columns {
font-size: 18px !important;
}
@media (min-width:769px) and (max-width:1024px) {
.btn-block {
font-size: 11px !important;
}
}
/* End Reset */
#back {
padding: 0px 0px 7px 0px;
}
/*
.order-info {
min-height:300px;
max-height:500px;
overflow:auto
}
*/
.others-payment{
line-height:100px;
text-align:center;
color:white;
width:300px;
height:100px;
font-size:18px;
}
.orders-table {
cursor: pointer;
}
.cashier_number{
width: 33%;
height:58px;
line-height:58px;
text-align:center;
background:#54A5AF;
// float:left;
// margin:2px;
font-size:20px;
color:white;
// cursor:pointer;
}
.access_number{
width: 33%;
height:58px;
line-height:58px;
text-align:center;
background:#54A5AF;
// float:left;
// margin:2px;
font-size:20px;
color:white;
// cursor:pointer;
}
.del_cashier_number{
opacity:0.6,
}
.pay{
width: 86%;
height:174px;
line-height:174px;
text-align:center;
font-size:20px;
color:white;
}
.move_table{
width: 100%;
height:74px;
line-height:74px;
text-align:center;
font-size:20px;
color:white;
}
.payment{
height:50px;
line-height:50px;
align:center;
color:white;
font-size:16px;
margin:5px;
}
.font-12 {
font-size: 12px;
}
.cash-color{
background-color:#2196F3;
}
.credit-color{
background-color:#FFA500;
}
.other-payment-color{
background-color:#795548;
}
.others-color{
background-color:#E1BEE7;
height: 30px !important;
line-height: 30px !important;
}
.cashier_number:hover{
background:#A9F5F2;
}
.action-btn {
white-space: normal !important;
height: 60px;
margin-bottom: 5px;
}
.radius-btn {
border-radius:5px;
color:#fff;
background-color:red;
}
.bottom-5 {
margin-bottom: 5px;
}
.fluid {
width: 100%;
}
.style2 {
border-top: 3px double #8c8b8b;
}
.long{
width:43%;
}
.sold {
background-color: red;
}
.paid {
background-color: green;
}
.selected-item {
color: #fff !important;
background-color: blue !important;
}
.selected-account {
color: #fff !important;
background-color: blue !important;
}
.selected-payment {
color: #fff !important;
background-color: blue !important;
}
.payment_btn {
white-space: normal !important;
margin-bottom: 15px;
margin-right: 15px;
color:#fff !important;
# background-color: green !important;
}
/* Reciept Style */
#order-charges-table td {
border-top: none !important;
}
.charges-name {
width: 80%;
text-align: left;
}
.item-name {
width: 60%;
text-align: left;
}
.item-attr {
width: 20%;
text-align: right;
}
.item-attr-edit{
width: 10%;
text-align: left;
}
.display-none{
display: none;
}
.text-white{
color: #fff;
}
/* Colors */
.purple {
background-color:#7a62d3;
}
.orange{
background-color:#FF7F50;
}
.red {
background-color:#F44336;
}
.green{
background-color: #009900;
}
.orange{
background-color: #FF8C00;
}
.blue{
background-color: blue;
}
/* End Colors */
.left{
margin-left:1px;
}
.dtp-date .left{
margin-left:0px;
}
.bottom{
margin-bottom:1px;
}
/* Discount */
.required abbr{
color: red !important;
}
.border-top{
border-top:1px solid #fff;
}
.border-right{
border-right:1px solid #fff;
}
.border-left{
border-left:1px solid #fff;
}
#sxModal {
display: none;
overflow: auto;
width: 100%;
height: 100%;
background-color: #000;
background-color: rgba(0,0,0,0.4);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1100;
}
#sxModal-Content {
position: relative;
left: 42%;
top: 30%;
background-color: #32ad1a;
color: #fff;
text-align: center;
width: 200px;
height: 200px;
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
}
/*Loading gif for payment*/
#loading_wrapper{
position: fixed;
background-color: #C8C8C8 ;
height: 100%;
width: 100%;
left: 0;
opacity: 0.6;
top: 0;
z-index: 9999999;
}
#loading{
position: relative;
height: 100%;
width: 100%;
background-image: url('../../../image/loading-ajax.gif');
background-position: center center;
background-repeat: no-repeat;
opacity: 1;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
}
/* For Payment Page */
.payment-long {
width:43%;
}
.payment-left {
margin-left: 20px;
}
/* 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 */
/* selected color for split bills */
.selected-split-item {
color: #fff !important;
background-color: #5DADE2 !important;
}
/* Start Is Member Modal */
#is_memberModal .modal-body {
height: 260px !important;
}
#is_memberModal .btn {
width: 80%;
}
#is_paymemberModal .modal-body {
height: 150px !important;
}
#is_paymemberModal .btn {
width: 80%;
}
/* End Is Member Modal */
/* Start iframe */
iframe {
border: none;
overflow: hidden !important;
width: 400px;
height: 550px;
}
#pdfModal .btn {
width: 150%;
height: 100%;
}
#receipt_pdf {
height: 400px;
}
/* End iframe */
/* section class for webview */
.section-margin {
margin-top: -50px;
}
.tax-btn-box {
width: 230px;
height: 80px;
}
/*Pagination*/
nav.pagination {
margin:10px;
}
nav.pagination .current{
background-color:#1f91f3;
color:#fff;
padding:4px 10px;
margin-top:-4px;
}
nav.pagination .page a,.next a,.last a,.prev a,.first a{
padding:6.5px 10px;
margin-left: 3px;
}
nav.pagination .page a:hover,
a:focus {
background-color: #ccc;
text-decoration: none;
}
nav.pagination .page a:hover,
.first a:hover,.last a:hover,.prev a:hover,.next a:hover{
background-color: #ccc;
text-decoration: none;
}
#oqs_loading_wrapper{
position: fixed;
background-color: #C8C8C8 ;
height: 100%;
width: 100%;
left: 0;
opacity: 0.6;
top: 0;
z-index: 100;
}
#oqs_loading{
position: relative;
height: 100%;
width: 100%;
background-image: url('../../../image/loading-ajax.gif');
background-position: center center;
background-repeat: no-repeat;
opacity: 1;
z-index: 101;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
}
.existing_invoice{
background-color:#ffab51;
color:#fff;
}
/*----chane font_size (Amount Due && Balance)----*/
#balance{
height: 50%;
font-size: 20px;
}
.amount_balance{
height: 50%;
font-size: 20px;
}
#amount_due{
height: 50%;
font-size: 20px;
}
/*customer modal UI */
.wizard {
background: #f1f1f1;
padding: 10px;
}
.wizard .nav-tabs {
position: relative;
border: 0px;
}
.wizard > div.wizard-inner {
position: relative;
margin: 0 0 0 145px !important;
}
.connecting-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 110%;
margin: 0 auto;
left: 0;
right: 0;
top:38%;
z-index: 1;
border-radius: 15px;
}
.active-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 5%;
margin: 0 auto;
left: 0;
right: 0;
top:61%;
z-index: 1;
border-radius: 15px !important;
}
.connecting-line a.active{
background-color: #2ED4E0;
}
.border-right{
border-radius: 15px 0 0 15px;
}
.border-left{
border-radius: 0;
}
.wizard .nav-tabs > li {
margin-bottom: -20px;
}
.wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus {
cursor: default;
border: 0;
color:#2ED4E0;
border-bottom-color: transparent;
}
.wizard .nav-tabs li p{
padding-top:40px;
font-size: 14px;
text-align: center;
}
.list-inline{
text-align: center;
}
span.round-tab {
width: 28px;
height: 28px;
line-height: 28px;
display: inline-block;
border-radius: 100px;
background:#DFE3E4;
border: 2px solid #fff;
z-index:1;
position:absolute;
text-align: center;
font-size: 16px;
}
.wizard li > a.active span.round-tab{
background:#2196F3;
color:white;
border: 1px solid #fff;
}
span.round-tab:hover{
color: white;
border: 1px solid #fff;
background-color:#2196F3;
}
.wizard .nav-tabs > li {
width: 25%;
}
.wizard .nav-tabs > li a{
width: 28px;
height: 28px;
margin: 18px auto;
border-radius: 100%;
padding: 0;
color: #777;
}
.wizard .tab-pane {
position: relative;
padding-top: 5px;
border-top: 1px solid #fff;
margin-top: 20px;
}
.next-step:hover, .next-step, .prev-step:hover, .prev-step{
position: relative;
background-color: #2196F3;
font-size: 14px;
color: #FFFFFF;
}
/*customer modal UI */
.payment-btn-box {
width: 130px;
height: 50px;
}
@media screen and (max-width: 785px) {
section.content{
margin: 80px 15px 0 225px;
}
.mbl_view{
display: none;
}
.navbar-brand-txt{
margin-top: -15px;
}
.toggle_mbl {
text-align: right;
}
.toggle_mbl img{
width: 24px;
margin-bottom: 14px;
}
.toggle_mbl a:hover, a:focus{
background-color: unset;
}
.col-mbl-view{
width: 50%;
}
.info-box .icon{
display: none;
}
.mbl_product_div{
display: none;
}
.sidebar .menu{
top: 10px;
}
.page-header{
width: 100% !important;
}
.ls-closed .bars:after, .ls-closed .bars:before{
top: 14px;
}
.mbl_card{
width: 100% !important;
}
.mbl_lbl{
display: none;
}
.mbl-style{
padding: 10px 10px;
}
.m-auto{
width: 33%;
}
.online_order{
text-align: right;
}
.mbl-right-btn{
text-align: right;
}
}

View File

@@ -1,11 +1,29 @@
class Api::ApiController < ActionController::API class Api::ApiController < ActionController::API
include MultiTenancy
include TokenVerification include TokenVerification
include ActionController::MimeResponds include ActionController::MimeResponds
include ActionView::Rendering
# before_action :lookup_domain before_action :core_allow
helper_method :current_token, :current_login_employee, :get_cashier helper_method :current_token, :current_login_employee, :get_cashier
def core_allow
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
private private
# ActionView::Rendering override render_to_body breaks render :json,
# resulting in an ActionView::MissingTemplate error.
def render_to_body(options)
_render_to_body_with_renderer(options) || super
end
#this is base api base controller to need to inherit. #this is base api base controller to need to inherit.
#all token authentication must be done here #all token authentication must be done here
#response format must be set to JSON #response format must be set to JSON

View File

@@ -1,13 +1,13 @@
class Api::AuthenticateController < Api::ApiController class Api::AuthenticateController < Api::ApiController
skip_before_action :authenticate skip_before_action :authenticate
before_action :find_shop # before_action :find_shop
def create def create
emp_id = params[:emp_id] emp_id = params[:emp_id]
password = params[:password] password = params[:password]
if emp_id && password if emp_id && password
@employee = Employee.login(@shop, emp_id, password) @employee = Employee.login(emp_id, password)
if @employee && @employee.role == "waiter" if @employee && @employee.role == "waiter"
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role}) render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
else else
@@ -67,8 +67,8 @@ class Api::AuthenticateController < Api::ApiController
params.permit(:emp_id, :password, :session_token) params.permit(:emp_id, :password, :session_token)
end end
private private
def find_shop def find_shop
@shop = Shop.find_by_shop_code(params[:shop_code]) @shop = Shop.find_by_shop_code(params[:shop_code])
end end
end end

View File

@@ -2,6 +2,7 @@ class Api::BillController < Api::ApiController
#Create invoice based on booking #Create invoice based on booking
#Output and invoice #Output and invoice
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."
@@ -106,7 +107,7 @@ class Api::BillController < Api::ApiController
# unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"
# #shop detail # #shop detail
# shop_details = Shop.find(1) # shop_details = @shop
# customer= Customer.find(@sale_data.customer_id) # customer= Customer.find(@sale_data.customer_id)
# # get member information # # get member information

View File

@@ -23,7 +23,6 @@ class Api::CallWaitersController < ActionController::API
end end
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids
# get printer info # get printer info
# @shop = Shop.first
unique_code = "CallWaiterPdf" unique_code = "CallWaiterPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)

View File

@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if !order_reservation_id.nil? && flag if !order_reservation_id.nil? && flag
shop = Shop.find_by_id(1) shop = @shop
if !shop.nil? if !shop.nil?
shop_code = shop.shop_code shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
@@ -96,9 +96,6 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" } result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
end end
end end
# puts "!!! send doemal ::"
# puts result
Rails.logger.debug "send status to doemal" Rails.logger.debug "send status to doemal"
Rails.logger.debug result Rails.logger.debug result

View File

@@ -46,9 +46,7 @@ class Api::OrdersController < Api::ApiController
@tax_profile = TaxProfile.where("lower(group_type)='cashier'") @tax_profile = TaxProfile.where("lower(group_type)='cashier'")
# end # end
# @shop = Shop.first #
puts "Hello world"
puts @shop.to_json
return @shop.to_json return @shop.to_json
end end
@@ -64,77 +62,89 @@ class Api::OrdersController < Api::ApiController
def create def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s Rails.logger.debug "Table ID - " + params[:table_id].to_s
@shop = Shop.find_by_shop_code(params[:shop_code])
current_shift = ShiftSale.current_shift
if current_shift.nil?
@status = false
@message = "No Current Open Shift for This Employee"
else
current_user =Employee.find(current_shift.employee_id)
if checkin_checkout_time(params[:booking_id])
if checkin_checkout_time(params[:booking_id]) if params[:booking_id].present?
booking = Booking.find(params[:booking_id])
if params[:booking_id].present? end
booking = Booking.find(params[:booking_id]) if params[:table_id].present?
end if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
if params[:table_id].present? table = DiningFacility.find(params[:table_id])
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i booking = table.get_current_booking
table = DiningFacility.find(params[:table_id]) end
booking = table.get_current_booking
end end
end
#for extratime #for extratime
is_extra_time = false is_extra_time = false
extra_time = '' extra_time = ''
params[:order_items].each { |i| params[:order_items].each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext" if i["item_instance_code"].include? "ext"
is_extra_time = true is_extra_time = true
arr_exts = i["item_instance_code"].split("_") arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/) if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time) extra_time = Time.at(time)
end
end
}
#end extra time
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items]
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.shop_code = @shop.shop_code
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
end
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
# # for parallel order
# remoteIP = ""
# begin
# @status, @booking = @order.generate
# remoteIP = request.remote_ip
# end while request.remote_ip != remoteIP
if current_user.role != "waiter" && params[:create_type] == "create_pay"
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
@status, @sale = Sale.request_bill(@order,current_user,current_user)
end end
end end
}
#end extra time
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items]
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
@order.new_booking = true
else else
@order.new_booking = false return return_json_status_with_code(406, "Checkout time is over!")
@order.booking_id = booking.booking_id
end end
@status, @booking = @order.generate
if @status && @booking
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
end
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
# # for parallel order
# remoteIP = ""
# begin
# @status, @booking = @order.generate
# remoteIP = request.remote_ip
# end while request.remote_ip != remoteIP
else
return return_json_status_with_code(406, "Checkout time is over!")
end end
end end
@@ -150,7 +160,6 @@ class Api::OrdersController < Api::ApiController
table = DiningFacility.find(table_id) table = DiningFacility.find(table_id)
if table if table
booking = table.get_current_booking booking = table.get_current_booking
# puts booking
if booking if booking
if !booking.sale_id.nil? if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"

View File

@@ -14,11 +14,12 @@ class Api::Payment::MobilepaymentController < Api::ApiController
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id)
# shop_detail = Shop.first
shop_detail = @shop
# rounding adjustment # rounding adjustment
if !path.include? ("credit_payment") if !path.include? ("credit_payment")
if @shop.is_rounding_adj if shop_detail.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #not calculate rounding if modulus is 0 and division is even

View File

@@ -1,5 +1,5 @@
class Api::PaymentsController < Api::ApiController class Api::PaymentsController < Api::ApiController
skip_before_action :authenticate
#Payment by Invoice ID #Payment by Invoice ID
# Payment Method - [Cash | CreditNote | VISA | MASTER | etc..] # Payment Method - [Cash | CreditNote | VISA | MASTER | etc..]
@@ -25,9 +25,14 @@ class Api::PaymentsController < Api::ApiController
if params[:sale_id] && params[:card_no] if params[:sale_id] && params[:card_no]
sale = Sale.find_by_sale_id(params[:sale_id]) sale = Sale.find_by_sale_id(params[:sale_id])
if !sale.nil? if !sale.nil?
sale_id =sale.sale_id
sale_items = SaleItem.get_all_sale_items(sale_id)
@shop =Shop.find_by_shop_code(sale.shop_code)
if sale.sale_status == "new" if sale.sale_status == "new"
if !params[:card_no].empty? if !params[:card_no].empty?
@status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no) current_shift = ShiftSale.current_shift
current_login_employee =Employee.find(current_shift.employee_id)
@status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no,current_login_employee)
if @status if @status
sale_payment = SalePayment.new sale_payment = SalePayment.new
status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:card_no]) status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:card_no])
@@ -36,9 +41,123 @@ class Api::PaymentsController < Api::ApiController
sale_payment = SalePayment.new sale_payment = SalePayment.new
status = sale_payment.process_payment(sale, current_login_employee, 0, "cash") status = sale_payment.process_payment(sale, current_login_employee, 0, "cash")
#card_balance amount for Paymal payment #card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(params[:sale_id]) card_balance_amount, transaction_ref = SaleAudit.getCardBalanceAmount(params[:sale_id])
render json: JSON.generate({:status => true, :balance_amount => card_balance_amount,:receipt_no => sale.receipt_no, :message => "Payment successful."})
rebate_amount = nil
# For Cashier by Zone
bookings = Booking.find_by_sale_id(sale_id)
shift = ShiftSale.current_open_shift(current_login_employee)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings.dining_facility_id.to_i > 0
table = DiningFacility.find(bookings.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
type = 'payment'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
end
# For Print
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
# else
end
end
end
end
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
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)
if member_info["status"] == true
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
end
#orders print out
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
end
booking.booking_orders.each do |order|
# Order.pay_process_order_queue(order.order_id, table_id)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
render json: JSON.generate({:status => true, :balance_amount => card_balance_amount,:receipt_no => sale.receipt_no,:order_no => latest_order_no, :message => "Payment successful."})
else else
if @membership_data if @membership_data
if @membership_data["card_balance_amount"] != "null" if @membership_data["card_balance_amount"] != "null"
@@ -67,15 +186,15 @@ class Api::PaymentsController < Api::ApiController
end end
end end
def send_account_paymal(amount, account_no, receipt_no) def send_account_paymal(amount, account_no, receipt_no,current_login_employee)
sale = Sale.find_by_receipt_no(receipt_no) sale = Sale.find_by_receipt_no(receipt_no)
@out = [] @out = []
action_by = current_login_employee.name action_by = current_login_employee.name
@status = true @status = true
@message = "" @message = ""
membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code)
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_and_shop_code("get_account_balance",sale.shop_code)
if member_actions.gateway_url if member_actions.gateway_url
@campaign_type_id = nil @campaign_type_id = nil
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
@@ -180,4 +299,13 @@ class Api::PaymentsController < Api::ApiController
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee) @status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee)
end end
end end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain.to_s + "." + request.domain.to_s
end
return from
end
end end

View File

@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
#sound effect / alarm api for doemal side calling #sound effect / alarm api for doemal side calling
def sound_effect def sound_effect
shop = Shop.find_by_id(1) shop = @shop
if !shop.nil? if !shop.nil?
shop_code = shop.shop_code shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio") order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")

View File

@@ -15,11 +15,7 @@ class Api::SurveyController < Api::ApiController
def create def create
dining_facility = DiningFacility.find(params[:id]) dining_facility = DiningFacility.find(params[:id])
# cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id) open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# puts params.to_json
# set cashier
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift(@shop.shop_code) current_shift = ShiftSale.current_shift(@shop.shop_code)
current_shift_user =Employee.find_by_id(current_shift.employee_id) current_shift_user =Employee.find_by_id(current_shift.employee_id)
if open_cashier.count>0 if open_cashier.count>0

View File

@@ -1,5 +1,5 @@
class Api::VerificationsController < ActionController::API class Api::VerificationsController < Api::ApiController
skip_before_action :authenticate
def new def new
phone_number = params[:phone_number] phone_number = params[:phone_number]

View File

@@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
#before_action :check_installation #before_action :check_installation
@@ -17,5 +18,4 @@ class ApplicationController < ActionController::Base
flash[:warning] = exception.message flash[:warning] = exception.message
redirect_to root_path redirect_to root_path
end end
end end

View File

@@ -1,5 +1,6 @@
class BaseController < ActionController::Base class BaseController < ActionController::Base
include MultiTenancy
layout "installation" layout "installation"
protect_from_forgery with: :exception protect_from_forgery with: :exception
end end

View File

@@ -1,4 +1,7 @@
class BaseCrmController < ActionController::Base class BaseCrmController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
layout "CRM" layout "CRM"

View File

@@ -0,0 +1,58 @@
class BaseFoodcourtController < ActionController::Base
include LoginVerification, MultiTenancy
layout "foodcourt"
before_action :check_user
#before_action :check_installation
protect_from_forgery with: :exception
helper_method :current_token
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
# redirect_to origami_root_path
redirect_to origami_dashboard_path
end
def check_user
if check_mobile
if current_user.nil?
return render status: 401, json: {
message: "User using other device!"
}.to_json
end
else
if current_user.nil?
redirect_to root_path
end
end
end
# def checkin_process
# CheckinJob.set(wait: 1.minute).perform_later()
# end
##already in LoginVerification
# Get current Cashier
# def get_cashier
# @cashier = Employee.where("role = 'cashier' AND token_session <> ''")
# end
#check webview
def check_mobile
status = false
authenticate_with_http_token do |token, options|
if token
session[:webview] = true
session[:session_token] = token
end
end
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
status = true
end
return status
end
end

View File

@@ -1,4 +1,6 @@
class BaseInventoryController < ActionController::Base class BaseInventoryController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
layout "inventory" layout "inventory"

View File

@@ -1,5 +1,8 @@
class BaseOqsController < ActionController::Base class BaseOqsController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
layout "OQS" layout "OQS"
before_action :check_user before_action :check_user

View File

@@ -1,4 +1,6 @@
class BaseOrigamiController < ActionController::Base class BaseOrigamiController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
layout "origami" layout "origami"

View File

@@ -1,11 +1,13 @@
class BaseReportController < ActionController::Base class BaseReportController < ActionController::Base
include MultiTenancy
include LoginVerification include LoginVerification
layout "application" layout "application"
before_action :check_user before_action :check_user
#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|
flash[:warning] = exception.message flash[:warning] = exception.message
@@ -26,61 +28,51 @@ class BaseReportController < ActionController::Base
} }
def get_date_range_from_params def get_date_range_from_params
period_type = params[:period_type] period_type = params[:period_type]
period = params[:period] period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now.utc.getlocal
if from.present? && to.present? if params[:from].present? && params[:to].present?
from = Time.parse(params[:from])
to = Time.parse(params[:to])
else
case period.to_i
when PERIOD["today"]
from = Time.now
to = Time.now
when PERIOD["yesterday"]
from = 1.day.ago
to = 1.day.ago
when PERIOD["this_week"]
from = Time.now.beginning_of_week
to = Time.now
when PERIOD["last_week"]
from = 1.week.ago.beginning_of_week
to = 1.week.ago.end_of_week
when PERIOD["last_7"]
from = 7.day.ago
to = Time.now
when PERIOD["this_month"]
from = Time.now.beginning_of_month
to = Time.now
when PERIOD["last_month"]
from = 1.month.ago.beginning_of_month
to = 1.month.ago.end_of_month
when PERIOD["last_30"]
from = 30.day.ago
to = Time.now
when PERIOD["this_year"]
from = Time.now.beginning_of_year
to = Time.now
when PERIOD["last_year"]
from = 1.year.ago.beginning_of_year
to = 1.year.ago.end_of_year
end
end
f_date = DateTime.parse(from) from = from.beginning_of_day
t_date = DateTime.parse(to) to = to.end_of_day
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else return from, to
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end end
def check_user def check_user

View File

@@ -1,5 +1,7 @@
class BaseWaiterController < ActionController::Base class BaseWaiterController < ActionController::Base
include LoginVerification
include MultiTenancy
include LoginVerification
layout "waiter" layout "waiter"
before_action :check_user before_action :check_user

View File

@@ -56,7 +56,7 @@ module LicenseVerification
elsif (flag == 2) elsif (flag == 2)
flash[:notice] = 'Expiring! Please, License extend...' flash[:notice] = 'Expiring! Please, License extend...'
else else
puts "RUN SAY BYAR" Rails.logger.info "License successed"
end end
end end

View File

@@ -2,7 +2,7 @@ module LoginVerification
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
before_action :authenticate_session_token before_action :authenticate_session_token
helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
end end
#this is base api base controller to need to inherit. #this is base api base controller to need to inherit.
@@ -18,38 +18,34 @@ module LoginVerification
def current_shop def current_shop
begin begin
shop_code ='262' return @shop
@shop =Shop.find_by_shop_code(shop_code)
return @shop
rescue rescue
return nil return nil
end end
end end
def current_login_employee def current_login_employee
@employee = Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code) @employee = Employee.find_by_token_session(session[:session_token])
end end
def current_user def current_user
@current_user ||= Employee.find_by_token_session_and_shop_code(session[:session_token],@shop.shop_code) if session[:session_token] @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end end
# Get current Cashiers # Get current Cashiers
def get_cashier def get_cashier
@cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") @cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end end
#Shop Name in Navbor #Shop Name in Navbor
def shop_detail def shop_detail
shop_code ='262' @shop = current_shop
@shop = Shop.find_by_shop_code(shop_code)
return @shop
end end
#check order reservation used #check order reservation used
def order_reservation def order_reservation
order_reserve = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation') order_reserve = Lookup.collection_of('order_reservation')
status = false status = false
if !order_reserve.empty? if !order_reserve.empty?
order_reserve.each do |order| order_reserve.each do |order|
@@ -65,7 +61,7 @@ module LoginVerification
#check bank integration used #check bank integration used
def bank_integration def bank_integration
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration') bank_integration = Lookup.collection_of('bank_integration')
status = false status = false
if !bank_integration.empty? if !bank_integration.empty?
bank_integration.each do |bank| bank_integration.each do |bank|
@@ -90,8 +86,7 @@ module LoginVerification
if (token) if (token)
#@current_user = User.find_by(api_key: token) #@current_user = User.find_by(api_key: token)
#Rails.logger.debug "token - " + token.to_s #Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token)
@user =Employee.authenticate_by_token(token,current_shop)
if @user if @user
return true return true
#Maybe log - login? #Maybe log - login?

View File

@@ -0,0 +1,20 @@
module MultiTenancy
extend ActiveSupport::Concern
included do
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
helper_method :current_shop if respond_to? :helper_method
end
private
def find_shop_by_subdomain_or_frist
if request.subdomain.present?
shop_code = request.subdomain.partition('-').last
@shop = Shop.find_by(shop_code: shop_code)
else
@shop = Shop.first
end
set_current_tenant(@shop)
end
end

View File

@@ -0,0 +1,68 @@
module NumberFormattable
extend ActiveSupport::Concern
def precision
return @precision if defined? @precision
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
end
if @precision.nil?
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
if @print_settings
@precision = @print_settings.precision.to_i
else
@precision = 2
end
end
end
def delimiter
return @delimiter if defined? @delimiter
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
end
if @delimiter.nil?
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
if @print_settings && @print_settings.delimiter
@delimiter = ","
else
@delimiter = ","
end
end
end
def strip_insignificant_zeros
return @strip_insignificant_zeros if defined? @strip_insignificant_zeros
@number_formats = Lookup.number_formats if !defined? @number_formats
if @number_formats
@strip_insignificant_zeros = @number_formats.find { |f| f.name.parameterize.underscore == 'strip_insignificant_zeros'}.value.in? ['1', 't', 'true', 'on', 'y', 'yes'] rescue false
end
end
def number_format(number, options = {})
options[:precision] = options[:precision] || precision
# options[:delimiter] = options[:delimiter] || delimiter
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
number = number.to_f.round(options[:precision])
if options[:precision] > 0
if options[:strip_insignificant_zeros]
formatted = "%.12g" % number
else
formatted = "%.#{options[:precision]}f" % number
end
else
formatted = number.to_i.to_s
end
if options[:delimiter] && !options[:delimiter].empty?
formatted = formatted.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, "\\1#{options[:delimiter]}")
end
return formatted
end
end

View File

@@ -9,18 +9,18 @@ module TokenVerification
protected protected
# Authenticate the user with token based authentication # Authenticate the user with token based authentication
def authenticate def authenticate
authenticate_token || render_unauthorized authenticate_token || render_unauthorized
end end
def authenticate_token def authenticate_token
authenticate_with_http_token do |token, options| authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s # Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL") if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud") if(ENV["SERVER_MODE"] === "cloud")
from = request.subdomain.downcase + "." + request.domain.downcase #"local" from = request.subdomain.downcase + "." + request.domain.downcase #"local"
aes = MyAesCrypt.new aes = MyAesCrypt.new
return aes.checkKeyForAuth(from, token) return aes.checkKeyForAuth(from, token)
end end
end end

View File

@@ -83,7 +83,7 @@ class Crm::CustomersController < BaseCrmController
@membership_types = Lookup.collection_of("member_group_type") @membership_types = Lookup.collection_of("member_group_type")
# @taxes = TaxProfile.where(:group_type => 'cashier') # @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC") .order("group_type ASC,order_by ASC")
@filter = filter @filter = filter
@@ -103,11 +103,6 @@ class Crm::CustomersController < BaseCrmController
end end
end end
end end
# if flash["errors"]
# @crm_customer.valid?
# end
# puts @crm_customers.to_json
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.json { render json: @crm_customers } format.json { render json: @crm_customers }

View File

@@ -6,8 +6,8 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues.json # GET /crm/dining_queues.json
def index def index
today = DateTime.now.strftime('%Y-%m-%d') today = DateTime.now.strftime('%Y-%m-%d')
@dining_queues = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") @dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
@complete_queue = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") @complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
if params[:term] if params[:term]
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%") @customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
@@ -39,7 +39,6 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues # POST /crm/dining_queues
# POST /crm/dining_queues.json # POST /crm/dining_queues.json
def create def create
puts dining_queue_params
@dining_queue = DiningQueue.new(dining_queue_params) @dining_queue = DiningQueue.new(dining_queue_params)
@dining_queue.shop_code = @shop.shop_code @dining_queue.shop_code = @shop.shop_code
respond_to do |format| respond_to do |format|
@@ -88,7 +87,7 @@ class Crm::DiningQueuesController < BaseCrmController
def assign def assign
@queue = DiningQueue.find(params[:id]) @queue = DiningQueue.find(params[:id])
@tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'") @tables = DiningFacility.where("status = 'available' and type!='HotelRoom'")
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
end end
@@ -109,8 +108,7 @@ class Crm::DiningQueuesController < BaseCrmController
:type => type, :type => type,
:checkin_at => Time.now.utc, :checkin_at => Time.now.utc,
:customer_id => queue.customer_id, :customer_id => queue.customer_id,
:booking_status => "assign", :booking_status => "assign"})
:shop_code => @shop.shop_code})
booking.save! booking.save!
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign") status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
@@ -139,7 +137,7 @@ class Crm::DiningQueuesController < BaseCrmController
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_dining_queue def set_dining_queue
@dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code) @dining_queue = DiningQueue.find_by_id(params[: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.

View File

@@ -0,0 +1,309 @@
class Foodcourt::AddordersController < BaseFoodcourtController
# before_action :set_dining, only: [:detail]
def index
@webview = false
if check_mobile
@webview = true
end
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
@all_table = Table.all.active.order('status desc')
@all_room = Room.all.active.order('status desc')
end
def detail
@cashier_type = params[:type]
@webview = false
if check_mobile
@webview = true
end
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@display_type = nil
end
@menus = []
@menu = []
@table_id = params[:id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
if @booking
@booking_id = @booking.booking_id
@obj_order = @booking.orders.first
@customer = @obj_order.customer
@date = @obj_order.created_at
@order_items = @booking.order_items
end
end
def get_menu_category ()
if (params[:id])
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
MenuCategory.current_menu
end
end
def get_item_instance
@instance = MenuItemInstance.find(params[:id])
end
def get_menu()
if (params[:id])
#Pull this menu
@menu = Menu.find_by_id(params[:id])
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
Menu.current_menu
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()
@product = Product.all
end
def create
if params[:booking_id].present?
booking = Booking.find(params[:booking_id])
end
if params[:table_id].present?
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
table = DiningFacility.find(params[:table_id])
booking = table.get_current_booking
end
end
is_extra_time = false
extra_time = ''
items_arr = []
JSON.parse(params[:order_items]).each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"];
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
else
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
end
items_arr.push(items)
}
# begin
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
customer_id = "CUS-000000000002" # for no customer id from mobile
else
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
end
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = customer_id
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.shop_code = @shop.shop_code
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
@status, @booking = @order.generate
if @status && @booking
#send order broadcast to order_channel
if @order.table_id.to_i > 0
table = DiningFacility.find(@booking.dining_facility_id)
type = 'order'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
process_order_queue(@order.order_id,@order.table_id,@order.source)
end
end
# Order.send_customer_view(@booking)
if current_user.role != "waiter" && params[:create_type] == "create_pay"
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
if @order.source == 'quick_service'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
end
#end
result = {:status=> @status, :data => @sale ,:current_user_role =>current_user.role}
render :json => result.to_json
end
else
result = {:status=> @status, :data => 0 }
render :json => result.to_json
end
end
# render json for http status code
def return_json_status_with_code(code, msg)
render status: code, json: {
message: msg,
booking_id: booking_id
}.to_json
end
def check_order_with_table(table_id)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
# puts booking
if booking
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
end
else
@order.new_booking = false
@order.booking_id = booking.booking_id
return false
end
end
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
return false
end
end
def process_order_queue(order_id,table_id,order_source)
print_status = nil
cup_status = nil
#Send to background job for processing
order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
from = ""
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
end
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
from = getCloudDomain #get sub domain in cloud mode
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
end
end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain.to_s + "." + request.domain.to_s
end
return from
end
end

View File

@@ -0,0 +1,27 @@
class Foodcourt::CardPaymentsController < BaseFoodcourtController
def index
@membership_rebate_balance = 0
@membership_id = 0
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
if membership_data["status"]==true
membership_account_data = membership_data["data"];
membership_account_data.each do |acc_data|
if acc_data["accountable_type"] == "REBATEACCOUNT"
@membership_rebate_balance=acc_data["balance"]
else
@membership_rebate_balance = 0
end
end
else
@membership_rebate_balance = 0
end
end
end
def create
end
end

View File

@@ -0,0 +1,43 @@
class Foodcourt::CashInsController < BaseFoodcourtController
def new
end
def create
reference = params[:reference]
remark = params[:remark]
amount = params[:amount]
payment_method = params[:payment_method]
payment_method_reference = params[:payment_method_reference]
type = params[:type]
p_jour = PaymentJournal.new
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
shift = ShiftSale.current_open_shift(current_user)
current_shift = ShiftSale.current_shift(@shop.shop_code)
# set cashier
if shift != nil
shift = shift
else
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0])
if shift
emp = Employee.find_by_id(shift.employee_id)
shift = ShiftSale.current_open_shift(emp)
else
shift = ShiftSale.current_open_shift(current_shift)
end
else
# shift = Employee.find(current_shift.employee_id).name
shift =current_shift
end
end
shift.cash_in = shift.cash_in + amount.to_f
shift.save
end
end

View File

@@ -0,0 +1,39 @@
class Foodcourt::CashOutsController < BaseFoodcourtController
def new
end
def create
reference = params[:reference]
remark = params[:remark]
amount = params[:amount]
p_jour = PaymentJournal.new
p_jour.cash_out(reference, remark, amount, current_user)
shift = ShiftSale.current_open_shift(current_user)
current_shift = ShiftSale.current_shift(@shop.shop_code)
# set cashier
if shift != nil
shift = shift
else
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0])
if shift
emp = Employee.find_by_id(shift.employee_id)
shift = ShiftSale.current_open_shift(emp)
else
shift = ShiftSale.current_open_shift(current_shift)
end
else
# shift = Employee.find(current_shift.employee_id).name
shift =current_shift
end
end
shift.cash_out = shift.cash_out + amount.to_i
shift.save
end
end

View File

@@ -0,0 +1,193 @@
class Foodcourt::CustomersController < BaseFoodcourtController
load_and_authorize_resource
def index
end
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
end
def get_customer
filter = params[:filter]
type = params[:type]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
# search account no from paypar
if !@crm_customers.present? && type == "card"
response = Customer.search_paypar_account_no(filter)
if response["status"] == true
@crm_customers = Customer.new
@crm_customers.name = response["customer_data"]["name"]
@crm_customers.contact_no = response["customer_data"]["phone"]
@crm_customers.email = response["customer_data"]["email"]
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
@crm_customers.nrc_no = response["customer_data"]["NRC"]
@crm_customers.address = response["customer_data"]["address"]
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
@crm_customers.paypar_account_no = filter
@crm_customers.membership_id = response["customer_data"]["id"]
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"]
@crm_customers.save
@crm_customers = Customer.search(filter)
else
@crm_customers = [{"customer_id": response["status"],"message": response["message"] }]
end
end
end
render :json => @crm_customers.to_json
end
def add_customer
@webview = false
if check_mobile
@webview = true
end
@sale_id = params[:sale_id]
@cashier_type = params[:type]
@page = params[:dir_page]
if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id)
if @booking.dining_facility_id.to_i > 0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@dining_facility = nil
end
else
@booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id)
if @booking.dining_facility_id.to_i > 0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@dining_facility = nil
end
end
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id") #.page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
# @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC")
# if flash["errors"]
# @crm_customer.valid?
# end
@membership_types = Lookup.collection_of("member_group_type")
#get paypar accountno
@paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no")
#for create customer on/off
@create_flag = true
lookup_customer = Lookup.collection_of('customer_settings')
if !lookup_customer.empty?
lookup_customer.each do |create_setting|
if create_setting[0].downcase == "create"
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
@create_flag = false
end
end
end
end
respond_to do |format|
# format.html { render :template => "crm/customers/index" }
format.html { render action: "index"}
format.json { render json: @crm_customers }
end
end
def update_sale_by_customer
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
order_source = params[:type]
# Check and find with card no
# if(!customer_id.include? "CUS")
# customer = Customer.find_by_paypar_account_no(customer_id)
# if(customer != nil)
# customer_id = customer.customer_id
# end
# end
if(id == "SAL")
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: customer_id)
sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
action_by = current_user.id
remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" )
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
@orders.each do |bo|
order = Order.find(bo.order_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
end
if status == true
render json: JSON.generate({:status => true})
if(id == "SAL")
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
end
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
def send_account
amount = params[:amount]
account_no = params[:account_no]
receipt_no = params[:receipt_no]
sale = Sale.find_by_receipt_no(receipt_no)
@out = []
action_by = current_user.name
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
if membership_data["status"]==true
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
else
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
end
@out = membership_data
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
end
end
end
end

View File

@@ -0,0 +1,121 @@
class Foodcourt::DashboardController < BaseFoodcourtController
def index
today = DateTime.now.strftime('%Y-%m-%d')
@display_type = Lookup.find_by_lookup_type("display_type")
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
pay = Sale.payment_sale(@shop,'card', today, current_user)
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
else
@sale_data = nil
end
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(@shop,today,current_user)
@total_accounts = Sale.total_account(@shop,today,current_user)
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(@shop,account.account_id, today,current_user)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
else
@account_data = nil
end
@top_items = Sale.top_items(@shop,today,current_user)
@total_foc_items = Sale.total_foc_items(@shop,today,current_user)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user
#dine-in cashier
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier')
@dinein_cashier = 0
if !dinein_cashier[0].nil?
@dinein_cashier = dinein_cashier[0][1]
end
#quick service
quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service')
@quick_service = 0
if !quick_service[0].nil?
@quick_service = quick_service[0][1]
end
#fourt court
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court')
@food_court = 0
@food_court_name = nil
if !food_court[0].nil?
@food_court = food_court[0][1]
@food_court_name = food_court[0][0]
end
#order reservation
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation')
@order_reservation = 0
if !order_reservation.empty?
order_reservation.each do |order_reserve|
if order_reserve[0] == 'OrderReservation'
@order_reservation = order_reserve[1]
end
end
end
#dashboard settings on/off for supervisor and cashier
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings')
@setting_flag = true
if !dashboard_settings.empty?
dashboard_settings.each do |setting|
if setting[0].to_s.downcase == current_user.role.downcase && setting[1] == '0'
@setting_flag = false
end
end
end
#reservation
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation')
@reservation = 0
if !reservation.empty?
reservation.each do |reserve|
if reserve[0] == 'Reservation'
@reservation = reserve[1]
end
end
end
end
def get_all_menu
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all
@item_attributes = MenuItemAttribute.all.load
@item_options = MenuItemOption.all.load
end
def get_credit_sales
credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code)
if !credit_sales.nil?
result = {:status=> true, :data=> credit_sales }
else
result = {:status=> false, :message=>"There is no record." }
end
render :json => result.to_json
end
end

View File

@@ -0,0 +1,336 @@
class Foodcourt::DiscountsController < BaseFoodcourtController
authorize_resource :class => false
#discount page show from origami index with selected order
def index
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@webview = false
if check_mobile
@webview = true
end
sale_id = params[:id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
if @sale_data.bookings[0].dining_facility_id.to_i > 0
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
else
@table = nil
end
end
@member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.where("shop_code='#{@shop.shop_code}'")
end
#discount page show from origami index with selected order
def create
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
overall_discount = params[:overall_discount]
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
else
table = nil
table_id = nil
end
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
if discount_items.length > 0
#save sale item for discount
discount_items.each do |di|
origin_sale_item = SaleItem.find(di["id"])
sale_item = SaleItem.new
# if !origin_sale_item.nil?
# menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items
# if !menu_category.nil?
# sale_item.menu_category_code = menu_category.code
# sale_item.menu_category_name = menu_category.name
# end
# end
sale_item.menu_category_code = origin_sale_item.menu_category_code
sale_item.menu_category_name = origin_sale_item.menu_category_name
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = di["name"]
sale_item.item_instance_code = origin_sale_item.item_instance_code
sale_item.product_alt_name = ""
sale_item.status = "Discount"
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * -1
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 1
sale_item.account_id = origin_sale_item.account_id
sale_item.price = di["price"]
sale_item.save
action_by = current_user.name
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" )
end
end
# Re-calc All Amount in Sale
if overall_discount.to_f > 0
action_by = current_user.name
if table.nil?
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- no Table "
else
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(overall_discount.to_f, nil,order_source)
if !table.nil?
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Success" }
end
else
if !table.nil?
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!" }
end
end
render :json => result.to_json
end
# Remove selected discount Items
def remove_discount_items
order_source = params[:cashier_type]
sale_id = params[:sale_id]
discount_items = JSON.parse(params[:discount_items])
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
else
table_id = nil
table = nil
end
if discount_items.length > 0
#destroy sale item for discount
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
sale.total_amount = (sale.total_amount + sale_item.price.abs)
action_by = current_user.name
if table.nil?
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
else
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" )
sale_item.destroy
end
end
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
end
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
end
render :json => result.to_json
end
# Remove all discount Items
def remove_all_discount
sale_id = params[:id]
order_source = params[:type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
table_type = table.type
else
table_id = nil
table = nil
table_type = nil
end
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
end
# sale.total_discount = 0
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
#destroy in sale.sale_items
sale.sale_items.destroy(discount_items)
action_by = current_user.name
if table.nil?
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
else
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(0, nil, order_source)
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
else
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
end
render :json => result.to_json
end
# Member Discount
def member_discount
order_source = params[:cashier_type]
sale_id = params[:sale_id]
is_card = params[:is_card]
sub_total = params[:sub_total]
tax_type = params[:tax_type]
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
is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments)
# if is_card != "true"
account_types = Account.where("discount=?",true)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
# Get Prices for each accounts (eg: food, beverage)
account_price = SaleItem.calculate_price_by_accounts(sale.sale_items)
acc_prices = Array.new;
account_types.each do |at|
account_price.each do |pc|
if pc[:name] == at.title && pc[:price]>0
str={type:pc[:name],amount:pc[:price]}
acc_prices.push(str)
end
end
end
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.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
if acc_prices.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: account_no,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
campaign_method:acc_prices.to_json,
total_sale_transaction_amount: sale.grand_total,
is_card: is_card,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
}, :timeout => 10)
rescue HTTParty::Error
response = {"status": false, "message": "Http party error" }
rescue Net::OpenTimeout
response = {"status": false, "message": "Connection TIme out " }
rescue OpenURI::HTTPError
response = {"status": false, "message": "Can't open membership server " }
rescue SocketError
response = {"status": false, "message": "Can't open membership server " }
end
else
response = {"status": false, "message": "You have no selected discount item" }
end
Rails.logger.debug "-------------- Member Discount Osaka ---------"
Rails.logger.debug response.to_json
# Re-calc All Amount in Sale
if response["status"] == true
discount_amount = response["discount_earned"]
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(discount_amount, 'member_discount', order_source, tax_type)
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
else
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
render :json => result.to_json
# end #end Is Card Payment
end
end

View File

@@ -0,0 +1,207 @@
class Foodcourt::FoodCourtController < ApplicationController
# before_action :set_dining, only: [:detail]
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
def index
today = DateTime.now
day = Date.today.wday
# if params[:menu] == "true"
@menus = []
@menu = []
# else
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# end
@zone = Zone.all.where("is_active= true")
@customer = Customer.all
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@cashier_type = "food_court"
#checked quick_service only
@quick_service_only = true
lookup_dine_in = Lookup.collection_of('dinein_cashier')
if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"
if dine_in[1] == '1'
@quick_service_only = false
end
end
end
end
@app_order_new_count = Booking.select("bookings.*,customers.*")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
render "foodcourt/addorders/detail"
end
def modify_order
@cashier_type = "food_court"
today = DateTime.now
day = Date.today.wday
# if params[:menu] == "true"
@menus = []
@menu = []
# else
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# end
if(params[:id][0,3] == "BKI")
@table_id = nil
@table = nil
@booking = Booking.find(params[:id])
else
@table_id = params[:id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
end
@sale_id = @booking.sale_id
if @booking
@booking_id = @booking.booking_id
@obj_order = @booking.orders.first
@customer = @obj_order.customer
@date = @obj_order.created_at
@order_items = @booking.order_items
end
render "foodcourt/addorders/detail"
end
def update_modify_order
booking = Booking.find(params[:booking_id])
sale = booking.sale
if sale && sale.sale_status != 'new'
render :json => { :status => false }
end
is_extra_time = false
extra_time = ''
cashier_type = "food_court"
items_arr = []
JSON.parse(params[:order_items]).each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"]
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
else
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
end
items_arr.push(items)
}
# begin
order = Order.new
order.source = params[:order_source]
order.order_type = params[:order_type]
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.items = items_arr
order.guest = params[:guest_info]
order.table_id = params[:table_id] # this is dining facilities's id
order.waiters = current_login_employee.name
order.employee_name = current_login_employee.name
order.is_extra_time = is_extra_time
order.extra_time = extra_time
order.new_booking = false
order.booking_id = booking.booking_id
if order.generate
if sale
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
render :json => { :status => true, :data => sale }
else
render :json => { :status => true, :data => 'OK' }
end
else
render :json => { :status => false }
end
end
def get_menu_category ()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
MenuCategory.current_menu
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()
@product = Product.where("shop_code='#{@shop.shop_code}'")
end
# render json for http status code
def return_json_status_with_code(code, msg)
render status: code, json: {
message: msg,
booking_id: booking_id
}.to_json
end
def check_order_with_table(table_id)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
# puts booking
if booking
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
end
else
@order.new_booking = false
@order.booking_id = booking.booking_id
return false
end
end
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
return false
end
end
end

View File

@@ -0,0 +1,167 @@
class Foodcourt::HomeController < BaseFoodcourtController
authorize_resource :class => false
before_action :set_dining, only: [:show]
def index
@webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name")
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
@shift = ShiftSale.current_open_shift(current_user)
end
# origami table detail
def show
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name")
@shift = ShiftSale.current_open_shift(current_user)
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
@order_items = Array.new
@dining_booking.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
# @assigned_order_items = Array.new
if booking.booking_orders.empty?
@booking = booking
else
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
if (order.status == "new")
@obj_order = order
@customer = order.customer
@date = order.created_at
@booking= booking
order.order_items.each do |item|
@order_items.push(item)
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
# end
end
@account_arr = Array.new
if @customer.tax_profiles
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find_by_id(acc)
if !account.nil?
@account_arr.push(account)
end
end
end
end
end
end
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find_by_id(acc)
if !account.nil?
@account_arr.push(account)
end
end
end
@sale_taxes = []
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
if !sale_taxes.empty?
sale_taxes.each do |sale_tax|
@sale_taxes.push(sale_tax)
end
end
end
end
#for bank integration
@checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
@checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time')
accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC")
@tax_arr =[]
accounts.each do |acc|
@tax_arr.push(acc.name)
end
lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
#for edit order on/off
@edit_order_origami = true
lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order')
if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami"
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
@edit_order_origami = false
end
end
end
end
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
if changable_tax[1] == '0'
@changable_tax = false
end
end
end
end
end
def check_emp_access_code
pin_code = params[:code]
employee = Employee.find_by_emp_id(pin_code)
if employee && (employee.role == "manager" || employee.role == "supervisor")
result = {:status=> true, :message=>"Success" }
else
result = {:status=> false, :message=>"Invalid Access Code" }
end
render :json => result.to_json
end
private
def set_dining
@dining = DiningFacility.find(params[:dining_id])
end
end

View File

@@ -0,0 +1,84 @@
class Foodcourt::OrdersController < BaseFoodcourtController
def show
@webview = false
if check_mobile
@webview = true
end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.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'))
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@order = Order.find(params[:order_id])
booking = Booking.select('bookings.booking_id, bookings.dining_facility_id')
.joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id")
.where("bo.order_id='#{params[:order_id]}'").first()
@booking = Array.new
if !booking.nil?
if booking.dining_facility_id.to_i > 0
dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id)
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
else
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil})
end
end
@customers = Customer.pluck("customer_id, name")
#for split bill
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
sale_order = SaleOrder.find_by_order_id(@order.order_id)
if sale_order
unless sale_order.sale_id.nil?
sale = Sale.find(sale_order.sale_id)
@sale_status = sale.sale_status
end
end
@order.order_items.each_with_index do |item, order_item_index|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
item.price = item.price.to_f + instance_item["price"].to_f
end
@order.order_items[order_item_index].set_menu_items = arr_instance_item_sets
end
end
end
def app_orders
if !params[:booking_id].nil? && !params[:booking_id].blank?
@booking = Booking.select("orders.*,bookings.*,customers.*")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and bookings.booking_id='#{params[:booking_id]}'").first
@customer_id =@booking.customer_id
@booking_id =@booking.booking_id
@order_id =@booking.order_id
@sale_data = Sale.find_by_sale_id(@booking.sale_id)
end
@bookings = Booking.select("bookings.*,customers.*")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and bookings.shop_code=? and DATE(bookings.created_at)=?",@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
end
def completed
customer =Customer.find_by_customer_id(params[:customer_id])
phone_number =customer.contact_no
if Order.send_message(phone_number,params[:order_id],@shop.name)
booking =Booking.find(params[:booking_id])
booking.booking_status ='completed'
booking.save!
end
end
end

View File

@@ -0,0 +1,85 @@
class Foodcourt::OtherChargesController < BaseFoodcourtController
authorize_resource :class => false
def index
@webview = false
if check_mobile
@webview = true
end
sale_id = params[:sale_id]
@cashier_type = params[:type]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
if @sale_data.bookings[0].dining_facility_id.to_i > 0
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
else
@table = nil
end
end
end
def create
sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total]
cashier_type = params[:cashier_type]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
else
table_id = nil
table = nil
end
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
# origin_sale_item = SaleItem.find(di["id"])
sale_item = SaleItem.new
sale_item.sale_id = sale_id
sale_item.menu_category_code = "0.0"
sale_item.menu_category_name = "Other Charges"
sale_item.product_code = "Other Charges"
sale_item.product_name = "*" + di["name"]
sale_item.product_alt_name = ""
sale_item.status = "Other Charges"
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"] * 1
sale_item.is_taxable = di["is_taxable"]
sale_item.account_id = 0
sale_item.price = di["price"] * 1
sale_item.save
action_by = current_user.name
if table.nil?
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->"
else
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
end
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" )
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.total_discount, nil, cashier_type)
end
if !table.nil?
dining = {:table_id => table_id, :table_type => table.type }
render :json => dining.to_json
end
end
end

View File

@@ -0,0 +1,98 @@
class Foodcourt::PaymalController < BaseFoodcourtController
def index
@sale_id = params[:sale_id]
payment_method = params[:payment_method]
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no
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
# @rounding_adj = sale_data.rounding_adjustment
@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
@payment_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
@out = false,0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
@out = false, 0
end
def create
cash = params[:payment_amount]
sale_id = params[:sale_id]
transaction_ref = params[:transaction_ref]
account_no = params[:account_no]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment
# if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
# rounding_adj = new_total-saleObj.grand_total
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
# end
# saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no)
if status == true && @membership_data["status"] == true
@out = true, "Success!"
else
@out =false, @membership_data["message"]
end
end
end
end

View File

@@ -0,0 +1,691 @@
class Foodcourt::PaymentsController < BaseFoodcourtController
authorize_resource :class => false
def index
end
def create
cash = params[:cash]
sale_id = params[:sale_id]
member_info = nil
type = params[:type]
tax_type = params[:tax_type]
path = request.fullpath
latest_order_no = nil
is_kbz = params[:is_kbz]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id)
#shop_detail = Shop.first
# rounding adjustment
if !path.include? ("credit_payment")
if @shop.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) if rounding_adj > 0
end
end
#end rounding adjustment
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
if is_kbz == 'false'
Rails.logger.info '################ CASH PAYMENT #################'
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user, cash, "cash")
else
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
end
# end
if !path.include? ("credit_payment")
rebate_amount = nil
# For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'")
bookings = Booking.find_by_sale_id(sale_id)
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings.dining_facility_id.to_i > 0
table = DiningFacility.find(bookings.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
type = 'payment'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
else
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
end
# For Print
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
# else
end
end
end
end
customer= Customer.find(saleObj.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
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)
if member_info["status"] == true
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
end
#orders print out
# if type == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
end
booking.booking_orders.each do |order|
# Order.pay_process_order_queue(order.order_id, table_id)
oqs = OrderQueueStation.new
oqs.pay_process_order_queue(order.order_id, table_id)
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
# end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
#end
end
logger.debug 'saleObj++++++++++++++++++++++++++'
logger.debug saleObj.to_json
if !saleObj.nil?
# InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj)
end
end
# status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, nil, nil)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
end
def show
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value
else
@display_type = nil
end
path = request.fullpath
sale_id = params[:sale_id]
@trans_flag = true
if params[:type] == "transaction"
@trans_flag = false
@cashier_type = "cashier"
else
@cashier_type = params[:type]
end
if path.include? ("credit_payment")
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
end
@member_discount = MembershipSetting.find_by_discount(1)
@membership_rebate_balance=0
if Sale.exists?(sale_id)
@cash = 0.0
@kbz_pay_amount = 0.0
@other = 0.0
@ppamount = 0.0
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@alipaycount = 0.0
@junctionpaycount = 0.0
@credit = 0.0
@paymalcount = 0.0
@dingacount = 0.0
@giftvouchercount = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0
@accountable_type = ''
@table_no = ''
@dining = ''
@other_payment = 0.0
@pdf_view = nil
@lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView")
if !@lookup_pdf.nil?
@pdf_view = @lookup_pdf.value
end
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop)
@kbz_pay_amount += amount.to_f
#for changable on/off
@changable_tax = true
lookup_changable_tax = Lookup.collection_of('changable_tax')
if !lookup_changable_tax.empty?
lookup_changable_tax.each do |changable_tax|
if changable_tax[0].downcase == "change"
if changable_tax[1] == '0'
@changable_tax = false
end
end
end
end
# @shop = shop_detail #show shop info
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
saleObj = Sale.find(sale_id)
#total customer with individual total amount
@individual_total = Array.new
if !saleObj.equal_persons.nil?
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
end
# rounding adjustment
# if @shop.is_rounding_adj
# a = saleObj.grand_total % 25 # Modulus
# 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
# else
# @rounding_adj = @sale_data.rounding_adjustment
# end
# else
# @rounding_adj = @sale_data.rounding_adjustment
# end
#end rounding adjustment
# rounding adjustment
if @shop.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)
@sale_data.grand_total = new_total
@sale_data.old_grand_total = saleObj.grand_total
@sale_data.rounding_adjustment = @rounding_adj
else
@rounding_adj = @sale_data.rounding_adjustment
end
else
@rounding_adj = @sale_data.rounding_adjustment
end
#end rounding adjustment
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# accounts = @customer.tax_profiles
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
@account_arr =[]
@tax_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc.id)
# @account_arr.push(account)
@tax_arr.push(account.name)
end
sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id)
if !sale_taxes.empty?
sale_taxes.each do |sale_tax|
@account_arr.push(sale_tax)
end
end
rebate = MembershipSetting.find_by_rebate(1)
# get member information
if @customer.membership_id != nil && rebate
response = Customer.get_member_account(@customer)
if response["status"]==true
response["account_data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
@balance = @balance.to_f + res["balance"].to_f
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
end
end
end
#end customer amount
#paymal payment
@sale_data.bookings.each do |sbk|
if sbk.dining_facility_id.to_i >0
df = DiningFacility.find(sbk.dining_facility_id)
@table_no = df.type + ' ' + df.name
@checkin_time = sbk.checkin_at
@dining = df
break
else
@table_no = nil
@checkin_time = nil
@dining = nil
end
end
if path.include? ("credit_payment")
@sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data)
else
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
end
@sale_payment_data.each do |spay|
if spay.payment_method == "cash"
@cash += spay.payment_amount
end
if spay.payment_method !="creditnote"
@other_payment += spay.payment_amount
end
if spay.payment_method == "mpu"
@other += spay.payment_amount
elsif spay.payment_method == "paypar"
@ppamount += spay.payment_amount
elsif spay.payment_method == "visa"
@visacount += spay.payment_amount
elsif spay.payment_method == "jcb"
@jcbcount += spay.payment_amount
elsif spay.payment_method == "master"
@mastercount += spay.payment_amount
elsif spay.payment_method == "unionpay"
@unionpaycount += spay.payment_amount
elsif spay.payment_method == "JunctionPay"
@junctionpaycount += spay.payment_amount
elsif spay.payment_method == "creditnote"
@credit += spay.payment_amount
elsif spay.payment_method == "paymal"
@paymalcount += spay.payment_amount
elsif spay.payment_method == "alipay"
@alipaycount += spay.payment_amount
elsif spay.payment_method == "dinga"
@dingacount += spay.payment_amount
elsif spay.payment_method == "giftvoucher"
@giftvouchercount += spay.payment_amount
end
end
end
end
def reprint
sale_id = params[:sale_id]
member_info = nil
latest_order_no = nil
saleObj = Sale.find(sale_id)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
booking = Booking.find_by_sale_id(sale_id)
latest_order = booking.booking_orders.joins(" JOIN orders ON orders.order_id = booking_orders.order_id").where("orders.source = 'quick_service'").order("order_id DESC").limit(1).first()
if !latest_order.nil?
latest_order_no = latest_order.order_id
end
# if bookings.count > 1
# # for Multiple Booking
# table = DiningFacility.find(bookings[0].dining_facility_id)
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
end
end
end
end
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = Shop.first
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
#for card sale data
card_data = Array.new
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
if !card_sale_trans_ref_no.nil?
card_sale_trans_ref_no.each do |cash_sale_trans|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
card_no = cash_sale_trans.pan.last(4)
card_no = card_no.rjust(19,"**** **** **** ")
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount,transaction_ref= SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
end
def foc
cash = params[:cash]
sale_id = params[:sale_id]
sub_total = params[:sub_total]
remark = params[:remark]
member_info = nil
rebate_amount = nil
current_balance = nil
order_source = params[:type]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
#calculate cash acmount
cash = saleObj.total_amount
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
saleObj.compute_by_sale_items(0, nil, order_source)
end
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id)
type = 'payment'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
if bookings[0].dining_facility_id.to_i > 0
table = DiningFacility.find(bookings[0].dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(saleObj.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
end
# Re-call Sale Data
saleObj = Sale.find(sale_id)
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
#shop detail
#shop_detail = Shop.first
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,table_id)
end
end
# end
if !saleObj.nil?
#InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj)
end
end
end
def rounding_adj
saleObj = Sale.find(params[:sale_id])
if @shop.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
#print function for receipt
def print
filename = params[:filename]
receipt_no = params[:receipt_no]
printer_name = params[:printer_name]
cashier_type = params[:type]
if cashier_type.strip.downcase == "doemal_order"
unique_code = "ReceiptBillOrderPdf"
else
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'")
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
# else
# unique_code = "ReceiptBillPdf"
end
end
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
result = {
:status => true,
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
Rails.logger.debug "$$$$$$$$$ result ::"
Rails.logger.debug result
# Mobile Print
render :json => result.to_json
# render :json => {status: true}
end
#changable tax for sale
def change_tax
sale_id = params[:sale_id]
order_source = params[:cashier_type]
tax_type = params[:tax_type]
sale = Sale.find(sale_id)
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
render json: JSON.generate({:status => true})
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain.to_s + "." + request.domain.to_s
end
return from
end
end

View File

@@ -0,0 +1,31 @@
class Foodcourt::PayparPaymentsController < BaseFoodcourtController
def create
sale_id = params[:sale_id]
@cashier_type = params[:type]
redeem_amount = params[:redeem_amount]
membership_id = params[:membership_id]
payment_method = "paypar"
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
# rounding adjustment
if @shop.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
status,msg =sale_payment.process_payment(saleObj, current_user, redeem_amount,payment_method)
if status == true
@out = true, "Success!"
else
@out =false, "Please try again payment!"
end
else
@out = false, "There has no sale record!"
end
end
end

View File

@@ -0,0 +1,113 @@
class Foodcourt::RequestBillsController < ApplicationController
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
# Print Request Bill and add to sale tables
def print
if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id
order = Order.find(order_id)
booking = order.booking
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil?
@status = false
@error_message = "Operation failed, Could not request bill!"
else
table = DiningFacility.find_by(id: booking.dining_facility_id)
if sale_data = booking.sale
@status = true
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
@status = true
# in-duty update
in_duties = InDuty.where("booking_id=?", booking.id)
if !in_duties.empty?
in_duties.each do |in_duty|
induty = InDuty.find(in_duty.id)
induty.sale_id = sale_data.sale_id
induty.out_time = Time.now.utc
induty.save
end
end
end
# Bind shift sale id to sale
# @sale_data.shift_sale_id = shift.id
# @sale_data.save
action_by = current_user.name
type = "REQUEST_BILL"
remark = "Request bill Receipt No #{sale_data.receipt_no}"
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
# Promotion Activation
Promotion.promo_activate(sale_data)
#bill channel
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
if order.source == "cashier" || order.source == "quick_service"
ActionCable.server.broadcast "bill_channel",table: table, from: from
end
if order.source == "quick_service" || order.source == "food_court"
result = {:status=> @status, :data => sale_data.sale_id }
render :json => result.to_json
else
#check checkInOut pdf print
checkout_time = Lookup.collection_of('checkout_time')
if !booking.dining_facility_id.nil?
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
unique_code = "CheckInOutPdf"
printer = PrintSetting.find_by_unique_code(unique_code)
# print when complete click
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
if !printer.nil?
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
end
end
end
end
end
@status = true
else
@status = false
@error_message = "No Current Open Shift for This Employee"
end
# Not Use for these printed bill cannot give customer
# unique_code = "ReceiptBillPdf"
# #shop detail
# shop_details = Shop.find(1)
# # customer= Customer.where('customer_id=' +.customer_id)
# customer= Customer.find(@sale_data.customer_id)
# # get member information
# member_info = Customer.get_member_account(customer)
# # get printer info
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# # find order id by sale id
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# # Calculate price_by_accounts
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
end
end

View File

@@ -0,0 +1,232 @@
class Foodcourt::SaleEditController < BaseFoodcourtController
authorize_resource class: false
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
if params[:table_id]
@table_id = params[:table_id]
@table_type = DiningFacility.find(@table_id).type
else
@table_id = nil
@table_type = nil
end
@cashier_type = params[:type]
@saleobj = Sale.find(sale_id)
end
# create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
remark = params[:remark]
access_code = params[:access_code]
order_source = params[:type]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.status = 'void'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
# @newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
# booking = Booking.find_by_sale_id(saleitemObj.sale_id)
# booking.booking_orders.each do |bo|
# order = Order.find(bo.order_id)
# order.order_items.each do |o|
# if saleitemObj.product_code == o.item_code
# o.qty = saleitemObj.qty * -1
# o.price = saleitemObj.price * -1
# o.save
# end
# end
# end
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" )
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
def item_foc
saleitemId = params[:sale_item_id]
remark = params[:remark]
access_code = params[:access_code]
order_source = params[:type]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.status = 'foc'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = saleitemObj.dup
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.unit_price = saleitemObj.unit_price * 1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" )
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
# def item_edit
# saleitemId = params[:sale_item_id]
# update_qty = params[:update_qty]
# update_price = params[:update_price]
# saleitemObj = SaleItem.find(saleitemId)
# saleitemObj.status = 'void'
# saleitemObj.save
# @newsaleitem = SaleItem.new
# @newsaleitem = saleitemObj.dup
# @newsaleitem.save
# @newsaleitem.qty = update_qty
# @newsaleitem.price = update_price
# @newsaleitem.unit_price = update_price
# @newsaleitem.taxable_price = update_price
# @newsaleitem.is_taxable = 0
# @newsaleitem.remark = 'edit'
# @newsaleitem.product_name = saleitemObj.product_name + " - updated"
# @newsaleitem.save
# end
def item_edit
saleitemId = params[:sale_item_id]
update_qty = params[:update_qty]
update_price = params[:update_price]
access_code = params[:access_code]
order_source = params[:type]
saleitemObj = SaleItem.find(saleitemId)
original_qty = saleitemObj.qty
original_price = saleitemObj.unit_price
sale = Sale.find(saleitemObj.sale_id)
saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Update From Qty=>#{original_qty} Price=>[#{original_price}] to qty=>#{update_qty} Price =>[#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" )
# saleitemObj.remark = 'edit'
unless saleitemObj.product_name.include? 'UPDATED'
saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)'
end
saleitemObj.save
# re-calc tax
# saleObj = Sale.find(saleitemObj.sale_id)
# order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
# order = Order.find(order_id)
# order.order_items.each do |o|
# if saleitemObj.product_code == o.item_code
# o.qty = update_qty
# o.price = update_price
# o.save
# end
# end
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
end
# make cancel void item
def item_void_cancel
saleitemId = params[:sale_item_id]
access_code = params[:access_code]
order_source = params[:type]
saleitemObj = SaleItem.find(saleitemId)
saleObj = saleitemObj.sale
saleObj.sale_items.where(product_code: saleitemObj.product_code)
.where(qty: saleitemObj.qty.abs)
.where(unit_price: saleitemObj.unit_price)
.where(status: saleitemObj.status).first.update(status: nil, remark: nil)
saleitemObj.destroy
# re-calc tax
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id(access_code).name
end
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source)
ProductCommission.remove_product_commission(saleitemObj)
end
# remove all void items
def cancel_all_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item|
if item.qty.to_i < 0
item.destroy
else
item.status = nil
end
item.save
ProductCommission.remove_product_commission(item)
end
saleObj.sale_items.reset
# re-calc tax
saleObj.compute_by_sale_items(saleObj.total_discount,nil, order_source)
end
def apply_void
sale_id = params[:sale_id]
order_source = params[:type]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void(order_source)
saleObj.sale_items.each do |item|
ProductCommission.remove_product_commission(item)
end
end
end

View File

@@ -0,0 +1,78 @@
class Foodcourt::SalesController < BaseFoodcourtController
def show
@webview = false
if check_mobile
@webview = true
end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name")
@sale = Sale.find(params[:sale_id])
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id
if Booking.find(@booking).dining_facility_id.to_i>0
@table_id = Booking.find(@booking).dining_facility_id
@dining = DiningFacility.find(@table_id)
else
@table_id = nil
@dining = nil
end
end
def add_to_existing_invoice
dining = params[:dining_id]
sale_id = params[:sale_id]
tax_type = params[:tax_type]
sale_data = []
table = DiningFacility.find(dining)
existing_booking = Booking.find_by_sale_id(sale_id)
table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking|
if booking.sale_id.nil?
order_array = []
booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved'
order = Order.find(booking_order.order_id)
order.status = 'billed'
order.order_items.each do |item|
item.order_item_status = 'billed'
end
# create sale item
saleobj = Sale.find(sale_id)
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
if !orer_item.set_menu_items.nil?
saleobj.add_sub_item(orer_item.set_menu_items)
end
sale_data.push(orer_item)
end
# Re-compute for add
saleobj.compute(order.source,tax_type)
saleobj.save
order.save
booking.save
order_array.push(order.order_id)
end
receipt_no = Sale.find(sale_id).receipt_no
action_by = current_user.name
type = "ADD_TO_EXISTING"
remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}"
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
booking_order = BookingOrder.where('booking_id=?',booking)
booking_order.each do |bo|
bo.booking_id = existing_booking.booking_id
bo.save
end
end
end
end
end

View File

@@ -0,0 +1,34 @@
class Foodcourt::SecondDisplayController < BaseFoodcourtController
def index
@display_images = DisplayImage.all
end
def show
end
def customer_view
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i == 2
if params[:status]!= "billed"
tax_profiles = TaxProfile.all.order("order_by asc")
else
tax_profiles = nil
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
end
# end
end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end

View File

@@ -0,0 +1,158 @@
class Foodcourt::ShiftsController < BaseFoodcourtController
def index
end
def show
@cashier_type = params[:type]
@shift = ShiftSale.current_open_shift(current_user)
#for bank integration
bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def new
@float = Lookup.where('lookup_type=?','float_value')
@terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'")
end
def create
opening_balance = params[:opening_balance]
cashier_terminal_param = params[:cashier_terminal]
# Multiple Cashier
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
if cashier_terminal.is_currently_login
respond_to do |format|
format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' }
end
end
# Update Cashier Terminal
cashier_terminal.is_currently_login = 1
cashier_terminal.save
@shift_sale = ShiftSale.new
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
end
def update_shift
closing_balance = params[:closing_balance]
shift_id = params[:shift_id]
@shift = ShiftSale.find_by_id(shift_id)
if @shift
@shift.shift_closed_at = DateTime.now.utc
@shift.closing_balance = closing_balance.to_f
@shift.save
# Multiple Cashier
cashier_terminal = @shift.cashier_terminal
cashier_terminal.is_currently_login = 0
cashier_terminal.save
#add shift_sale_id to card_settle_trans
bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code)
if !bank_integration.nil?
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
card_settle_trans.each do |data|
card_sett_trans = CardSettleTran.find(data.id)
card_sett_trans.shift_sale_id = @shift.id
card_sett_trans.save()
end
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if !close_cashier_print[0].nil?
# @close_cashier_print = close_cashier_print[0][1]
# end
close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings")
unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1'
unique_code="CloseCashierCustomisePdf"
else
unique_code="CloseCashierPdf"
end
end
end
end
shop_details = shop_detail
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = ''
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code)
if @lookup.to_i == 1
@sale_items = Sale.get_shift_sale_items(@shift.id)
other_charges = Sale.get_other_charges()
@total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift)
end
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
# print close cashier setting
close_cashier_print = Lookup.collection_of('close_cashier_print')
if close_cashier_print.empty?
@settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1")
@settings_lookup.save
end
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
if find_close_cashier_print[0][1].to_i > 0
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
end
end
end
Employee.logout(session[:session_token])
session[:session_token] = nil
end
def edit
end
def sale_summary
@shift = ShiftSale.current_open_shift(current_user)
# @shift = ShiftSale.find_by_id(shift_id)
if @shift
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'")
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end
end

View File

@@ -0,0 +1,112 @@
class Foodcourt::SurveysController < BaseFoodcourtController
def new
@webview = false
if check_mobile
@webview = true
end
@survey = Survey.new
@id = params[:id]
@cashier_type = params[:type]
if(@id[0,3] == "SAL")
@sale = Sale.find(@id)
@receipt_no = @sale.receipt_no
@grand_total = @sale.grand_total
@booking = Booking.find_by_sale_id(@id)
if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
if !survey_process.nil?
@survey_data = survey_process
end
else
@dining_facility = nil
@table_type = nil
end
else
@dining_facility = DiningFacility.find(@id)
@table_type = @dining_facility.type
@receipt_no = nil
@grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
end
end
def create
@type = params[:cashier_type]
@sale_id = params[:sale_id]
if params[:table_id].to_i>0
@dining_facility = DiningFacility.find(params[:table_id])
if params[:sale_id].to_i > 0
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
current_shift = ShiftSale.current_shift(@shop.shop_code)
current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])
else
shift_by_terminal = ShiftSale.current_open_shift(current_shift_user)
end
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
if @type == "quick_service" || @type == "food_court"
@url = "/foodcourt/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/foodcourt/"+@dining_facility.type.downcase+"/"+params[:table_id]
end
if params[:survey_id].nil? || params[:survey_id] == ""
@survey = Survey.new(survey_params)
@survey.shift_id = shift_by_terminal.id
@survey.foreigner = params["survey"]["foreigner"].to_json
@survey.shop_code = @shop.shop_code
# respond_to do |format|
if @survey.save
redirect_to @url
end
# end
else
survey = Survey.find_by_id(params[:survey_id])
survey.child = params["survey"]["child"]
survey.adult = params["survey"]["adult"]
survey.male = params["survey"]["male"]
survey.female = params["survey"]["female"]
survey.local = params["survey"]["local"]
survey.dining_name = params["survey"]["dining_name"]
survey.receipt_no = params["survey"]["receipt_no"]
survey.shift_id = shift_by_terminal.id
survey.created_by = params["survey"]["created_by"]
survey.total_customer = params["survey"]["total_customer"]
survey.total_amount = params["survey"]["total_amount"]
survey.foreigner = params["survey"]["foreigner"].to_json
if survey.save!
redirect_to @url
end
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def survey_params
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
end
end

View File

@@ -0,0 +1,157 @@
class Foodcourt::VoidController < BaseFoodcourtController
authorize_resource :class => false
def overall_void
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
access_code = params[:access_code]
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(0, nil, order_source)
end
# update count for shift sale
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.calculate(sale_id, "void")
end
else
# void before sale payment complete
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.total_void = shift.total_void + sale.grand_total
shift.save
end
end
sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
if sale.bookings[0].dining_facility_id.to_i > 0
table_avaliable = true
table_count = 0
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" )
#call paymal to void
if sale.sale_payments.nil?
membership_response =sale.paymal_payment_void
end
Rails.logger.debug "---------Paymal Payment Void response in VoidController"
Rails.logger.debug membership_response.to_json
# For Print
member_info = nil
rebate_amount = nil
current_balance = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
end
end
if bookings[0].dining_facility_id.to_i > 0
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
aoi.delivery_status = 1
aoi.save
end
end
end
end
end

View File

@@ -0,0 +1,144 @@
class Foodcourt::WasteSpoileController < BaseFoodcourtController
def waste_and_spoilage
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type]
access_code = params[:access_code] #tax profile source
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
sale.payment_status = remark
sale.sale_status = remark
sale.save
# add to sale item with foc
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
sale.sale_items.each do|item|
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
item.status = remark
item.remark = remark
item.save
end
if sale.bookings[0].dining_facility_id.to_i > 0
table_avaliable = true
table_count = 0
table = sale.bookings[0].dining_facility
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
table_avaliable = true
end
else
table_avaliable = false
table_count += 1
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
end
else
table = nil
end
# FOr Sale Audit
action_by = current_user.name
if access_code != "null" && current_user.role == "cashier"
action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name
end
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark )
# For Print
member_info = nil
rebate_amount = nil
current_balance = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
if bookings.count > 1
# for Multiple Booking
if bookings[0].dining_facility_id.to_i>0
table = DiningFacility.find(bookings[0].dining_facility_id)
end
end
if bookings[0].dining_facility_id.to_i > 0
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
end
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# unique_code = "ReceiptBillPdf"
customer= Customer.find(sale.customer_id)
# get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'")
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# end
#end print
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
aoi.delivery_status = 1
aoi.save
end
end
end
end
end

View File

@@ -18,8 +18,8 @@ class HomeController < ApplicationController
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.where("shop_code='#{current_shop.shop_code}' and is_active = true").order("name asc") @employees = Employee.all.where("shop_code='#{@shop.shop_code}' and is_active = true").order("name asc")
@roles = Employee.where("shop_code='#{current_shop.shop_code}'").distinct.pluck(:role) @roles = Employee.where("shop_code='#{@shop.shop_code}'").distinct.pluck(:role)
# byebug # byebug
# @roles = Lookup.collection_of("employee_roles") # @roles = Lookup.collection_of("employee_roles")
@@ -52,7 +52,7 @@ class HomeController < ApplicationController
@login_form = LoginForm.new() @login_form = LoginForm.new()
@login_form.emp_id = params[:login_form][:emp_id] @login_form.emp_id = params[:login_form][:emp_id]
@login_form.password = params[:login_form][:password] @login_form.password = params[:login_form][:password]
@employee = Employee.login(current_shop,@login_form.emp_id, @login_form.password) @employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee != nil if @employee != nil
if @employee.is_active if @employee.is_active
@@ -78,6 +78,9 @@ class HomeController < ApplicationController
elsif @employee.role == "kitchen" elsif @employee.role == "kitchen"
session[:session_token] = @employee.token_session session[:session_token] = @employee.token_session
redirect_to oqs_root_path redirect_to oqs_root_path
elsif @employee.role == "foodcourt_cashier"
session[:session_token] = @employee.token_session
route_by_role(@employee)
else else
render :index render :index
end end
@@ -91,31 +94,24 @@ class HomeController < ApplicationController
end end
def dashboard def dashboard
@from, @to, @from_time, @to_time = get_date_range_from_params @from, @to = get_date_range_from_params
today = DateTime.now.strftime('%Y-%m-%d')
if !@from.nil? && !@to.nil? @orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
if !@from_time.nil? && @to_time.nil? @sales = Sale.receipt_date_between(@from, @to).completed
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
else if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count() if shift = ShiftSale.current_open_shift(current_user.id)
end @orders = @orders.where(shift_sale_id: shift.id)
else @sales = @sales.where(shift_sale_id: shift.id)
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() end
end end
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count() @top_products = Sale.top_bottom_products(current_user,@from,@to,"top",current_shop)
else @bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom",current_shop)
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count() @hourly_sales = Sale.hourly_sales(current_user,@from,@to,current_shop)
end employee_sales = Sale.employee_sales(current_user,@from,@to,current_shop)
else
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
end
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top",@shop).sum('i.qty')
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom",@shop).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time,@shop).sum(:grand_total)
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time,@shop)
@employee_sales = [] @employee_sales = []
if !employee_sales.nil? if !employee_sales.nil?
employee_sales.each do |emp| employee_sales.each do |emp|
@@ -127,43 +123,43 @@ class HomeController < ApplicationController
end end
end end
end end
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time,@shop).sum(:balance)
@total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time,@shop) @inventories = StockJournal.inventory_balances(@from,@to, current_shop).sum(:balance)
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time,@shop)
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time,@shop) @total_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(current_user,@from,@to)
@total_credit = Sale.credit_payment(current_user,@from,@to, current_shop)
@sale_data = Array.new @sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user,@from,@to,@from_time,@to_time) @total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
if !@total_payment_methods.nil? if !@total_payment_methods.nil?
@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" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
pay = Sale.payment_sale(@shop,'card', today, current_user,@from,@to,@from_time,@to_time) @sale_data.push({payment.payment_method => pay.payment_amount})
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end end
end end
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_order = Sale.total_order(@shop,today,current_user,@from,@to,@from_time,@to_time) @summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
@total_accounts = Sale.total_account(@shop,today,current_user,@from,@to,@from_time,@to_time) @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(current_user,@from,@to, current_shop)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new @account_data = Array.new
if !@total_accounts.nil? if !@total_accounts.nil?
@total_accounts.each do |account| @total_accounts.each do |account|
acc = Sale.account_data(@shop,account.account_id, today,current_user,@from,@to,@from_time,@to_time)
if !acc.nil? acc = Sale.account_data(account.account_id,current_user,@from,@to)
if !acc.nil? && acc.cnt_acc > 0
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end end
end end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
end end
@top_items = Sale.top_items(@shop,today,current_user,@from,@to,@from_time,@to_time) @top_items = Sale.top_items(current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(@shop,today,current_user,@from,@to,@from_time,@to_time) @total_foc_items = Sale.total_foc_items(current_user,@from,@to)
# get printer info # get printer info
# @print_settings = get_precision_delimiter # @print_settings = get_precision_delimiter
@@ -171,7 +167,7 @@ class HomeController < ApplicationController
def destroy def destroy
# clear in employee session # clear in employee session
Employee.logout(@shop,session[:session_token]) Employee.logout(session[:session_token])
session[:session_token] = nil session[:session_token] = nil
# redirect_to root_path # redirect_to root_path
render :json => {:status=> "Success", :url => root_path }.to_json render :json => {:status=> "Success", :url => root_path }.to_json
@@ -221,27 +217,30 @@ class HomeController < ApplicationController
redirect_to origami_dashboard_path redirect_to origami_dashboard_path
elsif employee.role == "account" elsif employee.role == "account"
redirect_to reports_dailysale_index_path redirect_to reports_dailysale_index_path
elsif employee.role == "foodcourt_cashier"
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee)
if !shift.nil?
redirect_to foodcourt_food_court_path
else
redirect_to new_foodcourt_shift_path
end
end end
end end
def get_date_range_from_params def get_date_range_from_params
from = params[:from] if params[:from].present? && params[:to].present?
to = params[:to] if params[:from_time].present? && params[:to_time].present?
from_time = params[:from_time] from = Time.parse("#{params[:from]} #{params[:from_time]}")
to_time = params[:to_time] to = Time.parse("#{params[:to]} #{params[:to_time]}")
else
if from.present? && to.present? from = Time.parse(params[:from])
# f_date = DateTime.parse(from) to = Time.parse(params[:to]).end_of_day
# t_date = DateTime.parse(to)
# f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
# t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
# from = f_time.beginning_of_day.utc.getlocal
# to = t_time.end_of_day.utc.getlocal
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
end end
else
return from, to, from_time, to_time from = Time.now.beginning_of_day
to = Time.now.end_of_day
end
return from, to
end end
end end

View File

@@ -18,4 +18,5 @@ class Inventory::InventoryController < BaseInventoryController
format.xls format.xls
end end
end end
end end

View File

@@ -32,7 +32,7 @@ class Inventory::StockChecksController < BaseInventoryController
def save_to_journal def save_to_journal
check = params[:data] check = params[:data]
stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code) stockCheck = StockCheck.find_by_id(check)
stockCheck.stock_check_items.each do |item| stockCheck.stock_check_items.each do |item|
StockJournal.from_stock_check(item,@shop) StockJournal.from_stock_check(item,@shop)
end end
@@ -40,14 +40,14 @@ class Inventory::StockChecksController < BaseInventoryController
def print_stock_check def print_stock_check
stock_id = params[:stock_check_id] # sale_id stock_id = params[:stock_check_id] # sale_id
stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code) stockcheck = StockCheck.find_by_id(stock_id)
stockcheck_items = stockcheck.stock_check_items stockcheck_items = stockcheck.stock_check_items
member_info = nil member_info = nil
unique_code = 'StockCheckPdf' unique_code = 'StockCheckPdf'
shop_details = current_shop
checker = Employee.find_by_id_and_shop_code(stockcheck.check_by,@shop.shop_code) checker = Employee.find(stockcheck.check_by)
print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
if !print_settings.nil? if !print_settings.nil?
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop) printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, @shop)
@@ -59,20 +59,12 @@ class Inventory::StockChecksController < BaseInventoryController
#Pull this menu #Pull this menu
@menu_category = InventoryDefinition.search_by_category(params[:id]) @menu_category = InventoryDefinition.search_by_category(params[:id])
puts @menu_category.to_json
# puts @menu.menu_items[1].item_attributes.to_json
return @menu_category return @menu_category
else else
MenuCategory.current_menu MenuCategory.current_menu
end end
end end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = current_shop
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy] # before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
# GET /stock_checks # GET /stock_checks

View File

@@ -118,8 +118,6 @@ class Oqs::HomeController < BaseOqsController
status = params[:status] status = params[:status]
items = queue_items_query(false,oqs_id,filter,table_id,status) items = queue_items_query(false,oqs_id,filter,table_id,status)
puts "items0"
puts items.to_json
if !items.empty? if !items.empty?
items.each do |item| items.each do |item|
if !item.set_menu_items.nil? if !item.set_menu_items.nil?

View File

@@ -6,7 +6,6 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile if check_mobile
@webview = true @webview = true
end end
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
@@ -46,8 +45,6 @@ class Origami::AddordersController < BaseOrigamiController
#Pull this menu #Pull this menu
@menu = MenuCategory.find_by_id(params[:id]) @menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu return @menu
else else
MenuCategory.current_menu MenuCategory.current_menu
@@ -63,7 +60,6 @@ class Origami::AddordersController < BaseOrigamiController
#Pull this menu #Pull this menu
@menu = Menu.find_by_id(params[:id]) @menu = Menu.find_by_id(params[:id])
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc") @menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
# puts @menu.menu_items[1].item_attributes.to_json
return @menu return @menu
else else
Menu.current_menu Menu.current_menu
@@ -77,8 +73,6 @@ class Origami::AddordersController < BaseOrigamiController
if (id) if (id)
#Pull this menu #Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active @sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu return @sub_menu
end end
end end
@@ -136,7 +130,7 @@ class Origami::AddordersController < BaseOrigamiController
@order.new_booking = true @order.new_booking = true
@order.waiters = current_login_employee.name @order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name @order.employee_name = current_login_employee.name
@order.shop_code =@shop.shop_code @order.shop_code = @shop.shop_code
@order.is_extra_time = is_extra_time @order.is_extra_time = is_extra_time
@order.extra_time = extra_time @order.extra_time = extra_time
@@ -199,7 +193,6 @@ class Origami::AddordersController < BaseOrigamiController
table = DiningFacility.find(table_id) table = DiningFacility.find(table_id)
if table if table
booking = table.get_current_booking booking = table.get_current_booking
# puts booking
if booking if booking
if !booking.sale_id.nil? if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@@ -230,7 +223,6 @@ class Origami::AddordersController < BaseOrigamiController
def process_order_queue(order_id,table_id,order_source) def process_order_queue(order_id,table_id,order_source)
print_status = nil print_status = nil
cup_status = nil cup_status = nil
#Send to background job for processing #Send to background job for processing
order = Order.find(order_id) order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code)

View File

@@ -11,7 +11,7 @@ class Origami::AlipayController < BaseOrigamiController
end end
total = 0 total = 0
@alipaycount = 0 @alipaycount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_alipay = 0 @can_alipay = 0
@member_discount = 0 @member_discount = 0
@@ -64,7 +64,7 @@ class Origami::AlipayController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
@@ -85,9 +85,4 @@ class Origami::AlipayController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -36,7 +36,6 @@ class Origami::CashInsController < BaseOrigamiController
shift =current_shift shift =current_shift
end end
end end
puts shift.to_json
shift.cash_in = shift.cash_in + amount.to_f shift.cash_in = shift.cash_in + amount.to_f
shift.save shift.save
end end

View File

@@ -8,7 +8,6 @@ class Origami::CreditPaymentsController < BaseOrigamiController
total = sale_data.grand_total total = sale_data.grand_total
@creditcount = 0 @creditcount = 0
others = 0 others = 0
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else

View File

@@ -3,11 +3,11 @@ class Origami::CreditSalesController < BaseOrigamiController
@cashier_type = 'cashier' @cashier_type = 'cashier'
@webview = false @webview = false
if check_mobile if check_mobile
@webview = true @webview = true
end end
@tables = Table.unscoped.all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc') @rooms = Room.unscope(:order).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.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@@ -15,7 +15,7 @@ class Origami::CreditSalesController < BaseOrigamiController
@sale = Sale.find_by_sale_id(params[:sale_id]) @sale = Sale.find_by_sale_id(params[:sale_id])
@sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount") @sale_payment = SalePayment.select("SUM(payment_amount) as payment_amount")
.where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote") .where("sale_id = ? and payment_method=?", @sale.sale_id, "creditnote")
@sale_taxes = [] @sale_taxes = []
sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id) sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id)
if !sale_taxes.empty? if !sale_taxes.empty?
@@ -24,5 +24,5 @@ class Origami::CreditSalesController < BaseOrigamiController
end end
end end
end end
end end

View File

@@ -87,7 +87,7 @@ class Origami::CustomersController < BaseOrigamiController
@count_customer = Customer.count_customer @count_customer = Customer.count_customer
# @taxes = TaxProfile.where(:group_type => 'cashier') # @taxes = TaxProfile.where(:group_type => 'cashier')
@taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") @taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
.order("group_type ASC,order_by ASC") .order("group_type ASC,order_by ASC")
# if flash["errors"] # if flash["errors"]
# @crm_customer.valid? # @crm_customer.valid?
@@ -168,15 +168,17 @@ class Origami::CustomersController < BaseOrigamiController
sale = Sale.find_by_receipt_no(receipt_no) sale = Sale.find_by_receipt_no(receipt_no)
@out = [] @out = []
action_by = current_user.name action_by = current_user.name
membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
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_and_shop_code("get_account_balance",@shop.shop_code)
if member_actions.gateway_url if member_actions.gateway_url
@campaign_type_id = nil @campaign_type_id = nil
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_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no) membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
puts membership_data.to_json
if membership_data["status"]==true if membership_data["status"]==true
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}" remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )

View File

@@ -1,65 +1,67 @@
class Origami::DashboardController < BaseOrigamiController class Origami::DashboardController < BaseOrigamiController
def index def index
today = DateTime.now.strftime('%Y-%m-%d') @display_type = Lookup.find_by_lookup_type("display_type")
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type")
@sale_data = Array.new @sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
@total_payment_methods = Sale.total_payment_methods(current_user)
if !@total_payment_methods.nil? if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" @total_payment_methods.each do |payment|
pay = Sale.payment_sale(@shop,'card', today, current_user) pay = Sale.payment_sale(payment.payment_method, current_user)
@sale_data.push({'card' => pay.payment_amount}) @sale_data.push({payment.payment_method => pay.payment_amount})
else end
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
else else
@sale_data = nil @sale_data = nil
end end
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time) @summ_sale = Sale.summary_sale_receipt(current_user)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
# @total_other_customer = Sale.total_other_customer(today,current_user) # @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(@shop,today,current_user) @total_order = Sale.total_order(current_user)
@total_accounts = Sale.total_account(@shop,today,current_user)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new @account_data = Array.new
if !@total_accounts.nil? if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(@shop,account.account_id, today,current_user) @total_accounts.each do |account|
if !acc.nil? acc = Sale.account_data(account.account_id, current_user)
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) if !acc.nil?
end @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end end
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
else else
@account_data = nil @account_data = nil
end end
@top_items = Sale.top_items(@shop,today,current_user)
@total_foc_items = Sale.total_foc_items(@shop,today,current_user) @top_items = Sale.top_items(current_user)
@total_foc_items = Sale.total_foc_items(current_user)
# get printer info # get printer info
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@current_user = current_user @current_user = current_user
#dine-in cashier #dine-in cashier
dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier')
@dinein_cashier = 0 @dinein_cashier = 0
if !dinein_cashier[0].nil? if !dinein_cashier[0].nil?
@dinein_cashier = dinein_cashier[0][1] @dinein_cashier = dinein_cashier[0][1]
end end
#quick service #quick service
quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service') quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service')
@quick_service = 0 @quick_service = 0
if !quick_service[0].nil? if !quick_service[0].nil?
@quick_service = quick_service[0][1] @quick_service = quick_service[0][1]
end end
#fourt court #fourt court
food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court') food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court')
@food_court = 0 @food_court = 0
@food_court_name = nil @food_court_name = nil
if !food_court[0].nil? if !food_court[0].nil?
@@ -68,7 +70,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#order reservation #order reservation
order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation') order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation')
@order_reservation = 0 @order_reservation = 0
if !order_reservation.empty? if !order_reservation.empty?
order_reservation.each do |order_reserve| order_reservation.each do |order_reserve|
@@ -79,7 +81,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#dashboard settings on/off for supervisor and cashier #dashboard settings on/off for supervisor and cashier
dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings') dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings')
@setting_flag = true @setting_flag = true
if !dashboard_settings.empty? if !dashboard_settings.empty?
dashboard_settings.each do |setting| dashboard_settings.each do |setting|
@@ -90,7 +92,7 @@ class Origami::DashboardController < BaseOrigamiController
end end
#reservation #reservation
reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation') reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation')
@reservation = 0 @reservation = 0
if !reservation.empty? if !reservation.empty?
reservation.each do |reserve| reservation.each do |reserve|
@@ -102,7 +104,9 @@ class Origami::DashboardController < BaseOrigamiController
end end
def get_all_menu def get_all_menu
@menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'")
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.all
@item_attributes = MenuItemAttribute.all.load @item_attributes = MenuItemAttribute.all.load
@item_options = MenuItemOption.all.load @item_options = MenuItemOption.all.load
end end

View File

@@ -6,7 +6,6 @@ class Origami::DingaController < 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)
@receipt_no = @sale_data.receipt_no @receipt_no = @sale_data.receipt_no
# @shop = Shop.first
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total) new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else else
@@ -77,7 +76,7 @@ def create
account_no = params[:account_no] account_no = params[:account_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)

View File

@@ -134,10 +134,8 @@ class Origami::FoodCourtController < ApplicationController
def get_menu_category () def get_menu_category ()
if (params[:id]) if (params[:id])
puts params[:id]
#Pull this menu #Pull this menu
@menu = MenuCategory.find_by_id(params[:id]) @menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu return @menu
else else
MenuCategory.current_menu MenuCategory.current_menu
@@ -150,7 +148,6 @@ class Origami::FoodCourtController < ApplicationController
if (id) if (id)
#Pull this menu #Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active @sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu return @sub_menu
end end
end end
@@ -171,7 +168,6 @@ class Origami::FoodCourtController < ApplicationController
table = DiningFacility.find(table_id) table = DiningFacility.find(table_id)
if table if table
booking = table.get_current_booking booking = table.get_current_booking
# puts booking
if booking if booking
if !booking.sale_id.nil? if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"

View File

@@ -6,7 +6,6 @@ class Origami::GiftVoucherController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
total = 0 total = 0
@gift_vouchercount = 0 @gift_vouchercount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_gift_voucher = 0 @can_gift_voucher = 0
@member_discount = 0 @member_discount = 0
@@ -48,8 +47,6 @@ class Origami::GiftVoucherController < BaseOrigamiController
ref_no = params[:reference_no] ref_no = params[:reference_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -62,10 +59,4 @@ class Origami::GiftVoucherController < BaseOrigamiController
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "GiftVoucher",ref_no) @status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "GiftVoucher",ref_no)
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -4,10 +4,13 @@ class Origami::HomeController < BaseOrigamiController
def index def index
@webview = check_mobile @webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count @occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count
@@ -20,10 +23,12 @@ class Origami::HomeController < BaseOrigamiController
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile @webview = check_mobile
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.unscope(:order).includes(:zone).all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @rooms = Room.unscope(:order).includes(:zone).all.active.order('status desc')
@orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@shift = ShiftSale.current_open_shift(current_user) @shift = ShiftSale.current_open_shift(current_user)

View File

@@ -47,12 +47,6 @@ class Origami::InDutiesController < BaseOrigamiController
def create_for_in_duty def create_for_in_duty
# this one use for create and update # this one use for create and update
in_duty = in_duty_params in_duty = in_duty_params
# in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
# in_time = in_time.change(offset: '+06:30')
# out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
# out_time = out_time.change(offset: '+06:30')
# puts in_duty.to_json
# puts "sssssssssssssssssss"
@in_duty = InDuty.new @in_duty = InDuty.new
in_duty_id = in_duty[:id] in_duty_id = in_duty[:id]
unless in_duty_id.empty? unless in_duty_id.empty?

View File

@@ -12,7 +12,7 @@ class Origami::JcbController < BaseOrigamiController
end end
total = 0 total = 0
@jcbcount = 0 @jcbcount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_jcb = 0 @can_jcb = 0
@member_discount= 0 @member_discount= 0
@@ -66,8 +66,6 @@ class Origami::JcbController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -86,9 +84,4 @@ class Origami::JcbController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -11,7 +11,6 @@ class Origami::JunctionPayController < BaseOrigamiController
@cashier_id = current_user.emp_id @cashier_id = current_user.emp_id
@payment_method_setting_nav = PaymentMethodSetting.all @payment_method_setting_nav = PaymentMethodSetting.all
# @shop = Shop.first
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
@@ -52,7 +51,6 @@ class Origami::JunctionPayController < BaseOrigamiController
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj

View File

@@ -12,7 +12,6 @@ class Origami::MasterController < BaseOrigamiController
end end
total = 0 total = 0
@mastercount = 0 @mastercount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_master = 0 @can_master = 0
@member_discount = 0 @member_discount = 0
@@ -63,7 +62,6 @@ class Origami::MasterController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
@@ -83,10 +81,4 @@ class Origami::MasterController < BaseOrigamiController
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -105,7 +105,7 @@ class Origami::MovetableController < BaseOrigamiController
# @type = (DiningFacility.find(change_to)).type # @type = (DiningFacility.find(change_to)).type
# @moved_by = @current_user.name # @moved_by = @current_user.name
# @date = DateTime.now # @date = DateTime.now
# @shop = Shop.first # @shop = @shop
# unique_code = "MoveTablePdf" # unique_code = "MoveTablePdf"
# pdf_no = PrintSetting.where(:unique_code => unique_code).count # pdf_no = PrintSetting.where(:unique_code => unique_code).count
# #print_settings = PrintSetting.find_by_unique_code(unique_code) # #print_settings = PrintSetting.find_by_unique_code(unique_code)

View File

@@ -11,7 +11,6 @@ class Origami::MpuController < BaseOrigamiController
end end
total = 0 total = 0
@mpucount = 0 @mpucount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_mpu = 0 @can_mpu = 0
@member_discount = 0 @member_discount = 0
@@ -64,7 +63,6 @@ class Origami::MpuController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
@@ -83,10 +81,4 @@ class Origami::MpuController < BaseOrigamiController
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "mpu",ref_no,payment_for) @status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "mpu",ref_no,payment_for)
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -98,7 +98,7 @@ class Origami::OrderReservationController < BaseOrigamiController
end end
def get_order_info def get_order_info
order_reservation = OrderReservation.where("status = 'new' and shop_code='#{@shop.shop_code}'").count() order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count()
render :json => order_reservation render :json => order_reservation
end end

View File

@@ -5,8 +5,8 @@ class Origami::OrdersController < BaseOrigamiController
@webview = true @webview = true
end end
@tables = Table.unscoped.all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc') @rooms = Room.unscope(:order).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.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@order = Order.find(params[:order_id]) @order = Order.find(params[:order_id])

View File

@@ -6,7 +6,6 @@ class Origami::PaymalController < 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)
@receipt_no = sale_data.receipt_no @receipt_no = sale_data.receipt_no
# @shop = Shop.first
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else
@@ -74,7 +73,6 @@ def create
account_no = params[:account_no] account_no = params[:account_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj

View File

@@ -59,7 +59,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#shop detail #shop detail
## shop_detail = Shop.first ## shop_detail = @shop
# 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 # rounding adjustment
@@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
@@ -141,7 +141,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id)
#shop_detail = Shop.first #shop_detail = @shop
# rounding adjustment # rounding adjustment
if !path.include? ("credit_payment") if !path.include? ("credit_payment")
if @shop.is_rounding_adj if @shop.is_rounding_adj
@@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone # For Cashier by Zone
# bookings = Booking.where("sale_id='#{sale_id}'") # bookings = Booking.where("sale_id='#{sale_id}'")
bookings = Booking.find_by_sale_id(sale_id) bookings = saleObj.bookings[0]
shift = ShiftSale.current_open_shift(current_user) shift = ShiftSale.current_open_shift(current_user)
if !shift.nil? if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else else
if bookings.dining_facility_id.to_i > 0 if bookings.dining_facility_id.to_i > 0
table = DiningFacility.find(bookings.dining_facility_id) table = bookings.dining_facility
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
@@ -278,7 +278,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#card_balance amount for Paymal payment #card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
@@ -288,7 +288,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(sale_items) other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
#end #end
end end
@@ -577,7 +577,7 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
#shop detail #shop detail
#shop_detail = Shop.first #shop_detail = @shop
# 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
@@ -600,7 +600,7 @@ class Origami::PaymentsController < BaseOrigamiController
end end
#card_balance amount for Paymal payment #card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
result = { result = {
:status => true, :status => true,
@@ -686,8 +686,9 @@ class Origami::PaymentsController < BaseOrigamiController
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
#shop detail #shop detail
#shop_detail = Shop.first
printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") #shop_detail = @shop
printer = PrintSetting.all
unique_code="ReceiptBillPdf" unique_code="ReceiptBillPdf"
if !printer.empty? if !printer.empty?
@@ -711,7 +712,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil)
result = { result = {
:status => true, :status => true,
:filepath => filename, :filepath => filename,

View File

@@ -7,8 +7,6 @@ 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.first
# rounding adjustment # rounding adjustment
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total) new_total = Sale.get_rounding_adjustment(saleObj.grand_total)

View File

@@ -13,12 +13,12 @@ class Origami::QuickServiceController < ApplicationController
# if params[:menu] == "true" # if params[:menu] == "true"
@menus = [] @menus = []
@menu = [] @menu = []
@zone = Zone.all.where("shop_code='#{@shop.shop_code}'") @zone = Zone.all
@customer = Customer.all @customer = Customer.all
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.all.active.order('status desc')
@cashier_type = "quick_service" @cashier_type = "quick_service"
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2 if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value @display_type = display_type.value
else else
@@ -137,10 +137,8 @@ class Origami::QuickServiceController < ApplicationController
def get_menu_category () def get_menu_category ()
if (params[:id]) if (params[:id])
puts params[:id]
#Pull this menu #Pull this menu
@menu = MenuCategory.find_by_id(params[:id]) @menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu return @menu
else else
MenuCategory.current_menu MenuCategory.current_menu
@@ -153,7 +151,6 @@ class Origami::QuickServiceController < ApplicationController
if (id) if (id)
#Pull this menu #Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active @sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu return @sub_menu
end end
end end
@@ -174,7 +171,6 @@ class Origami::QuickServiceController < ApplicationController
table = DiningFacility.find(table_id) table = DiningFacility.find(table_id)
if table if table
booking = table.get_current_booking booking = table.get_current_booking
# puts booking
if booking if booking
if !booking.sale_id.nil? if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"

View File

@@ -5,8 +5,6 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
@cashier_type = params[:type] @cashier_type = params[:type]
@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)
# @shop = Shop.first
if @shop.is_rounding_adj if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total) new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else else

View File

@@ -8,7 +8,7 @@ class Origami::RequestBillsController < ApplicationController
end end
# Print Request Bill and add to sale tables # Print Request Bill and add to sale tables
def print def print
if !ShiftSale.current_shift(@shop.shop_code).nil? if !ShiftSale.current_shift.nil?
order_id = params[:id] # order_id order_id = params[:id] # order_id
order = Order.find(order_id) order = Order.find(order_id)
booking = order.booking booking = order.booking
@@ -45,7 +45,7 @@ class Origami::RequestBillsController < ApplicationController
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type ) sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
# Promotion Activation # Promotion Activation
Promotion.promo_activate(sale_data,@shop.shop_code) Promotion.promo_activate(sale_data)
#bill channel #bill channel
if ENV["SERVER_MODE"] == 'cloud' if ENV["SERVER_MODE"] == 'cloud'
@@ -90,7 +90,7 @@ class Origami::RequestBillsController < ApplicationController
# Not Use for these printed bill cannot give customer # Not Use for these printed bill cannot give customer
# unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"
# #shop detail # #shop detail
# shop_details = Shop.find(1) # shop_details = @shop
# # 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)
# # get member information # # get member information

View File

@@ -1,10 +1,8 @@
class Origami::RoomInvoicesController < BaseOrigamiController class Origami::RoomInvoicesController < BaseOrigamiController
def index def index
@room = DiningFacility.find(params[:room_id]) @room = DiningFacility.find(params[:room_id])
puts "room bookig lenght"
@sale_array = Array.new @sale_array = Array.new
@room.bookings.each do |booking| @room.bookings.each do |booking|
puts booking.sale_id
if booking.sale_id.nil? if booking.sale_id.nil?
else else

View File

@@ -1,8 +1,9 @@
class Origami::RoomsController < BaseOrigamiController class Origami::RoomsController < BaseOrigamiController
def index def index
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @rooms = Room.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@shift = ShiftSale.current_open_shift(current_user) @shift = ShiftSale.current_open_shift(current_user)
@webview = false @webview = false
@@ -17,9 +18,10 @@ class Origami::RoomsController < BaseOrigamiController
@webview = true @webview = true
end end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @rooms = Room.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@room = DiningFacility.find(params[:room_id]) @room = DiningFacility.find(params[:room_id])
@@ -30,7 +32,8 @@ class Origami::RoomsController < BaseOrigamiController
@sale_array = Array.new @sale_array = Array.new
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code) @membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code) @payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code)
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ")
@order_items = Array.new @order_items = Array.new
@dining_room.each do |booking| @dining_room.each do |booking|

View File

@@ -163,8 +163,6 @@ class Origami::SaleEditController < BaseOrigamiController
# end # end
# end # end
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
ProductCommission.edit_product_commission(saleitemObj,sale.shop_code) ProductCommission.edit_product_commission(saleitemObj,sale.shop_code)
end end

View File

@@ -5,9 +5,10 @@ class Origami::SalesController < BaseOrigamiController
@webview = true @webview = true
end end
@tables = Table.unscoped.all.active.order('status desc')
@rooms = Room.unscoped.all.active.order('status desc') @tables = Table.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @rooms = Room.unscope(:order).all.active.order('status desc')
@complete = Sale.completed_sale("cashier")
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@customers = Customer.pluck("customer_id, name") @customers = Customer.pluck("customer_id, name")
@sale = Sale.find(params[:sale_id]) @sale = Sale.find(params[:sale_id])

View File

@@ -27,7 +27,7 @@ class Origami::SecondDisplayController < BaseOrigamiController
#Shop Name in Navbor #Shop Name in Navbor
# helper_method :shop_detail # helper_method :shop_detail
# def shop_detail # def shop_detail
# @shop = Shop.first #
# end # end

View File

@@ -88,7 +88,6 @@ class Origami::ShiftsController < BaseOrigamiController
end end
end end
end end
shop_details = shop_detail
#get tax #get tax
shift_obj = ShiftSale.where('id =?',@shift.id) shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = '' sale_items = ''
@@ -125,7 +124,9 @@ class Origami::ShiftsController < BaseOrigamiController
end end
find_close_cashier_print = Lookup.collection_of('close_cashier_print') find_close_cashier_print = Lookup.collection_of('close_cashier_print')
if find_close_cashier_print[0][1].to_i > 0 if find_close_cashier_print[0][1].to_i > 0
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, @shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
end end
end end
end end

View File

@@ -158,15 +158,8 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
# puts order_id
# puts order_ids.count
# puts order_id_count
# puts order_items.count
# puts order_item_count
if !order_id.nil? if !order_id.nil?
if order_id_count > 1 if order_id_count > 1
puts "order_id_count > 1"
updated_order_id = Array.new updated_order_id = Array.new
arr_order_ids.each do |order| arr_order_ids.each do |order|
@@ -178,9 +171,6 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
# puts "updated_order_id"
# puts updated_order_id
if !updated_order_id.empty? if !updated_order_id.empty?
order_ids.each do |odr_id| order_ids.each do |odr_id|
unless updated_order_id.include?(odr_id) unless updated_order_id.include?(odr_id)
@@ -208,8 +198,6 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
# puts new_order_status
if new_order_status if new_order_status
BookingOrder.find_by_order_id(odr_id).delete BookingOrder.find_by_order_id(odr_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id}) BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
@@ -236,7 +224,6 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
else else
# puts "order_id_count < 1"
new_order_status = true new_order_status = true
order_items.each do |order_item| order_items.each do |order_item|
orderItem = OrderItem.find(order_item["id"]) orderItem = OrderItem.find(order_item["id"])
@@ -249,8 +236,6 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
# puts new_order_status
if new_order_status if new_order_status
BookingOrder.find_by_order_id(order_id).delete BookingOrder.find_by_order_id(order_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id}) BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
@@ -334,7 +319,7 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
Promotion.promo_activate(sale_data,@shop.shop_code) Promotion.promo_activate(sale_data)
if ENV["SERVER_MODE"] == 'cloud' if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain from = request.subdomain + "." + request.domain
else else
@@ -411,5 +396,4 @@ class Origami::SplitBillController < BaseOrigamiController
render :json => { status: true } render :json => { status: true }
end end
end end

View File

@@ -1,11 +1,8 @@
class Origami::TableInvoicesController < BaseOrigamiController class Origami::TableInvoicesController < BaseOrigamiController
def index def index
@table = DiningFacility.find(params[:table_id]) @table = DiningFacility.find(params[:table_id])
# shop = Shop.first
puts "table bookig lenght"
@sale_array = Array.new @sale_array = Array.new
@table.bookings.each do |booking| @table.bookings.each do |booking|
puts booking.sale_id
if booking.sale_id.nil? if booking.sale_id.nil?
else else
@@ -30,12 +27,10 @@ class Origami::TableInvoicesController < BaseOrigamiController
end end
def show def show
# puts 'Catch me if you can.......................'
@table = DiningFacility.find(params[:table_id]) @table = DiningFacility.find(params[:table_id])
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
# shop = Shop.first @membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
@sale_array = Array.new @sale_array = Array.new
@table.bookings.each do |booking| @table.bookings.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?

View File

@@ -11,7 +11,6 @@ class Origami::UnionpayController < BaseOrigamiController
end end
total = 0 total = 0
@unionpaycount = 0 @unionpaycount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_unionpay = 0 @can_unionpay = 0
@member_discount = 0 @member_discount = 0
@@ -61,8 +60,6 @@ class Origami::UnionpayController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -81,10 +78,4 @@ class Origami::UnionpayController < BaseOrigamiController
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "unionpay",ref_no,payment_for) @status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "unionpay",ref_no,payment_for)
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -11,7 +11,6 @@ class Origami::VisaController < BaseOrigamiController
end end
total = 0 total = 0
@visacount = 0 @visacount = 0
# @shop = Shop.first
@rounding_adj = 0 @rounding_adj = 0
@can_visa = 0 @can_visa = 0
@member_discount = 0 @member_discount = 0
@@ -61,8 +60,6 @@ class Origami::VisaController < BaseOrigamiController
ref_no = params[:ref_no] ref_no = params[:ref_no]
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
# shop_details = Shop.first
# rounding adjustment # rounding adjustment
# if shop_details.is_rounding_adj # if shop_details.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total) # new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@@ -81,10 +78,4 @@ class Origami::VisaController < BaseOrigamiController
@status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "visa",ref_no,payment_for) @status, @sale = sale_payment.process_payment(saleObj, current_user, cash, "visa",ref_no,payment_for)
end end
end end
#Shop Name in Navbor
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end end

View File

@@ -1,7 +1,6 @@
class Origami::VoidController < BaseOrigamiController class Origami::VoidController < BaseOrigamiController
authorize_resource :class => false authorize_resource :class => false
def overall_void def overall_void
sale_id = params[:sale_id] sale_id = params[:sale_id]
remark = params[:remark] remark = params[:remark]
order_source = params[:type] #tax profile source order_source = params[:type] #tax profile source
@@ -114,7 +113,6 @@ class Origami::VoidController < BaseOrigamiController
# end # end
customer= Customer.find(sale.customer_id) customer= Customer.find(sale.customer_id)
# get member information # get member information
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
if customer.membership_id != nil && rebate if customer.membership_id != nil && rebate
@@ -145,7 +143,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)
other_amount = SaleItem.calculate_other_charges(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil) filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil)
result = { result = {
:filepath => filename, :filepath => filename,
:printer_model => print_settings.brand_name, :printer_model => print_settings.brand_name,

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