production deployment changes
This commit is contained in:
5
Gemfile
5
Gemfile
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
|
||||
|
||||
#gem 'mysql2', '>= 0.3.18', '< 0.5'
|
||||
gem 'pg'
|
||||
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
||||
gem 'mysql2'
|
||||
|
||||
#Use PosgreSQL
|
||||
|
||||
@@ -41,12 +41,13 @@ gem 'rack-cors'
|
||||
# image upload
|
||||
gem 'carrierwave', '~> 1.0'
|
||||
gem 'mini_magick'
|
||||
gem 'jquery-fileupload-rails'
|
||||
gem 'jquery-fileupload-rails', '~> 0.4.7'
|
||||
|
||||
#Report and Printing gems
|
||||
gem 'cups'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
gem 'prawn-qrcode'
|
||||
gem 'to_xls-rails'
|
||||
gem 'rubyzip', '= 1.0.0'
|
||||
gem 'axlsx', '= 2.0.1'
|
||||
|
||||
274
Gemfile.lock
274
Gemfile.lock
@@ -1,88 +1,92 @@
|
||||
GIT
|
||||
remote: https://github.com/capistrano/rbenv.git
|
||||
revision: c029e4128e4a8f25adda35795f5729bd4f62e51f
|
||||
revision: b8807f3bbb3f424ac42cc8838a38822e028d0aa3
|
||||
specs:
|
||||
capistrano-rbenv (2.1.3)
|
||||
capistrano-rbenv (2.1.4)
|
||||
capistrano (~> 3.1)
|
||||
sshkit (~> 1.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actioncable (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
actionmailer (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
actionpack (5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
actionview (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activejob (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activerecord (5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activemodel (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
activerecord (5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.4)
|
||||
activesupport (5.1.7)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
aescrypt (1.0.0)
|
||||
airbrussh (1.3.0)
|
||||
airbrussh (1.4.0)
|
||||
sshkit (>= 1.6.1, != 1.7.0)
|
||||
arel (8.0.0)
|
||||
axlsx (2.0.1)
|
||||
htmlentities (~> 4.3.1)
|
||||
nokogiri (>= 1.4.1)
|
||||
rubyzip (~> 1.0.0)
|
||||
axlsx_rails (0.5.1)
|
||||
axlsx_rails (0.5.2)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
bcrypt (3.1.11)
|
||||
bindex (0.5.0)
|
||||
bcrypt (3.1.13)
|
||||
bindex (0.8.1)
|
||||
builder (3.2.3)
|
||||
byebug (9.1.0)
|
||||
byebug (11.0.1)
|
||||
cancancan (1.17.0)
|
||||
capistrano (3.10.1)
|
||||
airbrussh (>= 1.0.0)
|
||||
i18n
|
||||
rake (>= 10.0.0)
|
||||
sshkit (>= 1.9.0)
|
||||
capistrano-bundler (1.3.0)
|
||||
capistrano-bundler (1.6.0)
|
||||
capistrano (~> 3.1)
|
||||
sshkit (~> 1.2)
|
||||
capistrano-rails (1.3.1)
|
||||
capistrano-rails (1.4.0)
|
||||
capistrano (~> 3.1)
|
||||
capistrano-bundler (~> 1.1)
|
||||
<<<<<<< HEAD
|
||||
capistrano3-puma (3.1.1)
|
||||
capistrano (~> 3.7)
|
||||
capistrano-bundler
|
||||
puma (~> 3.4)
|
||||
carrierwave (1.2.1)
|
||||
=======
|
||||
carrierwave (1.3.1)
|
||||
>>>>>>> b025cc2cfd2b10df84cc1cee458efa4eef108752
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
chartkick (2.2.5)
|
||||
chartkick (3.2.1)
|
||||
chronic (0.10.2)
|
||||
chunky_png (1.3.11)
|
||||
coffee-rails (4.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0)
|
||||
@@ -90,46 +94,45 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
connection_pool (2.2.1)
|
||||
crass (1.0.2)
|
||||
concurrent-ruby (1.1.5)
|
||||
connection_pool (2.2.2)
|
||||
crass (1.0.5)
|
||||
cups (0.1.10)
|
||||
database_cleaner (1.6.2)
|
||||
database_cleaner (1.7.0)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.7.0)
|
||||
erubi (1.9.0)
|
||||
execjs (2.7.0)
|
||||
factory_girl (4.9.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.9.0)
|
||||
factory_girl (~> 4.9.0)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.8.4)
|
||||
i18n (~> 0.5)
|
||||
ffi (1.9.18)
|
||||
filterrific (2.1.2)
|
||||
font-awesome-rails (4.7.0.2)
|
||||
railties (>= 3.2, < 5.2)
|
||||
globalid (0.4.1)
|
||||
faker (2.5.0)
|
||||
i18n (~> 1.6.0)
|
||||
ffi (1.11.1)
|
||||
filterrific (5.2.1)
|
||||
font-awesome-rails (4.7.0.5)
|
||||
railties (>= 3.2, < 6.1)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
htmlentities (4.3.4)
|
||||
httparty (0.15.6)
|
||||
httparty (0.15.7)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.9.1)
|
||||
i18n (1.7.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.7.0)
|
||||
jbuilder (2.9.1)
|
||||
activesupport (>= 4.2.0)
|
||||
multi_json (>= 1.2)
|
||||
jquery-fileupload-rails (0.4.7)
|
||||
actionpack (>= 3.1)
|
||||
railties (>= 3.1)
|
||||
sass (>= 3.2)
|
||||
jquery-rails (4.3.1)
|
||||
jquery-rails (4.3.5)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (6.0.1)
|
||||
railties (>= 3.2.16)
|
||||
json (2.1.0)
|
||||
json (2.2.0)
|
||||
kaminari (1.0.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.0.1)
|
||||
@@ -145,108 +148,114 @@ GEM
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
loofah (2.1.1)
|
||||
loofah (2.3.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
material_icons (2.2.1)
|
||||
railties (>= 3.2)
|
||||
method_source (0.9.0)
|
||||
mime-types (3.1)
|
||||
method_source (0.9.2)
|
||||
mime-types (3.3)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_magick (4.8.0)
|
||||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
momentjs-rails (2.17.1)
|
||||
mime-types-data (3.2019.1009)
|
||||
mini_magick (4.9.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.12.2)
|
||||
momentjs-rails (2.20.1)
|
||||
railties (>= 3.1)
|
||||
multi_json (1.12.2)
|
||||
multi_xml (0.6.0)
|
||||
mysql2 (0.4.10)
|
||||
mysql2 (0.5.2)
|
||||
nested_form (0.3.2)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (4.2.0)
|
||||
nio4r (2.1.0)
|
||||
nokogiri (1.8.1)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
net-scp (2.0.0)
|
||||
net-ssh (>= 2.6.5, < 6.0.0)
|
||||
net-ssh (5.2.0)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
pdf-core (0.7.0)
|
||||
pdfjs_viewer-rails (0.2.0)
|
||||
pdfjs_viewer-rails (0.3.1)
|
||||
json (> 1.8.4)
|
||||
rails (> 4.2.0)
|
||||
sass-rails (~> 5.0)
|
||||
pg (0.21.0)
|
||||
pg (1.1.4)
|
||||
prawn (2.2.2)
|
||||
pdf-core (~> 0.7.0)
|
||||
ttfunk (~> 1.5)
|
||||
prawn-qrcode (0.4.0)
|
||||
prawn (>= 1)
|
||||
rqrcode (>= 1.0.0)
|
||||
prawn-table (0.2.2)
|
||||
prawn (>= 1.3.0, < 3.0.0)
|
||||
puma (3.10.0)
|
||||
rack (2.0.3)
|
||||
rack-cors (1.0.2)
|
||||
rack-protection (2.0.0)
|
||||
puma (3.12.1)
|
||||
rack (2.0.7)
|
||||
rack-cors (1.0.3)
|
||||
rack-protection (2.0.7)
|
||||
rack
|
||||
rack-test (0.7.0)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.4)
|
||||
actioncable (= 5.1.4)
|
||||
actionmailer (= 5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activerecord (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails (5.1.7)
|
||||
actioncable (= 5.1.7)
|
||||
actionmailer (= 5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activerecord (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.1.4)
|
||||
railties (= 5.1.7)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.2.1)
|
||||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rake (13.0.0)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
redis (3.3.5)
|
||||
roo (1.13.2)
|
||||
nokogiri
|
||||
rubyzip
|
||||
spreadsheet (> 0.6.4)
|
||||
rspec-core (3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
rqrcode (1.1.1)
|
||||
chunky_png (~> 1.0)
|
||||
rqrcode_core (~> 0.1.0)
|
||||
rqrcode_core (0.1.0)
|
||||
rspec-core (3.8.2)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-mocks (3.7.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-mocks (3.8.2)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-rails (3.7.1)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.7.0)
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.0)
|
||||
ruby-ole (1.2.12.1)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-support (3.8.3)
|
||||
ruby-ole (1.2.12.2)
|
||||
rubyzip (1.0.0)
|
||||
sass (3.5.3)
|
||||
sass (3.7.4)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.6)
|
||||
sass-rails (5.0.7)
|
||||
railties (>= 4.0.0, < 6)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
@@ -254,57 +263,57 @@ GEM
|
||||
tilt (>= 1.1, < 3)
|
||||
schema_to_scaffold (0.8.0)
|
||||
activesupport (>= 3.2.1)
|
||||
shoulda-matchers (3.1.2)
|
||||
shoulda-matchers (3.1.3)
|
||||
activesupport (>= 4.0.0)
|
||||
sidekiq (5.0.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
connection_pool (~> 2.2, >= 2.2.0)
|
||||
sidekiq (5.2.7)
|
||||
connection_pool (~> 2.2, >= 2.2.2)
|
||||
rack (>= 1.5.0)
|
||||
rack-protection (>= 1.5.0)
|
||||
redis (>= 3.3.4, < 5)
|
||||
simple_form (3.5.0)
|
||||
actionpack (> 4, < 5.2)
|
||||
activemodel (> 4, < 5.2)
|
||||
spreadsheet (1.1.4)
|
||||
redis (>= 3.3.5, < 5)
|
||||
simple_form (5.0.1)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
spreadsheet (1.2.4)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (3.7.1)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sshkit (1.15.1)
|
||||
sshkit (1.20.0)
|
||||
net-scp (>= 1.1.2)
|
||||
net-ssh (>= 2.8.0)
|
||||
tether-rails (1.4.0)
|
||||
rails (>= 3.1)
|
||||
thor (0.20.0)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
tilt (2.0.10)
|
||||
to_xls-rails (1.3.1)
|
||||
spreadsheet (>= 0.8.5)
|
||||
ttfunk (1.5.1)
|
||||
turbolinks (5.0.1)
|
||||
turbolinks-source (~> 5)
|
||||
turbolinks-source (5.0.3)
|
||||
tzinfo (1.2.4)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (3.2.0)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
web-console (3.5.1)
|
||||
web-console (3.7.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
whenever (0.9.7)
|
||||
websocket-extensions (0.1.4)
|
||||
whenever (1.0.0)
|
||||
chronic (>= 0.6.3)
|
||||
|
||||
PLATFORMS
|
||||
@@ -333,7 +342,7 @@ DEPENDENCIES
|
||||
font-awesome-rails (~> 4.7, >= 4.7.0.2)
|
||||
httparty (~> 0.15.5)
|
||||
jbuilder (~> 2.5)
|
||||
jquery-fileupload-rails
|
||||
jquery-fileupload-rails (~> 0.4.7)
|
||||
jquery-rails
|
||||
jquery-ui-rails
|
||||
kaminari (~> 1.0.1)
|
||||
@@ -341,11 +350,12 @@ DEPENDENCIES
|
||||
material_icons
|
||||
mini_magick
|
||||
momentjs-rails
|
||||
mysql2 (>= 0.3.18, < 0.5)
|
||||
mysql2
|
||||
nested_form
|
||||
pdfjs_viewer-rails
|
||||
pg
|
||||
prawn
|
||||
prawn-qrcode
|
||||
prawn-table
|
||||
puma (~> 3.0)
|
||||
rack-cors
|
||||
@@ -370,7 +380,7 @@ DEPENDENCIES
|
||||
whenever
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
ruby 2.3.1p112
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
|
||||
28
README.md
28
README.md
@@ -82,6 +82,23 @@ For ReceiptBillA5Pdf
|
||||
For ReceiptBillAltName options
|
||||
1) settings/lookups => { type:print_settings, name:ReceiptBillAltName, value:1 }
|
||||
|
||||
For Using Star Printer
|
||||
*** Need to change these print settings
|
||||
1) settings/print_settings/unique_code => OrderItemStarPdf
|
||||
2) settings/print_settings/unique_code => ReceiptBillStarPdf
|
||||
3) settings/print_settings/unique_code => SaleItemsStarPdf
|
||||
*** Other print settings aren't need to change.
|
||||
|
||||
For Show Sale Items Summary at CloseCashierPrint
|
||||
1) settings/print_settings
|
||||
a) Check => Shift Sale Items
|
||||
|
||||
For Show/Hide AddOrder Button in QuickService
|
||||
1) settings/lookups => {type:quickservice_add_order, name: QuickServiceAddOrder, value:1 OR 0}
|
||||
|
||||
For Show Print Button in ReceiptNo Report
|
||||
1) settings/lookups => {type:reprint_receipt, name: Reprint Receipt in Report, value:1}
|
||||
|
||||
For Bank Integration setting
|
||||
1) rake db:migrate for card_sale_trans, card_settle_trans
|
||||
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }
|
||||
@@ -273,6 +290,15 @@ For Online Order Receipt Setting
|
||||
1) settings/lookups => { type:order_reservation, name:ReceiptBill, value: {0 or 1} }
|
||||
2) settings/print_settings => {name: ReceiptBillOrder, unique_code: ReceiptBillOrderPdf, ....}
|
||||
|
||||
For Close Cashier Print Settings
|
||||
settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} }
|
||||
|
||||
For Second Display View Setting
|
||||
settings/lookups => {type:display_type, name: Display Type, value: 2}
|
||||
|
||||
For show total before tax in receipt bill
|
||||
settings/lookups => {type:show_total_before_tax, name:Show Total Before Tax, value: {0 or 1}}
|
||||
|
||||
* ToDo list
|
||||
|
||||
1. Migration
|
||||
@@ -369,5 +395,3 @@ For Online Order Receipt Setting
|
||||
2. Show/Detail Buttons => btn-info
|
||||
3. Delete => btn-delete
|
||||
4. Cancel/Back => btn-default
|
||||
|
||||
|
||||
|
||||
BIN
app/assets/images/online_order_icon.png
Normal file
BIN
app/assets/images/online_order_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 376 B |
BIN
app/assets/images/user_icon.png
Normal file
BIN
app/assets/images/user_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 819 B |
@@ -1,7 +1,7 @@
|
||||
//middle edit
|
||||
$(function() {
|
||||
var role = $('#role').val();
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
console.log(second_display_lookup);
|
||||
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
|
||||
modify_order = window.location.href.indexOf("modify_order");
|
||||
|
||||
@@ -25,7 +25,6 @@ $(function() {
|
||||
if (type ==-1 && modify_order == -1){
|
||||
url_item = url_item
|
||||
}
|
||||
console.log(url_item)
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
@@ -54,15 +53,27 @@ $(function() {
|
||||
if (type ==-1 && modify_order == -1){
|
||||
image_path = product[field].image_path.url;
|
||||
}
|
||||
}else{
|
||||
image_path = "/image/logo.png";
|
||||
}
|
||||
|
||||
row = '<div class="col-md-3">'
|
||||
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-3">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
|
||||
+'<div class="col-md-10">'+ product[field].name +'</div>'
|
||||
+"<div class='col-md-2 menu_item_box' data-item-code='"
|
||||
|
||||
+'</div>'
|
||||
|
||||
+"<div class='add_icon p-t-65 p-b-65' data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
|
||||
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(options) +"' data-opt = '"
|
||||
+ JSON.stringify(options) +"' data-image='"+image_path+"'>"
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer custom-flex-footer">'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ product[field].unit_price +'</span>'
|
||||
+"<div class='offset-4 col-2 menu_item_box' data-item-code='"
|
||||
+ product[field].item_code +"' data-instance = '"
|
||||
+JSON.stringify(item_attributes)+"' data-id = '"
|
||||
+JSON.stringify(item_attributes)+"' data-item = '"
|
||||
@@ -75,24 +86,55 @@ $(function() {
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
|
||||
+"<div class='add_icon p-t-65' data-item-code='"
|
||||
+'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-1">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;">'
|
||||
+'<div class="custom-card-head custom-card-no-img-head card-head row" style="margin:0px;display:flex;!important">'
|
||||
+"<div class='col-12 add_icon p-t-65 p-b-65' data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
|
||||
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(options) +"' data-opt = '"
|
||||
+ JSON.stringify(options) +"' data-image='"+image_path+"'>"
|
||||
+ JSON.stringify(options) +"' data-image=''>"
|
||||
+'<div class="product_box">'+ product[field].name +'</div>'
|
||||
+'</div>'
|
||||
|
||||
// +"<div class='card-block custom-card-block'>"
|
||||
// +"<img id='logo' height='125px' src='"+image_path+"'>"
|
||||
// +"</div>"
|
||||
|
||||
+'<div class="card-footer custom-card-footer">'
|
||||
+'<span>'+ product[field].unit_price +'</span>'
|
||||
+'</div>'
|
||||
|
||||
+"<div class='add_icon' data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
|
||||
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(options) +"' data-opt = '"
|
||||
+ JSON.stringify(options) +"' data-image=''>"
|
||||
|
||||
+'</div>'
|
||||
|
||||
+'<div class="card-footer custom-card-no-img-footer custom-flex-footer">'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ product[field].unit_price +'</span>'
|
||||
+"<div class='offset-4 col-2 menu_item_box menu_item_no_img_box' data-item-code='"
|
||||
+ product[field].item_code +"' data-instance = '"
|
||||
+JSON.stringify(item_attributes)+"' data-id = '"
|
||||
+JSON.stringify(item_attributes)+"' data-item = '"
|
||||
+JSON.stringify(item_attributes)+"' data-option = '"
|
||||
+JSON.stringify(options)+"'data-opt = '"
|
||||
+JSON.stringify(options)+"' data-item-sets = '"
|
||||
+JSON.stringify(item_attributes)+"' data-image='' data-toggle='modal' data-target='.sx_item_detailModal'>"
|
||||
+"<i class='fa fa-bars material-icons m-l--10'>"
|
||||
+'view_list</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
|
||||
+'</div>';
|
||||
}
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
}
|
||||
@@ -287,13 +329,12 @@ $(function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(var j in item_options) {
|
||||
value = item_options[j]["values"];
|
||||
type = item_options[j]["type"];
|
||||
row = "<h4>"+type+"</h4>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
|
||||
row +="<button class='btn btn- waves-effect check_option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
@@ -333,7 +374,7 @@ $(function() {
|
||||
type = item_options[field]["type"];
|
||||
row = "<p style='font-size:16px;margin-bottom:3px'>"+type+"</p>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn-default btn-sm option_btn "+ type +"' data-type='"
|
||||
row +="<button class='btn btn-default btn-sm check_option_btn"+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
|
||||
+value[i]+"</button>";
|
||||
});
|
||||
@@ -499,7 +540,6 @@ $(function() {
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
|
||||
$('.attributes-list').empty();
|
||||
$('.options-list').empty();
|
||||
$('#modal_box_img').empty();
|
||||
@@ -605,7 +645,7 @@ $(function() {
|
||||
type = item_options[field]["type"];
|
||||
row = "<h4>"+type+"</h4>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
|
||||
row +="<button class='btn btn- waves-effect check_option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-group='simple_menu'>"+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
@@ -669,6 +709,7 @@ $(function() {
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
console.log(group);
|
||||
options = $(".option_btn");
|
||||
$(options).each(function(i){
|
||||
if ($(options[i]).attr('data-type')==type){
|
||||
@@ -703,7 +744,38 @@ $(function() {
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.check_option_btn', function(event){
|
||||
active =$(this).hasClass('selected-option');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
if (active) {
|
||||
$(this).removeClass('selected-option');
|
||||
}else{
|
||||
$(this).addClass('selected-option');
|
||||
}
|
||||
if(group == "set_menu"){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$(".selected-set:last").attr('data-options',JSON.stringify(option_arr));
|
||||
$(".selected-set:last").children().children('#instance_option').text(option_arr);
|
||||
// instance = $(".selected-instance");
|
||||
// $(instance).each(function(i){
|
||||
// if ($(instance[i]).attr('data-code')==code){
|
||||
// option_arr = get_selected_attributes('selected-option');
|
||||
// $(instance[i]).attr('data-options',JSON.stringify(option_arr));
|
||||
// $(instance[i]).children().children('#instance_option').text(option_arr);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
if(group == "set_menu_default"){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$('.set-item').attr('data-options',JSON.stringify(option_arr));
|
||||
$('.set_default_option').text(option_arr);
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
// click add order
|
||||
$(document).on('click', '.add_to_order', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
@@ -732,6 +804,8 @@ $(function() {
|
||||
|
||||
}
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
|
||||
console.log('instances');
|
||||
console.log(attrbu);
|
||||
$('.add_to_order').attr('data-instance-code',instances[field].code);
|
||||
$('.add_to_order').attr('data-instance',instances[field].name);
|
||||
$('.add_to_order').attr('data-price',instances[field].price);
|
||||
@@ -773,7 +847,7 @@ $(function() {
|
||||
}); //End Add Icon Click
|
||||
|
||||
function show_item_detail(data,click_type){
|
||||
|
||||
testqty = parseInt($('.item_box').children('data_qty').text());
|
||||
qty = parseInt(data.attr('data-qty'));
|
||||
append = 0;
|
||||
price = data.attr('data-price');
|
||||
@@ -821,7 +895,7 @@ $(function() {
|
||||
if (append===0) {
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ " 'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||
+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+instance+ "' data-qty='"+qty +"' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+data.attr('data-instance-code')+"' data-attributes='"
|
||||
+data.attr('data-attributes')+"' data-options ='"
|
||||
+data_option+"' data-opt ='"
|
||||
@@ -844,8 +918,11 @@ $(function() {
|
||||
e.preventDefault();
|
||||
$("#oqs_loading_wrapper").show();
|
||||
var cashier_type = $("#link_type").val();
|
||||
localStorage.setItem('cashier_type',cashier_type);
|
||||
quick_service = window.location.href.indexOf("quick_service");
|
||||
localStorage.setItem('quick_service',quick_service);
|
||||
food_court = window.location.href.indexOf("food_court");
|
||||
localStorage.setItem('food_court',food_court);
|
||||
if (quick_service != -1 || food_court != -1) {
|
||||
type = cashier_type;
|
||||
var table_type = $('#table_type').text();
|
||||
@@ -985,6 +1062,7 @@ $(function() {
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
|
||||
var item_data = $(this);
|
||||
item = get_item(item_data,"remove_icon");
|
||||
customer_display_view(item,"remove");
|
||||
}
|
||||
@@ -1007,6 +1085,7 @@ $(function() {
|
||||
if ($('#modal-qty').val()>0) {
|
||||
summary_items_filter();
|
||||
calculate_sub_total();
|
||||
|
||||
}else{
|
||||
swal("Opps", "Please enter number for qty ","warning");
|
||||
}
|
||||
@@ -1046,6 +1125,7 @@ $(function() {
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
qty = $('#modal-qty').val();
|
||||
$(this).attr('data-qty',qty);
|
||||
price = parseFloat($(this).attr('data-price'));
|
||||
total_price = parseFloat(price*qty).toFixed(2);
|
||||
|
||||
@@ -1295,7 +1375,7 @@ $(function() {
|
||||
var sale_items = [];
|
||||
|
||||
var sale_item = {};
|
||||
sale_item.qty = parseInt(data.attr('data-qty'))
|
||||
sale_item.qty = parseInt(data.attr('data-qty'));
|
||||
sale_item.name = data.attr('data-name');
|
||||
sale_item.price = data.attr('data-price');
|
||||
sale_item.item_code = data.attr('data-item-code')
|
||||
@@ -1306,8 +1386,8 @@ $(function() {
|
||||
sale_item.click_type = click_type
|
||||
sale_item.instance = data.attr('data-instance')
|
||||
sale_items.push(sale_item);
|
||||
|
||||
return sale_items;
|
||||
|
||||
}
|
||||
|
||||
/* Get Item rows */
|
||||
@@ -1379,6 +1459,7 @@ $(function() {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
for(var field in menu_items) {
|
||||
console.log(menu_items[field].instances);
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
|
||||
@@ -1439,52 +1520,109 @@ $(function() {
|
||||
}else{
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
|
||||
}else{
|
||||
if (modify_order) {
|
||||
image_path = "../../image/logo.png";
|
||||
}else{
|
||||
image_path = "image/logo.png";
|
||||
}
|
||||
}
|
||||
|
||||
row = '<div class="col-md-3">'
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" >'
|
||||
+'<div class="col-md-10 " style="padding:0px !important;">'+ menu_items[field].name +'</div>'
|
||||
+"<div class='col-md-2 "+menu_item_box+" ' data-item-code='"
|
||||
+ menu_items[field].code +"' data-instance = '"
|
||||
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
|
||||
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
|
||||
+JSON.stringify(item_attributes)+"' data-option = '"
|
||||
+JSON.stringify(menu_items[field].options)+"'data-opt = '"
|
||||
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' style='padding:0px 5px 0px 5px'>"
|
||||
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 p-b-65 m-r-' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='"+ menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '" + JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='"+image_path+"' "
|
||||
+" data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+""
|
||||
+" 'data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer custom-flex-footer" style="opacity:0.7">'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ price +'</span>'
|
||||
+ "<div class='offset-4 col-2 "+menu_item_box
|
||||
+ "' data-item-code='" + menu_items[field].code
|
||||
+ "' data-instance='" + JSON.stringify(menu_items[field].instances)
|
||||
+ "' data-id='" + JSON.stringify(menu_items[field].attributes)
|
||||
+ "' data-item='" + JSON.stringify(item_attributes)
|
||||
+ "' data-option='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-opt='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-item-sets='" + JSON.stringify(menu_items[field].item_sets)
|
||||
+ "' data-toggle='modal'"
|
||||
+ " data-target='." + data_target +"'"
|
||||
+ " style='padding:0px 5px 0px 5px' >"
|
||||
+ "<i class='m-l--5 fa " + fa_plus + "'>"
|
||||
+ add
|
||||
+ "</i>"
|
||||
+'</div>'
|
||||
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
}else{
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-1">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;">'
|
||||
+'<div class="custom-card-no-img-head card-head '+add_icon+' " style="margin:0px;display:flex;!important "'
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
|
||||
+'<div class="product_box" style="width:100%;"><span>'+ menu_items[field].name +'<span></div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+"' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-no-img-footer custom-flex-footer">'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ price + '</span>'
|
||||
+" <div class='offset-4 col-2 menu_item_no_img_box "+menu_item_box+" ' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-instance = '" +JSON.stringify(menu_items[field].instances)+"' "
|
||||
+" data-id = '"+JSON.stringify(menu_items[field].attributes)+"' "
|
||||
+" data-item = '" +JSON.stringify(item_attributes)+"' "
|
||||
+" data-option = '"+JSON.stringify(menu_items[field].options)+"'"
|
||||
+" data-opt = '"+JSON.stringify(menu_items[field].options)+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"' "
|
||||
+" data-toggle='modal' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" style='padding:0px 5px 0px 5px'>"
|
||||
+"<i class='m-l--5 fa "+fa_plus+" '>"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 m-r-' data-item-code='"
|
||||
+ menu_items[field].code +"' data-name='"
|
||||
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
|
||||
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-opt = '"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
|
||||
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
|
||||
+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
|
||||
// +"<div class='card-block custom-card-block'>"
|
||||
// +"<img id='logo' height='' src='"+image_path+"'>"
|
||||
// +"</div>"
|
||||
|
||||
+'<div class="card-footer custom-card-footer" style="opacity:0.7">'
|
||||
+'<span>'+ price +'</span>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
+'</div>';
|
||||
}
|
||||
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
//end instances in menu-items alest 1 instance
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
//= require BSBMaterial/demo.js
|
||||
//= require custom.js
|
||||
//= require jquery-fileupload/basic
|
||||
//= require induties/induties.js
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.count-to').countTo();
|
||||
|
||||
@@ -40,6 +40,7 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
// }
|
||||
|
||||
d_option = items[i].opt;
|
||||
console.log(d_option)
|
||||
if (items[i].click_type != "add_icon"){
|
||||
option_name = "-"+items[i].options;
|
||||
data_option = items[i].options ;
|
||||
@@ -54,7 +55,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
$(item_row).each(function(j){
|
||||
var item_code = $(item_row[j]).attr('data-code');
|
||||
var instance_code = $(item_row[j]).attr('data-instance-code');
|
||||
var r_option = $(item_row[j]).attr('data-options');
|
||||
var r_option = $(item_row[j]).attr('data-opt');
|
||||
console.log(r_option)
|
||||
if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) {
|
||||
if (qty > 1) {
|
||||
qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty;
|
||||
@@ -74,7 +76,7 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
}
|
||||
});
|
||||
if (append===0) {
|
||||
row ="<tr class='item_box_"+items[i].item_code+"' data-price ='"
|
||||
row ="<tr class='item_box_"+items[i].instance_code+"' data-price ='"
|
||||
+price+ "' 'data-instance ='"
|
||||
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
|
||||
+items[i].instance_code+"' data-attributes='"
|
||||
@@ -130,15 +132,16 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
//remove item
|
||||
if(status == "remove"){
|
||||
for(var i in items) {
|
||||
var item_code = items[i].item_code;
|
||||
var item_code = items[i].instance_code;
|
||||
$("#order-items-table tbody > tr.item_box_"+item_code+"").remove();
|
||||
}
|
||||
}
|
||||
//remove item
|
||||
//update item qty
|
||||
if(status == "update_qty"){
|
||||
|
||||
for(var i in items) {
|
||||
var item_code = items[i].item_code;
|
||||
var item_code = items[i].instance_code;
|
||||
var item_qty = parseInt(items[i].qty);
|
||||
var item_price = parseFloat(items[i].price);
|
||||
var item_total = parseFloat(item_qty * item_price).toFixed(2);
|
||||
@@ -186,4 +189,3 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
3
app/assets/javascripts/induties/assign_in_duties.coffee
Normal file
3
app/assets/javascripts/induties/assign_in_duties.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
0
app/assets/javascripts/induties/induties.js
Normal file
0
app/assets/javascripts/induties/induties.js
Normal file
@@ -288,6 +288,8 @@ function show_order_detail(url,sr_no){
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var scrollTo = document.getElementById('div_card_order');
|
||||
$("HTML, body").animate({scrollTop: scrollTo.offsetTop - 60 }, 500 );
|
||||
// console.log(data);
|
||||
$("#order_remark").text("");
|
||||
$(".tbl_customer").show();
|
||||
@@ -373,6 +375,28 @@ function show_order_detail(url,sr_no){
|
||||
item_price = items[i].unit_price;
|
||||
}
|
||||
var total = items[i].qty * item_price;
|
||||
var check_mobile =document.getElementsByName("summary_items_mobile")[0].value;
|
||||
if (check_mobile == "true"){
|
||||
if(items[i].options!='[]' && items[i].options!="" && items[i].options!=null){
|
||||
row =
|
||||
'<tr>'
|
||||
+'<td width ="70%" class="body-td align-left">'+items[i].item_name
|
||||
+' <br>'
|
||||
+' <i><span class="font-12">'+items[i].options+'</span></i></td>'+
|
||||
'<td><span class="font-13">'+items[i].qty+ '</span>'
|
||||
+'</td>'
|
||||
+'<td width ="30%" class="body-td align-right">'+ total +'</td>'
|
||||
+'</tr>';
|
||||
}else{
|
||||
row = '<tr>'
|
||||
+'<td width ="70%" class="body-td align-left">'+items[i].item_name
|
||||
+' </td>'+
|
||||
'<td><span class="font-13">'+items[i].qty+ '</span></td>'
|
||||
+'<td width ="30%" class="body-td align-right">'+ total +'</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(items[i].options!='[]' && items[i].options!="" && items[i].options!=null){
|
||||
row = '<tr>'
|
||||
+'<td width ="70%" class="body-td align-left">'+items[i].item_name
|
||||
@@ -391,6 +415,9 @@ function show_order_detail(url,sr_no){
|
||||
+'<td width ="30%" class="body-td align-right">'+ total +'</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.summary-items').append(row);
|
||||
}
|
||||
|
||||
@@ -2323,7 +2323,7 @@
|
||||
@media (max-width: 767px) {
|
||||
.navbar > .container .navbar-brand,
|
||||
.navbar > .container-fluid .navbar-brand {
|
||||
margin-left: 35px;
|
||||
margin-left: 15px;
|
||||
width: 73%; }
|
||||
.navbar .navbar-header {
|
||||
display: inline-block;
|
||||
@@ -8054,4 +8054,3 @@ html.ie11 .dropdown-menu ul.menu li a {
|
||||
|
||||
html.ie11 .bs-searchbox .form-control {
|
||||
width: 90%; }
|
||||
|
||||
|
||||
@@ -269,3 +269,78 @@ i.logout_icon{
|
||||
color: #FFFFFF;
|
||||
}
|
||||
/*customer modal UI */
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,3 +121,78 @@ i.logout_icon{
|
||||
.table-width{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ section .content{
|
||||
}
|
||||
.custom-card-head{
|
||||
height: 40px;
|
||||
#background-color: #54A5AF;
|
||||
background-color: #a1aade;
|
||||
// background-color: #79D0F2;
|
||||
background-color: #3F52B5;
|
||||
color :#fff;
|
||||
#background-color: #a1aade;
|
||||
opacity: 0.8;
|
||||
padding:5px;
|
||||
color :#000000;
|
||||
|
||||
font-weight:600;
|
||||
}
|
||||
.custom-card {
|
||||
border: 2px solid rgba(0, 0, 0, 0.125) !important;
|
||||
@@ -16,6 +17,10 @@ section .content{
|
||||
}
|
||||
.custom-card-footer{
|
||||
padding:0.35rem 1.25rem !important;
|
||||
bottom:0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
font-weight:900;
|
||||
}
|
||||
|
||||
.custom-card-block {
|
||||
@@ -264,7 +269,7 @@ i.logout_icon{
|
||||
.list-menu > a:hover{
|
||||
text-decoration: none;
|
||||
}
|
||||
.cashier_number{
|
||||
.cashier_number, .qty_number{
|
||||
width: 33%;
|
||||
height:58px;
|
||||
line-height:58px;
|
||||
@@ -301,3 +306,39 @@ i.logout_icon{
|
||||
margin-left: 15px !important;
|
||||
margin-right: 15px !important;
|
||||
}
|
||||
.product_box{
|
||||
position:relative;
|
||||
text-align:center;
|
||||
font-weight:900;
|
||||
color:#fff;
|
||||
font-size:1.5em;
|
||||
margin:auto;
|
||||
}
|
||||
.custom-card-no-img-head{
|
||||
#background-color: #54A5AF;
|
||||
opacity: 0.8;
|
||||
padding:5px;
|
||||
color :#273040;
|
||||
min-height:100px;
|
||||
height: 150px;
|
||||
// background-color:#79D0F2;
|
||||
background-color: #3F52B5;
|
||||
|
||||
}
|
||||
.menu_item_no_img_box{
|
||||
cursor: pointer;
|
||||
|
||||
}
|
||||
.custom-card-no-img-footer{
|
||||
padding:0.35rem 1.25rem !important;
|
||||
|
||||
}
|
||||
.custom-flex-footer{
|
||||
display:flex;
|
||||
}
|
||||
.check_option_btn {
|
||||
white-space: normal !important;
|
||||
margin-bottom: 5px;
|
||||
margin-right: 5px;
|
||||
color: #111 !important;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
@import "BSBMaterial/style";
|
||||
@import "BSBMaterial/themes/all-themes";
|
||||
@import "reset";
|
||||
@import "induties/assign_in_duties";
|
||||
|
||||
/*@import "bootstrap-select/css/bootstrap-select.min";*/
|
||||
|
||||
@@ -125,3 +126,102 @@ i.logout_icon{
|
||||
width: 130px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 785px) {
|
||||
#setting{ display: none;}
|
||||
.menu-up{ display: none;}
|
||||
.card-btn{padding: 0px 35px;}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
.mbl-table{
|
||||
display: block;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.mbl-table-card{
|
||||
overflow: scroll;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.p-l-15{
|
||||
padding: 0px 10px;
|
||||
}
|
||||
|
||||
#order_by{
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
96
app/assets/stylesheets/induties/assign_in_duties.scss
Normal file
96
app/assets/stylesheets/induties/assign_in_duties.scss
Normal file
@@ -0,0 +1,96 @@
|
||||
// Place all the styles related to the induties/assign_in_duties controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
.custom-card-head{
|
||||
height: 40px;
|
||||
background-color: grey;
|
||||
color :#fff;
|
||||
opacity: 0.8;
|
||||
padding:5px;
|
||||
font-weight:400;
|
||||
align-items: center;
|
||||
}
|
||||
.form-group .form-control {
|
||||
width: 100%;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
-ms-border-radius: 0;
|
||||
border-radius: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
.radio-room{
|
||||
margin-right:2rem;
|
||||
}
|
||||
.radio-table{
|
||||
margin-left:1rem;
|
||||
}
|
||||
.bmd-form-group {
|
||||
position: relative;
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
.btn_create_induty{
|
||||
display: inline;
|
||||
padding: 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
.create_induty_card{
|
||||
min-height:500px;
|
||||
}
|
||||
|
||||
#save_induties_by_name{
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
.checkboxLabel:before{
|
||||
content: '\e40c';
|
||||
font-family: "Material Icons";
|
||||
font-size: 25px;
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
color: #2196F3;
|
||||
}
|
||||
|
||||
#save_induties_by_name:checked ~ .checkboxLabel:before{
|
||||
content: '\e86c';
|
||||
}
|
||||
.checkboxLabel {
|
||||
font-size: 18px !important;
|
||||
}
|
||||
.add_more{
|
||||
content: '\e40c';
|
||||
font-family: "Material Icons";
|
||||
font-size: 25px;
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
color: #2196F3;
|
||||
}
|
||||
.success-msg {
|
||||
color: #270;
|
||||
background-color: #DFF2BF;
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
display: none;
|
||||
margin-right: 0.5rem;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
.show_all_commissioner_card{
|
||||
min-height: 830px;
|
||||
max-height: 830px;
|
||||
overflow: scroll;
|
||||
}
|
||||
.sweet-alert p {
|
||||
font-size: 14px !important;
|
||||
font-weight:bold;
|
||||
}
|
||||
.sweet-alert {
|
||||
top :0;
|
||||
margin-top: 20px !important;
|
||||
}
|
||||
.add_to_charges{
|
||||
width:100%;
|
||||
padding:1rem;
|
||||
}
|
||||
@@ -280,3 +280,78 @@ i.logout_icon{
|
||||
position: relative;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,3 +118,13 @@
|
||||
.box {
|
||||
margin : 0 -60px 0 -60px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 785px) {
|
||||
.login_pwd{width: 90%;}
|
||||
.login_ent{width: 10%;}
|
||||
// .card-btn{padding: 0px 35px;}
|
||||
// .nav-tabs{padding: 0px 44px;}
|
||||
.box{margin: unset;}
|
||||
.mbl-btn-usrgp{width: 48%;}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,3 +100,9 @@ td.grand-total-padding {
|
||||
font-size: 17px;
|
||||
padding-top: 20px !important;
|
||||
}
|
||||
.mobile_tab-col-teal > li {
|
||||
margin:auto;
|
||||
}
|
||||
.mobile_tab-col-teal{
|
||||
margin-left:1.5rem;
|
||||
}
|
||||
@@ -298,13 +298,6 @@ select.form-control {
|
||||
|
||||
/* Discount */
|
||||
|
||||
.discount-item-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
tr.discount-item-row:hover {
|
||||
background-color: #e3e3e3 !important;
|
||||
}
|
||||
.required abbr{
|
||||
color: red !important;
|
||||
}
|
||||
@@ -659,3 +652,78 @@ nav.pagination .page a:hover,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
# include TokenVerification
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
@@ -19,8 +19,7 @@ class Api::BillController < Api::ApiController
|
||||
# for Multiple Cashier by Zone
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
|
||||
bk_order = BookingOrder.find_by_booking_id(booking.booking_id)
|
||||
order = Order.find(bk_order.order_id)
|
||||
order = booking.orders.first
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
|
||||
@@ -40,40 +39,34 @@ class Api::BillController < Api::ApiController
|
||||
end
|
||||
end
|
||||
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
else
|
||||
if @sale_data = booking.sale
|
||||
@status = true
|
||||
@sale_id = booking.sale_id
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
end
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, cashier, order.source, params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||
end
|
||||
elsif (params[:order_id])
|
||||
order = Order.find(params[:order_id])
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
||||
|
||||
# for Job
|
||||
booking = Booking.find_by_sale_id(@sale_id)
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
# elsif (params[:order_id])
|
||||
# order = Order.find(params[:order_id])
|
||||
# @status, @sale_id = Sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
||||
#
|
||||
# # for Job
|
||||
# booking = Booking.find_by_sale_id(@sale_id)
|
||||
# table = DiningFacility.find(booking.dining_facility_id)
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||
# @sale_data.save
|
||||
if @status
|
||||
if @sale_data
|
||||
#check checkInOut pdf print
|
||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
|
||||
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
|
||||
@@ -85,11 +78,11 @@ class Api::BillController < Api::ApiController
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer,cashier_terminal , check_booking, table)
|
||||
order_queue_printer.print_check_in_out(printer,cashier_terminal , booking, table)
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(@sale)
|
||||
Promotion.promo_activate(@sale_data)
|
||||
|
||||
#BillBroadcastJob.perform_later(table)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
@@ -131,7 +124,7 @@ class Api::BillController < Api::ApiController
|
||||
#member_info = Customer.get_member_account(customer)
|
||||
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
||||
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
||||
end
|
||||
|
||||
def request_bill
|
||||
@@ -175,18 +168,16 @@ class Api::BillController < Api::ApiController
|
||||
booking_order = BookingOrder.find_by_booking_id(@booking.booking_id)
|
||||
order = Order.find(booking_order.order_id)
|
||||
|
||||
if @booking.sale_id.nil?
|
||||
@sale = Sale.new
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
else
|
||||
if @sale_data = @booking.sale
|
||||
@status = true
|
||||
@sale_id = @booking.sale_id
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(@booking, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
|
||||
@status = true
|
||||
else
|
||||
@status = false
|
||||
end
|
||||
end
|
||||
# Promotion.promo_activate(@sale)
|
||||
@status = true
|
||||
# @status = true
|
||||
# render json: JSON.generate({:status => true, :sale_id => @sale_id, :sale_data => @sale_data.to_json })
|
||||
else
|
||||
@status = false
|
||||
|
||||
@@ -47,8 +47,12 @@ class Api::OrdersController < Api::ApiController
|
||||
# end
|
||||
|
||||
@shop = Shop.first
|
||||
puts "Hello world"
|
||||
puts @shop.to_json
|
||||
return @shop.to_json
|
||||
end
|
||||
|
||||
|
||||
# Description
|
||||
# This API allow new order creation
|
||||
# Input Params
|
||||
@@ -62,6 +66,17 @@ class Api::OrdersController < Api::ApiController
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
|
||||
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
|
||||
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
@@ -78,8 +93,7 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
puts params[:order_items]
|
||||
puts "ORDER ITEMS"
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@@ -94,37 +108,13 @@ class Api::OrdersController < Api::ApiController
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
#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 = params[:booking_id]
|
||||
end
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
@@ -136,7 +126,6 @@ class Api::OrdersController < Api::ApiController
|
||||
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 = ""
|
||||
@@ -207,12 +196,9 @@ class Api::OrdersController < Api::ApiController
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
if !booking_id.nil?
|
||||
today = Time.now.utc
|
||||
booking = Booking.find(booking_id)
|
||||
if !booking.nil?
|
||||
if !booking.checkout_at.nil?
|
||||
checkout_time = booking.checkout_at.utc
|
||||
if checkout_time <= today
|
||||
if booking = Booking.find(booking_id)
|
||||
if booking.checkout_at.present?
|
||||
if booking.checkout_at.utc <= Time.now.utc
|
||||
status = false
|
||||
end
|
||||
end
|
||||
@@ -299,4 +285,3 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
18
app/controllers/api/payment/callback_controller.rb
Normal file
18
app/controllers/api/payment/callback_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Api::Payment::CallbackController < Api::ApiController
|
||||
|
||||
skip_before_action :authenticate
|
||||
|
||||
def kbzpay
|
||||
Rails.logger.info params[:Request]
|
||||
callback_value = params[:Request]
|
||||
trade_status = params[:Request][:trade_status]
|
||||
total_amount = params[:Request][:total_amount]
|
||||
if trade_status == "PAY_SUCCESS"
|
||||
merch_order_id = params[:Request][:merch_order_id]
|
||||
|
||||
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, 'kbzpay', merch_order_id)
|
||||
render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
56
app/controllers/api/payment/mobilepayment_controller.rb
Normal file
56
app/controllers/api/payment/mobilepayment_controller.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
class Api::Payment::MobilepaymentController < Api::ApiController
|
||||
|
||||
# skip_before_action :authenticate
|
||||
|
||||
def cash
|
||||
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
cashier_id = params[:cashier_id]
|
||||
|
||||
current_user = Employee.find(cashier_id)
|
||||
|
||||
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_detail.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
|
||||
# end rounding adjustment
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
|
||||
sale_payment =sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
if sale_payment[0]
|
||||
@cash ={"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''}
|
||||
end
|
||||
@out = true,@cash
|
||||
|
||||
else
|
||||
@out =false,"Something wrong!"
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment = sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
if sale_payment[0]
|
||||
@cash = {"change_amount"=>sale_payment[3],"balance_amount"=>sale_payment[4] ,"receipt_url"=>''}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
20
app/controllers/api/sync_controller.rb
Normal file
20
app/controllers/api/sync_controller.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class Api::SyncController < Api::ApiController
|
||||
|
||||
def sync_data
|
||||
# Here comes to save the sync records.
|
||||
Order.sync_order_records(params[:orders])
|
||||
OrderItem.sync_order_item_records(params[:order_items])
|
||||
SaleOrder.sync_sale_order_records(params[:sale_orders])
|
||||
Sale.sync_sale_records(params[:sales])
|
||||
SaleItem.sync_sale_item_records(params[:sale_items])
|
||||
SaleAudit.sync_sale_audit_records(params[:sale_audits])
|
||||
SalePayment.sync_sale_payment_records(params[:sale_payments])
|
||||
SaleTax.sync_sale_tax_records(params[:sale_taxes])
|
||||
ShiftSale.sync_shift_sale_records(params[:shift_sales])
|
||||
Booking.sync_booking_records(params[:bookings])
|
||||
AssignedOrderItem.sync_assigned_order_item_records(params[:assigned_order_items])
|
||||
SeedGenerator.sync_seed_generator_records(params[:seed_generators])
|
||||
|
||||
# render :json => { :status => true, :message => "Hello!" }
|
||||
end
|
||||
end
|
||||
@@ -1,19 +1,29 @@
|
||||
class Crm::CustomersController < BaseCrmController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy,:sync]
|
||||
|
||||
# GET /crm/customers
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
@no_need_validation =false
|
||||
filter = params[:filter]
|
||||
filter_card_no = params[:filter_card_no]
|
||||
type = params[:type]
|
||||
if filter.nil?
|
||||
@customer_update_phone_email_membertype =false
|
||||
if filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
elsif !filter_card_no.nil?
|
||||
@crm_customers=Customer.where("card_no=?",filter_card_no)
|
||||
elsif filter.nil? || filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
if type == "card"
|
||||
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if !@crm_customers.present?
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@@ -30,6 +40,38 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
flash[:member_notice]='Customer was successfully created.'
|
||||
else
|
||||
flash[:member_error]=response["message"]
|
||||
end
|
||||
else
|
||||
if response["status"] ==true
|
||||
@crm_customers.each do |customer|
|
||||
if !response["customer_data"].nil?
|
||||
if customer.contact_no != response["customer_data"]["phone"]
|
||||
@customer_update_phone_email_membertype =true
|
||||
end
|
||||
if customer.email != response["customer_data"]["email"]
|
||||
@customer_update_phone_email_membertype =true
|
||||
end
|
||||
if customer.name != response["customer_data"]["name"]
|
||||
@customer_update_phone_email_membertype =true
|
||||
end
|
||||
if customer.membership_type.to_i != response["customer_data"]["member_group_id"]
|
||||
@customer_update_phone_email_membertype =true
|
||||
end
|
||||
else
|
||||
flash[:member_error]=response["message"]
|
||||
end
|
||||
end
|
||||
else
|
||||
if response["message"] =='No internet connection '
|
||||
flash[:member_error]=response["message"]
|
||||
else
|
||||
flash[:member_error]="Need to press sync button "
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -64,6 +106,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
# puts @crm_customers.to_json
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @crm_customers }
|
||||
@@ -115,7 +158,98 @@ class Crm::CustomersController < BaseCrmController
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
def sync
|
||||
@customer = Customer.find(params[:id])
|
||||
respond_to do |format|
|
||||
name = @customer.name
|
||||
phone = @customer.contact_no
|
||||
email = @customer.email
|
||||
dob = @customer.date_of_birth
|
||||
address = @customer.address
|
||||
nrc = @customer.nrc_no
|
||||
card_no = @customer.card_no
|
||||
paypar_account_no = @customer.paypar_account_no
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = @customer.membership_type
|
||||
if !id.present? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
if paypar_account_no.present?
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
Rails.logger.debug "--------Sync Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
if response["status"] == true
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully synced'
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
# When paypar account no not exist in paypar
|
||||
if response["message"] == "Account does not exist."
|
||||
customer.destroy
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] ='Member cannot created.Invalid Account.'
|
||||
else
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
@@ -173,16 +307,16 @@ class Crm::CustomersController < BaseCrmController
|
||||
)
|
||||
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "Can't open membership server "}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status" => false, "message" => "Can't open membership server "}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status" => false, "message" => "Can't open membership server "}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = {"status" => false, "message" => "Can't open membership server "}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "--------------Create Member---------"
|
||||
Rails.logger.debug response.to_json
|
||||
@@ -191,9 +325,11 @@ class Crm::CustomersController < BaseCrmController
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' }
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] }
|
||||
flash[:member_notice]='Member was successfully created.'
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Member was successfully created.'
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
@@ -202,24 +338,31 @@ class Crm::CustomersController < BaseCrmController
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Member was successfully created.'
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
end
|
||||
|
||||
# When paypar account no not exist in paypar
|
||||
if response["message"] == "Account has not exist."
|
||||
if response["message"] == "Account does not exist."
|
||||
customer.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] }
|
||||
flash[:member_error]='Member cannot created.Invalid Account.'
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] }
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error]='Member cannot created.Invalid Account.'
|
||||
end
|
||||
else
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error]=response["message"]
|
||||
end
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] }
|
||||
flash[:member_notice]='Member was successfully created.' + response["message"]
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
format.html { redirect_to crm_customers_path }
|
||||
# flash[:member_notice]='Member was successfully created.'
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -312,14 +455,17 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
Rails.logger.debug "--------Update Member response -------"
|
||||
@@ -328,16 +474,19 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Member was successfully updated'
|
||||
else
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Member was successfully updated'
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id)
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error]=response["message"]
|
||||
end
|
||||
|
||||
format.html { redirect_to crm_customers_path, notice: response["error"] }
|
||||
end
|
||||
else
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
@@ -371,14 +520,17 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "--------Update Member response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
@@ -390,7 +542,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice] ='Member was successfully updated.'
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
else
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
@@ -400,7 +553,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_error] =response["message"]
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -433,6 +587,24 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
end
|
||||
|
||||
def customer_update_phone_email_member_type
|
||||
@customer = Customer.find(params[:id])
|
||||
response = Customer.search_paypar_account_no(@customer.paypar_account_no)
|
||||
if response["status"] == true
|
||||
@customer.name =response["customer_data"]["name"]
|
||||
@customer.contact_no =response["customer_data"]["phone"]
|
||||
@customer.email =response["customer_data"]["email"]
|
||||
@customer.membership_type =response["customer_data"]["member_group_id"]
|
||||
@customer.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Membership was successfully updated'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_crm_customer
|
||||
@@ -447,3 +619,4 @@ class Crm::CustomersController < BaseCrmController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -117,7 +117,8 @@ class HomeController < ApplicationController
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
|
||||
logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><'
|
||||
logger.debug @hourly_sales.to_json
|
||||
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
|
||||
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
|
||||
@employee_sales = []
|
||||
|
||||
71
app/controllers/induties/assign_in_duties_controller.rb
Normal file
71
app/controllers/induties/assign_in_duties_controller.rb
Normal file
@@ -0,0 +1,71 @@
|
||||
class Induties::AssignInDutiesController < ApplicationController
|
||||
def index
|
||||
@commissioners =[]
|
||||
@commiss=Commissioner.active.all.order(created_at: :desc)
|
||||
@commiss.each do|commissioner|
|
||||
check_in_count =InDuty.where('commissioner_ids =? and out_time is null', commissioner.id.to_json).count;
|
||||
@commissioners.push({ "id"=>commissioner.id,
|
||||
"name"=>commissioner.name,
|
||||
"image_path"=>commissioner.image_path.url,
|
||||
"check_in_count"=>check_in_count
|
||||
})
|
||||
|
||||
end
|
||||
@booking_id = params[:booking_id]
|
||||
|
||||
end
|
||||
|
||||
def get_all_occupied_dining
|
||||
commissionerIds =params[:id]
|
||||
@check_in_commissioner =InDuty.select("in_duties.*,dining_facilities.type as dinning_type")
|
||||
.joins(" LEFT JOIN dining_facilities on dining_facilities.id = in_duties.dinning_id").where('commissioner_ids =? and out_time is null', commissionerIds).order(created_at: :asc);
|
||||
respond_to do |format|
|
||||
format.json { render json: @check_in_commissioner.to_json }
|
||||
end
|
||||
end
|
||||
def induties_create
|
||||
commissioner_ids =params[:commissionerId]
|
||||
booking_id =params[:booking_id]
|
||||
dinning_id = params[:dinning_id]
|
||||
induty = InDuty.new
|
||||
induty.dinning_id = dinning_id
|
||||
induty.booking_id = booking_id
|
||||
induty.commissioner_ids = commissioner_ids
|
||||
induty.by_name = params[:by_name]
|
||||
induty.in_time = Time.now.utc
|
||||
if induty.save
|
||||
dinning = DiningFacility.find(induty.dinning_id)
|
||||
@induty= {"id"=>induty.id,
|
||||
"dinning_id"=>induty.dinning_id,
|
||||
"in_time"=>induty.in_time,
|
||||
"out_time"=>induty.out_time,
|
||||
"dinning_type"=>dinning.type }
|
||||
respond_to do |format|
|
||||
format.json { render json: @induty.to_json }
|
||||
end
|
||||
end
|
||||
end
|
||||
def induties_checkout
|
||||
induty_id = params[:induty_id]
|
||||
induty = InDuty.find(induty_id)
|
||||
induty.out_time = Time.now.utc
|
||||
induty.save
|
||||
@induty =induty
|
||||
respond_to do |format|
|
||||
format.json { render json: @induty.to_json }
|
||||
end
|
||||
end
|
||||
def induties_remove
|
||||
induty_id = params[:induty_id]
|
||||
induty = InDuty.find(induty_id)
|
||||
induty.destroy
|
||||
end
|
||||
def get_current_booking
|
||||
@current_booking =InDuty.select("in_duties.*,dining_facilities.type as dinning_type")
|
||||
.joins(" LEFT JOIN dining_facilities on dining_facilities.id = in_duties.dinning_id").where('booking_id =? and out_time is null', params[:booking_id]).order(created_at: :asc);
|
||||
respond_to do |format|
|
||||
format.json { render json: @current_booking.to_json }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -12,7 +12,7 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
inventory_definition_id = params[:inventory_definition_id]
|
||||
inventory = InventoryDefinition.find(inventory_definition_id)
|
||||
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code)
|
||||
@stock_journals = StockJournal.where(item_code: inventory.item_code).order("id DESC")
|
||||
@stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20)
|
||||
|
||||
respond_to do |format|
|
||||
@@ -21,6 +21,8 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
|
||||
@@ -83,11 +83,24 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# DELETE /inventory_definitions/1
|
||||
# DELETE /inventory_definitions/1.json
|
||||
def destroy
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
@inventory_definition.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
|
||||
inventory = InventoryDefinition.find(params[:id])
|
||||
StockJournal.delete_stock_journal(inventory.item_code)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||
if !inventory.nil?
|
||||
inventory.destroy
|
||||
flash[:message] = 'Inventory was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => inventory_url }.to_json
|
||||
else
|
||||
flash[:error] = 'Inventory could not destroy! This record is using in somewhere.'
|
||||
render :json => {:status=> "Error", :url => inventory_url }.to_json
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -49,8 +49,7 @@ class Oqs::EditController < BaseOqsController
|
||||
oqs = assign_item.order_queue_station
|
||||
|
||||
printer = PrintSetting.all
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
unique_code= ""
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'OrderItemPdf'
|
||||
@@ -65,6 +64,8 @@ class Oqs::EditController < BaseOqsController
|
||||
unique_code="OrderSetItemCustomisePdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemSlimCustomisePdf'
|
||||
unique_code="OrderItemSlimCustomisePdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemStarPdf'
|
||||
unique_code="OrderItemStarPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,12 +5,14 @@ class Oqs::PrintController < ApplicationController
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
printer = PrintSetting.all
|
||||
unique_code="OrderItemPdf"
|
||||
unique_code="OrderItemStarPdf"
|
||||
if !order_slim_pdf.empty?
|
||||
if !printer.empty?
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'OrderItemPdf'
|
||||
unique_code="OrderItemPdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemStarPdf'
|
||||
unique_code="OrderItemStarPdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
||||
@@ -49,7 +51,7 @@ class Oqs::PrintController < ApplicationController
|
||||
ai.save
|
||||
end
|
||||
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
result = {
|
||||
:filepath => filename,
|
||||
@@ -117,7 +119,7 @@ class Oqs::PrintController < ApplicationController
|
||||
ai.save
|
||||
end
|
||||
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
result = {
|
||||
:filepath => filename,
|
||||
|
||||
@@ -38,20 +38,10 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@booking = @table.get_booking
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@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
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,8 +92,16 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def create
|
||||
# Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
# Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
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 = ''
|
||||
|
||||
@@ -131,6 +129,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
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]
|
||||
@@ -144,43 +143,12 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
|
||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
@order.booking_id = booking.booking_id
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
@@ -3,6 +3,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#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
|
||||
|
||||
@@ -59,34 +59,29 @@ class Origami::FoodCourtController < ApplicationController
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@sale_id = @booking.sale_id
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@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
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
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"
|
||||
cashier_type = "food_court"
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
@@ -108,81 +103,31 @@ class Origami::FoodCourtController < ApplicationController
|
||||
}
|
||||
|
||||
# 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.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
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.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if(params[:sale_id][0,3] == "SAL")
|
||||
if @status && @booking && (@order.source == 'quick_service' || @order.source == 'food_court')
|
||||
if params[:sale_id]
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
if @order.table_id.to_i > 0
|
||||
@table_id = @order.table_id
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
else
|
||||
@table_id = nil
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
|
||||
end
|
||||
|
||||
result = {:status=> true, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
elsif (params[:sale_id][0,3] == "BKI")
|
||||
result = {:status=> true, :data => 'OK' }
|
||||
render :json => result.to_json
|
||||
else
|
||||
result = {:status=> true, :data => nil }
|
||||
render :json => result.to_json
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -17,6 +17,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
# origami table detail
|
||||
def show
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@webview = check_mobile
|
||||
|
||||
@tables = Table.unscoped.all.active.order('status desc')
|
||||
@@ -144,6 +146,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def check_emp_access_code
|
||||
|
||||
@@ -5,12 +5,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
def first_bill
|
||||
sale_id = params[:sale_id] # sale_id
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_data = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
member_info = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
@@ -21,12 +21,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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)
|
||||
if booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(booking.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)
|
||||
shift = ShiftSale.find(sale_data.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
end
|
||||
@@ -35,13 +35,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
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
|
||||
unique_code = "ReceiptBillPdf"
|
||||
unique_code = unique_code#{}"ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -91,7 +102,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil)
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
|
||||
if !kbz_pay_method.nil?
|
||||
if kbz_pay_method.is_active == true
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
|
||||
|
||||
status, qr = KbzPay.pay(sale_data.grand_total.to_i, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
|
||||
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_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
@@ -99,6 +127,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
@@ -112,6 +142,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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)
|
||||
@@ -133,12 +164,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# if pay_from = 'kbzpay'
|
||||
# salePayment = SalePayment.find(sale_payment_id)
|
||||
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
|
||||
# else
|
||||
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
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true)
|
||||
else
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
end
|
||||
else
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
rebate_amount = nil
|
||||
@@ -169,13 +212,24 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# 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
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# else
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -197,7 +251,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if params[:type] == "quick_service"
|
||||
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
|
||||
@@ -246,16 +300,37 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,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})
|
||||
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_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
#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 kbz_query
|
||||
# sale_id = params[:sale_id]
|
||||
# table_id = params[:table_id]
|
||||
# sp = SalePayment.where('sale_id=?', sale_id).last
|
||||
# status, table_id = KbzPay.query(sp.sale_payment_id)
|
||||
# render json: JSON.generate({:status => status, :table_id => table_id, :message => @message})
|
||||
# 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
|
||||
@@ -275,6 +350,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@@ -299,6 +375,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
@@ -454,6 +533,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -543,7 +623,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "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_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
@@ -613,12 +694,25 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
#shop_detail = Shop.first
|
||||
printer = PrintSetting.all
|
||||
|
||||
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(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
@@ -629,7 +723,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "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_detail, "FOC",nil,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
@@ -653,6 +747,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# end
|
||||
if !saleObj.nil?
|
||||
#InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -686,13 +784,23 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
else
|
||||
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
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# else
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,26 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
id = params[:sale_id]
|
||||
if id.start_with?("SAL")
|
||||
@sale = Sale.find(id)
|
||||
if @sale.sale_status == "new"
|
||||
@bookings = @sale.bookings.first
|
||||
@status = "sale"
|
||||
else
|
||||
redirect_to "/origami/#{params[:type]}" and return
|
||||
end
|
||||
elsif id.start_with?("BKI")
|
||||
@bookings = Booking.find(id)
|
||||
@order = @bookings.orders.where(status: "new").first
|
||||
@order_items = @bookings.order_items
|
||||
@status = "order"
|
||||
end
|
||||
|
||||
if @dining = @bookings.dining_facility
|
||||
@table_id = @dining.id
|
||||
end
|
||||
|
||||
@cashier_type = params[:type]
|
||||
@sales = Sale.pending_sale(@cashier_type)
|
||||
@orders = Sale.pending_order(@cashier_type)
|
||||
@@ -20,38 +40,6 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
|
||||
@occupied_table = @sales.count.length + @orders.count.length
|
||||
|
||||
@id = params[:sale_id]
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@bookings = Booking.find(@booking)
|
||||
@status = "sale"
|
||||
else
|
||||
# @booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@bookings = Booking.find(@id)
|
||||
@status = "order"
|
||||
|
||||
@order_items = Array.new
|
||||
@bookings.booking_orders.each do |booking_order|
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# puts @status
|
||||
if @bookings.dining_facility_id.to_i > 0
|
||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
@customers = Customer.pluck("customer_id, name")
|
||||
end
|
||||
|
||||
def completed_sale
|
||||
|
||||
@@ -30,13 +30,15 @@ class Origami::QuickServiceController < ApplicationController
|
||||
end
|
||||
|
||||
#checked quick_service only
|
||||
@quick_service_only = true
|
||||
lookup_dine_in = Lookup.collection_of('dinein_cashier')
|
||||
@quick_service_only = false
|
||||
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||
puts 'lookup_dine_in!!!!'
|
||||
puts lookup_dine_in
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "dineincashier"
|
||||
if dine_in[0].downcase == "quickserviceaddorder"
|
||||
if dine_in[1] == '1'
|
||||
@quick_service_only = false
|
||||
@quick_service_only = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -66,34 +68,29 @@ class Origami::QuickServiceController < ApplicationController
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@sale_id = @booking.sale_id
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@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
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
@obj_order = @booking.orders.first
|
||||
@customer = @obj_order.customer
|
||||
@date = @obj_order.created_at
|
||||
@order_items = @booking.order_items
|
||||
end
|
||||
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
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 = "quick_service"
|
||||
cashier_type = "quick_service"
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
@@ -115,81 +112,31 @@ class Origami::QuickServiceController < ApplicationController
|
||||
}
|
||||
|
||||
# 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.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
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.is_extra_time = is_extra_time
|
||||
order.extra_time = extra_time
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
order.new_booking = false
|
||||
order.booking_id = booking.booking_id
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if(params[:sale_id][0,3] == "SAL")
|
||||
if @status && @booking && @order.source == 'quick_service'
|
||||
if params[:sale_id]
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
if @order.table_id.to_i > 0
|
||||
@table_id = @order.table_id
|
||||
if order.generate
|
||||
if sale
|
||||
Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking)
|
||||
render :json => { :status => true, :data => sale }
|
||||
else
|
||||
@table_id = nil
|
||||
render :json => { :status => true, :data => 'OK' }
|
||||
end
|
||||
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
|
||||
end
|
||||
|
||||
result = {:status=> true, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
elsif (params[:sale_id][0,3] == "BKI")
|
||||
result = {:status=> true, :data => 'OK' }
|
||||
render :json => result.to_json
|
||||
else
|
||||
result = {:status=> true, :data => nil }
|
||||
render :json => result.to_json
|
||||
render :json => { :status => false }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,42 +8,30 @@ class Origami::RequestBillsController < ApplicationController
|
||||
end
|
||||
# Print Request Bill and add to sale tables
|
||||
def print
|
||||
@sale = Sale.new
|
||||
sale_order=SaleOrder.new
|
||||
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = params[:id] # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
if check_booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && check_booking.checkout_at.nil?
|
||||
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
|
||||
if check_booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
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=?",bk_order.booking_id)
|
||||
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_id
|
||||
induty.sale_id = sale_data.sale_id
|
||||
induty.out_time = Time.now.utc
|
||||
induty.save
|
||||
end
|
||||
end
|
||||
else
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@@ -53,11 +41,11 @@ class Origami::RequestBillsController < ApplicationController
|
||||
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 )
|
||||
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)
|
||||
Promotion.promo_activate(sale_data)
|
||||
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
@@ -70,14 +58,13 @@ class Origami::RequestBillsController < ApplicationController
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
end
|
||||
if order.source == "quick_service" || order.source == "food_court"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
else
|
||||
#check checkInOut pdf print
|
||||
check_booking = Booking.find_by_sale_id(@sale_id)
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
if !check_booking.dining_facility_id.nil?
|
||||
terminal = DiningFacility.find_by_id(check_booking.dining_facility_id)
|
||||
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
|
||||
@@ -88,12 +75,13 @@ class Origami::RequestBillsController < ApplicationController
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||
|
||||
if !printer.nil?
|
||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, check_booking, table)
|
||||
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"
|
||||
@@ -119,7 +107,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
# @newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.is_taxable = 1
|
||||
@@ -40,17 +40,17 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
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
|
||||
# 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"
|
||||
@@ -74,7 +74,6 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * -1
|
||||
@newsaleitem.unit_price = saleitemObj.unit_price * 1
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@@ -156,13 +155,13 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
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
|
||||
# order.order_items.each do |o|
|
||||
# if saleitemObj.product_code == o.item_code
|
||||
# o.qty = update_qty
|
||||
# o.price = update_price
|
||||
# o.save
|
||||
# end
|
||||
# end
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
|
||||
@@ -174,18 +173,18 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
saleitemId = params[:sale_item_id]
|
||||
access_code = params[:access_code]
|
||||
order_source = params[:type]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
||||
both.each do |item|
|
||||
if item.qty.to_i > 0
|
||||
item.status = nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
saleitemObj.destroy
|
||||
|
||||
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
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
@@ -30,9 +30,6 @@ class Origami::SalesController < BaseOrigamiController
|
||||
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.checkout_at.nil?
|
||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
order_array = []
|
||||
booking.booking_orders.each do |booking_order|
|
||||
@@ -60,7 +57,6 @@ class Origami::SalesController < BaseOrigamiController
|
||||
booking.save
|
||||
|
||||
order_array.push(order.order_id)
|
||||
|
||||
end
|
||||
|
||||
receipt_no = Sale.find(sale_id).receipt_no
|
||||
@@ -77,10 +73,6 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
if !sale_data.empty?
|
||||
# InventoryJob.perform_now(self.id)
|
||||
InventoryDefinition.calculate_product_count(nil,sale_data)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -38,6 +39,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update_shift
|
||||
closing_balance = params[:closing_balance]
|
||||
shift_id = params[:shift_id]
|
||||
@@ -66,6 +69,11 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
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.collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
@@ -83,6 +91,13 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
shop_details = shop_detail
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
sale_items = ''
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
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='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
@@ -102,7 +117,16 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
# 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])
|
||||
|
||||
@@ -117,16 +117,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
else
|
||||
if sale_data = booking.sale
|
||||
status = true
|
||||
sale_id = booking.sale_id
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
end
|
||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
else
|
||||
status = false
|
||||
end
|
||||
else
|
||||
if params[:type] == "Table"
|
||||
@@ -332,11 +328,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale)
|
||||
Promotion.promo_activate(sale_data)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
|
||||
@@ -30,7 +30,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
puts 'Catch me if you can.......................'
|
||||
# puts 'Catch me if you can.......................'
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
@@ -8,7 +8,6 @@ class Origami::VoidController < BaseOrigamiController
|
||||
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(sale_id, sale.sale_items,0,order_source)
|
||||
@@ -105,7 +104,15 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# get printer info
|
||||
# print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf
|
||||
#
|
||||
# if !print_settings.nil?
|
||||
# unique_code = 'ReceiptBillPdf'
|
||||
# elsif
|
||||
# unique_code = 'ReceiptBillStarPdf'
|
||||
# end
|
||||
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
@@ -119,6 +126,20 @@ class Origami::VoidController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.all
|
||||
|
||||
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(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
@@ -126,7 +147,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
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,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,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_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -86,7 +86,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
# unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
@@ -100,6 +100,21 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
printer = PrintSetting.all
|
||||
|
||||
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(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
@@ -107,7 +122,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
|
||||
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,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,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_details, remark,current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
@@ -11,6 +11,7 @@ class PrintSettingsController < ApplicationController
|
||||
# GET /print_settings/1
|
||||
# GET /print_settings/1.json
|
||||
def show
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
end
|
||||
|
||||
# GET /print_settings/new
|
||||
@@ -21,6 +22,7 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# GET /print_settings/1/edit
|
||||
def edit
|
||||
@lookup = Lookup.shift_sale_items_lookup_value
|
||||
@server_mode = ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
@@ -45,6 +47,10 @@ class PrintSettingsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @print_setting.update(print_setting_params)
|
||||
if @print_setting.unique_code == 'CloseCashierPdf'
|
||||
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
|
||||
end
|
||||
|
||||
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @print_setting }
|
||||
else
|
||||
|
||||
@@ -9,6 +9,7 @@ class Reports::DailysaleController < BaseReportController
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
|
||||
200
app/controllers/reports/hourly_saleitem_controller.bk.rb
Normal file
200
app/controllers/reports/hourly_saleitem_controller.bk.rb
Normal file
@@ -0,0 +1,200 @@
|
||||
class Reports::HourlySaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
logger.debug 'product>>>>>>>>>>>>>>>>>>>>>>>>>>'
|
||||
# logger.debug @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"Date" =>key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
|
||||
@hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
logger.debug @hourly_total_qty
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
if shift.present?
|
||||
shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
sale_data = @sale_data
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
logger.debug 'show date arr####################'
|
||||
logger.debug date_arr
|
||||
end
|
||||
|
||||
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
def print_sale_items
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
shift_name = 'All Shift'
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
sh_name = "#{shift_sale.shift_started_at.utc.getlocal.strftime('%d %B %l:%M%p')} - #{shift_sale.shift_closed_at.utc.getlocal.strftime('%d %B %l:%M%p')}"
|
||||
employee = Employee.find(shift_sale.employee_id)
|
||||
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
|
||||
end
|
||||
|
||||
shop_details = shop_detail
|
||||
account_type = params[:account_type]
|
||||
@type = params[:period_type]
|
||||
period_name = get_period_name(params[:period])
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
other_charges = Sale.get_other_charges()
|
||||
if shift.present?
|
||||
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
else
|
||||
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
|
||||
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
|
||||
|
||||
# if print_settings.nil? && print_settings_star.nil?
|
||||
# @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" )
|
||||
# @print_setting.save
|
||||
# end
|
||||
|
||||
if print_settings.nil?
|
||||
if !print_settings_star.nil?
|
||||
printer = Printer::CashierStationPrinter.new(print_settings_star)
|
||||
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
else
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
|
||||
format
|
||||
end
|
||||
end
|
||||
|
||||
def get_period_name(period)
|
||||
period_name = '-'
|
||||
unless period.nil? or period.blank?
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
period_name = "Today"
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
period_name = "Yesterday"
|
||||
|
||||
when PERIOD["this_week"]
|
||||
period_name = "This Week"
|
||||
|
||||
when PERIOD["last_week"]
|
||||
period_name = "Last Week"
|
||||
|
||||
when PERIOD["last_7"]
|
||||
period_name = "Last 7 days"
|
||||
|
||||
when PERIOD["this_month"]
|
||||
period_name = "This Month"
|
||||
|
||||
when PERIOD["last_month"]
|
||||
period_name = "Last Month"
|
||||
|
||||
when PERIOD["last_30"]
|
||||
period_name = "Last 30 Days"
|
||||
|
||||
when PERIOD["this_year"]
|
||||
period_name = "This Year"
|
||||
|
||||
when PERIOD["last_year"]
|
||||
period_name = "Last Year"
|
||||
|
||||
end
|
||||
end
|
||||
return period_name
|
||||
end
|
||||
|
||||
end
|
||||
196
app/controllers/reports/hourly_saleitem_controller.rb
Normal file
196
app/controllers/reports/hourly_saleitem_controller.rb
Normal file
@@ -0,0 +1,196 @@
|
||||
class Reports::HourlySaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
if shift.present?
|
||||
shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
# @hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
@hourly_total_qty = @sale_data.group_by(&:date_format).map { |k,v|{"date" => k , "total_qty" => v.count }}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
sale_data = @sale_data
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
def print_sale_items
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
shift_name = 'All Shift'
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
sh_name = "#{shift_sale.shift_started_at.utc.getlocal.strftime('%d %B %l:%M%p')} - #{shift_sale.shift_closed_at.utc.getlocal.strftime('%d %B %l:%M%p')}"
|
||||
employee = Employee.find(shift_sale.employee_id)
|
||||
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
|
||||
end
|
||||
|
||||
shop_details = shop_detail
|
||||
account_type = params[:account_type]
|
||||
@type = params[:period_type]
|
||||
period_name = get_period_name(params[:period])
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
other_charges = Sale.get_other_charges()
|
||||
if shift.present?
|
||||
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
else
|
||||
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
|
||||
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
|
||||
|
||||
# if print_settings.nil? && print_settings_star.nil?
|
||||
# @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" )
|
||||
# @print_setting.save
|
||||
# end
|
||||
|
||||
if print_settings.nil?
|
||||
if !print_settings_star.nil?
|
||||
printer = Printer::CashierStationPrinter.new(print_settings_star)
|
||||
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
else
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
|
||||
format
|
||||
end
|
||||
end
|
||||
|
||||
def get_period_name(period)
|
||||
period_name = '-'
|
||||
unless period.nil? or period.blank?
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
period_name = "Today"
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
period_name = "Yesterday"
|
||||
|
||||
when PERIOD["this_week"]
|
||||
period_name = "This Week"
|
||||
|
||||
when PERIOD["last_week"]
|
||||
period_name = "Last Week"
|
||||
|
||||
when PERIOD["last_7"]
|
||||
period_name = "Last 7 days"
|
||||
|
||||
when PERIOD["this_month"]
|
||||
period_name = "This Month"
|
||||
|
||||
when PERIOD["last_month"]
|
||||
period_name = "Last Month"
|
||||
|
||||
when PERIOD["last_30"]
|
||||
period_name = "Last 30 Days"
|
||||
|
||||
when PERIOD["this_year"]
|
||||
period_name = "This Year"
|
||||
|
||||
when PERIOD["last_year"]
|
||||
period_name = "Last Year"
|
||||
|
||||
end
|
||||
end
|
||||
return period_name
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,7 +2,7 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"],
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"],
|
||||
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
|
||||
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
|
||||
["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"],
|
||||
|
||||
@@ -24,6 +24,11 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
@lookup = Lookup.find_by_lookup_type('reprint_receipt')
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_reprint_receipt_lookup
|
||||
end
|
||||
|
||||
payment_type = params[:payment_type]
|
||||
@sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type)
|
||||
@@ -70,4 +75,165 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
def sync_data
|
||||
@orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales = Booking.get_sync_data(params[:sale_id])
|
||||
|
||||
# Here comes to call the sync api
|
||||
# url = "http://192.168.1.176:3000/en/api/sync_data"
|
||||
url = Lookup.sync_url
|
||||
token = Lookup.get_sync_token
|
||||
@message = ''
|
||||
# token = Lookup.token
|
||||
|
||||
unless url.nil? and token.nil?
|
||||
begin
|
||||
@result = HTTParty.post(url.to_str,
|
||||
:body => { :orders => @orders,
|
||||
:order_items => @order_items,
|
||||
:sale_orders => @sale_orders,
|
||||
:sales => @sales,
|
||||
:sale_items => @sale_items,
|
||||
:sale_audits => @sale_audits,
|
||||
:sale_payments => @sale_payments,
|
||||
:sale_taxes => @sale_taxes,
|
||||
:bookings => @bookings,
|
||||
:assigned_order_items => @assigned_order_items,
|
||||
:shift_sales => @shift_sales
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer #{token}"
|
||||
}, :timeout => 10,
|
||||
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
||||
:verify => false )
|
||||
|
||||
rescue HTTParty::Error
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
rescue OpenURI::HTTPError
|
||||
puts "Fire in here"
|
||||
response = { status: false, message: "Can't open membership server "}
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't open server "}
|
||||
rescue Errno::EHOSTDOWN
|
||||
response = { status: false, message: "Can't open server "}
|
||||
rescue Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
||||
response = { status: false, message: "Can't open membership server"}
|
||||
end
|
||||
|
||||
puts url
|
||||
puts response
|
||||
@message = @result.parsed_response['message']
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/receipt_no/', notice: @message}
|
||||
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.id)
|
||||
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 = 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_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,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
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/receipt_no/', notice: "Printing Completed."}
|
||||
format.json { render json: result }
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -31,10 +31,9 @@ class Reports::SaleitemController < BaseReportController
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
|
||||
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
||||
|
||||
@@ -55,7 +54,6 @@ class Reports::SaleitemController < BaseReportController
|
||||
@shift_data = sh
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
@@ -87,4 +85,108 @@ class Reports::SaleitemController < BaseReportController
|
||||
end
|
||||
end
|
||||
|
||||
def print_sale_items
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
shift_name = 'All Shift'
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
|
||||
sh_name = "#{shift_sale.shift_started_at.utc.getlocal.strftime('%d %B %l:%M%p')} - #{shift_sale.shift_closed_at.utc.getlocal.strftime('%d %B %l:%M%p')}"
|
||||
employee = Employee.find(shift_sale.employee_id)
|
||||
shift_name = employee.nil? ? sh_name : "#{sh_name} (#{employee.name})"
|
||||
end
|
||||
|
||||
shop_details = shop_detail
|
||||
account_type = params[:account_type]
|
||||
@type = params[:period_type]
|
||||
period_name = get_period_name(params[:period])
|
||||
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
other_charges = Sale.get_other_charges()
|
||||
if shift.present?
|
||||
@total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
else
|
||||
@total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf
|
||||
print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf')
|
||||
|
||||
# if print_settings.nil? && print_settings_star.nil?
|
||||
# @print_setting = PrintSetting.new(name: "SaleItemsPdf", unique_code: "SaleItemsPdf", template: "",font: "Zawgyi-One", header_font_size: "10", item_font_size: "8", printer_name: "", api_settings: "", brand_name: nil, printer_type: nil, page_width: "210", page_height: "1450", print_copies: "1", precision: "0", delimiter: "0", heading_space: "5" )
|
||||
# @print_setting.save
|
||||
# end
|
||||
|
||||
if print_settings.nil?
|
||||
if !print_settings_star.nil?
|
||||
printer = Printer::CashierStationPrinter.new(print_settings_star)
|
||||
printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
else
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
|
||||
format
|
||||
end
|
||||
end
|
||||
|
||||
def get_period_name(period)
|
||||
period_name = '-'
|
||||
unless period.nil? or period.blank?
|
||||
case period.to_i
|
||||
when PERIOD["today"]
|
||||
period_name = "Today"
|
||||
|
||||
when PERIOD["yesterday"]
|
||||
period_name = "Yesterday"
|
||||
|
||||
when PERIOD["this_week"]
|
||||
period_name = "This Week"
|
||||
|
||||
when PERIOD["last_week"]
|
||||
period_name = "Last Week"
|
||||
|
||||
when PERIOD["last_7"]
|
||||
period_name = "Last 7 days"
|
||||
|
||||
when PERIOD["this_month"]
|
||||
period_name = "This Month"
|
||||
|
||||
when PERIOD["last_month"]
|
||||
period_name = "Last Month"
|
||||
|
||||
when PERIOD["last_30"]
|
||||
period_name = "Last 30 Days"
|
||||
|
||||
when PERIOD["this_year"]
|
||||
period_name = "This Year"
|
||||
|
||||
when PERIOD["last_year"]
|
||||
period_name = "Last Year"
|
||||
|
||||
end
|
||||
end
|
||||
return period_name
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -48,5 +48,61 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
end
|
||||
end
|
||||
|
||||
def print_close_receipt
|
||||
shift_id = params[:id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
shift_obj = ShiftSale.where('id =?',shift_id)
|
||||
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
unique_code="CloseCashierCustomisePdf"
|
||||
else
|
||||
unique_code="CloseCashierPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shop_details = shop_detail
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@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)
|
||||
|
||||
# printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, 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_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)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||
format
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -48,4 +48,3 @@ class Reports::StockCheckController < BaseReportController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class Settings::CommissionersController < ApplicationController
|
||||
def new
|
||||
@commissioner = Commissioner.new
|
||||
@employee = Employee.all.order('name asc')
|
||||
|
||||
end
|
||||
|
||||
# GET /commissioners/1/edit
|
||||
@@ -35,6 +36,8 @@ class Settings::CommissionersController < ApplicationController
|
||||
unless @commissioner.resigned_date.nil?
|
||||
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
# puts params[:from_induty].length
|
||||
if (params[:from_induty] != "true")
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'}
|
||||
@@ -44,6 +47,11 @@ class Settings::CommissionersController < ApplicationController
|
||||
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
else
|
||||
@commissioner.save
|
||||
flash[:notice] = 'Commissioner was successfully created.'
|
||||
redirect_to induties_assign_in_duties_path(params[:booking_id])
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /commissioners/1
|
||||
|
||||
@@ -30,9 +30,6 @@ class Settings::EmployeesController < ApplicationController
|
||||
# POST /employees
|
||||
# POST /employees.json
|
||||
def create
|
||||
puts "puts ssssssssssssssssssssssssss"
|
||||
puts employee_params.to_json
|
||||
|
||||
@employee = Employee.new(employee_params)
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -55,7 +55,26 @@ class Settings::MenuItemAttributesController < ApplicationController
|
||||
# DELETE /settings/menu_item_attributes/1
|
||||
# DELETE /settings/menu_item_attributes/1.json
|
||||
def destroy
|
||||
@settings_menu_item_attribute.destroy
|
||||
item_attribute_id =@settings_menu_item_attribute.id
|
||||
item_attribute_id_string=""+item_attribute_id.to_s+""
|
||||
if @settings_menu_item_attribute.destroy
|
||||
menu_items =MenuItem.all
|
||||
menu_items.each do |item|
|
||||
if item.item_attributes.include?(item_attribute_id)
|
||||
item_update =item.item_attributes.reject { |i| i == item_attribute_id }
|
||||
item.item_code =item.item_code
|
||||
item.item_attributes =item_update
|
||||
item.save
|
||||
end
|
||||
if item.item_attributes.include?(item_attribute_id_string)
|
||||
item_update =item.item_attributes.reject { |i| i == item_attribute_id_string }
|
||||
item.item_code =item.item_code
|
||||
item.item_attributes =item_update
|
||||
item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
# @settings_menu_item_attribute.destroy
|
||||
flash[:notice] = 'Menu item attribute was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => settings_menu_item_attributes_path }.to_json
|
||||
# respond_to do |format|
|
||||
|
||||
@@ -55,7 +55,25 @@ class Settings::MenuItemOptionsController < ApplicationController
|
||||
# DELETE /settings/menu_item_options/1
|
||||
# DELETE /settings/menu_item_options/1.json
|
||||
def destroy
|
||||
@settings_menu_item_option.destroy
|
||||
item_option_id =@settings_menu_item_option.id
|
||||
item_option_id_string=""+item_option_id.to_s+""
|
||||
if @settings_menu_item_option.destroy
|
||||
menu_items =MenuItem.all
|
||||
menu_items.each do |item|
|
||||
if item.item_options.include?(item_option_id)
|
||||
item_update =item.item_options.reject { |i| i == item_option_id }
|
||||
item.item_code =item.item_code
|
||||
item.item_options =item_update
|
||||
item.save
|
||||
end
|
||||
if item.item_options.include?(item_option_id_string)
|
||||
item_update =item.item_options.reject { |i| i == item_option_id_string }
|
||||
item.item_code =item.item_code
|
||||
item.item_options =item_update
|
||||
item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
flash[:notice] = 'Menu item option was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => settings_menu_item_options_path }.to_json
|
||||
# respond_to do |format|
|
||||
|
||||
@@ -109,7 +109,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController
|
||||
|
||||
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,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_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
|
||||
2
app/helpers/induties/assign_in_duties_helper.rb
Normal file
2
app/helpers/induties/assign_in_duties_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Induties::AssignInDutiesHelper
|
||||
end
|
||||
@@ -7,6 +7,27 @@ class AssignedOrderItem < ApplicationRecord
|
||||
belongs_to :order
|
||||
belongs_to :order_queue_station
|
||||
|
||||
def self.sync_assigned_order_item_records(assigned_order_items)
|
||||
if !assigned_order_items.nil?
|
||||
assigned_order_items.each do |item|
|
||||
order_item = AssignedOrderItem.find_by_assigned_order_item_id(item['assigned_order_item_id'])
|
||||
# unless AssignedOrderItem.exists?(item['assigned_order_item_id'])
|
||||
if order_item.nil?
|
||||
order_item = AssignedOrderItem.new
|
||||
end
|
||||
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
||||
order_item.item_code = item['item_code']
|
||||
order_item.instance_code = item['instance_code']
|
||||
order_item.order_queue_station_id = item['order_queue_station_id']
|
||||
order_item.order_id = item['order_id']
|
||||
order_item.print_status = item['print_status']
|
||||
order_item.delivery_status = item['delivery_status']
|
||||
order_item.save
|
||||
end
|
||||
Rails.logger.debug '....... Assigned Order Item sync completed .......'
|
||||
end
|
||||
end
|
||||
|
||||
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
|
||||
assigned_order_item = AssignedOrderItem.new()
|
||||
assigned_order_item.order = order
|
||||
@@ -43,6 +64,8 @@ class AssignedOrderItem < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.assigned_order_item_id.nil?
|
||||
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,9 +8,36 @@ class Booking < ApplicationRecord
|
||||
belongs_to :sale, :optional => true
|
||||
has_many :booking_orders
|
||||
has_many :orders, :through => :booking_orders
|
||||
has_many :order_items, :through => :orders
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||
|
||||
def self.sync_booking_records(bookings)
|
||||
if !bookings.nil?
|
||||
bookings.each do |b|
|
||||
booking = TableBooking.find_by_booking_id(b['booking_id'])
|
||||
# unless TableBooking.exists?(b['booking_id'])
|
||||
if booking.nil?
|
||||
booking = TableBooking.new
|
||||
end
|
||||
booking.booking_id = b['booking_id']
|
||||
booking.dining_facility_id = b['dining_facility_id']
|
||||
# booking.type = b['type']
|
||||
booking.checkin_at = b['checkin_at']
|
||||
booking.checkin_by = b['checkin_by']
|
||||
booking.checkout_at = b['checkout_at']
|
||||
booking.checkout_by = b['checkout_by']
|
||||
booking.reserved_at = b['reserved_at']
|
||||
booking.reserved_by = b['reserved_by']
|
||||
booking.booking_status = b['booking_status']
|
||||
booking.sale_id = b['sale_id']
|
||||
booking.customer_id = b['customer_id']
|
||||
booking.save
|
||||
end
|
||||
puts '....... Booking sync completed ......'
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_dining_facility(booking_arr, newd, old)
|
||||
table = DiningFacility.find(newd)
|
||||
exist = table.get_booking
|
||||
@@ -60,8 +87,44 @@ class Booking < ApplicationRecord
|
||||
.order("sale_id DESC")
|
||||
end
|
||||
|
||||
def self.get_sync_data(sale_id)
|
||||
@orders = Order.select('orders.*')
|
||||
.joins('left join sale_orders on sale_orders.order_id = orders.order_id')
|
||||
.where('sale_orders.sale_id=?', sale_id)
|
||||
|
||||
@order_items = OrderItem.select('order_items.*')
|
||||
.joins('left join sale_orders on sale_orders.order_id = order_items.order_id')
|
||||
.where('sale_orders.sale_id=?', sale_id)
|
||||
|
||||
@assigned_order_items = AssignedOrderItem.select('assigned_order_items.*')
|
||||
.joins('left join sale_orders on sale_orders.order_id=assigned_order_items.order_id')
|
||||
.where('sale_orders.sale_id=?', sale_id)
|
||||
|
||||
@bookings = TableBooking.where('sale_id=?', sale_id)
|
||||
|
||||
@sales = Sale.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_items = SaleItem.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_taxes = SaleTax.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_orders = SaleOrder.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_audits = SaleAudit.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_payments = SalePayment.where("sale_id=?", sale_id)
|
||||
|
||||
@shift_sales = ShiftSale.select('shift_sales.*')
|
||||
.joins('left join sales on sales.shift_sale_id = shift_sales.id')
|
||||
.where('sales.sale_id=?', sale_id)
|
||||
|
||||
return @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.booking_id.nil?
|
||||
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,6 @@ class Commission < ApplicationRecord
|
||||
scope :active, -> {where(is_active: true)}
|
||||
private
|
||||
def generate_custom_id
|
||||
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
|
||||
self.commission_id = SeedGenerator.generate_id(self.class.name, "COM")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Commissioner < ApplicationRecord
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_id'
|
||||
has_many :in_juties
|
||||
has_many :in_duties
|
||||
has_many :product_commissions
|
||||
scope :active, -> { where(is_active: true) }
|
||||
|
||||
|
||||
@@ -325,16 +325,16 @@ class Customer < ApplicationRecord
|
||||
:timeout => 10
|
||||
)
|
||||
rescue HTTParty::Error
|
||||
response = {status: false, message: "Server Error"}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false , message: "Server Time out"}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
end
|
||||
Rails.logger.debug "--------Search Paypar Account No response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
@@ -34,7 +34,6 @@ class DiningCharge < ApplicationRecord
|
||||
charge_block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.strftime('%H:%M'))
|
||||
|
||||
result = dining_minutes / charge_block
|
||||
|
||||
rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M'))
|
||||
if result.to_i < 1
|
||||
# for dining minute is under charge_block
|
||||
|
||||
@@ -32,7 +32,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||
# booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
@@ -42,7 +43,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_moved_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
@@ -68,7 +70,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def get_current_checkout_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
@@ -115,7 +118,8 @@ class DiningFacility < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_checkin_booking
|
||||
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||
arr_booking = Array.new
|
||||
if bookings
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
|
||||
5
app/models/induties.rb
Normal file
5
app/models/induties.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Induties
|
||||
def self.table_name_prefix
|
||||
'induties_'
|
||||
end
|
||||
end
|
||||
2
app/models/induties/assign_in_duty.rb
Normal file
2
app/models/induties/assign_in_duty.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Induties::AssignInDuty < ApplicationRecord
|
||||
end
|
||||
@@ -3,6 +3,9 @@ class InventoryDefinition < ApplicationRecord
|
||||
scope :active, -> {where(:is_active => true)}
|
||||
|
||||
def self.calculate_product_count(saleObj=nil,saleobj_after_req_bill=nil)
|
||||
# check_sj = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
logger.debug 'saleObj<<<<<<<<<<<<<<<<<<<<<<<<<<<'
|
||||
logger.debug saleObj.sale_items.to_json
|
||||
if !saleObj.nil?
|
||||
saleObj.sale_items.each do |item|
|
||||
found, inventory_definition = find_product_in_inventory(item)
|
||||
@@ -21,45 +24,48 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.find_product_in_inventory(item)
|
||||
product = InventoryDefinition.find_by_item_code(item.item_instance_code)
|
||||
if product.nil?
|
||||
return false, nil
|
||||
else
|
||||
stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
|
||||
if stock_check_item.nil?
|
||||
return false, nil
|
||||
else
|
||||
if product = InventoryDefinition.find_by_item_code(item.item_instance_code)
|
||||
if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
|
||||
return true, product
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_balance(item, inventory_definition) # item => saleItemOBj
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order('created_at desc').take
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
modify_balance(item, stock, inventory_definition)
|
||||
else
|
||||
StockJournal.add_to_journal(item, 0, "out of stock", inventory_definition)
|
||||
puts "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OUT OF STOCK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
|
||||
StockJournal.add_to_journal(item.item_instance_code, item.qty, 0, "out of stock", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
end
|
||||
end
|
||||
|
||||
def self.modify_balance(item, stock, inventory_definition) #saleitemObj
|
||||
if stock.balance.to_i >= item.qty
|
||||
check_item = StockCheckItem.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
if item.qty.to_i >= 0
|
||||
qty = item.qty - item.qty_was
|
||||
if !item.id_was.nil?
|
||||
remark = "edit"
|
||||
elsif stock.balance.to_i >= qty
|
||||
puts ">> stock is greater than order qty"
|
||||
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
|
||||
remark = "ok"
|
||||
else
|
||||
puts " << stock is less than order qty"
|
||||
data = item
|
||||
extra_qty = item.qty.to_i - stock.balance.to_i
|
||||
if stock.balance.to_i > 0
|
||||
item.qty = stock.balance.to_i
|
||||
StockJournal.add_to_journal(item, stock.balance, "ok", inventory_definition)
|
||||
data.qty = extra_qty
|
||||
StockJournal.add_to_journal(data, 0, "out of stock", inventory_definition)
|
||||
else
|
||||
StockJournal.add_to_journal(item, stock.balance, "out of stock", inventory_definition)
|
||||
remark = "out of stock"
|
||||
end
|
||||
else # item.qty < 0
|
||||
qty = item.qty
|
||||
remark = "void"
|
||||
end
|
||||
if item.is_a? OrderItem
|
||||
trans_type = StockJournal::ORDER_TRANS
|
||||
elsif item.is_a? SaleItem
|
||||
trans_type = StockJournal::SALES_TRANS
|
||||
end
|
||||
StockJournal.add_to_journal(item.item_instance_code, qty, stock.balance, remark, inventory_definition, item.id, trans_type)
|
||||
check_item.different = check_item.different - qty
|
||||
check_item.save
|
||||
end
|
||||
|
||||
def self.search_by_category(cat_id)
|
||||
@@ -76,13 +82,20 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_category(filter)
|
||||
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
|
||||
THEN (SELECT balance FROM stock_journals
|
||||
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
|
||||
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
|
||||
# THEN (SELECT min(balance) FROM stock_journals
|
||||
# least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
|
||||
# THEN (SELECT balance FROM stock_journals
|
||||
# WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
|
||||
# ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
|
||||
# FROM stock_journals
|
||||
# WHERE stock_journals.item_code = inventory_definitions.item_code
|
||||
# ORDER BY stock_journals.created_at DESC LIMIT 1"
|
||||
least_stock = "(SELECT
|
||||
(SELECT balance FROM stock_journals WHERE item_code = inventory_definitions.item_code
|
||||
ORDER BY id DESC LIMIT 1)
|
||||
FROM stock_journals
|
||||
WHERE stock_journals.item_code = inventory_definitions.item_code
|
||||
ORDER BY stock_journals.created_at DESC LIMIT 1"
|
||||
ORDER BY stock_journals.created_at DESC LIMIT 1)"
|
||||
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
||||
@@ -102,7 +115,7 @@ class InventoryDefinition < ApplicationRecord
|
||||
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%",
|
||||
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
|
||||
.group("mi.menu_category_id,inventory_definitions.item_code")
|
||||
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
|
||||
.order("balance asc, mi.name asc,acc.title desc,mi.menu_category_id desc")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
138
app/models/kbz_pay.rb
Normal file
138
app/models/kbz_pay.rb
Normal file
@@ -0,0 +1,138 @@
|
||||
class KbzPay
|
||||
|
||||
KBZ_PAY = 'KBZPay'
|
||||
|
||||
def self.pay(amount, receipt_no, url, key, app_id, code)
|
||||
shop = Shop.first
|
||||
prefix = shop.shop_code
|
||||
receipt_no = "#{prefix}#{receipt_no}"
|
||||
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
kbz_provider_url = "#{url}/precreate"
|
||||
|
||||
kbz_method = 'kbz.payment.precreate'
|
||||
kbz_trade_type = "PAY_BY_QRCODE"
|
||||
kbz_version = "1.0"
|
||||
kbz_currency = "MMK"
|
||||
kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback"
|
||||
|
||||
nounce_str = SecureRandom.base64(32).first(32).upcase
|
||||
|
||||
params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"¬ify_url="+ kbz_callback_url + "&timeout_express=20m×tamp="+datetime+"&total_amount="+amount.to_s+"&trade_type="+kbz_trade_type+"&trans_currency="+ kbz_currency+"&version="+kbz_version+"&key="+kbz_api_key
|
||||
|
||||
Rails.logger.info params
|
||||
sign = Digest::SHA256.hexdigest(params)
|
||||
str = {
|
||||
"timestamp": datetime,
|
||||
"method": kbz_method,
|
||||
"notify_url": kbz_callback_url,
|
||||
"nonce_str": nounce_str.to_s,
|
||||
"sign_type": "SHA256",
|
||||
"sign": sign,
|
||||
"version": kbz_version,
|
||||
"biz_content": {
|
||||
"merch_order_id": receipt_no,
|
||||
"merch_code": kbz_merch_code,
|
||||
"appid": kbz_app_id,
|
||||
"trade_type": kbz_trade_type,
|
||||
"total_amount": amount.to_s,
|
||||
"timeout_express": "20m",
|
||||
"trans_currency": kbz_currency
|
||||
}
|
||||
}
|
||||
|
||||
result = HTTParty.post(kbz_provider_url,
|
||||
:body => { :Request => str}.to_json,
|
||||
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
|
||||
)
|
||||
Rails.logger.info result
|
||||
Rails.logger.info '===================================='
|
||||
if result['Response']['result'] == "SUCCESS"
|
||||
#TODO QR return
|
||||
qr = result['Response']['qrCode']
|
||||
return true, qr
|
||||
else
|
||||
# Rails.logger.debug result['Response']
|
||||
return false, result['Response']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.query(receipt_no, current_user, url, key, app_id, code)
|
||||
shop = Shop.first
|
||||
prefix = shop.shop_code
|
||||
receipt_no = "#{prefix}#{receipt_no}"
|
||||
amount = 0
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
kbz_provider_url = "#{url}/queryorder"
|
||||
|
||||
kbz_method = 'kbz.payment.queryorder'
|
||||
kbz_trade_type = "PAY_BY_QRCODE"
|
||||
kbz_version = "1.0"
|
||||
kbz_currency = "MMK"
|
||||
kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback"
|
||||
|
||||
nounce_str = SecureRandom.base64(32).first(32).upcase
|
||||
|
||||
params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"×tamp="+datetime+"&version="+kbz_version+"&key="+kbz_api_key
|
||||
|
||||
Rails.logger.info params
|
||||
sign = Digest::SHA256.hexdigest(params)
|
||||
str = {"timestamp": datetime,
|
||||
"method": kbz_method,
|
||||
"nonce_str": nounce_str.to_s,
|
||||
"sign_type": "SHA256",
|
||||
"sign": sign,
|
||||
"version": kbz_version,
|
||||
"biz_content": {
|
||||
"merch_order_id": receipt_no,
|
||||
"merch_code": kbz_merch_code,
|
||||
"appid": kbz_app_id
|
||||
}
|
||||
}
|
||||
|
||||
result = HTTParty.post(kbz_provider_url,
|
||||
:body => { :Request => str}.to_json,
|
||||
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
|
||||
)
|
||||
Rails.logger.info result
|
||||
Rails.logger.info "........................."
|
||||
if result['Response']['result'] == "SUCCESS"
|
||||
if result['Response']['trade_status'] == "PAY_SUCCESS"
|
||||
merch_order_id = result['Response']['merch_order_id']
|
||||
cash = result['Response']['total_amount']
|
||||
|
||||
merch_order_id.slice! "#{prefix}"
|
||||
|
||||
sp = SalePayment.find(merch_order_id)
|
||||
if !sp.nil?
|
||||
if sp.payment_status == 'pending'
|
||||
saleObj = Sale.find(sp.sale_id)
|
||||
if sp.process_payment(saleObj, current_user, cash, KbzPay::KBZ_PAY)
|
||||
amount = cash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# return true, "successfully paid by KBZ PAY"
|
||||
elsif result['Response']['trade_status'] == "PAY_FAILED"
|
||||
|
||||
# return false, "pay failed by KBZ PAY"
|
||||
elsif result['Response']['trade_status'] == "WAIT_PAY"
|
||||
# return false , "Waiting to pay by KBZ PAY"
|
||||
end
|
||||
else
|
||||
#FAIL result
|
||||
# return false, "pay by KBZ PAY has failed"
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
end
|
||||
@@ -21,8 +21,78 @@ class Lookup < ApplicationRecord
|
||||
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
|
||||
# end
|
||||
|
||||
def self.get_checkin_time_limit
|
||||
time_limit = 5
|
||||
|
||||
lookup = Lookup.find_by_lookup_type('checkin_time_limit')
|
||||
if !lookup.nil?
|
||||
time_limit = lookup.value.to_i
|
||||
end
|
||||
|
||||
return time_limit
|
||||
end
|
||||
|
||||
def self.sync_url
|
||||
url = ""
|
||||
|
||||
lookup = Lookup.find_by_lookup_type('sync_data')
|
||||
if !lookup.nil?
|
||||
url = lookup.value
|
||||
end
|
||||
|
||||
return url
|
||||
end
|
||||
|
||||
def self.get_sync_token
|
||||
token = ""
|
||||
|
||||
lookup = Lookup.find_by_lookup_type('sync_token')
|
||||
if !lookup.nil?
|
||||
token = lookup.value
|
||||
end
|
||||
|
||||
return token
|
||||
end
|
||||
|
||||
def self.collection_of(type)
|
||||
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
|
||||
|
||||
end
|
||||
|
||||
def self.create_shift_sale_lookup
|
||||
@lookup = Lookup.new
|
||||
@lookup.lookup_type = 'shift_sale_items'
|
||||
@lookup.name = 'Shift Sale Items'
|
||||
@lookup.value = 0
|
||||
@lookup.save
|
||||
|
||||
return @lookup
|
||||
end
|
||||
|
||||
def self.create_reprint_receipt_lookup
|
||||
@lookup = Lookup.new
|
||||
@lookup.lookup_type = 'reprint_receipt'
|
||||
@lookup.name = 'Reprint Receipt in Report'
|
||||
@lookup.value = 0
|
||||
@lookup.save
|
||||
|
||||
return @lookup
|
||||
end
|
||||
|
||||
def self.save_shift_sale_items_settings(val)
|
||||
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_shift_sale_lookup
|
||||
end
|
||||
@lookup.value = val
|
||||
@lookup.save
|
||||
end
|
||||
|
||||
def self.shift_sale_items_lookup_value
|
||||
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
|
||||
if @lookup.nil?
|
||||
@lookup = Lookup.create_shift_sale_lookup
|
||||
end
|
||||
return @lookup.value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,8 @@ class Order < ApplicationRecord
|
||||
belongs_to :customer
|
||||
has_many :order_items, autosave: true , inverse_of: :order
|
||||
has_many :assigned_order_items
|
||||
has_one :booking_order
|
||||
has_one :booking, through: :booking_order
|
||||
|
||||
#internal references attributes for business logic control
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
|
||||
@@ -55,13 +57,12 @@ class Order < ApplicationRecord
|
||||
if self.is_extra_time
|
||||
if !booking.checkout_at.nil?
|
||||
new_time = booking.checkout_at + self.extra_time.to_i
|
||||
booking.update_attributes(checkout_at: new_time)
|
||||
booking.update(checkout_at: new_time)
|
||||
end
|
||||
end
|
||||
#end extra time
|
||||
end
|
||||
|
||||
booking.save!
|
||||
self.default_values
|
||||
|
||||
# cashier already opened?
|
||||
@@ -209,7 +210,6 @@ class Order < ApplicationRecord
|
||||
self.customer = Customer.find(1) if self.customer_id.nil?
|
||||
self.source = "emenu" if self.source.nil?
|
||||
self.order_type = "dine-in" if self.order_type.nil?
|
||||
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -550,14 +550,44 @@ class Order < ApplicationRecord
|
||||
return false
|
||||
end
|
||||
|
||||
def self.env
|
||||
return ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
if self.order_id.nil?
|
||||
self.order_id = SeedGenerator.generate_id(self.class.name, "ODR")
|
||||
end
|
||||
end
|
||||
|
||||
def set_order_date
|
||||
self.date = Time.now.utc
|
||||
end
|
||||
|
||||
def self.sync_order_records(orders)
|
||||
if !orders.nil?
|
||||
orders.each do |o|
|
||||
order = Order.find_by_order_id(o['order_id'])
|
||||
# unless Order.exists?(o['order_id'])
|
||||
if order.nil?
|
||||
order = Order.new
|
||||
end
|
||||
order.order_id = o['order_id']
|
||||
order.date = o['date']
|
||||
order.source = o['source']
|
||||
order.order_type = o['order_type']
|
||||
order.customer_id = o['customer_id']
|
||||
order.item_count = o['item_count']
|
||||
order.quantity_count = o['quantity_count']
|
||||
order.status = o['status']
|
||||
order.waiters = o['waiters']
|
||||
order.guest_info = o['guest_info']
|
||||
order.save
|
||||
end
|
||||
Rails.logger.debug '...... order sync completed .....'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,6 +13,13 @@ class OrderItem < ApplicationRecord
|
||||
# validates :qty, numericality: { :greater_than => 0 }
|
||||
validates_associated :order
|
||||
|
||||
after_save :update_stock_journal
|
||||
|
||||
# after_save :add_to_journal, if: Proc.new { !self.id_changed? }
|
||||
# after_save :update_stock_journal, if: Proc.new { self.id_changed? }
|
||||
|
||||
|
||||
|
||||
#This Method - handle how items is added into order
|
||||
# order_item : {
|
||||
# order_item_code : "",
|
||||
@@ -65,8 +72,85 @@ class OrderItem < ApplicationRecord
|
||||
return order_details
|
||||
end
|
||||
|
||||
def self.sync_order_item_records(order_items)
|
||||
if !order_items.nil?
|
||||
order_items.each do |item|
|
||||
order_item = OrderItem.find_by_order_items_id(item['order_items_id'])
|
||||
# unless OrderItem.exists?(item['order_items_id'])
|
||||
if order_item.nil?
|
||||
order_item = OrderItem.new
|
||||
end
|
||||
order_item.order_items_id = item['order_items_id']
|
||||
order_item.order_id = item['order_id']
|
||||
order_item.order_item_status = item['order_item_status']
|
||||
order_item.item_order_by = item['item_order_by']
|
||||
order_item.item_code = item['item_code']
|
||||
order_item.item_instance_code = item['item_instance_code']
|
||||
order_item.item_name = item['item_name']
|
||||
order_item.alt_name = item['alt_name']
|
||||
order_item.account_id = item['account_id']
|
||||
order_item.qty = item['qty']
|
||||
order_item.price = item['price']
|
||||
order_item.remark = item['remark']
|
||||
order_item.options = item['options']
|
||||
order_item.set_menu_items = item['set_menu_items']
|
||||
order_item.taxable = item['taxable']
|
||||
order_item.completed_by = item['completed_by']
|
||||
order_item.save
|
||||
end
|
||||
Rails.logger.debug '...... order item sync completed. .....'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.order_items_id.nil?
|
||||
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
||||
end
|
||||
end
|
||||
|
||||
def add_to_journal
|
||||
defination = InventoryDefinition.find_by_item_code(self.item_instance_code)
|
||||
stock = StockJournal.where('item_code = ?', self.item_instance_code).order("id DESC").first
|
||||
journal = StockJournal.create(
|
||||
item_code: self.item_instance_code,
|
||||
credit: 0,
|
||||
debit: self.qty,
|
||||
balance: stock.balance - self.qty,
|
||||
inventory_definition_id: defination.id,
|
||||
remark: 'ok',
|
||||
trans_ref: self.order.id,
|
||||
trans_type: StockJournal::SALES_TRANS
|
||||
)
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
if self.qty != self.qty_before_last_save
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
InventoryDefinition.check_balance(self, inventory_definition)
|
||||
end
|
||||
end
|
||||
# if self.qty > self.qty_was
|
||||
# credit = 0
|
||||
# debit = self.qty.to_i - self.qty_was.to_i
|
||||
# else
|
||||
# credit = self.qty_was.to_i - self.qty.to_i
|
||||
# debit = 0
|
||||
# end
|
||||
# if credit != debit
|
||||
# defination = InventoryDefinition.find_by_item_code(self.item_instance_code)
|
||||
# stock = StockJournal.where('item_code = ?', self.item_instance_code).order("id DESC").first
|
||||
# journal = StockJournal.create(
|
||||
# item_code: self.item_instance_code,
|
||||
# credit: credit,
|
||||
# debit: debit,
|
||||
# balance: stock.balance - debit + credit,
|
||||
# inventory_definition_id: defination.id,
|
||||
# remark: 'ok',
|
||||
# trans_ref: self.order.id,
|
||||
# trans_type: StockJournal::SALES_TRANS
|
||||
# )
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -256,6 +256,8 @@ class OrderQueueStation < ApplicationRecord
|
||||
printer.each do |printer_setting|
|
||||
if printer_setting.unique_code == 'OrderItemPdf'
|
||||
unique_code="OrderItemPdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemStarPdf'
|
||||
unique_code="OrderItemStarPdf"
|
||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
||||
|
||||
@@ -75,7 +75,7 @@ class OrderReservation < ApplicationRecord
|
||||
order_reservation.discount_amount = order_reserve[:payment_info][:discount_amount]
|
||||
order_reservation.convenience_charge = order_reserve[:payment_info][:convenience_charge]
|
||||
order_reservation.grand_total = order_reserve[:payment_info][:grand_total]
|
||||
order_reservation.transaction_fee = order_reserve[:payment_info][:transaction_fee]
|
||||
# order_reservation.transaction_fee = order_reserve[:payment_info][:transaction_fee]
|
||||
order_reservation.order_remark = order_reserve[:order_info][:order_remark]
|
||||
end
|
||||
if order_reserve[:reservation_info]
|
||||
@@ -203,7 +203,7 @@ class OrderReservation < ApplicationRecord
|
||||
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,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation)
|
||||
#receipt bill pdf setting
|
||||
|
||||
result = {:status=> true,
|
||||
|
||||
6
app/models/payment.rb
Normal file
6
app/models/payment.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Payment
|
||||
|
||||
# def self.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, pay_from, sale_payment_id)
|
||||
|
||||
# end
|
||||
end
|
||||
@@ -5,7 +5,12 @@ class PrintSetting < ApplicationRecord
|
||||
def self.get_precision_delimiter
|
||||
setting = PrintSetting.find_by_unique_code("CloseCashierPdf")
|
||||
if setting.nil?
|
||||
star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf")
|
||||
if star_setting.nil?
|
||||
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
|
||||
else
|
||||
return star_setting
|
||||
end
|
||||
end
|
||||
return setting
|
||||
end
|
||||
|
||||
@@ -38,7 +38,20 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
# self.print(filename, cashier_terminal.printer_name)
|
||||
# end
|
||||
|
||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
|
||||
if !sale_items.blank? or !sale_items.nil?
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
end
|
||||
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
@@ -46,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
cashier = shift_sale.employee.name
|
||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
@@ -55,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
if close_cashier[1] == '1'
|
||||
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
else
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,5 +80,25 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
end
|
||||
end
|
||||
|
||||
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
filename = "tmp/reports_sale_items.pdf"
|
||||
|
||||
if print_settings.unique_code == "SaleItemsPdf"
|
||||
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
puts 'Printing!!!!'
|
||||
end
|
||||
if print_settings.unique_code == "SaleItemsStarPdf"
|
||||
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
|
||||
puts 'PrintingStar!!!!'
|
||||
end
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, print_settings.printer_name)
|
||||
end
|
||||
end
|
||||
#sqa
|
||||
end
|
||||
|
||||
@@ -11,16 +11,18 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
options = order_item[0].options
|
||||
# filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
# pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
print_setting = PrintSetting.all
|
||||
|
||||
# check for item not to show
|
||||
|
||||
pdf = ''
|
||||
# if order_item[0].price != 0
|
||||
if !print_setting.empty?
|
||||
print_setting.each do |print_settings|
|
||||
if print_settings.unique_code == 'OrderItemPdf'
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||
@@ -100,6 +102,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
print_setting.each do |print_settings|
|
||||
if print_settings.unique_code == 'OrderItemPdf'
|
||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||
@@ -207,6 +211,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
print_setting.each do |print_settings|
|
||||
if print_settings.unique_code == 'OrderItemPdf'
|
||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
||||
pdf = OrderItemStarPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
||||
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
||||
|
||||
0
app/models/printer/printing_data.rb
Normal file
0
app/models/printer/printing_data.rb
Normal file
0
app/models/printer/printservice.rb
Normal file
0
app/models/printer/printservice.rb
Normal file
@@ -188,21 +188,32 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
if !printer_settings.nil?
|
||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
settings = PrintSetting.all
|
||||
if !settings.nil?
|
||||
settings.each do |setting|
|
||||
if setting.unique_code == 'ReceiptBillPdf'
|
||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
||||
pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
||||
if receipt_bilA5[1] == '1'
|
||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
else
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
# else
|
||||
# pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#new_promotion
|
||||
class Promotion < ApplicationRecord
|
||||
validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_type,:original_product,:min_qty
|
||||
|
||||
@@ -11,6 +12,7 @@ class Promotion < ApplicationRecord
|
||||
PROMO_TYPE4 = "Percentage"
|
||||
|
||||
def self.promo_activate(saleObj)
|
||||
array_same =[]
|
||||
current_day = Time.now.strftime("%Y-%m-%d")
|
||||
current_time = Time.now.strftime('%H:%M:%S')
|
||||
day = Date.today.wday
|
||||
@@ -18,10 +20,29 @@ class Promotion < ApplicationRecord
|
||||
puts "promoList - " + promoList.size.to_s
|
||||
if promoList.size > 0
|
||||
itemList = combine_item(saleObj)
|
||||
puts itemList.to_json
|
||||
is_promo_day(promoList,day, itemList, saleObj.sale_id)
|
||||
itemList.each do|list|
|
||||
list.each do |l|
|
||||
array_same.push({
|
||||
item_instance_code: l.item_instance_code,
|
||||
order_id:l.order_id,
|
||||
qty:l.qty
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
item_list =[]
|
||||
array_same.group_by do |same|
|
||||
same.values_at :item_instance_code
|
||||
end.map do |(item_instance_code), array_same|
|
||||
quantities = array_same.map { |p| p[:qty] }
|
||||
qty = quantities.all? ? quantities.reduce(:+) : nil
|
||||
item_list.push({ item_instance_code: item_instance_code, qty: qty })
|
||||
end
|
||||
Rails.logger.debug "-------promo_activate array_same-------"
|
||||
puts item_list.to_json
|
||||
is_promo_day(promoList,day, item_list, saleObj.sale_id)
|
||||
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
@@ -31,9 +52,11 @@ class Promotion < ApplicationRecord
|
||||
def self.combine_item(saleObj)
|
||||
# order_id = saleObj.sale_orders[0][0].order_id
|
||||
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
|
||||
# array_same =[]
|
||||
itemList = []
|
||||
saleObj.sale_orders.each do |so|
|
||||
itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)
|
||||
# itemList << OrderItem.where("order_id = ?",so.order_id).group(["item_instance_code", "order_id"]).sum(:qty)
|
||||
itemList << OrderItem.where("order_id = ?",so.order_id).select(:item_instance_code,:order_id,:qty)
|
||||
end
|
||||
|
||||
return itemList
|
||||
@@ -52,21 +75,21 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.find_promo_item(promo, orderitem, sale_id)
|
||||
# item_code = OrderItem.find_by_item_instance_code(orderitem[0][0]).item_code
|
||||
orderitem.each do |odr_item|
|
||||
if promo.original_product.downcase.to_s == odr_item[0][0]
|
||||
if promo.min_qty.to_i > odr_item[1].to_i
|
||||
item_code = OrderItem.find_by_item_instance_code(orderitem[:item_instance_code]).item_code
|
||||
# orderitem.each do |odr_item|
|
||||
if promo.original_product.downcase.to_s == orderitem[:item_instance_code]
|
||||
if promo.min_qty.to_i > orderitem[:qty].to_i
|
||||
return false
|
||||
else
|
||||
check_promo_type(promo,odr_item, sale_id)
|
||||
end
|
||||
check_promo_type(promo,orderitem, sale_id)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
def self.check_promo_type(promo, orderitem, sale_id)
|
||||
promo.promotion_products.each do |promo_product|
|
||||
if promo_product.item_code.downcase == orderitem[0][0]
|
||||
if promo_product.item_code.downcase == orderitem[:item_instance_code]
|
||||
same = true
|
||||
else
|
||||
# return false, promo_product
|
||||
@@ -75,9 +98,9 @@ class Promotion < ApplicationRecord
|
||||
# same, promo_product = check_giveaway_product(promo, orderitem[0][0])
|
||||
if promo.promo_type == Promotion::PROMO_TYPE1
|
||||
if same
|
||||
give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code)
|
||||
give_promotion_same_product(orderitem[:qty], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code)
|
||||
else
|
||||
give_promotion_second_product(orderitem[1], promo.min_qty, promo_product.item_code, orderitem, sale_id)
|
||||
give_promotion_second_product(orderitem[:qty], promo.min_qty, promo_product.item_code, orderitem, sale_id)
|
||||
end
|
||||
|
||||
elsif promo.promo_type == Promotion::PROMO_TYPE2
|
||||
@@ -106,6 +129,7 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id,promo_product)
|
||||
item =''
|
||||
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
|
||||
multiple = qty.to_i / promoqty.to_i # loop count
|
||||
charge_qty = 0
|
||||
@@ -132,20 +156,45 @@ class Promotion < ApplicationRecord
|
||||
else
|
||||
charge_qty += qty
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
if promo_product.downcase != item.item_instance_code
|
||||
# item = item
|
||||
# else
|
||||
# item = OrderItem.find_by_item_code(promo_product)
|
||||
item = OrderItem.where("item_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
price =0
|
||||
source =''
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if promo_product.downcase != item[:item_instance_code]
|
||||
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_code = ?",promo_product).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
end
|
||||
if !item.nil?
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion", item.price,source)
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion", item[:price],source)
|
||||
end
|
||||
end
|
||||
# AA - 10 # 3 # BB # orderList, #S34345
|
||||
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
|
||||
source =''
|
||||
item =''
|
||||
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
|
||||
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
|
||||
foc_qty = find_second_item_qty(sale_id, promo_product)
|
||||
@@ -153,27 +202,42 @@ class Promotion < ApplicationRecord
|
||||
promotion_qty = foc_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product)
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
price =0
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product}' and order_id = '#{orderitem[0][1]}'").first
|
||||
if !item.nil?
|
||||
source = Order.find(item.order_id).source
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price,source)
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(promotion_qty, item, sale_id, "promotion", item[:price],source)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.update_existing_item(qty, item, sale_id, type, item_price,source)
|
||||
menu_category = MenuCategory.get_menu_category(item.item_code) #get menu category for menu items
|
||||
if qty >0
|
||||
menu_category = MenuCategory.get_menu_category(item[:item_code]) #get menu category for menu items
|
||||
|
||||
sale_item = SaleItem.new
|
||||
if !menu_category.nil?
|
||||
sale_item.menu_category_code = menu_category.code
|
||||
sale_item.menu_category_name = menu_category.name
|
||||
end
|
||||
sale_item.product_code = item.item_code
|
||||
sale_item.item_instance_code = item.item_instance_code
|
||||
sale_item.product_name = item.item_name + "(promotion)"
|
||||
sale_item.product_alt_name = item.alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.product_code = item[:item_code]
|
||||
sale_item.item_instance_code = item[:item_instance_code]
|
||||
sale_item.product_name = item[:item_name] + "(promotion)"
|
||||
sale_item.product_alt_name = item[:alt_name]
|
||||
sale_item.account_id = item[:account_id]
|
||||
sale_item.remark = type
|
||||
sale_item.status = "promotion"
|
||||
sale_item.qty = qty * (-1)
|
||||
@@ -188,26 +252,56 @@ class Promotion < ApplicationRecord
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,nil,source)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.give_promotion_nett_off(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
item =''
|
||||
source =''
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
|
||||
price =0
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
if !item.nil?
|
||||
source = Order.find(item.order_id).source
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
|
||||
else
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if !item.nil?
|
||||
source = Order.find(item.order_id).source
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off,source)
|
||||
end
|
||||
|
||||
@@ -216,28 +310,56 @@ class Promotion < ApplicationRecord
|
||||
|
||||
def self.give_promotion_nett_price(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
source =''
|
||||
item =''
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0]) # need to specify with menu item instance
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
if !item.nil?
|
||||
price = item.price.to_i - promo_product.net_price.to_i
|
||||
source = Order.find(item.order_id).source
|
||||
price = item[:price].to_i - promo_product.net_price.to_i
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
end
|
||||
|
||||
else
|
||||
order_qty = find_second_item_qty(sale_id, promo_product.item_code)# need to check for qty
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
|
||||
if foc_qty > order_qty
|
||||
foc_qty = order_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
|
||||
if !item.nil?
|
||||
price = item.price - promo_product.net_price
|
||||
source = Order.find(item.order_id).source
|
||||
price = item[:price].to_i - promo_product.net_price.to_i
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price,source)
|
||||
end
|
||||
|
||||
@@ -246,47 +368,90 @@ class Promotion < ApplicationRecord
|
||||
|
||||
def self.give_promotion_discount(same, promo_product, foc_min_qty, orderitem, sale_id)
|
||||
puts " same: " + same.to_s + " promo_product: " + promo_product.item_code.to_s + " foc_min_qty: " + foc_min_qty.to_s + " orderitem: " + orderitem.to_s
|
||||
sale_order =SaleOrder.where("sale_id=?",sale_id)
|
||||
source =''
|
||||
item =''
|
||||
if same
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# item = OrderItem.find_by_item_instance_code(orderitem[0][0])
|
||||
item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# item = OrderItem.where("item_instance_code = '#{orderitem[0][0]}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",orderitem[:item_instance_code]).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# total = orderitem[1].to_i * item.price
|
||||
if !item.nil?
|
||||
total = item.price
|
||||
total = item[:price]
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
source = Order.find(item.order_id).source
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||
end
|
||||
|
||||
else
|
||||
order_qty = find_second_item_qty(sale_id, promo_product.item_code) #need to check
|
||||
foc_qty = orderitem[1].to_i / foc_min_qty
|
||||
foc_qty = orderitem[:qty].to_i / foc_min_qty
|
||||
# give total qty is 1
|
||||
#foc_qty = (foc_qty - foc_qty) + 1
|
||||
if foc_qty > order_qty
|
||||
foc_qty = order_qty
|
||||
end
|
||||
# item = OrderItem.find_by_item_instance_code(promo_product.item_code)
|
||||
item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
# item = OrderItem.where("item_instance_code = '#{promo_product.item_code}' and order_id = '#{orderitem[0][1]}'").first
|
||||
sale_order.each do|order|
|
||||
source = Order.find(order.order_id).source
|
||||
end
|
||||
item = OrderItem.where("item_instance_code = ?",promo_product.item_code).order("order_items_id DESC").first
|
||||
item ={
|
||||
item_code:item.item_code,
|
||||
item_instance_code:item.item_instance_code,
|
||||
item_name:item.item_name,
|
||||
alt_name:item.alt_name,
|
||||
account_id:item.account_id,
|
||||
price:item.price
|
||||
}
|
||||
# total = item.price * foc_qty
|
||||
if !item.nil?
|
||||
total = item.price
|
||||
total = item[:price]
|
||||
price = calculate_discount(total, promo_product.percentage)
|
||||
source = Order.find(item.order_id).source
|
||||
# source = Order.find(item.order_id).source
|
||||
update_existing_item(foc_qty, item, sale_id, "promotion discount", price,source)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_second_item_qty(sale_id, promo_item)
|
||||
array_same =[]
|
||||
saleObj = Sale.find_by_sale_id(sale_id)
|
||||
itemList = combine_item(saleObj)
|
||||
itemList.each do |item|
|
||||
item.each do |i|
|
||||
if i[0][0] == promo_item.downcase
|
||||
return i[1]
|
||||
itemList.each do|list|
|
||||
list.each do |l|
|
||||
array_same.push({
|
||||
item_instance_code: l.item_instance_code,
|
||||
order_id:l.order_id,
|
||||
qty:l.qty
|
||||
})
|
||||
end
|
||||
end
|
||||
item_list =[]
|
||||
array_same.group_by do |same|
|
||||
same.values_at :item_instance_code
|
||||
end.map do |(item_instance_code), array_same|
|
||||
quantities = array_same.map { |p| p[:qty] }
|
||||
qty = quantities.all? ? quantities.reduce(:+) : nil
|
||||
item_list.push({ item_instance_code: item_instance_code, qty: qty })
|
||||
end
|
||||
item_list.each do |item|
|
||||
if item[:item_instance_code] == promo_item.downcase
|
||||
return item[:qty].to_i
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -13,9 +13,12 @@ class Sale < ApplicationRecord
|
||||
has_many :sale_taxes
|
||||
has_many :sale_payments
|
||||
has_many :sale_orders
|
||||
has_many :orders, through: :sale_orders
|
||||
has_many :bookings
|
||||
has_many :product_commissions
|
||||
|
||||
after_update :update_stock_journal
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
|
||||
@@ -26,26 +29,64 @@ class Sale < ApplicationRecord
|
||||
}
|
||||
SALE_STATUS_OUTSTANDING = "outstanding"
|
||||
SALE_STATUS_COMPLETED = "completed"
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil)
|
||||
booking = Booking.find(booking_id)
|
||||
status = false
|
||||
def self.sync_sale_records(sales)
|
||||
if !sales.nil?
|
||||
sales.each do |s|
|
||||
sale = Sale.find_by_sale_id(s['sale_id'])
|
||||
# unless Sale.exists?(s['sale_id'])
|
||||
if sale.nil?
|
||||
sale = Sale.new
|
||||
end
|
||||
sale.sale_id = s['sale_id']
|
||||
sale.cashier_id = s['cashier_id']
|
||||
sale.cashier_name = s['cashier_name']
|
||||
sale.requested_by = s['requested_by']
|
||||
sale.requested_at = s['requested_at']
|
||||
sale.receipt_no = s['receipt_no']
|
||||
sale.receipt_date = s['receipt_date']
|
||||
sale.customer_id = s['customer_id']
|
||||
sale.payment_status = s['payment_status']
|
||||
sale.sale_status = s['sale_status']
|
||||
sale.total_amount = s['total_amount']
|
||||
sale.discount_type = s['discount_type']
|
||||
sale.total_tax = s['total_tax']
|
||||
sale.total_discount = s['total_discount']
|
||||
sale.tax_type = s['tax_type']
|
||||
sale.grand_total = s['grand_total']
|
||||
sale.rounding_adjustment = s['rounding_adjustment']
|
||||
sale.amount_received = s['amount_received']
|
||||
sale.amount_changed = s['amount_changed']
|
||||
sale.shift_sale_id = s['shift_sale_id']
|
||||
sale.old_grand_total = s['old_grand_total']
|
||||
sale.rebate_status = s['rebate_status']
|
||||
sale.equal_persons = s['equal_persons']
|
||||
sale.save
|
||||
end
|
||||
Rails.logger.debug '........ Sale data sync completed .......'
|
||||
end
|
||||
end
|
||||
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
||||
if booking
|
||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
||||
if (booking)
|
||||
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
||||
#get all order attached to this booking and combine into 1 invoice
|
||||
|
||||
unless sale = booking.sale
|
||||
sale = booking.build_sale(
|
||||
{
|
||||
tax_type: "execulive" # Default Tax - Values
|
||||
}
|
||||
)
|
||||
end
|
||||
booking.booking_orders.each do |order|
|
||||
if booking.sale_id
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier, order_source)
|
||||
else
|
||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier, order_source)
|
||||
end
|
||||
booking.sale_id = sale_id
|
||||
sale.generate_invoice_from_order(order.order_id, booking, requested_by, cashier, order_source)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
# order = booking.booking_orders.take.order
|
||||
# link_order_sale(order.order_id)
|
||||
end
|
||||
# InventoryJob.perform_now(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
|
||||
order = booking.booking_orders.take.order
|
||||
link_order_sale(order.id)
|
||||
|
||||
# dining charges
|
||||
charges = DiningCharge.where('dining_facility_id=?', booking.dining_facility_id).take
|
||||
@@ -56,38 +97,39 @@ class Sale < ApplicationRecord
|
||||
else
|
||||
dining_time = booking.checkin_at.strftime('%B %d, %H:%M %p').to_s + " - " + booking.checkout_at.strftime('%B %d, %H:%M %p').to_s
|
||||
end
|
||||
create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
||||
later_time = booking.checkout_at
|
||||
early_time = booking.checkin_at
|
||||
distance_in_minutes = ((later_time - early_time)/60.0).round
|
||||
basic_pay_amount = 0
|
||||
name = ""
|
||||
if current_checkin_induties_count != "0"
|
||||
basic_pay = Commission.where('commission_type=?','Basic Pay')
|
||||
basic_pay.each do |pay|
|
||||
basic_pay_amount = pay.amount
|
||||
name = pay.name
|
||||
end
|
||||
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
||||
sale.create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
||||
end
|
||||
sale.create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
||||
end
|
||||
|
||||
return status, sale_id
|
||||
return sale
|
||||
end
|
||||
end
|
||||
|
||||
def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil, order_source = nil)
|
||||
def generate_invoice_from_order(order_id, booking, requested_by, cashier = nil, order_source = nil)
|
||||
taxable = true
|
||||
#if sale_id is exsit and validate
|
||||
#add order to that invoice
|
||||
if (sale_id)
|
||||
self.find(sale_id)
|
||||
end
|
||||
Rails.logger.debug "Does it have Existing Sale -> [#{self.id.to_s}] - Status [#{self.sale_status}]"
|
||||
|
||||
if self.sale_status == "void"
|
||||
return false, "Invoice is void. Cannot be edited"
|
||||
else
|
||||
#if this is new sale generate_receipt_no
|
||||
# generate_receipt_no
|
||||
order = Order.find(order_id)
|
||||
|
||||
#Default Tax - Values
|
||||
self.tax_type = "exclusive"
|
||||
# current cashier login
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
# shift with terminal zone
|
||||
|
||||
# set cashier
|
||||
if order_source.downcase == "emenu"
|
||||
if order_source.present? && order_source.downcase == "emenu"
|
||||
if !booking.dining_facility_id.nil?
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
@@ -141,29 +183,25 @@ class Sale < ApplicationRecord
|
||||
Rails.logger.debug "Order -> #{order.id} | Items Count -> #{order.order_items.count}"
|
||||
|
||||
order.order_items.each do |item|
|
||||
add_item(item)
|
||||
self.add_item(item)
|
||||
if !item.set_menu_items.nil?
|
||||
add_sub_item(item.set_menu_items)
|
||||
self.add_sub_item(item.set_menu_items)
|
||||
end
|
||||
end
|
||||
|
||||
link_order_sale(order.id)
|
||||
|
||||
self.orders << order
|
||||
end
|
||||
self.save!
|
||||
|
||||
#compute sales summary
|
||||
if order_source.nil?
|
||||
order_source = order.source
|
||||
end
|
||||
compute(order_source)
|
||||
self.compute(order_source)
|
||||
|
||||
#Update the order items that is billed
|
||||
order.update_items_status_to_billed(nil)
|
||||
order.status = "billed"
|
||||
order.save
|
||||
|
||||
booking.sale_id = self.id
|
||||
if !booking.checkout_at.nil?
|
||||
if booking.checkout_at.utc < Time.now.utc
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
@@ -176,35 +214,25 @@ class Sale < ApplicationRecord
|
||||
booking.save
|
||||
|
||||
# InventoryJob.perform_now(self.id)
|
||||
saleObj = Sale.find(self.id)
|
||||
InventoryDefinition.calculate_product_count(saleObj)
|
||||
|
||||
return true, self.id
|
||||
end
|
||||
|
||||
return false, nil
|
||||
# saleObj = Sale.find(self.id)
|
||||
# InventoryDefinition.calculate_product_count(saleObj)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#fOR Quick Service pay and create
|
||||
def self.request_bill(order,current_user,current_login_employee)
|
||||
@sale = Sale.new
|
||||
sale_order=SaleOrder.new
|
||||
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = order.order_id # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
if check_booking.sale_id.nil?
|
||||
if @sale_data = check_booking.sale
|
||||
# Create Sale if it doesn't exist
|
||||
# puts "current_login_employee"
|
||||
# puts current_login_employee.name
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user,order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
@@ -213,9 +241,9 @@ class Sale < ApplicationRecord
|
||||
# @sale_data.save
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
Promotion.promo_activate(@sale_data)
|
||||
@status = true
|
||||
return @status, @sale
|
||||
return @status, @sale_data
|
||||
else
|
||||
@status = false
|
||||
@message = "No Current Open Shift for This Employee"
|
||||
@@ -330,7 +358,25 @@ class Sale < ApplicationRecord
|
||||
sale = Sale.find(self.id)
|
||||
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source)
|
||||
end
|
||||
|
||||
def create_saleitem_indutycharges(chargeObj, current_checkin_induties_count, induties_pay_amount, dining_name, dining_time, order_source = nil, basic_pay_amount)
|
||||
sale_item = SaleItem.new
|
||||
sale_item.menu_category_code = "IndutyCharge"
|
||||
sale_item.menu_category_name = "Induty Charge"
|
||||
sale_item.product_code = ""
|
||||
sale_item.product_name ='Vocalist' + " ( " + dining_time.to_s + " )"
|
||||
sale_item.account_id = 0
|
||||
sale_item.product_alt_name = "-"
|
||||
sale_item.qty = current_checkin_induties_count
|
||||
sale_item.unit_price = basic_pay_amount
|
||||
sale_item.taxable_price = induties_pay_amount
|
||||
sale_item.is_taxable = chargeObj.taxable
|
||||
sale_item.sale_id = self.id
|
||||
sale_item.price = induties_pay_amount
|
||||
sale_item.save
|
||||
# Re-calc
|
||||
sale = Sale.find(self.id)
|
||||
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source)
|
||||
end
|
||||
def update_item (item)
|
||||
#save sale_audit
|
||||
|
||||
@@ -374,6 +420,7 @@ class Sale < ApplicationRecord
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||
self.grand_total_round
|
||||
#compute rounding adjustment
|
||||
adjust_rounding
|
||||
|
||||
@@ -382,7 +429,8 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
#compute - invoice total
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil)
|
||||
def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil,type=nil)
|
||||
shop = Shop.first
|
||||
sale = Sale.find(sale_id)
|
||||
sales_items = sale_itemss
|
||||
|
||||
@@ -400,12 +448,16 @@ class Sale < ApplicationRecord
|
||||
total_taxable = total_taxable + item.taxable_price
|
||||
end
|
||||
end
|
||||
|
||||
compute_tax(sale, total_taxable, total_discount, order_source, tax_type)
|
||||
|
||||
sale.total_amount = subtotal_price
|
||||
sale.total_discount = total_discount
|
||||
if type =="foc"
|
||||
sale.grand_total = 0
|
||||
else
|
||||
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
|
||||
sale.grand_total_round
|
||||
end
|
||||
|
||||
if discount_type == "member_discount"
|
||||
sale.discount_type = discount_type
|
||||
end
|
||||
@@ -441,6 +493,7 @@ class Sale < ApplicationRecord
|
||||
self.total_amount = subtotal_price
|
||||
self.total_discount = total_discount
|
||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||
self.grand_total_round
|
||||
#compute rounding adjustment
|
||||
adjust_rounding
|
||||
|
||||
@@ -658,9 +711,11 @@ class Sale < ApplicationRecord
|
||||
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
|
||||
|
||||
if saleOrder.nil?
|
||||
sale_order = SaleOrder.new
|
||||
sale = sale_order.create_sale_order(self.id, order_id)
|
||||
saleOrder = SaleOrder.new
|
||||
# sale = saleOrder.create_sale_order(self.id, order_id)
|
||||
end
|
||||
|
||||
sale = saleOrder.create_sale_order(self.id, order_id)
|
||||
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
|
||||
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
|
||||
# end
|
||||
@@ -842,6 +897,7 @@ def self.daily_sales_list(from,to)
|
||||
AND DATE_FORMAT(CONVERT_TZ(s.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') = DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d')"
|
||||
|
||||
payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
||||
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
||||
@@ -891,6 +947,7 @@ def self.daily_sales_list(from,to)
|
||||
:paypar_amount => pay.paypar_amount,
|
||||
:unionpay_amount => pay.unionpay_amount,
|
||||
:alipay_amount => pay.alipay_amount,
|
||||
:kbzpay_amount => pay.kbzpay_amount,
|
||||
:paymal_amount => pay.paymal_amount,
|
||||
:dinga_amount => pay.dinga_amount,
|
||||
:junctionpay_amount => pay.junctionpay_amount,
|
||||
@@ -959,7 +1016,8 @@ def self.get_by_shiftsales(from,to,shift)
|
||||
:credit_sales => shift_sale.credit_sales,
|
||||
:other_sales => shift_sale.other_sales.to_f,
|
||||
:foc_sales => foc,
|
||||
:grand_total => shift_sale.grand_total
|
||||
:grand_total => shift_sale.grand_total,
|
||||
:shift_id => shift_sale.id
|
||||
}
|
||||
end
|
||||
|
||||
@@ -1001,13 +1059,15 @@ def self.get_item_query(type)
|
||||
elsif type == "promotion"
|
||||
sale_type = "#{check_product} and i.status = 'promotion'"
|
||||
end
|
||||
query = Sale.select("acc.title as account_name,
|
||||
query = Sale.select("sales.sale_id,acc.title as account_name,
|
||||
i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,
|
||||
SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.status as status_type,i.remark as remark,"+
|
||||
"i.unit_price,i.price as price,i.product_name as product_name, " +
|
||||
"i.menu_category_name,i.menu_category_code as menu_category_id ")
|
||||
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
|
||||
"date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')
|
||||
as date_format")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||
@@ -1015,7 +1075,8 @@ def self.get_item_query(type)
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||
query = query.where("#{sale_type}")
|
||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
|
||||
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.item_instance_code asc, SUM(i.qty) desc, i.unit_price asc")
|
||||
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||
end
|
||||
|
||||
def self.get_other_charges()
|
||||
@@ -1098,7 +1159,6 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
@@ -1372,6 +1432,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount,
|
||||
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
|
||||
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
||||
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
||||
@@ -1429,7 +1490,7 @@ def self.get_wastes_and_spoilages(from,to,status)
|
||||
.joins("JOIN sale_items ON sales.sale_id = sale_items.sale_id" )
|
||||
.where("sales.receipt_date between ? and ? #{type}",from,to)
|
||||
.group("sales.receipt_no,sale_items.menu_category_code,sale_items.item_instance_code")
|
||||
.order("sales.sale_id,sale_items.menu_category_name,sale_items.product_name")
|
||||
.order("sales.sale_id,sale_items.qty desc,sale_items.menu_category_name,sale_items.product_name")
|
||||
end
|
||||
|
||||
# def self.get_separate_tax(from,to,payment_method=nil)
|
||||
@@ -1554,6 +1615,13 @@ end
|
||||
end
|
||||
|
||||
def self.hourly_sales(today,current_user,from,to,from_time,to_time)
|
||||
logger.debug 'hourly_sales<<<<<<<<<<<<<<<<<<<<<<<<'
|
||||
logger.debug today
|
||||
logger.debug current_user.to_json
|
||||
logger.debug from
|
||||
logger.debug to
|
||||
logger.debug from_time
|
||||
logger.debug to_time
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
if current_user.nil?
|
||||
query = Sale.hourly_sale_data(today,nil,from,to,from_time,to_time)
|
||||
@@ -2465,72 +2533,34 @@ end
|
||||
|
||||
def self.add_to_existing_pending_invoice(dining,sale_id,booking)
|
||||
|
||||
sale = Sale.find(sale_id)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
if dining.to_i > 0
|
||||
table = DiningFacility.find(dining)
|
||||
table.bookings.each do |booking|
|
||||
# if !booking.checkout_at.nil?
|
||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
if booking.sale_id.nil? || booking.booking_id != existing_booking.booking_id
|
||||
booking.orders.where(status: 'new').update(booking: existing_booking)
|
||||
booking.update(booking_status: 'moved')
|
||||
end
|
||||
|
||||
existing_booking.orders.where(status: 'new').each do |order|
|
||||
order.status = 'billed'
|
||||
order.order_items.each do |item|
|
||||
item.order_item_status = 'billed'
|
||||
sale.add_item(item)
|
||||
end
|
||||
# create sale item
|
||||
saleobj = Sale.find(sale_id)
|
||||
order.order_items.each do |orer_item|
|
||||
saleobj.add_item (orer_item)
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
saleobj.compute(order.source)
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
sale.compute(order.source)
|
||||
sale.orders << order
|
||||
end
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if booking.sale_id.nil?
|
||||
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)
|
||||
end
|
||||
|
||||
# Re-compute for add
|
||||
saleobj.compute(order.source)
|
||||
saleobj.save
|
||||
order.save
|
||||
booking.save
|
||||
end
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
bo.save
|
||||
end
|
||||
end
|
||||
end
|
||||
def self.get_shift_sale_items(sh_id)
|
||||
query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark")
|
||||
.joins("JOIN sale_items i on i.sale_id = sales.sale_id")
|
||||
.joins("JOIN accounts acc on acc.id = i.account_id")
|
||||
.where("sales.shift_sale_id=?", sh_id)
|
||||
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
|
||||
end
|
||||
|
||||
def self.pending_sale(type)
|
||||
@@ -2710,9 +2740,182 @@ def self.employee_sale(today,shift=nil,from=nil,to=nil,from_time=nil,to_time=nil
|
||||
return query
|
||||
end
|
||||
|
||||
# Start hourly sale item report
|
||||
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type)
|
||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||
if account_type.blank?
|
||||
account_type = ''
|
||||
else
|
||||
account_type = " and acc.title = '#{account_type}'"
|
||||
end
|
||||
|
||||
query = self.get_hourly_item_query(type)
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
total_cash_amount = 0
|
||||
total_credit_amount = 0
|
||||
total_foc_amount = 0
|
||||
total_grand_total = 0
|
||||
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = self.get_other_charges()
|
||||
end
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
### => get all sales range in shift_sales
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
end
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
total_credit_amount += s_c.credit_amount.to_f
|
||||
total_foc_amount += s_c.foc_amount.to_f
|
||||
end
|
||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||
|
||||
end
|
||||
|
||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
end
|
||||
|
||||
def self.get_hourly_item_query(type)
|
||||
check_product = "i.menu_category_name != 'product'"
|
||||
if type == "revenue"
|
||||
sale_type = "i.qty > 0 and status IS NULL"
|
||||
elsif type == "all" || type.nil?
|
||||
sale_type = "#{check_product}"
|
||||
elsif type == "discount"
|
||||
sale_type = "#{check_product} and i.status = 'Discount'"
|
||||
elsif type == "foc"
|
||||
sale_type = "#{check_product} and i.status = 'foc' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "void"
|
||||
sale_type = "#{check_product} and i.status = 'void' and i.item_instance_code IS NOT NULL and i.qty > 0"
|
||||
elsif type == "other"
|
||||
sale_type = "#{check_product} and i.item_instance_code IS NULL"
|
||||
elsif type == "promotion"
|
||||
sale_type = "#{check_product} and i.status = 'promotion'"
|
||||
end
|
||||
query = Sale.select("sales.sale_id,acc.title as account_name,
|
||||
i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,
|
||||
SUM(i.qty) as total_item,i.qty as qty," +
|
||||
"i.status as status_type,i.remark as remark,"+
|
||||
"i.unit_price,i.price as price,i.product_name as product_name, " +
|
||||
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
|
||||
|
||||
"concat(hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')), ':00 - ', hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) + 1, ':00') as date_format," +
|
||||
"hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) as hour")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||
query = query.where("#{sale_type}")
|
||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price,hour")
|
||||
.order("hour asc")
|
||||
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||
end
|
||||
|
||||
# End hourly sale item report
|
||||
|
||||
|
||||
#not to show decimal in grand total
|
||||
def grand_total_round
|
||||
print_settings = PrintSetting.get_precision_delimiter()
|
||||
if !print_settings.nil?
|
||||
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
if self.sale_id.nil?
|
||||
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
|
||||
end
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
if self.sale_status == "void" && self.sale_status_before_last_save != "void"
|
||||
self.sale_items.each do |item|
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', item.item_instance_code).order("id DESC").first
|
||||
StockJournal.add_to_journal(item.item_instance_code, -item.qty, stock.balance, "void", inventory_definition, item.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different + item.qty
|
||||
check_item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif self.sale_status == "waste" || self.sale_status == "spoile" || (self.payment_status == "foc" && self.payment_status_was != "foc")
|
||||
self.bookings.first.order_items.each do |item|
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
|
||||
if found
|
||||
if stock_journal = StockJournal.find_by_trans_ref(item.order_items_id)
|
||||
stock_journal.update(remark: self.sale_status)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,28 @@ class SaleAudit < ApplicationRecord
|
||||
|
||||
belongs_to :sale
|
||||
|
||||
def self.sync_sale_audit_records(sale_audits)
|
||||
if !sale_audits.nil?
|
||||
sale_audits.each do |sa|
|
||||
sale_audit = SaleAudit.find_by_sale_audit_id(sa['sale_audit_id'])
|
||||
# unless SaleAudit.exists?(sa['sale_audit_id'])
|
||||
if sale_audit.nil?
|
||||
sale_audit = SaleAudit.new
|
||||
end
|
||||
sale_audit.sale_audit_id = sa['sale_audit_id']
|
||||
sale_audit.sale_id = sa['sale_id']
|
||||
sale_audit.action = sa['action']
|
||||
sale_audit.action_at = sa['action_at']
|
||||
sale_audit.action_by = sa['action_by']
|
||||
sale_audit.approved_by = sa['approved_by']
|
||||
sale_audit.approved_at = sa['approved_at']
|
||||
sale_audit.remark = sa['remark']
|
||||
sale_audit.save
|
||||
end
|
||||
Rails.logger.debug '....... Sale Audit sync completed .......'
|
||||
end
|
||||
end
|
||||
|
||||
def self.record_audit_void(sale_id, void_by, approved_by, reason)
|
||||
#sale_audit
|
||||
sale_audit = SaleAudit.new()
|
||||
@@ -154,6 +176,8 @@ class SaleAudit < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_audit_id.nil?
|
||||
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,12 +11,13 @@ class SaleItem < ApplicationRecord
|
||||
def compute_item
|
||||
end
|
||||
|
||||
after_update :update_stock_journal
|
||||
|
||||
# Add Sale Items
|
||||
def self.add_sale_items(sale_items)
|
||||
sale_items.each do|saleitemObj|
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@newsaleitem.save
|
||||
@newsaleitem.qty = saleitemObj.qty * (-1)
|
||||
@newsaleitem.unit_price = saleitemObj.unit_price * (-1)
|
||||
@newsaleitem.taxable_price = (saleitemObj.unit_price * saleitemObj.qty) * (-1)
|
||||
@@ -26,38 +27,70 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.sync_sale_item_records(sale_items)
|
||||
if !sale_items.nil?
|
||||
sale_items.each do |si|
|
||||
sale_item = SaleItem.find_by_sale_item_id(si['sale_item_id'])
|
||||
# unless SaleItem.exists?(si['sale_item_id'])
|
||||
if sale_item.nil?
|
||||
sale_item = SaleItem.new
|
||||
end
|
||||
sale_item.sale_item_id = si['sale_item_id']
|
||||
sale_item.sale_id = si['sale_id']
|
||||
sale_item.menu_category_code = si['menu_category_code']
|
||||
sale_item.menu_category_name = si['menu_category_name']
|
||||
sale_item.product_code = si['product_code']
|
||||
sale_item.product_name = si['product_name']
|
||||
sale_item.product_alt_name = si['product_alt_name']
|
||||
sale_item.item_instance_code = si['item_instance_code']
|
||||
sale_item.account_id = si['account_id']
|
||||
sale_item.status = si['status']
|
||||
sale_item['remark'] = si['remark']
|
||||
sale_item['qty'] = si['qty']
|
||||
sale_item['unit_price'] = si['unit_price']
|
||||
sale_item['taxable_price'] = si['taxable_price']
|
||||
sale_item['price'] = si['price']
|
||||
sale_item['is_taxable'] = si['is_taxable']
|
||||
sale_item.save
|
||||
end
|
||||
Rails.logger.debug '....... Sale Item sync completed ......'
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
||||
# Original Item to add remark
|
||||
item.status = type
|
||||
item.save
|
||||
menu_category = MenuCategory.get_menu_category(item.product_code) #get menu category for menu items
|
||||
|
||||
sale_item = SaleItem.new
|
||||
sale_item.menu_category_code = menu_category.code ? menu_category.code : nil
|
||||
sale_item.menu_category_name = menu_category.name
|
||||
sale_item.product_code = item.product_code
|
||||
sale_item.item_instance_code = item.item_instance_code
|
||||
sale_item.product_name = item.product_name + " (#{type.upcase})"
|
||||
sale_item.product_alt_name = item.product_alt_name
|
||||
sale_item.account_id = item.account_id
|
||||
sale_item.status = type
|
||||
sale_item.remark = type
|
||||
if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile"
|
||||
sale_item.qty = qty * (-1)
|
||||
else
|
||||
sale_item.qty = qty
|
||||
end
|
||||
# sale_item = SaleItem.new
|
||||
# sale_item.menu_category_code = menu_category.code ? menu_category.code : nil
|
||||
# sale_item.menu_category_name = menu_category.name
|
||||
# sale_item.product_code = item.product_code
|
||||
# sale_item.item_instance_code = item.item_instance_code
|
||||
# sale_item.product_name = item.product_name + " (#{type.upcase})"
|
||||
# sale_item.product_alt_name = item.product_alt_name
|
||||
# sale_item.account_id = item.account_id
|
||||
# sale_item.status = type
|
||||
# sale_item.remark = type
|
||||
# if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile"
|
||||
# sale_item.qty = qty * (-1)
|
||||
# else
|
||||
# sale_item.qty = qty
|
||||
# end
|
||||
|
||||
sale_item.unit_price = item_price # * (-1)
|
||||
sale_item.taxable_price = (price) * (-1)
|
||||
sale_item.price = (price) * (-1)
|
||||
# sale_item.unit_price = item_price # * (-1)
|
||||
# sale_item.taxable_price = (price) * (-1)
|
||||
# sale_item.price = (price) * (-1)
|
||||
|
||||
sale_item.is_taxable = 1
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.save
|
||||
# sale_item.is_taxable = 1
|
||||
# sale_item.sale_id = sale_id
|
||||
# sale_item.save
|
||||
if type != "foc"
|
||||
sale = Sale.find(sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount)
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_order_items_details(sale_id)
|
||||
order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,sales.receipt_date as receipt_date,
|
||||
@@ -180,10 +213,10 @@ class SaleItem < ApplicationRecord
|
||||
def self.get_all_sale_items(sale_id)
|
||||
sale_items = SaleItem.select("sale_id,product_code,item_instance_code,
|
||||
product_name,product_alt_name,account_id,status,remark,
|
||||
(CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty,
|
||||
SUM(qty) as qty,
|
||||
unit_price,
|
||||
taxable_price,
|
||||
(CASE WHEN (price > 0 AND remark IS NULL) OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price,
|
||||
SUM(price) as price,
|
||||
is_taxable")
|
||||
.where("sale_id = ?",sale_id)
|
||||
.order("product_name asc")
|
||||
@@ -193,6 +226,53 @@ class SaleItem < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_item_id.nil?
|
||||
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
||||
end
|
||||
end
|
||||
|
||||
def update_stock_journal
|
||||
is_void = self.status == "void" && self.status_before_last_save != "void"
|
||||
cancel_void = self.status_before_last_save == "void" && self.status.nil?
|
||||
is_edit = self.qty >= 0 && self.qty != self.qty_before_last_save
|
||||
is_foc = self.status == "foc" && self.status_before_last_save != "foc"
|
||||
cancel_foc = self.status_before_last_save == "foc"
|
||||
|
||||
if is_void or cancel_void or is_edit or is_foc or cancel_foc
|
||||
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
|
||||
if found
|
||||
stock = StockJournal.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
unless stock.nil?
|
||||
check_item = StockCheckItem.where('item_code=?', self.item_instance_code).order("id DESC").first
|
||||
if is_void or cancel_void or is_edit
|
||||
if is_void
|
||||
qty = -self.qty
|
||||
remark = "void"
|
||||
elsif cancel_void
|
||||
qty = self.qty
|
||||
remark = "cancel void"
|
||||
elsif is_edit
|
||||
qty = self.qty - self.qty_before_last_save
|
||||
remark = "edit"
|
||||
end
|
||||
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
|
||||
check_item.different = check_item.different + qty
|
||||
check_item.save
|
||||
else is_foc or cancel_foc
|
||||
qty = StockJournal.where(trans_ref: self.sale_item_id).sum("credit-debit")
|
||||
if order_item_id = self.sale.bookings.first.order_items.where(item_instance_code: self.item_instance_code, qty: self.qty + qty).select(:order_items_id).first.order_items_id
|
||||
if stock_journal = StockJournal.find_by_trans_ref(order_item_id)
|
||||
if is_foc
|
||||
stock_journal.update(remark: "foc")
|
||||
elsif cancel_foc
|
||||
stock_journal.update(remark: "cancel_foc")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,17 +7,36 @@ class SaleOrder < ApplicationRecord
|
||||
belongs_to :sale
|
||||
belongs_to :order
|
||||
|
||||
def create_sale_order(sale, order)
|
||||
def create_sale_order(sale_id, order_id)
|
||||
# sale_order = SaleOrder.new
|
||||
self.sale_id = sale_id
|
||||
self.order_id = order_id
|
||||
self.save!
|
||||
end
|
||||
|
||||
def self.sync_sale_order_records(sale_orders)
|
||||
if !sale_orders.nil?
|
||||
sale_orders.each do |so|
|
||||
sale_order = SaleOrder.find_by_sale_order_id(so['sale_order_id'])
|
||||
# unless SaleOrder.exists?(so['sale_order_id'])
|
||||
if sale_order.nil?
|
||||
sale_order = SaleOrder.new
|
||||
sale_order.sale_id = sale
|
||||
sale_order.order_id = order
|
||||
sale_order.save!
|
||||
end
|
||||
sale_order.sale_order_id = so['sale_order_id']
|
||||
sale_order.sale_id = so['sale_id']
|
||||
sale_order.order_id = so['order_id']
|
||||
sale_order.save
|
||||
end
|
||||
Rails.logger.debug '......... Sale Order sync completed ........'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def generate_sale_order_id
|
||||
self.class.name
|
||||
saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
|
||||
self.sale_order_id = saleOrderId
|
||||
# self.class.name
|
||||
if self.sale_order_id.nil?
|
||||
self.sale_order_id = SeedGenerator.generate_id(self.class.name, 'SOI')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,59 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
|
||||
|
||||
def self.sync_sale_payment_records(sale_payments)
|
||||
if !sale_payments.nil?
|
||||
sale_payments.each do |sp|
|
||||
payment = SalePayment.find_by_sale_payment_id(sp['sale_payment_id'])
|
||||
# unless SalePayment.exists?(sp['sale_payment_id'])
|
||||
if payment.nil?
|
||||
payment = SalePayment.new
|
||||
end
|
||||
payment.sale_payment_id = sp['sale_payment_id']
|
||||
payment.sale_id = sp['sale_id']
|
||||
payment.payment_method = sp['payment_method']
|
||||
payment.payment_amount = sp['payment_amount']
|
||||
payment.outstanding_amount = sp['outstanding_amount']
|
||||
payment.payment_reference = sp['payment_reference']
|
||||
payment.payment_status = sp['payment_status']
|
||||
payment.save
|
||||
end
|
||||
Rails.logger.debug '....... Sale Payment sync completed ......'
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_kbz_pay_amount(sale_id, current_user)
|
||||
amount = 0
|
||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
|
||||
if !sale_payment.nil? and !kbz_pay_method.nil?
|
||||
if sale_payment.payment_status == 'pending'
|
||||
amount = KbzPay.query(sale_payment.id, current_user, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters)
|
||||
elsif sale_payment.payment_status == 'paid'
|
||||
amount = sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
def process_kbz_payment(sale_id, grand_total, pay_amount, status)
|
||||
if status == 'pending'
|
||||
SalePayment.where("sale_id=? and payment_method=? and payment_status=?", sale_id, KbzPay::KBZ_PAY, 'pending').update_all(:payment_status => 'dead')
|
||||
end
|
||||
|
||||
self.sale_id = sale_id
|
||||
self.payment_method = KbzPay::KBZ_PAY
|
||||
self.payment_amount = self.payment_amount.to_i + pay_amount.to_i
|
||||
if grand_total > 0
|
||||
self.outstanding_amount = grand_total.to_i - pay_amount.to_i
|
||||
else
|
||||
self.outstanding_amount = self.outstanding_amount.to_i - pay_amount.to_i
|
||||
end
|
||||
self.payment_status = status
|
||||
return self.save
|
||||
end
|
||||
|
||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
@@ -29,14 +82,13 @@ class SalePayment < ApplicationRecord
|
||||
amount_due = amount_due - payment.payment_amount
|
||||
end
|
||||
end
|
||||
|
||||
if (amount_due >= 0)
|
||||
payment_status = false
|
||||
membership_data = nil
|
||||
#route to payment type
|
||||
case payment_method
|
||||
when "cash"
|
||||
payment_status = cash_payment(payment_for)
|
||||
payment_status ,outstanding_amount ,balance_amount = cash_payment(payment_for)
|
||||
when "creditnote"
|
||||
if !self.sale.customer_id.nil?
|
||||
payment_status = creditnote_payment(self.customer_id)
|
||||
@@ -69,6 +121,8 @@ class SalePayment < ApplicationRecord
|
||||
payment_status,membership_data = dinga_payment
|
||||
when "GiftVoucher"
|
||||
payment_status = giftvoucher_payment
|
||||
when KbzPay::KBZ_PAY
|
||||
payment_status = kbz_payment
|
||||
else
|
||||
puts "it was something else"
|
||||
end
|
||||
@@ -106,7 +160,7 @@ class SalePayment < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
|
||||
return true, self.save,membership_data
|
||||
return true, self.save,membership_data, outstanding_amount ,balance_amount
|
||||
else
|
||||
#record an payment in sale-audit
|
||||
remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||
@@ -123,6 +177,11 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def kbz_edit_sale_payment(amt, action_by)
|
||||
self.action_by = action_by
|
||||
sale_update_payment_status(amt)
|
||||
end
|
||||
|
||||
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token)
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
@@ -178,7 +237,8 @@ class SalePayment < ApplicationRecord
|
||||
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
|
||||
# membership_actions_data = MembershipAction.find_by_membership_type("redeem");
|
||||
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
|
||||
|
||||
puts "This is membership_actions_data"
|
||||
puts membership_actions_data.to_json
|
||||
if !membership_actions_data.nil?
|
||||
|
||||
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
|
||||
@@ -322,6 +382,7 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
payment_status = false
|
||||
|
||||
self.payment_method = "cash"
|
||||
self.payment_amount = self.received_amount
|
||||
if !payment_for
|
||||
@@ -330,12 +391,22 @@ class SalePayment < ApplicationRecord
|
||||
credit_sale_payment = SalePayment.get_credit_total_left(self.sale_id)[0] ? SalePayment.get_credit_total_left(self.sale_id)[0].payment_amount.to_f : 0 ###need to calculate creditnote total in here
|
||||
self.outstanding_amount = credit_sale_payment - self.received_amount.to_f
|
||||
end
|
||||
|
||||
self.payment_status = "paid"
|
||||
payment_status = self.save!
|
||||
if !payment_for
|
||||
sale_update_payment_status(self.received_amount,status)
|
||||
end
|
||||
return payment_status
|
||||
balance_amount =0.0
|
||||
outstanding_amount =0.0
|
||||
if self.sale.grand_total.to_f > self.received_amount.to_f
|
||||
balance_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
outstanding_amount = 0.0
|
||||
else
|
||||
balance_amount = 0.0
|
||||
outstanding_amount = self.received_amount.to_f - self.sale.grand_total.to_f
|
||||
end
|
||||
return payment_status , outstanding_amount.to_i, balance_amount.to_i
|
||||
end
|
||||
|
||||
def foc_payment
|
||||
@@ -347,6 +418,8 @@ class SalePayment < ApplicationRecord
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
end
|
||||
sale = Sale.find(self.sale.sale_id)
|
||||
sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,'','','',"foc")
|
||||
|
||||
self.payment_method = "foc"
|
||||
self.payment_amount = self.received_amount
|
||||
@@ -551,6 +624,17 @@ class SalePayment < ApplicationRecord
|
||||
return payment_status
|
||||
end
|
||||
|
||||
def kbz_payment
|
||||
payment_status = false
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_status = self.save!
|
||||
# sale_update_payment_status(self.received_amount)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
@@ -560,6 +644,7 @@ class SalePayment < ApplicationRecord
|
||||
sObj = Sale.find(self.sale_id)
|
||||
is_credit = 0
|
||||
is_foc = 0
|
||||
is_kbz_pay = 0
|
||||
method_status = false
|
||||
sObj.sale_payments.each do |spay|
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
@@ -569,11 +654,13 @@ class SalePayment < ApplicationRecord
|
||||
if spay.payment_method == "foc"
|
||||
is_foc = 1
|
||||
end
|
||||
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
|
||||
if spay.payment_method == KbzPay::KBZ_PAY
|
||||
is_kbz_pay = 1
|
||||
end
|
||||
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" || spay.payment_method == KbzPay::KBZ_PAY
|
||||
method_status = true
|
||||
end
|
||||
end
|
||||
|
||||
if (self.sale.grand_total <= all_received_amount) && method_status
|
||||
if is_credit == 0
|
||||
self.sale.payment_status = "paid"
|
||||
@@ -587,6 +674,10 @@ class SalePayment < ApplicationRecord
|
||||
self.sale.payment_status = "foc"
|
||||
end
|
||||
|
||||
if is_kbz_pay == 1
|
||||
self.sale.payment_status = 'paid'
|
||||
end
|
||||
|
||||
self.sale.sale_status = "completed"
|
||||
|
||||
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
|
||||
@@ -973,6 +1064,8 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_payment_id.nil?
|
||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,26 @@ class SaleTax < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
belongs_to :sale
|
||||
|
||||
def self.sync_sale_tax_records(sale_taxes)
|
||||
if !sale_taxes.nil?
|
||||
sale_taxes.each do |t|
|
||||
tax = SaleTax.find_by_sale_tax_id(t['sale_tax_id'])
|
||||
# unless SaleTax.exists?(t['sale_tax_id'])
|
||||
if tax.nil?
|
||||
tax = SaleTax.new
|
||||
end
|
||||
tax.sale_tax_id = t['sale_tax_id']
|
||||
tax.sale_id = t['sale_id']
|
||||
tax.tax_name = t['tax_name']
|
||||
tax.tax_rate = t['tax_rate']
|
||||
tax.tax_payable_amount = t['tax_payable_amount']
|
||||
tax.inclusive = t['inclusive']
|
||||
tax.save
|
||||
end
|
||||
Rails.logger.debug '...... Sale Tax sync completed .....'
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_tax(from,to)
|
||||
query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount")
|
||||
.joins("join sales on sales.sale_id = sale_taxes.sale_id")
|
||||
@@ -14,6 +34,8 @@ class SaleTax < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
if self.sale_tax_id.nil?
|
||||
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
class SeedGenerator < ApplicationRecord
|
||||
# Generate ID for Tables
|
||||
def self.generate_id(model, prefix)
|
||||
cur_val, next_val = self.update_seed(model)
|
||||
model_name = self.get_model_name(model)
|
||||
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
prefix = "C#{prefix}"
|
||||
end
|
||||
|
||||
cur_val, next_val = self.update_seed(model_name)
|
||||
|
||||
if (cur_val == 0)
|
||||
cur_val, next_val = self.execute_query(model)
|
||||
cur_val, next_val = self.execute_query(model_name)
|
||||
end
|
||||
|
||||
padding_len = 15 - prefix.length
|
||||
@@ -12,6 +18,23 @@ class SeedGenerator < ApplicationRecord
|
||||
return saleOrderId
|
||||
end
|
||||
|
||||
def self.sync_seed_generator_records(seed_generators)
|
||||
if !seed_generators.nil?
|
||||
seed_generators.each do |sg|
|
||||
seed = SeedGenerator.find_by_model(sg['model'])
|
||||
if seed.nil?
|
||||
seed = SeedGenerator.new
|
||||
end
|
||||
seed.model = sg['model']
|
||||
seed.increase_by = sg['increase_by']
|
||||
seed.current = sg['current']
|
||||
seed.next = sg['next']
|
||||
seed.save
|
||||
end
|
||||
Rails.logger.debug '....... Seed Generator sync completed! .......'
|
||||
end
|
||||
end
|
||||
|
||||
# Generate Receipt No for number order (1,2,3) Don't touch
|
||||
def self.new_receipt_no
|
||||
seed = SeedGenerator.find_by_model("Sale")
|
||||
@@ -66,6 +89,17 @@ class SeedGenerator < ApplicationRecord
|
||||
# return next_code
|
||||
# end
|
||||
|
||||
def self.get_model_name(model)
|
||||
model_name = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
model_name = "Cloud#{model}"
|
||||
else
|
||||
model_name = model
|
||||
end
|
||||
|
||||
return model_name
|
||||
end
|
||||
|
||||
def self.execute_query(model)
|
||||
current = 0
|
||||
nex = 0
|
||||
|
||||
@@ -32,6 +32,51 @@ class ShiftSale < ApplicationRecord
|
||||
#end
|
||||
end
|
||||
|
||||
def self.sync_shift_sale_records(shift_sales)
|
||||
if !shift_sales.nil?
|
||||
shift_sales.each do |ss|
|
||||
# status = nil
|
||||
shift_sale = nil
|
||||
|
||||
# if ShiftSale.exists?(ss['id'])
|
||||
shift_sale = ShiftSale.find_by_id(ss['id'])
|
||||
# status = 'updated'
|
||||
if shift_sale.nil?
|
||||
shift_sale = ShiftSale.new
|
||||
# status = 'created'
|
||||
end
|
||||
|
||||
shift_sale.id = ss['id']
|
||||
shift_sale.cashier_terminal_id = ss['cashier_terminal_id']
|
||||
shift_sale.shift_started_at = ss['shift_started_at']
|
||||
shift_sale.shift_closed_at = ss['shift_closed_at']
|
||||
shift_sale.employee_id = ss['employee_id']
|
||||
shift_sale.opening_balance = ss['opening_balance']
|
||||
shift_sale.closing_balance = ss['closing_balance']
|
||||
shift_sale.total_revenue = ss['total_revenue']
|
||||
shift_sale.total_discounts = ss['total_discounts']
|
||||
shift_sale.total_taxes = ss['total_taxes']
|
||||
shift_sale.grand_total = ss['grand_total']
|
||||
shift_sale.nett_sales = ss['nett_sales']
|
||||
shift_sale.cash_sales = ss['cash_sales']
|
||||
shift_sale.credit_sales = ss['credit_sales']
|
||||
shift_sale.other_sales = ss['other_sales']
|
||||
shift_sale.commercial_taxes = ss['commercial_taxes']
|
||||
shift_sale.cash_in = ss['cash_in']
|
||||
shift_sale.cash_out = ss['cash_out']
|
||||
shift_sale.dining_count = ss['dining_count']
|
||||
shift_sale.takeaway_count = ss['takeaway_count']
|
||||
shift_sale.member_count = ss['member_count']
|
||||
shift_sale.total_rounding = ss['total_rounding']
|
||||
shift_sale.total_receipt = ss['total_receipt']
|
||||
shift_sale.total_void = ss['total_void']
|
||||
shift_sale.save
|
||||
|
||||
end
|
||||
Rails.logger.debug "....... Shift Sale sync completed ......"
|
||||
end
|
||||
end
|
||||
|
||||
def create(opening_balance,cashier_terminal, current_user)
|
||||
self.cashier_terminal_id = cashier_terminal
|
||||
self.shift_started_at = DateTime.now
|
||||
@@ -112,6 +157,7 @@ class ShiftSale < ApplicationRecord
|
||||
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
|
||||
SUM(case when (sale_payments.payment_method='unionpay') then (sale_payments.payment_amount) else 0 end) as unionpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='alipay') then (sale_payments.payment_amount) else 0 end) as alipay_amount,
|
||||
SUM(case when (sale_payments.payment_method='KBZPay') then (sale_payments.payment_amount) else 0 end) as kbzpay_amount,
|
||||
SUM(case when (sale_payments.payment_method='dinga') then (sale_payments.payment_amount) else 0 end) as dinga_amount,
|
||||
SUM(case when (sale_payments.payment_method='giftvoucher') then (sale_payments.payment_amount) else 0 end) as giftvoucher_amount,
|
||||
SUM(case when (sale_payments.payment_method='JunctionPay') then (sale_payments.payment_amount) else 0 end) as junctionpay_amount,
|
||||
@@ -158,6 +204,13 @@ class ShiftSale < ApplicationRecord
|
||||
.first()
|
||||
end
|
||||
|
||||
# def self.get_total_other_charges_for_sale_item_report(from, to)
|
||||
# query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||
# .joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
# .joins("JOIN shift_sales ss ON ss.id = s.shift_sale_id")
|
||||
# .where('s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null and s.receipt_date between ? and ?',from, to)
|
||||
# end
|
||||
|
||||
def self.get_total_other_charges(shift)
|
||||
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Shop < ApplicationRecord
|
||||
ShopDetail = Shop.find_by_id(1)
|
||||
#ShopDetail = Shop.find_by_id(1)
|
||||
|
||||
# Shop Image Uploader
|
||||
mount_uploader :logo, ShopImageUploader
|
||||
|
||||
@@ -2,7 +2,14 @@ class StockCheckItem < ApplicationRecord
|
||||
belongs_to :stock_check
|
||||
|
||||
def create(stock_id, item)
|
||||
journal_id, balance = StockCheckItem.find_journal(item['sku'])
|
||||
# check_item = StockCheckItem.find_by_item_code(item['sku'])
|
||||
check_item = StockCheckItem.where('item_code=?', item_code).order("id DESC").first
|
||||
if check_item.nil?
|
||||
balance = 0
|
||||
else
|
||||
balance = check_item.different
|
||||
end
|
||||
journal_id = StockCheckItem.find_journal(item['sku'])
|
||||
remark, different = StockCheckItem.stock_different(item['qty'], balance )
|
||||
self.stock_check_id = stock_id
|
||||
self.item_code = item['sku']
|
||||
@@ -15,7 +22,7 @@ class StockCheckItem < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.find_journal(item_code)
|
||||
journal = StockJournal.where('item_code=?', item_code).order('created_at desc').take
|
||||
journal = StockJournal.where('item_code=?', item_code).order("id DESC").first
|
||||
if journal
|
||||
return journal.id, journal.balance
|
||||
else
|
||||
@@ -24,13 +31,14 @@ class StockCheckItem < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.stock_different(stock_check_qty, journal_balance)
|
||||
if stock_check_qty.to_i == journal_balance.to_i
|
||||
return 'match', stock_check_qty
|
||||
elsif stock_check_qty.to_i > journal_balance.to_i
|
||||
return 'missing order item', stock_check_qty.to_i - journal_balance.to_i
|
||||
elsif stock_check_qty.to_i < journal_balance.to_i
|
||||
return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
|
||||
end
|
||||
# if stock_check_qty.to_i == journal_balance.to_i
|
||||
# return 'match', stock_check_qty
|
||||
# elsif stock_check_qty.to_i > journal_balance.to_i
|
||||
# return 'missing order item', stock_check_qty.to_i - journal_balance.to_i
|
||||
# elsif stock_check_qty.to_i < journal_balance.to_i
|
||||
# return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
|
||||
# end
|
||||
return 'add new stock', stock_check_qty.to_i + journal_balance.to_i
|
||||
end
|
||||
|
||||
def self.get_transaction(from, to, item_code)
|
||||
@@ -58,4 +66,8 @@ class StockCheckItem < ApplicationRecord
|
||||
.order("acc.title desc,mi.menu_category_id desc")
|
||||
return query
|
||||
end
|
||||
|
||||
def self.delete_stock_check_item(item_code)
|
||||
self.where("item_code=?", item_code).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
class StockJournal < ApplicationRecord
|
||||
|
||||
SALES_TRANS = "sale"
|
||||
ORDER_TRANS = "order"
|
||||
STOCK_CHECK_TRANS = "stock_check"
|
||||
|
||||
def self.add_to_journal(item, balance, stock_message, inventory_definition) # item => saleObj | balance => Stock journal
|
||||
journal = StockJournal.new
|
||||
journal.credit = balance
|
||||
def self.add_to_journal(item_instance_code, qty, old_balance, stock_message, inventory_definition, trans_ref, trans_type) # item => saleObj | balance => Stock journal
|
||||
|
||||
balance = calculate_balance(balance, item.qty)
|
||||
balance = calculate_balance(old_balance, qty)
|
||||
|
||||
journal.item_code = item.item_instance_code
|
||||
journal.inventory_definition_id = inventory_definition.id
|
||||
journal.debit = item.qty
|
||||
journal.balance = balance
|
||||
journal.remark = stock_message
|
||||
journal.trans_ref = item.id
|
||||
journal.trans_type = StockJournal::SALES_TRANS
|
||||
journal.save
|
||||
if balance < old_balance
|
||||
credit = 0
|
||||
debit = qty.abs
|
||||
else
|
||||
credit = qty.abs
|
||||
debit = 0
|
||||
end
|
||||
|
||||
journal = StockJournal.create(
|
||||
item_code: item_instance_code,
|
||||
credit: credit,
|
||||
debit: debit,
|
||||
balance: balance,
|
||||
inventory_definition_id: inventory_definition.id,
|
||||
remark: stock_message,
|
||||
trans_ref: trans_ref,
|
||||
trans_type: trans_type
|
||||
)
|
||||
end
|
||||
|
||||
def self.calculate_balance(balance, qty)
|
||||
@@ -24,13 +33,19 @@ class StockJournal < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.from_stock_check(item)
|
||||
stock_journal = StockJournal.where('item_code=?', item.item_code).order("id DESC").first
|
||||
if stock_journal.nil?
|
||||
old_blance = 0
|
||||
else
|
||||
old_blance = stock_journal.balance
|
||||
end
|
||||
definition_id = InventoryDefinition.find_by_item_code(item.item_code)
|
||||
journal = StockJournal.new
|
||||
journal.item_code = item.item_code
|
||||
journal.inventory_definition_id = definition_id.id
|
||||
journal.debit = 0
|
||||
journal.credit = item.stock_count
|
||||
journal.balance = item.stock_count
|
||||
journal.balance = item.stock_count + old_blance.to_i
|
||||
journal.remark = StockJournal::STOCK_CHECK_TRANS
|
||||
journal.trans_ref = item.id
|
||||
journal.trans_type = StockJournal::STOCK_CHECK_TRANS
|
||||
@@ -57,4 +72,17 @@ class StockJournal < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_stock_journal(item_instance_code,remark)
|
||||
product = InventoryDefinition.find_by_item_code(item_instance_code)
|
||||
if !product.nil?
|
||||
stock = self.where("item_code=?", item_instance_code).order("id DESC").first
|
||||
stock.remark = remark
|
||||
stock.save
|
||||
end
|
||||
end
|
||||
|
||||
def self.delete_stock_journal(item_code)
|
||||
self.where("item_code=?", item_code).delete_all
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user