diff --git a/.idea/.generators b/.idea/.generators
new file mode 100644
index 00000000..16189766
--- /dev/null
+++ b/.idea/.generators
@@ -0,0 +1,8 @@
+
+
diff --git a/.idea/.rakeTasks b/.idea/.rakeTasks
new file mode 100644
index 00000000..3577d8ad
--- /dev/null
+++ b/.idea/.rakeTasks
@@ -0,0 +1,7 @@
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..157739d4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..21ecc838
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml
new file mode 100644
index 00000000..586fd380
--- /dev/null
+++ b/.idea/sxrestaurant.iml
@@ -0,0 +1,236 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..4d3242d5
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,817 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ origami
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1498458293643
+
+
+ 1498458293643
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 8f16e924..227cfa72 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL
-#gem 'pg'
+gem 'pg'
# redis server for cable
# gem 'redis', '~> 3.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index e4b905ea..7e27774a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -122,7 +122,7 @@ GEM
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pdf-core (0.7.0)
- pg (0.21.0)
+ pg (0.20.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js
index c2e99054..2097db44 100644
--- a/app/assets/javascripts/OQS.js
+++ b/app/assets/javascripts/OQS.js
@@ -27,7 +27,7 @@ $(document).ready(function(){
$('.queue_station').on('click',function(){
var orderZone=$(this).children().children().children('.order-zone').text().trim();
// var orderItem=$(this).children().children().children('.order-item').text();
- //var assigned_item_id = $(this).children().find(".assigned-order-item").text();
+ var assigned_item_id = $(this).children().find(".assigned-order-item").text();
var orderQty = $(this).children().children().children('.order-qty').text();
var orderBy = $(this).children().children().children().children('.order-by').text();
var orderAt = $(this).children().children().children().children('.order-at').text();
@@ -68,6 +68,12 @@ $(document).ready(function(){
$(this).addClass('selected-item');
});
+ $(".order-item-edit").on('click', function(){
+ var _self = $(this); // To know in ajax return
+ var assigned_item_id=$(this).attr('id').substr(5);
+ window.location.href = '/oqs/'+ assigned_item_id + "/edit"
+ });
+
// complete for queue item
$('.order-complete').on('click',function(e){
//e.preventDefault();
@@ -134,4 +140,21 @@ $(document).ready(function(){
success: function(data){ }
});
});
+
+ // Qty update for OQS Edit Controller
+ $('#qty-update').on('click', function(){
+ var qty_weight = $("input[name='qty_weight']").val();
+ var remarks = $("textarea[name='remarks']").val();
+ var order_items_id = $(this).attr('data-id');
+ var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks }
+ $.ajax({
+ type: 'POST',
+ url: '/oqs/' + order_items_id,
+ data: params,
+ success: function(result){
+ alert("Updated!");
+ window.location.href = '/oqs';
+ }
+ });
+ });
});
diff --git a/app/assets/javascripts/reports/daily_sales.coffee b/app/assets/javascripts/reports/daily_sales.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/reports/daily_sales.coffee
@@ -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/
diff --git a/app/assets/javascripts/reports/dailysales.coffee b/app/assets/javascripts/reports/dailysales.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/reports/dailysales.coffee
@@ -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/
diff --git a/app/assets/javascripts/reports/sale_items.coffee b/app/assets/javascripts/reports/sale_items.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/reports/sale_items.coffee
@@ -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/
diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss
index b516836a..57c5a36d 100644
--- a/app/assets/stylesheets/OQS.scss
+++ b/app/assets/stylesheets/OQS.scss
@@ -19,3 +19,9 @@
color: #fff !important;
background-color: blue;
}
+
+.order-item {
+ width: 49%;
+ font-size: 18px;
+ margin: 0px 0px 5px 0px;
+}
\ No newline at end of file
diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss
index 3606dadc..2ba6fe52 100644
--- a/app/assets/stylesheets/origami.scss
+++ b/app/assets/stylesheets/origami.scss
@@ -148,6 +148,10 @@
background-color:#7a62d3;
}
+.orange{
+ background-color:#FF7F50;
+}
+
.red {
background-color:#ff0000;
}
@@ -160,6 +164,10 @@
background-color: #FF8C00
}
+.blue{
+ background-color: blue
+}
+
.left{
margin-left:1px;
}
diff --git a/app/assets/stylesheets/reports/daily_sales.scss b/app/assets/stylesheets/reports/daily_sales.scss
new file mode 100644
index 00000000..79ed876a
--- /dev/null
+++ b/app/assets/stylesheets/reports/daily_sales.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the reports/daily_sales controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/reports/dailysales.scss b/app/assets/stylesheets/reports/dailysales.scss
new file mode 100644
index 00000000..cfc48374
--- /dev/null
+++ b/app/assets/stylesheets/reports/dailysales.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the reports/dailysales controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/reports/sale_items.scss b/app/assets/stylesheets/reports/sale_items.scss
new file mode 100644
index 00000000..b9692327
--- /dev/null
+++ b/app/assets/stylesheets/reports/sale_items.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the reports/sale_items controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d0a8ca9e..a877bda0 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -3,16 +3,17 @@ class ApplicationController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception
- helper_method :current_company,:current_login_employee
-
+ helper_method :current_company,:current_login_employee,:current_user
+ # alias_method :current_user, :current_login_employee,:current_user
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
- # rescue_from CanCan::AccessDenied do |exception|
- # flash[:warning] = exception.message
- # redirect_to root_path
- # end
+
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:warning] = exception.message
+ redirect_to root_path
+ end
def current_user
diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb
index a6bf7754..38f0df3d 100644
--- a/app/controllers/base_crm_controller.rb
+++ b/app/controllers/base_crm_controller.rb
@@ -1,9 +1,17 @@
class BaseCrmController < ActionController::Base
- include LoginVerification
- layout "CRM"
+ include LoginVerification
+ layout "CRM"
#before_action :check_installation
protect_from_forgery with: :exception
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:warning] = exception.message
+ redirect_to root_path
+ end
+
+ def current_user
+ @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
+ end
end
diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb
index 16fe9b07..50d7bd55 100644
--- a/app/controllers/base_oqs_controller.rb
+++ b/app/controllers/base_oqs_controller.rb
@@ -5,5 +5,13 @@ class BaseOqsController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:warning] = exception.message
+ redirect_to root_path
+ end
+
+ def current_user
+ @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
+ end
end
diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb
index b250303d..2af895da 100644
--- a/app/controllers/base_origami_controller.rb
+++ b/app/controllers/base_origami_controller.rb
@@ -5,5 +5,14 @@ class BaseOrigamiController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:warning] = exception.message
+ redirect_to root_path
+ end
+
+ def current_user
+ @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
+ end
+
end
diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb
index 0ea51cf5..28ba5c2b 100644
--- a/app/controllers/base_report_controller.rb
+++ b/app/controllers/base_report_controller.rb
@@ -5,6 +5,15 @@ class BaseReportController < ActionController::Base
#before_action :check_installation
protect_from_forgery with: :exception
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:warning] = exception.message
+ redirect_to root_path
+ end
+
+ def current_user
+ @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
+ end
+
PERIOD = {
"today" => 0,
"yesterday" => 1,
diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb
index 65511512..efaa5419 100644
--- a/app/controllers/crm/bookings_controller.rb
+++ b/app/controllers/crm/bookings_controller.rb
@@ -1,5 +1,5 @@
class Crm::BookingsController < BaseCrmController
-
+ load_and_authorize_resource
def update_booking
booking = Booking.find(params[:booking_id])
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index 43b0618e..f2846c12 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -1,4 +1,5 @@
class Crm::CustomersController < BaseCrmController
+ load_and_authorize_resource except: [:create]
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
# GET /crm/customers
@@ -47,7 +48,8 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
- @response = Customer.get_membership_transactions(@customer)
+ @response = Customer.get_membership_transactions(@customer)
+ # @response = ""
#end customer amount
end
@@ -68,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
def create
@crm_customers = Customer.new(customer_params)
-
+
respond_to do |format|
if @crm_customers.save
name = customer_params[:name]
@@ -77,6 +79,7 @@ class Crm::CustomersController < BaseCrmController
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
+ card_no = customer_params[:card_no]
member_group_id = params[:member_group_id]
if !member_group_id.nil?
@@ -87,16 +90,17 @@ class Crm::CustomersController < BaseCrmController
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
- response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
- dob: dob,address: address,nrc:nrc,
- member_group_id: member_group_id,
- merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
- :headers => {
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json'
+ response = HTTParty.post(url,
+ :body => {name: name,phone: phone,email: email,
+ dob: dob,address: address,nrc:nrc,card_no:card_no,
+ member_group_id: member_group_id,
+ merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
},
- :timeout => 10
- )
+ :timeout => 10
+ )
rescue Net::OpenTimeout
response = { status: false }
end
@@ -149,10 +153,12 @@ end
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
+ card_no = customer_params[:card_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
if id.nil? && !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
@@ -160,16 +166,17 @@ end
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
- response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
- dob: dob,address: address,nrc:nrc,
- member_group_id: member_group_id,
- merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
- :headers => {
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json'
+ response = HTTParty.post(url,
+ :body => { name: name,phone: phone,email: email,
+ dob: dob,address: address,nrc:nrc,
+ card_no:card_no,member_group_id: member_group_id,
+ merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
},
- :timeout => 10
- )
+ :timeout => 10
+ )
rescue Net::OpenTimeout
response = { status: false }
end
@@ -185,20 +192,22 @@ end
end
else
+
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_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
begin
- response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
- dob: dob,address: address,nrc:nrc,
- id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
- :headers => {
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json'
+ response = HTTParty.post(url,
+ :body => {name: name,phone: phone,email: email,
+ dob: dob,address: address,nrc:nrc,card_no:card_no,
+ id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
},
- :timeout => 10
+ :timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb
index dbcc4046..b4f902fc 100644
--- a/app/controllers/crm/dining_queues_controller.rb
+++ b/app/controllers/crm/dining_queues_controller.rb
@@ -1,4 +1,5 @@
class Crm::DiningQueuesController < BaseCrmController
+ load_and_authorize_resource
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
# GET /crm/dining_queues
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 29e9082a..f480b95f 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -18,6 +18,12 @@ class HomeController < ApplicationController
elsif @employee.role == "cashier"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
+ elsif @employee.role == "manager"
+ session[:session_token] = @employee.token_session
+ redirect_to dashboard_path
+ elsif @employee.role == "accountant"
+ session[:session_token] = @employee.token_session
+ redirect_to dashboard_path
else
render :index
end
diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb
new file mode 100644
index 00000000..d2236caa
--- /dev/null
+++ b/app/controllers/oqs/edit_controller.rb
@@ -0,0 +1,18 @@
+class Oqs::EditController < BaseOqsController
+ def index
+ assigned_item_id = params[:id]
+ assigned_item = AssignedOrderItem.find(assigned_item_id)
+ @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_code='#{ assigned_item.item_code }'");
+ end
+
+ def update
+ order_items_id = params[:order_items_id]
+ qty_weight = params[:qty_weight]
+ remarks = params[:remarks]
+
+ order_item = OrderItem.find(order_items_id);
+ order_item.qty = qty_weight
+ order_item.remark = remarks
+ order_item.save
+ end
+end
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index 64fd840d..692b9c4a 100644
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -109,7 +109,7 @@ class Oqs::HomeController < BaseOqsController
# queue_items.push(queue_item)
# end
# return queue_items
- AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
@@ -118,6 +118,6 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status}")
- .group("odt.order_items_id")
+ .group("assigned_order_items.assigned_order_item_id")
end
end
diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb
index a348951e..ff9ae413 100644
--- a/app/controllers/origami/credit_payments_controller.rb
+++ b/app/controllers/origami/credit_payments_controller.rb
@@ -2,9 +2,31 @@ class Origami::CreditPaymentsController < BaseOrigamiController
def index
+ @sale_id = params[:sale_id]
+
+ # limit visa_amount
+ sale_data = Sale.find_by_sale_id(@sale_id)
+ total = sale_data.grand_total
+ @creditcount = 0
+ others = 0
+ sale_data.sale_payments.each do |sale_payment|
+ if sale_payment.payment_method == "visa"
+ @creditcount = @creditcount + sale_payment.payment_amount
+ else
+ others = others + sale_payment.payment_amount
+ end
+ end
+ @can_credit = total - @creditcount - others
end
def create
+ cash = params[:amount]
+ sale_id = params[:sale_id]
+ if(Sale.exists?(sale_id))
+ saleObj = Sale.find(sale_id)
+ sale_payment = SalePayment.new
+ @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "creditnote")
+ end
end
end
diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb
index f15b8545..e8376fc4 100644
--- a/app/controllers/origami/customers_controller.rb
+++ b/app/controllers/origami/customers_controller.rb
@@ -1,8 +1,6 @@
class Origami::CustomersController < BaseOrigamiController
- #Form to add customer -
+ load_and_authorize_resource
def index
-
-
end
# GET /crm/customers/1
@@ -54,6 +52,10 @@ class Origami::CustomersController < BaseOrigamiController
if(id == "SAL")
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: params[:customer_id])
+ sale.sale_orders.each do |sale_order|
+ order = Order.find(sale_order.order_id)
+ status = order.update_attributes(customer_id: params[:customer_id])
+ end
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb
index 73038556..463f6dc6 100644
--- a/app/controllers/origami/discounts_controller.rb
+++ b/app/controllers/origami/discounts_controller.rb
@@ -1,4 +1,5 @@
class Origami::DiscountsController < BaseOrigamiController
+ authorize_resource :class => false
#discount page show from origami index with selected order
def index
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 3f70ad01..1b0aa491 100644
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -35,7 +35,7 @@ class Origami::HomeController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
- if sale.sale_status != "completed"
+ if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb
index c51fcbb1..ef1c286a 100644
--- a/app/controllers/origami/moveroom_controller.rb
+++ b/app/controllers/origami/moveroom_controller.rb
@@ -1,5 +1,7 @@
class Origami::MoveroomController < BaseOrigamiController
-
+
+ authorize_resource :class => false
+
def move_dining
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb
index 461f8694..50f2c774 100644
--- a/app/controllers/origami/movetable_controller.rb
+++ b/app/controllers/origami/movetable_controller.rb
@@ -1,4 +1,6 @@
class Origami::MovetableController < BaseOrigamiController
+
+ authorize_resource :class => false
def move_dining
@tables = Table.all.active.order('status desc')
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 0119953f..f5a0023e 100644
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -1,6 +1,6 @@
class Origami::PaymentsController < BaseOrigamiController
-
+ authorize_resource :class => false
def index
end
@@ -17,6 +17,8 @@ class Origami::PaymentsController < BaseOrigamiController
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
rebate_amount = Customer.get_membership_transactions(customer)
+ #shop detail
+ shop_details = Shop.find(1)
# get member information
member_info = Customer.get_member_account(customer)
@@ -26,7 +28,7 @@ class Origami::PaymentsController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
- printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
+ printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
end
end
@@ -39,6 +41,7 @@ class Origami::PaymentsController < BaseOrigamiController
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
+ @credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@@ -51,8 +54,8 @@ class Origami::PaymentsController < BaseOrigamiController
@accountable_type = ''
if response["status"]==true
response["data"].each do |res|
- if res["accountable_type"] == "RebateAccount"
- @balance = res["balance"]
+ if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
+ @balance += res["balance"]
# @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end
@@ -75,6 +78,8 @@ class Origami::PaymentsController < BaseOrigamiController
@jcbcount += spay.payment_amount
elsif spay.payment_method == "master"
@mastercount += spay.payment_amount
+ elsif spay.payment_method == "creditnote"
+ @credit += spay.payment_amount
end
end
end
@@ -89,6 +94,8 @@ class Origami::PaymentsController < BaseOrigamiController
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
+ #shop detail
+ shop_details = Shop.find(1)
# get member information
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer)
@@ -99,7 +106,7 @@ class Origami::PaymentsController < BaseOrigamiController
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
- printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
+ printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
end
diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb
index 95f63e58..314835a2 100644
--- a/app/controllers/origami/request_bills_controller.rb
+++ b/app/controllers/origami/request_bills_controller.rb
@@ -1,4 +1,5 @@
class Origami::RequestBillsController < BaseOrigamiController
+
# Print Request Bill and add to sale tables
def print
@sale = Sale.new
@@ -20,8 +21,9 @@ class Origami::RequestBillsController < BaseOrigamiController
end
unique_code = "ReceiptBillPdf"
+ #shop detail
+ shop_details = Shop.find(1)
# customer= Customer.where('customer_id=' +.customer_id)
-
customer= Customer.find(@sale_data.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
@@ -36,7 +38,7 @@ class Origami::RequestBillsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
- printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info)
+ printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
# redirect_to origami_path(@sale_data.sale_id)
end
diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb
new file mode 100644
index 00000000..8d805771
--- /dev/null
+++ b/app/controllers/origami/room_invoices_controller.rb
@@ -0,0 +1,40 @@
+class Origami::RoomInvoicesController < BaseOrigamiController
+ def index
+ @room = DiningFacility.find(params[:room_id])
+ puts "room bookig lenght"
+ @sale_array = Array.new
+ @room.bookings.each do |booking|
+ puts booking.sale_id
+
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+ end
+
+ def show
+ @room = DiningFacility.find(params[:room_id])
+ @sale_array = Array.new
+ @room.bookings.each do |booking|
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+
+ @sale = Sale.find(params[:invoice_id])
+ @date = @sale.created_at
+ @status_sale = 'sale'
+ @customer = @sale.customer
+ end
+
+end
diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb
index 88cdf315..70a5a380 100644
--- a/app/controllers/origami/sale_edit_controller.rb
+++ b/app/controllers/origami/sale_edit_controller.rb
@@ -1,11 +1,13 @@
class Origami::SaleEditController < BaseOrigamiController
+ # Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
end
+ # create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
@@ -19,4 +21,38 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.product_name = saleitemObj.product_name + " - void"
@newsaleitem.save
end
+
+ # make cancel void item
+ def item_void_cancel
+ saleitemId = params[:sale_item_id]
+ saleitemObj = SaleItem.find(saleitemId)
+ both = SaleItem.where('product_code=?',saleitemObj.product_code)
+ both.each do |item|
+ if item.qty.to_i > 0
+ item.remark = nil
+ item.save
+ end
+ end
+ saleitemObj.destroy
+ end
+
+ # remove all void items
+ def cancel_all_void
+ sale_id = params[:sale_id]
+ saleobj = Sale.find(sale_id)
+ saleobj.sale_items.each do |item|
+ if item.qty.to_i < 0
+ item.destroy
+ else
+ item.remark = nil
+ end
+ item.save
+ end
+ end
+
+ def apply_void
+ sale_id = params[:sale_id]
+ saleObj = Sale.find(sale_id)
+ saleObj.compute_without_void
+ end
end
diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb
new file mode 100644
index 00000000..32e0ef7f
--- /dev/null
+++ b/app/controllers/origami/table_invoices_controller.rb
@@ -0,0 +1,40 @@
+class Origami::TableInvoicesController < BaseOrigamiController
+ def index
+ @table = DiningFacility.find(params[:table_id])
+ puts "table bookig lenght"
+ @sale_array = Array.new
+ @table.bookings.each do |booking|
+ puts booking.sale_id
+
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+ end
+
+ def show
+ @table = DiningFacility.find(params[:table_id])
+ @sale_array = Array.new
+ @table.bookings.each do |booking|
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+
+ @sale = Sale.find(params[:invoice_id])
+ @date = @sale.created_at
+ @status_sale = 'sale'
+ @customer = @sale.customer
+ end
+
+end
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
new file mode 100644
index 00000000..bea37a21
--- /dev/null
+++ b/app/controllers/origami/void_controller.rb
@@ -0,0 +1,28 @@
+class Origami::VoidController < BaseOrigamiController
+
+ def overall_void
+
+ sale_id = params[:sale_id]
+ if Sale.exists?(sale_id)
+ sale = Sale.find_by_sale_id(sale_id)
+ sale.payment_status = 'void'
+ sale.sale_status = 'void'
+ sale.save
+
+ table_avaliable = true
+ table = sale.bookings[0].dining_facility
+ table.bookings.each do |booking|
+ if booking.sale.sale_status == 'new'
+ table_avaliable = false
+ end
+ end
+
+ if table_avaliable == true
+ table.status = 'available'
+ table.save
+ end
+
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb
index fa5af7e8..bdd3061a 100644
--- a/app/controllers/print_settings_controller.rb
+++ b/app/controllers/print_settings_controller.rb
@@ -1,4 +1,5 @@
class PrintSettingsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_print_setting, only: [:show, :edit, :update, :destroy]
# GET /print_settings
diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/bksale_items_controller.rb
similarity index 74%
rename from app/controllers/reports/sale_item_controller.rb
rename to app/controllers/reports/bksale_items_controller.rb
index eb7d3b86..1f349320 100644
--- a/app/controllers/reports/sale_item_controller.rb
+++ b/app/controllers/reports/bksale_items_controller.rb
@@ -1,5 +1,5 @@
-class Reports::SaleItemController < BaseReportController
-
+class Reports::SaleItemsController < BaseReportController
+ authorize_resource :class => false
def index
from, to, report_type = get_date_range_from_params
diff --git a/app/controllers/reports/daily_sales_controller.rb b/app/controllers/reports/daily_sales_controller.rb
new file mode 100644
index 00000000..6d99551d
--- /dev/null
+++ b/app/controllers/reports/daily_sales_controller.rb
@@ -0,0 +1,17 @@
+class Reports::DailySalesController < BaseReportController
+ # authorize_resource :class => false
+ def index
+ from, to ,report_type = get_date_range_from_params
+ @sale_data = Sale.daily_sales_list(from,to)
+ @tax = SaleTax.get_tax(from,to)
+ respond_to do |format|
+ format.html
+ format.xls
+ end
+ end
+
+ def show
+
+ end
+
+end
\ No newline at end of file
diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_salesbk_controller.rb
similarity index 72%
rename from app/controllers/reports/daily_sale_controller.rb
rename to app/controllers/reports/daily_salesbk_controller.rb
index ba453f55..1a878aaa 100644
--- a/app/controllers/reports/daily_sale_controller.rb
+++ b/app/controllers/reports/daily_salesbk_controller.rb
@@ -1,5 +1,5 @@
-class Reports::DailySaleController < BaseReportController
-
+class Reports::DailySalesController < BaseReportController
+ authorize_resource :class => false
def index
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
diff --git a/app/controllers/reports/sale_items_controller.rb b/app/controllers/reports/sale_items_controller.rb
new file mode 100644
index 00000000..81f7af01
--- /dev/null
+++ b/app/controllers/reports/sale_items_controller.rb
@@ -0,0 +1,19 @@
+class Reports::SaleItemsController < BaseReportController
+ # authorize_resource :class => false
+ def index
+
+ from, to, report_type = get_date_range_from_params
+
+ @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
+
+ respond_to do |format|
+ format.html
+ format.xls
+ end
+ end
+
+ def show
+
+ end
+
+end
\ No newline at end of file
diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb
index 90e6a304..54f27480 100644
--- a/app/controllers/settings/accounts_controller.rb
+++ b/app/controllers/settings/accounts_controller.rb
@@ -1,4 +1,5 @@
class Settings::AccountsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_account, only: [:show, :edit, :update, :destroy]
# GET /settings/accounts
diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb
index b397d68d..0808c0a7 100644
--- a/app/controllers/settings/cashier_terminals_controller.rb
+++ b/app/controllers/settings/cashier_terminals_controller.rb
@@ -1,4 +1,5 @@
class Settings::CashierTerminalsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_cashier_terminal, only: [:show, :edit, :update, :destroy]
# GET /settings/cashier_terminals
diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb
index dc7093f3..07656470 100644
--- a/app/controllers/settings/employees_controller.rb
+++ b/app/controllers/settings/employees_controller.rb
@@ -1,5 +1,5 @@
class Settings::EmployeesController < ApplicationController
- # load_and_authorize_resource
+ load_and_authorize_resource
before_action :set_employee, only: [:show, :edit, :update, :destroy]
diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb
index ad7311f2..f386aecd 100644
--- a/app/controllers/settings/membership_actions_controller.rb
+++ b/app/controllers/settings/membership_actions_controller.rb
@@ -1,4 +1,5 @@
class Settings::MembershipActionsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy]
# GET /settings/membership_actions
diff --git a/app/controllers/settings/membership_settings_controller.rb b/app/controllers/settings/membership_settings_controller.rb
index cfd672d0..36bb0092 100644
--- a/app/controllers/settings/membership_settings_controller.rb
+++ b/app/controllers/settings/membership_settings_controller.rb
@@ -1,4 +1,5 @@
class Settings::MembershipSettingsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_membership_setting, only: [:show, :edit, :update, :destroy]
# GET /settings/membership_settings
diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb
index c2a521ae..8ca9cfb4 100644
--- a/app/controllers/settings/menu_categories_controller.rb
+++ b/app/controllers/settings/menu_categories_controller.rb
@@ -1,4 +1,5 @@
class Settings::MenuCategoriesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_menu_category, only: [:show, :edit, :update, :destroy]
before_action :set_settings_menu, only: [:new]
diff --git a/app/controllers/settings/menu_item_attributes_controller.rb b/app/controllers/settings/menu_item_attributes_controller.rb
index 1433cf34..162325a2 100644
--- a/app/controllers/settings/menu_item_attributes_controller.rb
+++ b/app/controllers/settings/menu_item_attributes_controller.rb
@@ -1,4 +1,5 @@
class Settings::MenuItemAttributesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_menu_item_attribute, only: [:show, :edit, :update, :destroy]
# GET /settings/menu_item_attributes
diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb
index 2b1fcecf..fd651e5e 100644
--- a/app/controllers/settings/menu_item_instances_controller.rb
+++ b/app/controllers/settings/menu_item_instances_controller.rb
@@ -1,4 +1,5 @@
class Settings::MenuItemInstancesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy]
before_action :set_settings_menu_item, only: [ :show, :edit, :new, :update]
diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb
index 4a3a44b7..41679796 100644
--- a/app/controllers/settings/menu_item_options_controller.rb
+++ b/app/controllers/settings/menu_item_options_controller.rb
@@ -1,4 +1,5 @@
class Settings::MenuItemOptionsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_menu_item_option, only: [:show, :edit, :update, :destroy]
# GET /settings/menu_item_options
diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb
index fa6ac158..1a5ada31 100644
--- a/app/controllers/settings/menus_controller.rb
+++ b/app/controllers/settings/menus_controller.rb
@@ -1,4 +1,5 @@
class Settings::MenusController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_menu, only: [:show, :edit, :update, :destroy]
# GET /settings/menus
diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb
index 5a540ddb..9fe78de4 100644
--- a/app/controllers/settings/order_queue_stations_controller.rb
+++ b/app/controllers/settings/order_queue_stations_controller.rb
@@ -1,4 +1,5 @@
class Settings::OrderQueueStationsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy]
# GET /settings/order_queue_stations
diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb
index f3ac595e..ecbbcced 100644
--- a/app/controllers/settings/payment_method_settings_controller.rb
+++ b/app/controllers/settings/payment_method_settings_controller.rb
@@ -1,4 +1,5 @@
class Settings::PaymentMethodSettingsController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_payment_method_setting, only: [:show, :edit, :update, :destroy]
# GET /settings/payment_method_settings
diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb
index 1064055b..992f637a 100644
--- a/app/controllers/settings/tax_profiles_controller.rb
+++ b/app/controllers/settings/tax_profiles_controller.rb
@@ -1,4 +1,5 @@
class Settings::TaxProfilesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_tax_profile, only: [:show, :edit, :update, :destroy]
# GET /settings/tax_profiles
diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb
index 08a6f189..49505854 100644
--- a/app/controllers/settings/zones_controller.rb
+++ b/app/controllers/settings/zones_controller.rb
@@ -1,4 +1,5 @@
class Settings::ZonesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_settings_zone, only: [:show, :edit, :update, :destroy]
# GET /settings/zones
diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb
new file mode 100644
index 00000000..0f370c96
--- /dev/null
+++ b/app/controllers/transactions/credit_notes_controller.rb
@@ -0,0 +1,18 @@
+class Transactions::CreditNotesController < ApplicationController
+ before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
+
+ # GET /transactions/sales
+ # GET /transactions/sales.json
+ def index
+
+ @sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
+
+
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @sales }
+ end
+
+ end
+ end
\ No newline at end of file
diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb
index 35cefe6f..8303780f 100644
--- a/app/controllers/transactions/orders_controller.rb
+++ b/app/controllers/transactions/orders_controller.rb
@@ -1,4 +1,5 @@
class Transactions::OrdersController < ApplicationController
+ load_and_authorize_resource except: [:create]
def index
filter = params[:filter]
diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb
index 54432c38..19803c0d 100644
--- a/app/controllers/transactions/sales_controller.rb
+++ b/app/controllers/transactions/sales_controller.rb
@@ -1,4 +1,5 @@
class Transactions::SalesController < ApplicationController
+ load_and_authorize_resource except: [:create]
before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy]
# GET /transactions/sales
diff --git a/app/helpers/reports/daily_sales_helper.rb b/app/helpers/reports/daily_sales_helper.rb
new file mode 100644
index 00000000..eb04c7b9
--- /dev/null
+++ b/app/helpers/reports/daily_sales_helper.rb
@@ -0,0 +1,2 @@
+module Reports::DailySalesHelper
+end
diff --git a/app/helpers/reports/dailysales_helper.rb b/app/helpers/reports/dailysales_helper.rb
new file mode 100644
index 00000000..94e34c27
--- /dev/null
+++ b/app/helpers/reports/dailysales_helper.rb
@@ -0,0 +1,2 @@
+module Reports::DailysalesHelper
+end
diff --git a/app/helpers/reports/sale_items_helper.rb b/app/helpers/reports/sale_items_helper.rb
new file mode 100644
index 00000000..63e884d7
--- /dev/null
+++ b/app/helpers/reports/sale_items_helper.rb
@@ -0,0 +1,2 @@
+module Reports::SaleItemsHelper
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 2b28ab61..5e5fb4f3 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -4,30 +4,84 @@ class Ability
def initialize(user)
user ||= Employee.new
- if user.role? :administrator
+ if user.role == "administrator"
can :manage, :all
- elsif user.role? :cashier
- can :read, Order
- can :update, Order
- can :completed_order_item, Order
+ elsif user.role == "manager"
+
+ can :manage, Menu
+ can :manage, MenuCategory
+ can :manage, MenuItemAttribute
+ can :manage, MenuItemInstance
+ can :manage, MenuItemOption
+ can :manage, SetMenuItem
+ can :manage, OrderQueueStation
+ can :manage, Zone
+ can :manage, CashierTerminal
+ can :manage, Employee
+ # can :manage, MembershipSetting
+ # can :manage, MembershipAction
+ # can :manage, PaymentMethodSetting
+ can :manage, TaxProfile
+ can :manage, PrintSetting
+ can :manage, Account
+
+ can :manage, Order
+ can :manage, Sale
+
+ can :manage, Customer
+
+ can :index, :dailysale
+ can :index, :saleitem
+
+ can :add_customer, Customer
+ can :update_sale_by_customer, Customer
+
+ can :index, :discount
+ can :create, :discount
+
+ can :show, :payment
+ can :create, :payment
+ can :reprint, :payment
+
+ can :move_dining, :movetable
+ can :moving, :movetable
+
+ can :move_dining, :moveroom
+
+ elsif user.role == "cashier"
+
+ can :read, Order
+ can :update, Order
- can :read, Sale
- can :update, Sale
+ can :read, Sale
+ can :update, Sale
+ can :add_customer, Customer
+ can :update_sale_by_customer, Customer
+
+ can :index, :discount
+ can :create, :discount
+
+ can :show, :payment
+ can :create, :payment
+ can :reprint, :payment
+
+ can :move_dining, :movetable
+ can :moving, :movetable
+
+ can :move_dining, :moveroom
- elsif user.role? :accountant
+ elsif user.role == "accountant"
- can :read, Order
- can :update, Order
- can :completed_order_item, Order
-
- can :read, Sale
- can :update, Sale
- can :manual_complete_sale, Sale
+ can :index, :dailysale
+ can :index, :saleitem
+ can :index, :receiptno
+ can :show, :dailysale
+ can :show, :saleitem
+ can :show, :receiptno
end
-
end
-end
\ No newline at end of file
+end
diff --git a/app/models/order.rb b/app/models/order.rb
index 78585b52..018013e4 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -27,7 +27,7 @@ class Order < ApplicationRecord
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
- :checkin_at => Time.now.utc, :checkin_by => self.employee_name,
+ :checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name,
:booking_status => "assign" })
table = DiningFacility.find(self.table_id)
table.status = "occupied"
diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb
index 04619379..bd2e85ca 100644
--- a/app/models/order_queue_station.rb
+++ b/app/models/order_queue_station.rb
@@ -22,7 +22,8 @@ class OrderQueueStation < ApplicationRecord
#Assign OQS id to order Items
oqs_stations.each do |oqs|
- is_auto_printed = false
+ is_auto_printed = false
+ oqs_order_items = []
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
@@ -37,15 +38,18 @@ class OrderQueueStation < ApplicationRecord
# else
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
- # end
-
- # Auto Printing
- if oqs.auto_print && is_auto_printed == false
- print_slip(oqs, order, order_items)
- is_auto_printed = true
- end
+ oqs_order_items.push(order_item)
+ # end
end
end
+ end
+ # Auto Printing
+ # ToDo per item per printer
+ if oqs.auto_print && is_auto_printed == false
+ if oqs_order_items.length > 0
+ print_slip(oqs, order, oqs_order_items)
+ is_auto_printed = true
+ end
end
end
end
@@ -57,7 +61,7 @@ class OrderQueueStation < ApplicationRecord
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
- order_queue_printer.print_order_summary(oqs,order.order_id, print_status="")
+ order_queue_printer.print_order_summary(oqs,order.order_id, order_items, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb
index f8fb5027..bbeafecf 100644
--- a/app/models/printer/order_queue_printer.rb
+++ b/app/models/printer/order_queue_printer.rb
@@ -22,14 +22,14 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# Query for per order
- def print_order_summary(oqs, order_id, print_status)
+ def print_order_summary(oqs, order_id, order_items, print_status)
#Use CUPS service
#Generate PDF
- #Print
+ #Print
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
- order.each do|odi|
+ order_items.each do|odi|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
# For Item Options
options = odi.options == "[]"? "" : odi.options
@@ -46,7 +46,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Order Summary
else
filename = "tmp/order_summary_#{ order_id }" + ".pdf"
- pdf = OrderSummaryPdf.new(order, print_status)
+ pdf = OrderSummaryPdf.new(order, print_status, order_items)
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
@@ -103,7 +103,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Query for OQS with status
def print_query(type, id)
if type == "order_item"
- OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
+ OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
@@ -112,7 +112,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
.where("order_items.item_code = '#{ id }'")
.group("order_items.item_code")
elsif type == "order_summary"
- OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
+ OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
@@ -122,7 +122,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
.group("order_items.order_items_id")
else
# order summary for booking
- OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
+ OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb
index 4b7287db..8e389e79 100644
--- a/app/models/printer/receipt_printer.rb
+++ b/app/models/printer/receipt_printer.rb
@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
- def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil)
+ def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
#Use CUPS service
#Generate PDF
#Print
- pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount)
+ pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf")
diff --git a/app/models/sale.rb b/app/models/sale.rb
index f79d8642..8f7f17d8 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -21,9 +21,9 @@ class Sale < ApplicationRecord
"daily" => 0,
"monthly" => 1,
"yearly" => 2
- }
-
- SALE_STATUS_COMPLETED = "completed"
+ }
+ SALE_STATUS_OUTSTANDING = "outstanding"
+ SALE_STATUS_COMPLETED = "completed"
def generate_invoice_from_booking(booking_id, requested_by)
booking = Booking.find(booking_id)
@@ -98,7 +98,7 @@ class Sale < ApplicationRecord
order.save
booking.sale_id = self.id
- booking.checkout_at = Time.now.utc
+ booking.checkout_at = Time.now.utc.getlocal
booking.checkout_by = requested_by.name
booking.save
@@ -115,7 +115,7 @@ class Sale < ApplicationRecord
def generate_invoice_by_items (items, requested_by)
taxable = true
self.requested_by = requested_by
- self.requested_at = DateTime.now.utc
+ self.requested_at = DateTime.now.utc.getlocal
items.each do |item|
add_item(item)
@@ -185,7 +185,7 @@ class Sale < ApplicationRecord
sales_items.each do |item|
#compute each item and added to total
subtotal_price = subtotal_price + item.price
- total_taxable = total_taxable + item.taxable_price
+ total_taxable = total_taxable + (item.taxable_price * item.qty)
end
apply_tax (total_taxable)
@@ -199,6 +199,31 @@ class Sale < ApplicationRecord
end
+ def compute_without_void
+ sales_items = self.sale_items
+
+ #Computation Fields
+ subtotal_price = 0
+ total_taxable = 0
+ rounding_adjustment = 0
+
+ sales_items.each do |item|
+ if item.remark != 'void'
+ #compute each item and added to total
+ subtotal_price = subtotal_price + item.price
+ total_taxable = total_taxable + item.taxable_price
+ end
+ end
+
+ apply_tax (total_taxable)
+ self.total_amount = subtotal_price
+ self.total_discount = total_discount
+ self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
+ #compute rounding adjustment
+ adjust_rounding
+
+ self.save!
+ end
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record
@@ -354,28 +379,28 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
mc.name as menu_category_name,
mc.id as menu_category_id ")
.group('mi.id')
- .order("mi.menu_category_id")
-
- query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
- JOIN menu_items mi ON i.product_code = mi.item_code" +
- " JOIN menu_categories mc ON mc.id = mi.menu_category_id
+ .order("mi.menu_category_id")
+
+ query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
+ JOIN menu_items mi ON i.product_code = mi.item_code" +
+ " JOIN menu_categories mc ON mc.id = mi.menu_category_id
JOIN employees ea ON ea.id = sales.cashier_id")
-
+
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
-
+
case report_type.to_i
when REPORT_TYPE["daily"]
return query
when REPORT_TYPE["monthly"]
-
- return query.group("MONTH(date)")
+
+ return query.group("MONTH(date)")
when REPORT_TYPE["yearly"]
- return query.group("YEAR(date)")
+ return query.group("YEAR(date)")
end
-
+
end
private
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 950334cb..e4ad5364 100644
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -9,7 +9,6 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
def process_payment(invoice, action_by, cash_amount, payment_method)
-
self.sale = invoice
self.received_amount = cash_amount
amount_due = invoice.grand_total
@@ -28,7 +27,7 @@ class SalePayment < ApplicationRecord
when "cash"
payment_status = cash_payment
when "creditnote"
- if !self.customer_id.nil?
+ if !self.sale.customer_id.nil?
payment_status = creditnote_payment(self.customer_id)
end
when "visa"
@@ -54,7 +53,7 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
-
+
return true, self.save
else
#record an payment in sale-audit
@@ -94,10 +93,15 @@ class SalePayment < ApplicationRecord
sale_data = Sale.find_by_sale_id(sale_id)
if sale_data
+ others = 0
+ sale_data.sale_payments.each do |sale_payment|
+ others = others + sale_payment.payment_amount
+ end
+ redeem_prices = sale_data.grand_total -others
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
- :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
+ :body => { generic_customer_id:membership_id,total_amount: redeem_prices,total_sale_transaction_amount: sale_data.grand_total,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -137,7 +141,7 @@ class SalePayment < ApplicationRecord
self.payment_method = "creditnote"
self.payment_amount = self.received_amount
self.customer_id = self.customer_id
- self.outstanding_amount = 0 - self.received_amount
+ self.outstanding_amount = 0 - self.received_amount.to_f
self.payment_status = "outstanding"
payment_method = self.save!
@@ -202,10 +206,7 @@ class SalePayment < ApplicationRecord
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
- puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm'
- puts membership_data.to_json
- puts "amountttttttttttttttttttttt"
- puts self.received_amount
+
if membership_data["status"]==true
self.payment_method = "paypar"
self.payment_amount = self.received_amount
@@ -266,8 +267,7 @@ class SalePayment < ApplicationRecord
def rebat(sObj)
rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items)
- puts "eeeeeeeeeeeeeeeeeeeeeeee"
- puts rebate_prices
+
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments
@@ -292,7 +292,7 @@ class SalePayment < ApplicationRecord
# Control for Paypar Cloud
begin
- response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
+ response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
receipt_no: receipt_no,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb
index 4b7559b1..6d6346f9 100644
--- a/app/pdf/order_item_pdf.rb
+++ b/app/pdf/order_item_pdf.rb
@@ -18,24 +18,29 @@ class OrderItemPdf < Prawn::Document
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
- self.header_font_size = 14
- self.item_font_size = 12
+ self.header_font_size = 12
+ self.item_font_size = 10
- text "#{ order_item.dining+print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
+ text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
#order_info
- order_info(order_item.order_by,order_item.order_at)
+ order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
order_items(order_item, options)
end
# Write Order Information to PDF
- def order_info(order_by, order_at)
+ def order_info(order_no, order_by, order_at)
y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ end
+ move_down 5
+ y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
@@ -43,7 +48,7 @@ class OrderItemPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb
index 176749b8..d85a5916 100644
--- a/app/pdf/order_summary_pdf.rb
+++ b/app/pdf/order_summary_pdf.rb
@@ -1,6 +1,6 @@
class OrderSummaryPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
- def initialize(order, print_status)
+ def initialize(order, print_status, order_items = nil)
self.page_width = 210
self.page_height = 1450
self.margin = 5
@@ -20,22 +20,30 @@ class OrderSummaryPdf < Prawn::Document
self.header_font_size = 12
self.item_font_size = 10
- text "#{ order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
+ text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule
move_down 5
#order_info
- order_info(order[0].order_by,order[0].order_at)
+ order_info(order[0].order_id, order[0].order_by,order[0].order_at)
# order items
- order_items(order)
-
+ if order_items == nil
+ order_items(order)
+ else
+ order_items(order_items)
+ end
end
# Write Order Information to PDF
- def order_info(order_by, order_at)
+ def order_info(order_no, order_by, order_at)
y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
+ end
+ move_down 5
+ y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
@@ -43,7 +51,7 @@ class OrderSummaryPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
- text "Date: #{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
+ text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
@@ -68,6 +76,7 @@ class OrderSummaryPdf < Prawn::Document
#Add Order Item
add_order_items(order_item)
+
end
# Add order items under order info
@@ -84,11 +93,11 @@ class OrderSummaryPdf < Prawn::Document
# text_box "#{odi.qty}", :at =>[self.item_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
# }
bounding_box([0,y_position], :width => self.item_width) do
- text "#{odi.item_name}", :size => self.item_font_size,:align => :left, :height => self.item_height
+ text "#{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
- text "#{odi.qty}", :size => self.item_font_size,:align => :left, :height => self.item_height
+ text "#{odi.qty}", :size => self.item_font_size,:align => :left
end
move_down 5
@@ -104,6 +113,10 @@ class OrderSummaryPdf < Prawn::Document
move_down 5
end
+
+ dash(1, :space => 1, :phase => 1)
+ stroke_horizontal_line 0, (self.page_width - self.margin)
+ move_down 5
end
end
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 96e16cf4..b156e2c2 100644
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -1,6 +1,6 @@
class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
- def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil)
+ def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
self.page_width = 210
self.page_height = 2500
self.margin = 5
@@ -24,13 +24,12 @@ class ReceiptBillPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
- header( "Beauty In the Pot", printer_settings.name)
+ header( shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name)
line_items(sale_items)
- items_account(item_price_by_accounts)
all_total(sale_data)
@@ -39,16 +38,21 @@ class ReceiptBillPdf < Prawn::Document
end
customer(customer_name)
+
+ items_account(item_price_by_accounts)
footer
end
- def header (printer_name, name)
- text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
+ def header (shop_details)
+ move_down 7
+ text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
- text "#{name}", :size => self.header_font_size,:align => :center
+ text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 5
+ text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
+ move_down 5
stroke_horizontal_rule
end
@@ -61,19 +65,10 @@ class ReceiptBillPdf < Prawn::Document
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
+ text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
end
move_down 5
- # y_position = cursor
- # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
- # text "Customer:", :size => self.item_font_size,:align => :left
- # end
- # bounding_box([self.label_width,y_position], :width =>self.item_width) do
- # text "#{customer_name}" , :size => self.item_font_size,:align => :left
- # end
- # move_down 5
-
y_position = cursor
bounding_box([0, y_position], :width =>self.item_width) do
text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
@@ -86,27 +81,26 @@ class ReceiptBillPdf < Prawn::Document
end
move_down 5
- # bounding_box([self.label_width,y_position], :width =>self.item_width) do
- # text "#{customer_name}" , :size => self.item_font_size,:align => :left
- # end
- # move_down 5
-
y_position = cursor
- bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
- text "Time In: #{ sale_data.bookings[0].checkin_at.strftime('%I:%M %p') }", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "Time Out: #{ sale_data.bookings[0].checkout_at.strftime('%I:%M %p') }" , :size => self.item_font_size,:align => :right
+ bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
+ text "Receipt Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left
end
+
+ # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
+ # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
+ # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
+ # :size => self.item_font_size,:align => :right
+ # end
+
move_down 5
stroke_horizontal_rule
- move_down 5
end
def line_items(sale_items)
+ move_down 5
y_position = cursor
-
+ move_down 5
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
@@ -114,10 +108,8 @@ class ReceiptBillPdf < Prawn::Document
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
-
- move_down 5
+ move_down -5
stroke_horizontal_rule
-
add_line_item_row(sale_items)
end
@@ -142,7 +134,7 @@ class ReceiptBillPdf < Prawn::Document
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
- move_down 3
+ move_down 1
end
stroke_horizontal_rule
@@ -158,20 +150,6 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
- def items_account(item_price_by_accounts)
- y_position = cursor
- item_price_by_accounts.each do |ipa|
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right
- end
- move_down 5
- end
- end
-
def all_total(sale_data)
item_name_width = self.item_width
y_position = cursor
@@ -267,7 +245,7 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Rebate Amount", :size => self.item_font_size,:align => :left
+ text "Current Rebate Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right
@@ -278,10 +256,10 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Redeem Amount", :size => self.item_font_size,:align => :left
+ text "Current Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right
+ text "(#{ res["redeem"] })" , :size => self.item_font_size,:align => :right
end
end
@@ -289,22 +267,23 @@ class ReceiptBillPdf < Prawn::Document
end
end
if member_info["status"] == true
+ balance = 0.0
member_info["data"].each do |res|
- if res["accountable_type"]== "RebateAccount"
-
- move_down 5
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "Current Balance", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
- end
+ if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
+ balance = balance + res["balance"]
end
end
+ move_down 5
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "Current Balance", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
+ text "#{ balance }" , :size => self.item_font_size,:align => :right
+ end
end
end
@@ -317,7 +296,23 @@ class ReceiptBillPdf < Prawn::Document
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
- end
+ end
+ end
+
+ def items_account(item_price_by_accounts)
+ move_down 5
+ stroke_horizontal_rule
+ move_down 5
+ y_position = cursor
+ item_price_by_accounts.each do |ipa|
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
+ text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right
+ end
+ end
end
def footer
@@ -331,3 +326,4 @@ class ReceiptBillPdf < Prawn::Document
end
end
+
diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb
index eb121c14..d52c0456 100644
--- a/app/views/crm/customers/_new_form.html.erb
+++ b/app/views/crm/customers/_new_form.html.erb
@@ -11,24 +11,20 @@
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
- <%= str %>
+ <%= str %>
<% end -%>
-
-
-
-
+
+ <%= f.radio_button :salutation,"Mr", :class => "salutation mr", :value=>"Mr", :style=>"width: 30px"%>
+
+ <%= f.radio_button :salutation,"Mrs", :class => "salutation mrs", :value=>"Mrs", :style=>"width: 30px"%>
+
+ <%= f.radio_button :salutation,"Miss", :class => "salutation miss", :value=>"Miss", :style=>"width: 30px"%>
+
+ <%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
">
@@ -37,18 +33,16 @@
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
- <%= str %>
+ <%= str %>
<% end -%>
-
-
+
+ <%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male", :style=>"width: 30px"%>
+
+ <%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female", :style=>"width: 30px"%>
@@ -62,7 +56,7 @@
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
- <%= str %>
+ <%= str %>
<% end -%>
">
@@ -72,7 +66,7 @@
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
- <%= str %>
+ <%= str %>
<% end -%>
@@ -83,7 +77,7 @@
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
- <%= str %>
+ <%= str %>
<% end -%>
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb
index 67dc46f4..b3c1fce7 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -47,7 +47,7 @@
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
- <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
+ <% if crm_customer.customer_id != "CUS-00001" && crm_customer.customer_id != "CUS-000000000" %>
|
|
@@ -152,7 +152,6 @@ $(document).on('click',".customer_tr",function(){
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+customer_id;
- alert(id)
$("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id);
diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb
index 0dead477..5c4bf7c8 100644
--- a/app/views/crm/customers/show.html.erb
+++ b/app/views/crm/customers/show.html.erb
@@ -55,12 +55,16 @@
+ <% puts "'''''''''''''''''''"
+ puts @response
+ if @response["status"] == true %>
| Membership Transactions |
<% if @response["status"] == true %>
Current Balance : <%= @response["data"][0]["balance"]%> |
<% end %>
+ <% end %>
| Date |
Redeem |
@@ -99,28 +103,22 @@
- | Order ID |
- Menu Item |
- QTY |
- Unit Price |
- Option |
- Status |
- Waiter |
- Created at |
+ Order ID |
+ Type |
+ Order status |
+ Order date |
+ Items Count |
- <% @order_items.each do |order_item| %>
+ <% @orders.each do |order| %>
- | <%= order_item.order_id %> |
- <%= order_item.item_name %> |
- <%= order_item.qty %> |
- <%= order_item.price %> |
- <%= order_item.options %> |
- <%= order_item.order_item_status %> |
- <%= order_item.item_order_by %> |
- <%= order_item.created_at.strftime("%d-%m-%y") %> |
+ <%= order.order_id %> |
+ <%= order.order_type %> |
+ <%= order.status %> |
+ <%= order.date.strftime("%d-%m-%Y") %> |
+ <%= order.item_count %> |
<% end %>
@@ -135,62 +133,33 @@
- | Sale ID |
- Menu Item |
- QTY |
- Unit Price |
- Tax Price |
- Created At |
+ Sale Id |
+ Receipt no |
+ Grand total |
+ Tax amount |
+ Cashier |
+ Sales status |
+ Receipt Date |
- <% @sale_items.each do |sale_item| %>
-
- | <%= sale_item.sale_id %> |
- <%= sale_item.product_name %> |
- <%= sale_item.qty %> |
- <%= sale_item.unit_price %> |
-
- <%= sale_item.taxable_price %> |
- <%= sale_item.created_at %> |
-
- <% end %>
+ <% @sales.each do |sale| %>
+
+ | <%= sale.sale_id %> |
+ <%= sale.receipt_no %> |
+ <%= sale.grand_total rescue '-' %> |
+ <%= sale.total_tax %> |
+ <%= sale.cashier_name rescue '-' %> |
+ <%= sale.sale_status %> |
+ <%= sale.receipt_date.strftime("%d-%m-%Y") %> |
+
+ <% end %>
-
-
Sale Details
-
-
-
-
- | Sale ID |
- Menu Item |
- QTY |
- Unit Price |
- Tax Price |
- Created At |
-
-
-
-
- <% @sale_items.each do |sale_item| %>
-
- | <%= sale_item.sale_id %> |
- <%= sale_item.product_name %> |
- <%= sale_item.qty %> |
- <%= sale_item.unit_price %> |
-
- <%= sale_item.taxable_price %> |
- <%= sale_item.created_at %> |
-
- <% end %>
-
-
-
-
+
diff --git a/app/views/layouts/OQS.html.erb b/app/views/layouts/OQS.html.erb
index 9f736336..102edba2 100644
--- a/app/views/layouts/OQS.html.erb
+++ b/app/views/layouts/OQS.html.erb
@@ -23,7 +23,6 @@
<% end %>
<%= yield %>
-