diff --git a/Gemfile b/Gemfile
index 02dca6af..7295ffab 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'
@@ -93,4 +93,8 @@ 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', '>= 2.9.0'
+# gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
gem 'bootstrap-datepicker-rails'
diff --git a/Gemfile.lock b/Gemfile.lock
index 4235d035..6a7c6340 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -110,7 +110,6 @@ GEM
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
pdf-core (0.7.0)
- pg (0.20.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -247,7 +246,6 @@ DEPENDENCIES
kaminari (~> 0.16.3)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
- pg
prawn
prawn-table
puma (~> 3.0)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 8ff96589..59e4a386 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -17,5 +17,11 @@
//= require turbolinks
//= require cable
//= require settings/processing_items
-//= require bootstrap-datepicker
+//= require bootstrap-datepicker/core
+//= require bootstrap-datepicker/locales/bootstrap-datepicker.es
+
+$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
+ $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
+ $('.dropdown-toggle').dropdown();
+});
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index d8101494..468ac33d 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -2,7 +2,7 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
-@import "bootstrap-datepicker3";
+@import 'bootstrap-datepicker';
/* Show it is fixed to the top */
// body {
diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb
index 05065fee..930659b9 100644
--- a/app/controllers/reports/receipt_no_controller.rb
+++ b/app/controllers/reports/receipt_no_controller.rb
@@ -1,9 +1,85 @@
-class Reports::ReceiptNoController < BaseReportController
+class Reports::ReceiptNoController < ApplicationController
+ PERIOD = {
+ "today" => 0,
+ "yesterday" => 1,
+ "this_week" => 2,
+ "last_week" => 3,
+ "last_7" => 4,
+ "this_month" => 5,
+ "last_month" => 6,
+ "last_30" => 7,
+ "this_year" => 8,
+ "last_year" => 9
+ }
+
def index
- @hi = "hi"
+ from, to = get_date_range_from_params
+ puts "from..."
+ puts from
+ puts "to..."
+ puts to
+ @sale_data = Sale.get_receipt_no_list(from,to)
+ @sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
end
def show
+
+ end
+ private
+ def get_date_range_from_params
+ period_type = params[:period_type]
+ period = params[:period]
+ from = params[:from]
+ to = params[:to]
+ day_ref = Time.now
+ if period_type.to_i == 1
+ if params[:from] && params[:to]
+ if params[:from] != "" && params[:to] !=""
+ from = DateTime.strptime(params[:from], "%m/%d/%Y")
+ to = DateTime.strptime(params[:to], "%m/%d/%Y")
+ else
+ from = day_ref.beginning_of_day.utc
+ to = day_ref.end_of_day.utc
+ end
+ end
+ else
+ case period.to_i
+ when PERIOD["today"]
+
+ from = day_ref.beginning_of_day.utc
+ to = day_ref.end_of_day.utc
+
+ when PERIOD["yesterday"]
+ from = (day_ref - 1.day).beginning_of_day.utc
+ to = (day_ref - 1.day).end_of_day.utc
+
+ when PERIOD["this_week"]
+ from = Time.now.beginning_of_week.utc
+ to = Time.now.utc
+ when PERIOD["last_week"]
+ from = (day_ref - 7.day).beginning_of_week.utc
+ to = (day_ref - 7.day).end_of_week.utc
+ when PERIOD["last_7"]
+ from = (day_ref - 7.day).utc
+ to = Time.now.utc
+ when PERIOD["this_month"]
+ from = Time.now.beginning_of_month.utc
+ to = Time.now.utc
+ when PERIOD["last_month"]
+ from = (day_ref - 1.month).beginning_of_month.utc
+ to = (day_ref - 1.month).end_of_month.utc
+ when PERIOD["last_30"]
+ from = (day_ref - 30.day).utc
+ to = Time.now.utc
+ when PERIOD["this_year"]
+ from = Time.now.beginning_of_year.utc
+ to = Time.now.utc
+ when PERIOD["last_year"]
+ from = (day_ref - 1.year).beginning_of_year.utc
+ to = (day_ref - 1.year).end_of_year.utc
+ end
+ end
+ return from, to
end
end
\ No newline at end of file
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 47d271f1..52625917 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -263,4 +263,8 @@ class Sale < ApplicationRecord
def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end
+
+ def self.get_receipt_no_list(from,to)
+ sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
+ end
end
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index bdd146b7..641678f9 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -36,7 +36,7 @@
diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb
new file mode 100644
index 00000000..9c87d843
--- /dev/null
+++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb
@@ -0,0 +1,246 @@
+<%= form_tag report_path, :method => :get, :id=>"frm_report" do %>
+
+
+ <% if defined? product_account %>
+ <%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%>
+ <% end %>
+ <% if defined? shift_product_account %>
+ <%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account]), :prompt => 'All Group'%>
+ <% end %>
+
+
+
+ <% if period_type != false %>
+
+
+
+
+ Today
+ Yesterday
+ This week
+ Last week
+ Last 7 days
+ This month
+ Last month
+ Last 30 days
+ This year
+ Last year
+
+ <% end %>
+
+
+
+
+
+
+
+
+ <% if defined? show_sale_type %>
+
+ All Sale Type
+ Revenue Only
+ Discount Only
+ Void Only
+ Taxes Only
+ Other Amount Only
+
+ <% end %>
+
+ <% if defined? promotions %>
+ <%= select_tag "promotion", options_for_select(@promotions, :selected => params[:promotion_type]) %>
+ <% end %>
+
+ <% if defined? menu_types %>
+ <%= select_tag "menu_type", options_for_select(@menu_types, :selected => params[:menu_type]) %>
+ <% end %>
+
+ <% if defined? payments %>
+ <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]) %>
+ <% end %>
+
+ <% if defined? shift_name %>
+
+
+ <% end %>
+ <% if defined? cashiers %>
+ <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations" %>
+ <% end %>
+
+ <% if defined? singer %>
+ <%= select_tag "singer", options_from_collection_for_select(singer,"id","name"),:prompt => "All Vocal List" %>
+ <% end %>
+
+ <% if defined? bsm %>
+ <%= select_tag "singer", options_from_collection_for_select(bsm,"id","name"),:prompt => "All BSM List" %>
+ <% end %>
+
+ <% if defined? guest_role %>
+ <%= select_tag "guest_role", options_from_collection_for_select(@guest_role,"id","name"),:prompt => "Vocal/BSM List" %>
+ <% end %>
+
+ <% if defined? list_by_payment_type %>
+ <%= select_tag "payment_type_list", options_for_select(@payment_list, :selected => params[:payment_type_list]) %>
+ <% end %>
+
+ <% if defined? products %>
+ <%= select_tag "product", options_from_collection_for_select(@products,"id","name"),:prompt => "All Products" %>
+ <% end %>
+ <% if defined? items %>
+ <%= select_tag "item", options_for_select(@items, :selected => params[:item_type]) %>
+ <% end %>
+
+
+
+
+
+ <% if defined? show_monthly %>
+
+
+
+
+ Monthly
+ Yearly
+
+
+ <% end %>
+
+
+
+
+
+
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb
index 0bae50e7..fac08039 100644
--- a/app/views/reports/receipt_no/index.html.erb
+++ b/app/views/reports/receipt_no/index.html.erb
@@ -1,3 +1,95 @@
-
- <%= @hi %>
-
\ No newline at end of file
+
+
+
+
+
+ Date
+ Receipt No
+ Cashier Name
+ Gross Sales
+ Discount
+ Total Sales
+ CT
+ Nett Sales
+
+
+
+
+ <% total_sales = 0 %>
+ <% net_sales = 0 %>
+ <% @sale_data.each do |sale| %>
+ <% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%>
+ <% net_sales = total_sales.to_f + sale.total_tax.to_f%>
+
+ <%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %>
+ <%=sale.receipt_no.to_s rescue ''%>
+ <%=sale.cashier_id rescue ''%>
+ <%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
+
+ <% end %>
+
+
+
+<%= paginate @sale_data %>
+
\ No newline at end of file
diff --git a/app/views/reports/receipt_no/index.xls.erb b/app/views/reports/receipt_no/index.xls.erb
new file mode 100644
index 00000000..2191d814
--- /dev/null
+++ b/app/views/reports/receipt_no/index.xls.erb
@@ -0,0 +1,135 @@
+
+
+
+<% unless @sale_data.empty? %>
+
<%=current_active_location.name%>
+
Sales Summary Report (BreadTalk)
+<% if params[:from]%>
+
From Date : <%= params[:from] %> , To Date : <%= params[:to] %>
+<% end %>
+
+
+
+
+ Location Name
+ Date
+ Cash Sales
+ Credit Sales
+ Credit Received
+
+ Card Payment
+ Total Discount
+ Total Taxes
+ Total Other Charges
+ FOC Sales
+ Void Sales
+ Grand Total
+
+
+
+ <% void = 0 %>
+ <% card = 0 %>
+ <% credit_payment = 0 %>
+ <% cash = 0 %>
+ <% credit = 0 %>
+ <% foc = 0 %>
+ <% discount = 0 %>
+ <% total = 0 %>
+ <% count = 1 %>
+ <% discount_rev = 0 %>
+ <% total_rev = 0 %>
+ <% grand_rev = 0 %>
+ <% total_other_charges=0 %>
+ <% total_tax=0 %>
+ <% cash_received = 0 %>
+ <% total_cash_received = 0 %>
+ <% today_credit_payment_amount = 0 %>
+ <% old_location_id = 0%>
+ <% sub_total = 0 %>
+ <% count_of_void = 0 %>
+ <% flag = false %>
+ <% @sale_data.each do |sale| %>
+ <% credit_payment += sale[:credit_payment].to_f %>
+ <% card += sale[:card_amount].to_f %>
+ <% cash += sale[:cash_amount].to_f %>
+ <% credit += sale[:credit_amount].to_f %>
+ <% foc += sale[:foc_amount].to_f %>
+ <% discount += sale[:total_discount].to_f %>
+ <% total += sale[:grand_total].to_f %>
+ <% total_other_charges +=sale[:other_charges].to_f %>
+ <% total_tax +=sale[:total_tax].to_f %>
+
+ <% cash_received = sale[:cash_amount].to_f + sale[:credit_payment].to_f%>
+ <% total_cash_received = cash.to_f + credit_payment.to_f%>
+ <% today_credit_payment_amount += sale[:today_credit_payment].to_f %>
+
+
+
+
+ <%= sale[:location].to_s rescue '-' %>
+ <%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:credit_payment].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:card_amount].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:total_discount].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:total_tax].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:other_charges].to_f), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount].to_f), :delimiter => ',') %>
+ <% total_void_amount = 0 %>
+ <% if !@daily_void.nil? %>
+ <% @daily_void.each do |d_v|%>
+
+ <% if d_v[:daily_void_amt].to_i > 0 %>
+ <% if d_v[:location_id] == sale[:location_id] %>
+ <% if d_v[:date].utc.getlocal.strftime("%Y-%m-%d").to_s == sale[:sale_date].to_s%>
+ <%count_of_void+=1%>
+
+ <%total_void_amount += d_v[:daily_void_amt].to_f%>
+ <% flag = true %>
+
+
+
+ <%end %>
+ <% end%>
+ <% end%>
+ <% end%>
+ <% end%>
+ <% if flag == true%>
+ <% void += total_void_amount.to_f %>
+ <%= number_with_delimiter(sprintf("%.2f",total_void_amount.to_f), :delimiter => ',') %>
+ <% flag = false %>
+ <% end%>
+ <%if count_of_void == 0%>
+ <%= number_with_delimiter(sprintf("%.2f",0.to_f), :delimiter => ',') %>
+ <%end %>
+
+ <%= number_with_delimiter(sprintf("%.2f",((sale[:cash_amount].to_f + sale[:credit_amount].to_f + sale[:card_amount].to_f + sale[:credit_payment].to_f) - sale[:today_credit_payment].to_f) ).to_f, :delimiter => ',') %>
+
+
+
+
+<%count_of_void= 0%>
+ <% count = count + 1 %>
+ <% end %>
+
+
+ Grand Total
+ <%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",credit ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",credit_payment ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",card ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",discount ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",total_tax ), :delimiter => ',') %>
+
+ <%= number_with_delimiter(sprintf("%.2f",total_other_charges ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",foc ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f",void ), :delimiter => ',') %>
+ <%= number_with_delimiter(sprintf("%.2f", (cash.to_f + credit.to_f + card.to_f + credit_payment.to_f) - today_credit_payment_amount.to_f ).to_f, :delimiter => ',') %>
+
+
+
+<% end %>
+
+
+
\ No newline at end of file