diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml
index 0413cc5e..7db49a58 100644
--- a/.idea/sxrestaurant.iml
+++ b/.idea/sxrestaurant.iml
@@ -38,6 +38,7 @@
+
@@ -80,6 +81,7 @@
+
@@ -112,6 +114,7 @@
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index bda1b51d..e3687c57 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,32 +2,21 @@
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -42,7 +31,7 @@
-
+
@@ -69,51 +58,58 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -122,28 +118,38 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -173,6 +179,8 @@
green
reports_dailysale_index_path
mom
+ gem "select2-rails"
+ custom_excel
@@ -181,7 +189,6 @@
-
@@ -212,26 +219,27 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -255,11 +263,11 @@
-
+
-
+
@@ -294,78 +302,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -373,70 +315,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -452,71 +336,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -922,12 +741,12 @@
-
+
-
+
@@ -939,25 +758,25 @@
-
+
-
+
-
+
+
-
+
-
+
-
@@ -969,62 +788,18 @@
-
+
+
+ file://$PROJECT_DIR$/app/controllers/reports/commission_controller.rb
+ 4
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1057,13 +832,6 @@
-
-
-
-
-
-
-
@@ -1080,6 +848,7 @@
+
@@ -1087,6 +856,7 @@
+
@@ -1125,6 +895,7 @@
+
@@ -1135,43 +906,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1195,13 +929,6 @@
-
-
-
-
-
-
-
@@ -1216,14 +943,6 @@
-
-
-
-
-
-
-
-
@@ -1263,25 +982,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1306,22 +1006,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1356,11 +1040,170 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index c0783d50..49974e05 100644
--- a/Gemfile
+++ b/Gemfile
@@ -112,9 +112,10 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'httparty', '~> 0.15.5'
-# gem 'momentjs-rails', '>= 2.9.0'
-# gem 'bootstrap-datepicker-rails'
+gem 'momentjs-rails', :git => 'git://github.com/derekprior/momentjs-rails.git'
+gem 'bootstrap-daterangepicker-rails'
# # gem 'momentjs-rails', '>= 2.9.0'
# gem 'bootstrap3-datetimepicker-rails'z
gem 'bootstrap-datepicker-rails'
gem 'jquery-datetimepicker-rails'
+gem 'select2-rails'
diff --git a/Gemfile.lock b/Gemfile.lock
index 8fca836c..f8c439bc 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/derekprior/momentjs-rails.git
+ revision: ea58a20b7b2c901831dd01f34e0054ef6c75bde8
+ specs:
+ momentjs-rails (2.17.1)
+ railties (>= 3.1)
+
GEM
remote: https://rubygems.org/
specs:
@@ -48,6 +55,8 @@ GEM
sass (>= 3.4.19)
bootstrap-datepicker-rails (1.6.4.1)
railties (>= 3.0)
+ bootstrap-daterangepicker-rails (0.0.8)
+ railties (>= 3.1)
builder (3.2.3)
byebug (9.0.6)
cancancan (1.17.0)
@@ -202,6 +211,8 @@ GEM
tilt (>= 1.1, < 3)
schema_to_scaffold (0.8.0)
activesupport (>= 3.2.1)
+ select2-rails (4.0.3)
+ thor (~> 0.14)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
sidekiq (5.0.3)
@@ -259,6 +270,7 @@ DEPENDENCIES
bcrypt (~> 3.1.7)
bootstrap (~> 4.0.0.alpha3)
bootstrap-datepicker-rails
+ bootstrap-daterangepicker-rails
byebug
cancancan (~> 1.10)
carrierwave (~> 1.0)
@@ -277,6 +289,7 @@ DEPENDENCIES
jquery-ui-rails
kaminari (~> 1.0.1)
listen (~> 3.0.5)
+ momentjs-rails!
mysql2 (>= 0.3.18, < 0.5)
nested_form
pg
@@ -288,6 +301,7 @@ DEPENDENCIES
rspec-rails (~> 3.5)
sass-rails (~> 5.0)
schema_to_scaffold
+ select2-rails
shoulda-matchers (~> 3.1)
sidekiq
simple_form
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 89f95729..49abe57d 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -22,6 +22,9 @@
//= require bootstrap-datepicker
//= require jquery.datetimepicker
//= require dataTables/jquery.dataTables
+//= require moment
+//= require daterangepicker
+//= require select2
$(document).on('turbolinks:load', function() {
$('.datepicker').datepicker({
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 6cd24771..edfadb8a 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -6,6 +6,8 @@
@import "bootstrap-datepicker3";
@import "jquery.datetimepicker";
@import "dataTables/jquery.dataTables";
+@import "daterangepicker-bs3";
+@import "select2";
/* Show it is fixed to the top */
// body {
diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb
index 2d421ef5..df484589 100644
--- a/app/controllers/reports/commission_controller.rb
+++ b/app/controllers/reports/commission_controller.rb
@@ -2,21 +2,14 @@ class Reports::CommissionController < BaseReportController
# authorize_resource :class => false
def index
+ from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
+ to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
+ commissioner = params[:commissioner].to_i
+ @commissioner = Commissioner.active.all
- from, to = get_date_range_from_params
- @shift = ''
- if params[:shift_name].to_i != 0
- @shift = ShiftSale.find(params[:shift_name])
- end
- @sale_data = Sale.get_by_shiftsales(from,to,@shift)
- @from = from
- @to = to
- if @shift.present?
-
- @shift_from = @shift.shift_started_at.nil? ? '-' : @shift.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
- @shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
- @shift_data = @shift
- end
+ @transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
+ @from = from_date
+ @to = to_date
respond_to do |format|
format.html
diff --git a/app/models/commission.rb b/app/models/commission.rb
index 055d9618..40d69f81 100644
--- a/app/models/commission.rb
+++ b/app/models/commission.rb
@@ -9,7 +9,6 @@ class Commission < ApplicationRecord
has_many :product_commissions
private
-
def generate_custom_id
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
end
diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb
index 1f3b6423..0e39f9f3 100644
--- a/app/models/product_commission.rb
+++ b/app/models/product_commission.rb
@@ -5,5 +5,14 @@ class ProductCommission < ApplicationRecord
belongs_to :sale_item, foreign_key: 'sale_item_id'
belongs_to :sale, foreign_key: 'sale_id'
-
+ def self.get_transaction(from, to, commissioner)
+ transaction = self.all
+ if !from.nil? && !to.nil?
+ transaction = transaction.where('updated_at between ? and ?', from, to)
+ end
+ if commissioner != 0
+ transaction = transaction.where(commissioner_id: commissioner)
+ end
+ return transaction
+ end
end
diff --git a/app/models/promotion.rb b/app/models/promotion.rb
index 482d2c3b..dfcfc105 100644
--- a/app/models/promotion.rb
+++ b/app/models/promotion.rb
@@ -23,7 +23,7 @@ class Promotion < ApplicationRecord
end
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
- promoList = Promotion.where("(TO_CHAR(promo_start_date, 'YYYY-MM-DD') <=? AND TO_CHAR(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
+ promoList = Promotion.where("(date_format(promo_start_date, 'YYYY-MM-DD') <=? AND date_format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
return promoList
end
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index a8369af2..47ab23d2 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -55,7 +55,7 @@
<%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %>
<%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %>
<%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %>
-
+ <%= link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %>
diff --git a/app/views/reports/commission/_commission_report_filter.html.erb b/app/views/reports/commission/_commission_report_filter.html.erb
index ff1a044b..acfcef25 100644
--- a/app/views/reports/commission/_commission_report_filter.html.erb
+++ b/app/views/reports/commission/_commission_report_filter.html.erb
@@ -1,36 +1,20 @@
- <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
+ <%= form_tag report_path, :method => :get, :id => "frm_report", :class => "form" do %>
<% if period_type != false %>
- <%= render :partial=>'commission_report_filter',
- :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_commission_index_path} %>
-
+ <%= render :partial => 'commission_report_filter',
+ :locals => {:period_type => true, :shift_name => true, :report_path => reports_commission_index_path} %>
+
-
- From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
-
-
+ From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- <% if @shift_from %>
-
- <% if @shift_data.employee %>
- <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
- <% end %>
- Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
-
- <% end %>
- Cashier Station
- Cashier Name
- Shift Name
-
- Cash Payment
-
- Credit Payment
-
- Other Payment
-
-
- Grand Total
+ Commissioner Name
+ Product Name
+ Qty
+ Commission Price
+ Commission Amount
+ Date
- <% void = 0%>
- <% cash = 0%>
- <% credit = 0%>
- <% accept_credit = 0%>
- <% foc = 0%>
- <% card = 0%>
- <% total = 0%>
- <% rounding_adj = 0%>
- <% g_total = 0 %>
+ <% total_qty = 0 %>
+ <% total_price = 0 %>
+ <% total_amount = 0 %>
- <% @sale_data.each do |result|%>
+ <% @transaction.each do |result| %>
- <%= result.cashier_terminal.name rescue '-'%>
+ <%= result.commissioner.name rescue '-' %>
- <%= result.employee.name rescue '-'%>
+ <%= result.commission.menu_item.name rescue '-' %>
- <%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
- <%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
-
-
- <%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%>
- <%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%>
-
-
- <%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%>
- <%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%>
-
-
- <% grand_total = result.grand_total.to_f %>
-
+ <%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %>
+ <%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %>
+ <%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %>
+ <%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
- <% cash += result.cash_sales.to_f %>
- <% credit += result.credit_sales.to_f %>
- <% card += result.other_sales.to_f %>
-
- <% total += result.grand_total.to_f %>
- <% g_total += grand_total.to_f %>
-
+ <% total_qty += result.qty.to_f %>
+ <% total_price += result.price.to_f %>
+ <% total_amount += result.amount.to_f %>
<% end %>
-
-
- <%= sprintf("%.2f",cash) rescue '-'%>
- <%= sprintf("%.2f",credit) rescue '-'%>
-
-
- <%= sprintf("%.2f",card) rescue '-'%>
-
-
- <%= sprintf("%.2f",g_total) rescue '-'%>
+
+ <%= sprintf("%.2f", total_qty) rescue '-' %>
+ <%= sprintf("%.2f", total_price) rescue '-' %>
+ <%= sprintf("%.2f", total_amount) rescue '-' %>
+
@@ -119,91 +73,7 @@
diff --git a/app/views/reports/commission/index.xls.erb b/app/views/reports/commission/index.xls.erb
index e3daaca2..4ea1f2f0 100644
--- a/app/views/reports/commission/index.xls.erb
+++ b/app/views/reports/commission/index.xls.erb
@@ -1,100 +1,52 @@
-
- From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
-
-
+ From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
- <% if @shift_from %>
-
- <% if @shift_data.employee %>
- <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
- <% end %>
- Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
-
- <% end %>
-
- Cashier Station
- Cashier Name
- Shift Name
-
- Cash Payment
-
- Credit Payment
-
- Other Payment
-
-
- Grand Total
+ Commissioner Name
+ Product Name
+ Qty
+ Commission Price
+ Commission Amount
+ Date
- <% void = 0%>
- <% cash = 0%>
- <% credit = 0%>
- <% accept_credit = 0%>
- <% foc = 0%>
- <% card = 0%>
- <% total = 0%>
- <% rounding_adj = 0%>
- <% g_total = 0 %>
+ <% total_qty = 0 %>
+ <% total_price = 0 %>
+ <% total_amount = 0 %>
- <% @sale_data.each do |result|%>
+ <% @transaction.each do |result| %>
- <%= result.cashier_terminal.name rescue '-'%>
+ <%= result.commissioner.name rescue '-' %>
- <%= result.employee.name rescue '-'%>
+ <%= result.commission.menu_item.name rescue '-' %>
- <%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
- <%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
-
-
- <%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%>
- <%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%>
-
-
- <%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%>
- <%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%>
-
-
- <% grand_total = result.grand_total.to_f %>
-
+ <%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %>
+ <%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %>
+ <%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %>
+ <%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
- <% cash += result.cash_sales.to_f %>
- <% credit += result.credit_sales.to_f %>
- <% card += result.other_sales.to_f %>
-
- <% total += result.grand_total.to_f %>
- <% g_total += grand_total.to_f %>
-
+ <% total_qty += result.qty.to_f %>
+ <% total_price += result.price.to_f %>
+ <% total_amount += result.amount.to_f %>
<% end %>
-
-
- <%= sprintf("%.2f",cash) rescue '-'%>
- <%= sprintf("%.2f",credit) rescue '-'%>
-
-
- <%= sprintf("%.2f",card) rescue '-'%>
-
-
- <%= sprintf("%.2f",g_total) rescue '-'%>
+
+ <%= sprintf("%.2f", total_qty) rescue '-' %>
+ <%= sprintf("%.2f", total_price) rescue '-' %>
+ <%= sprintf("%.2f", total_amount) rescue '-' %>
+
-
\ No newline at end of file
+
diff --git a/dump.rdb b/dump.rdb
index 6e3e4bdb..3826c8c6 100644
Binary files a/dump.rdb and b/dump.rdb differ