diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb
index cf66d0e9..8d0f9422 100644
--- a/app/controllers/origami/discounts_controller.rb
+++ b/app/controllers/origami/discounts_controller.rb
@@ -49,11 +49,14 @@ class Origami::DiscountsController < BaseOrigamiController
end
# Re-calc All Amount in Sale
- sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
+ sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
+ result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
+ else
+ result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
end
- dining = {:table_id => table_id, :table_type => table_type }
- render :json => dining.to_json
+
+ render :json => result.to_json
end
# Remove selected discount Items
@@ -78,11 +81,12 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
- end
+ result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
+ else
+ result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
+ end
- dining = {:table_id => table_id, :table_type => table_type }
-
- render :json => dining.to_json
+ render :json => result.to_json
end
# Remove all discount Items
@@ -108,11 +112,12 @@ class Origami::DiscountsController < BaseOrigamiController
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
- end
+ result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
+ else
+ result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
+ end
- dining = {:table_id => table_id, :table_type => table_type }
-
- render :json => dining.to_json
+ render :json => result.to_json
end
# Member Discount
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index c956f7f9..9918266a 100644
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -67,10 +67,8 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_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, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
-
-
- end
+ printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
+ end
end
def show
diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb
index cfea9d37..687c872f 100644
--- a/app/controllers/origami/request_bills_controller.rb
+++ b/app/controllers/origami/request_bills_controller.rb
@@ -5,19 +5,24 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale = Sale.new
sale_order=SaleOrder.new
- order_id = params[:id] # order_id
- bk_order = BookingOrder.find_by_order_id(order_id)
- check_booking = Booking.find_by_booking_id(bk_order.booking_id)
- if check_booking.sale_id.nil?
- # Create Sale if it doesn't exist
- # puts "current_login_employee"
- # puts current_login_employee.name
- @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
- @sale_data = Sale.find_by_sale_id(@sale_id)
- @sale_items = SaleItem.where("sale_id=?",@sale_id)
+ if ShiftSale.current_open_shift(current_user.id)
+ order_id = params[:id] # order_id
+ bk_order = BookingOrder.find_by_order_id(order_id)
+ check_booking = Booking.find_by_booking_id(bk_order.booking_id)
+ if check_booking.sale_id.nil?
+ # Create Sale if it doesn't exist
+ # puts "current_login_employee"
+ # puts current_login_employee.name
+ @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
+ @sale_data = Sale.find_by_sale_id(@sale_id)
+ @sale_items = SaleItem.where("sale_id=?",@sale_id)
+ else
+ @sale_data = Sale.find_by_sale_id(check_booking.sale_id)
+ @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
+ end
else
- @sale_data = Sale.find_by_sale_id(check_booking.sale_id)
- @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
+ @status = false
+ @error_message = "No Current Open Shift for This Employee"
end
# Not Use for these printed bill cannot give customer
diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb
index 27e812ab..14013a1b 100644
--- a/app/controllers/reports/dailysale_controller.rb
+++ b/app/controllers/reports/dailysale_controller.rb
@@ -5,6 +5,9 @@ class Reports::DailysaleController < BaseReportController
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
+ puts from
+ puts to
+ puts "sssssssss"
respond_to do |format|
format.html
format.xls
diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb
index e4157c4e..fd203791 100644
--- a/app/controllers/reports/receipt_no_controller.rb
+++ b/app/controllers/reports/receipt_no_controller.rb
@@ -1,13 +1,36 @@
class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false
def index
- 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)
+ from, to, report_type = get_date_range_from_params
+ # if to.blank?
+ # @shift = ShiftSale.where('shift_started_at <= ? and shift_closed_at is NULL',from).take
+ # else
+ # @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take
+ # end
+ # puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z"
+ # puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC"
+# puts params[:shift_name]
+# puts from.utc
+# puts to.utc
+
+ if params[:shift_name].to_i != 0
+ @shift = ShiftSale.where('shift_started_at >= ? and shift_closed_at <= ?',from,to).take
+ # puts @shift.to_json
+ if @shift.present?
+ @sale_data = Sale.where('shift_sale_id = ? ',@shift.id)
+ @sale_taxes = Sale.get_separate_tax(from,to)
+ end
+ else
+ @sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc)
+ @sale_taxes = Sale.get_separate_tax(from.utc,to.utc)
+ end
+
+
+ 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")
+ end
+
respond_to do |format|
format.html
format.xls
@@ -15,6 +38,231 @@ authorize_resource :class => false
end
def show
-
+ from, to, report_type = get_date_range_from_params
+
+ @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
+puts "hhhhhhhhhhhhhhhhhhhhh"
+puts @sale_data.to_json
+puts from
+puts to
+puts report_type
+puts params[:shift_name]
+
+ date_arr = Array.new
+ @sale_data.each do |sale|
+ local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
+ closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
+ str = { :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
+ date_arr.push(str)
+ end
+
+ out = {:status => 'ok', :message => date_arr}
+
+ respond_to do |format|
+ format.json { render json: out }
+ end
end
+
+
+ def get_date_range_from_params
+
+ period_type = params[:period_type]
+ period = params[:period]
+
+ branch = params[:branch]
+ report_type = params[:report_type]
+
+ shift_name = params[:shift_name]
+ unless shift_name.nil?
+ shift_arr = shift_name.split(' - ')
+ shift_from = shift_arr[0]
+ shift_to = shift_arr[1]
+ end
+
+ day_ref = day_ref = Time.now.utc.getlocal
+
+ if period_type.to_i == 1
+
+ ### =>search by from and to
+ unless shift_name.nil?
+ if shift_name.to_s == '0'
+ ### => all shift
+ f_date = DateTime.parse(params[:from])
+ t_date = DateTime.parse(params[:to])
+ f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
+ t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
+ from = f_time.beginning_of_day.utc.getlocal
+ to = t_time.end_of_day.utc.getlocal
+
+ else
+ unless shift_from == '-'
+ f_date = DateTime.parse(shift_from)
+ from = f_date
+ else
+ from = ''
+ end
+
+ unless shift_to == '-'
+ t_date = DateTime.parse(shift_to)
+ to = t_date
+ else
+ to = ''
+ end
+ end
+ else
+ f_date = DateTime.parse(params[:from])
+ t_date = DateTime.parse(params[:to])
+ f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
+ t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
+ from = f_time.beginning_of_day.utc.getlocal
+ to = t_time.end_of_day.utc.getlocal
+ end
+ else
+ ### => search by Today or yesterday
+
+ unless shift_name.nil?
+ if shift_name.to_s == '0'
+ ### => all shift
+ 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
+
+ else
+ unless shift_from == '-'
+ f_date = DateTime.parse(shift_from)
+ #f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
+ from = f_date.utc
+ else
+ from = ''
+ end
+
+ unless shift_to == '-'
+ t_date = DateTime.parse(shift_to)
+ #t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
+ to = t_date.utc
+ else
+ to = ''
+ end
+ end
+ else
+ if params[:report_type].to_i != 0
+ r_type = params[:report_type].to_s
+
+ if r_type == 'shift_item'
+
+ 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
+ else
+ ### => report not shift
+ 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
+ end
+
+ end
+
+ return from, to,report_type
+ end
+
+
end
\ No newline at end of file
diff --git a/app/models/sale.rb b/app/models/sale.rb
index c1c81685..661222bc 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -445,6 +445,7 @@ class Sale < ApplicationRecord
total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
+ IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj")
.where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date)
@@ -454,6 +455,7 @@ class Sale < ApplicationRecord
old_grand_total = sale.old_grand_total
total_discount = sale.total_discount
void_amount = sale.void_amount
+ total_change_amount = sale.total_change_amount
total = {:sale_date => pay.sale_date,
:mpu_amount => pay.mpu_amount,
:master_amount => pay.master_amount,
@@ -464,6 +466,7 @@ class Sale < ApplicationRecord
:credit_amount => pay.credit_amount,
:foc_amount => pay.foc_amount,
:total_discount => total_discount,
+ :total_change_amount => total_change_amount,
:grand_total => grand_total,
:old_grand_total => old_grand_total,
:void_amount => void_amount,
@@ -493,7 +496,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
JOIN employees ea ON ea.id = sales.cashier_id")
- query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
+ query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
@@ -514,7 +517,7 @@ def self.get_by_shiftsales(from,to)
return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
-# def self.get_by_shiftsales(employee,from,to)
+# def self.get_by_shiftsales(from,to)
# shift_sales = ShiftSale.select('shift_sales.id, cs.name as cashier_station_name, shift_sales.shift_started_at as opening_date, shift_sales.shift_closeed_at as closing_date')
# .joins(" INNER JOIN cashier_terminals cs ON cs.id = shift_sales.cashier_terminal_id")
# .where("shift_sales.employee_id = ? and (shift_sales.shift_started_at between ? and ? OR shift_sales.shift_closeed_at between ? and ? )", employee, from, to, from, to)
@@ -529,23 +532,23 @@ end
# void = Sale.select("SUM(sales.grand_total) AS grand_total")
# .joins("join shift_sales sh on sh.id = sales.shift_sale_id")
-# .where('sales.sales_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
+# .where('sales.sale_status = "void" and sales.total_amount != 0 and sales.shift_sale_id = ?', shift.id)
# .sum(:grand_total)
# cash = all_total.select('sr.payment_type')
# .where('sr.payment_type = "cash"')
# .sum(:amount)
-# credit = all_total.where('sr.payment_type = "credit"')
+# credit = all_total.where('sr.payment_type = "creditnote"')
# .sum(:amount)
# accept_credit = all_total.select('ci.amout')
# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id")
-# .where('sr.payment_type = "credit"')
+# .where('sr.payment_type = "creditnote"')
# .sum(:amout)
-# foc = all_total.where('sales.payment_type = "foc" and sales.sales_status = "completed"')
+# foc = all_total.where('sales.payment_type = "foc" and sales.sale_status = "completed"')
# .sum(:grand_total)
# card = all_total.select('payment_type')
@@ -571,6 +574,31 @@ end
# return sale_arr
# end
+# def self.get_receipt_no_list(from,to)
+# sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
+# end
+
+def self.get_by_shift_sale(from,to,status)
+ query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,shift_closed_at As closing_date," +
+ " grand_total AS grand_total, cash_sales AS cash," +
+ "total_taxes AS total_tax,total_discounts As total_discount")
+ .order("shift_sales.id DESC")
+ return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to)
+end
+
+def self.get_separate_tax(from,to,payment_type=nil)
+
+ query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
+ .joins("INNER JOIN sales ON sales.id = sale_taxes.sale_id")
+ .group("sale_taxes.tax_name")
+
+ return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
+end
+
+def grand_total_after_rounding
+ return self.old_grand_total.to_f + self.rounding_adjustment.to_f
+end
+
def get_cash_amount
cash = 0.0
self.sale_payments.each do |pay|
@@ -616,8 +644,4 @@ end
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/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index 2a4b365a..82507e67 100644
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -118,6 +118,23 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.closing_balance}", :size => self.item_font_size, :align => :right
end
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Cash In:", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{shift_sale.cash_in}", :size => self.item_font_size, :align => :right
+ end
+
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Cash Out:", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{shift_sale.cash_out}", :size => self.item_font_size, :align => :right
+ end
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Net Sales:", :size => self.item_font_size, :align => :right
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index bd65ed20..1bf4b95f 100644
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -317,16 +317,16 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
- # old = balance + redeem
+ old = balance + redeem
- # move_down 5
- # y_position = cursor
- # bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- # text "Old Balance", :size => self.item_font_size,:align => :left
- # end
- # bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- # text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
- # end
+ move_down 5
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
+ text "Old Balance", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
+ text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
+ end
end
end
@@ -386,10 +386,10 @@ class ReceiptBillPdf < Prawn::Document
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
+ bounding_box([0,y_position], :width =>self.label_width) 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
+ bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb
index 6e8b26a8..ee63f2d3 100644
--- a/app/views/origami/discounts/index.html.erb
+++ b/app/views/origami/discounts/index.html.erb
@@ -190,8 +190,8 @@
RemoveItem Discount
Remove All
Enter
-
- Member Discount
+
@@ -283,7 +283,7 @@ $(document).ready(function(){
$("#net").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
- var discount_value = $('#discount-amount').val();
+ var discount_value = parseFloat($('#discount-amount').val());
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
@@ -330,10 +330,15 @@ $(document).ready(function(){
// Remove selected discount items
$("#remove-item").on('click', function(e){
e.preventDefault();
+ var origin_sub_total = parseFloat($("#order-sub-total").text());
+ var total = 0;
$('.discount-item-row.selected-item').each(function(i){
+ var amount = parseFloat($(this).find('#item-total-price').text());
+ total = total + Math.abs(amount);
$(this).remove();
});
+ $("#order-sub-total").text(origin_sub_total + total);
});
// Pay Discount for Payment
@@ -352,13 +357,24 @@ $(document).ready(function(){
url: ajax_url,
data: params,
success:function(result){
- alert("Successfully Discount!");
- if(result.table_type == "Table"){
- window.location.href = "/origami/table/" + result.table_id
- }
- else {
- window.location.href = "/origami/room/" + result.table_id
- }
+ $.confirm({
+ title: 'Infomation!',
+ content: result.status,
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ if(result.table_type == "Table"){
+ window.location.href = "/origami/table/" + result.table_id
+ }
+ else {
+ window.location.href = "/origami/room/" + result.table_id
+ }
+ }
+ }
+ }
+ });
}
});
});
@@ -372,8 +388,19 @@ $(document).ready(function(){
// Selected Items
var sale_items = get_selected_sale_items();
if(sale_items.length == 0){
- alert("You have no selected item!");
- return;
+ $.confirm({
+ title: 'Infomation!',
+ content: "You have no selected item!",
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ return;
+ }
+ }
+ }
+ });
}
for(var i=0;i < sale_items.length;i++){
@@ -381,8 +408,19 @@ $(document).ready(function(){
discount_items.push(sale_items[i]);
}
else {
- alert("You have selected no discount item!");
- return;
+ $.confirm({
+ title: 'Infomation!',
+ content: "You have selected no discount item!!",
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ return;
+ }
+ }
+ }
+ });
}
}
@@ -392,13 +430,24 @@ $(document).ready(function(){
url: "/origami/" + sale_id + "/remove_discount_items",
data: params,
success: function(result){
- alert('Removed Discount');
- if(result.table_type == "Table"){
- window.location.href = "/origami/table/" + result.table_id
- }
- else {
- window.location.href = "/origami/room/" + result.table_id
- }
+ $.confirm({
+ title: 'Infomation!',
+ content: result.status,
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ if(result.table_type == "Table"){
+ window.location.href = "/origami/table/" + result.table_id
+ }
+ else {
+ window.location.href = "/origami/room/" + result.table_id
+ }
+ }
+ }
+ }
+ });
}
});
});
@@ -410,43 +459,54 @@ $(document).ready(function(){
type: "GET",
url: "/origami/" + sale_id + "/remove_all_discount",
success: function(result){
- alert('Removed All Discount');
- if(result.table_type == "Table"){
- window.location.href = "/origami/table/" + result.table_id
- }
- else {
- window.location.href = "/origami/room/" + result.table_id
- }
+ $.confirm({
+ title: 'Infomation!',
+ content: result.status,
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ if(result.table_type == "Table"){
+ window.location.href = "/origami/table/" + result.table_id
+ }
+ else {
+ window.location.href = "/origami/room/" + result.table_id
+ }
+ }
+ }
+ }
+ });
}
});
});
// Pay Discount for membership
- $("#member-discount").on('click', function(e){
- e.preventDefault();
- var sale_id = $('#sale-id').text();
- var sub_total = $('#order-sub-total').text();
- var ajax_url = "/origami/" + sale_id + "/member_discount";
+ // $("#member-discount").on('click', function(e){
+ // e.preventDefault();
+ // var sale_id = $('#sale-id').text();
+ // var sub_total = $('#order-sub-total').text();
+ // var ajax_url = "/origami/" + sale_id + "/member_discount";
- // Selected Account
- var account_types = JSON.stringify(get_selected_account_types());
- var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
+ // // Selected Account
+ // var account_types = JSON.stringify(get_selected_account_types());
+ // var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
- $.ajax({
- type: "POST",
- url: ajax_url,
- data: params,
- success:function(result){
- alert("Successfully Discount!");
- if(result.table_type == "Table"){
- window.location.href = "/origami/table/" + result.table_id
- }
- else {
- window.location.href = "/origami/room/" + result.table_id
- }
- }
- });
- });
+ // $.ajax({
+ // type: "POST",
+ // url: ajax_url,
+ // data: params,
+ // success:function(result){
+ // alert("Successfully Discount!");
+ // if(result.table_type == "Table"){
+ // window.location.href = "/origami/table/" + result.table_id
+ // }
+ // else {
+ // window.location.href = "/origami/room/" + result.table_id
+ // }
+ // }
+ // });
+ // });
});
/* Remove Selection */
@@ -540,10 +600,23 @@ function calculate_overall_discount(type, amount){
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
- aler("Percentage Value over 100!");
- return;
+ $.confirm({
+ title: 'Infomation!',
+ content: "Percentage Value over 100!",
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ return;
+ }
+ }
+ }
+ });
+ }
+ else{
+ total_discount = (origin_sub_total * amount)/100;
}
- total_discount = (origin_sub_total * amount)/100;
}
$("#order-discount").text(total_discount);
@@ -560,42 +633,43 @@ function calculate_item_discount(type, amount, sale_items, account_types){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
- if(account_types.length > 0){
- for(var j=0; j < account_types.length; j++){
- if(sale_items[i].account_id != account_types[j].id){
- // Discount Items
- var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + amount;
- }
- }
- }
- else {
- var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + amount;
- }
+ // if(account_types.length > 0){
+ // for(var j=0; j < account_types.length; j++){
+ // if(sale_items[i].account_id == account_types[j].id){
+ // // Discount Items
+ // var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
+ // $("#order-items-table tbody").append(discount_item_row);
+ // total_discount = total_discount + amount;
+ // }
+ // }
+ // }
+ // else {
+ var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
+ $("#order-items-table tbody").append(discount_item_row);
+ total_discount = total_discount + amount;
+ // }
}
}
- if(account_types.length > 0){
- var item_rows=get_item_rows();
- if(item_rows.length > 0){
- for(var k=0; k < item_rows.length; k++){
- for(var j=0; j < account_types.length; j++){
- if(item_rows[k].account_id == account_types[j].id){
- // Discount Items
- var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + amount;
- }
- }
- }
- }
- else {
- alert("No Items!");
- }
- }
+ // No Needs For Auto Selected
+ // if(account_types.length > 0){
+ // var item_rows=get_item_rows();
+ // if(item_rows.length > 0){
+ // for(var k=0; k < item_rows.length; k++){
+ // for(var j=0; j < account_types.length; j++){
+ // if(item_rows[k].account_id == account_types[j].id){
+ // // Discount Items
+ // var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
+ // $("#order-items-table tbody").append(discount_item_row);
+ // total_discount = total_discount + amount;
+ // }
+ // }
+ // }
+ // }
+ // else {
+ // alert("No Items!");
+ // }
+ // }
sub_total = origin_sub_total - total_discount;
}
@@ -603,57 +677,67 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
- aler("Percentage Value over 100!");
- return;
+ $.confirm({
+ title: 'Infomation!',
+ content: "Percentage Value over 100!",
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ return;
+ }
+ }
+ }
+ });
}
-
- // Check sale items exists
- if(sale_items.length > 0){
- for(var i=0;i < sale_items.length;i++){
- if(account_types.length > 0){
- for(var j=0; j < account_types.length; j++){
- if(sale_items[i].account_id != account_types[j].id){
- // Discount Items
- dis_amount = 0 - ((sale_items[i].price * amount)/100);
- var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + dis_amount;
- }
- }
- }
- else {
- dis_amount = 0 - ((sale_items[i].price * amount)/100);
- var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + dis_amount;
-
+ else{
+ // Check sale items exists
+ if(sale_items.length > 0){
+ for(var i=0;i < sale_items.length;i++){
+ // if(account_types.length > 0){
+ // for(var j=0; j < account_types.length; j++){
+ // if(sale_items[i].account_id == account_types[j].id){
+ // // Discount Items
+ // dis_amount = 0 - ((sale_items[i].price * amount)/100);
+ // var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
+ // $("#order-items-table tbody").append(discount_item_row);
+ // total_discount = total_discount + dis_amount;
+ // }
+ // }
+ // }
+ // else {
+ dis_amount = 0 - ((sale_items[i].price * amount)/100);
+ var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
+ $("#order-items-table tbody").append(discount_item_row);
+ total_discount = total_discount + dis_amount;
+ // }
}
+ sub_total = origin_sub_total + total_discount;
}
}
-
+ // No Needs For Auto Selected
// Check account types exists
- if(account_types.length > 0){
- var item_rows=get_item_rows();
- console.log(account_types);
- if(item_rows.length > 0){
- for(var k=0; k < item_rows.length; k++){
- for(var j=0; j < account_types.length; j++){
- if(item_rows[k].account_id == account_types[j].id){
- // Discount Items
- dis_amount = 0 - ((item_rows[k].price * amount)/100);
- var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
- $("#order-items-table tbody").append(discount_item_row);
- total_discount = total_discount + dis_amount;
- }
- }
- }
- }
- else {
- alert("No Items!");
- }
- }
-
- sub_total = origin_sub_total + total_discount;
+ // if(account_types.length > 0){
+ // var item_rows=get_item_rows();
+ // console.log(account_types);
+ // if(item_rows.length > 0){
+ // for(var k=0; k < item_rows.length; k++){
+ // for(var j=0; j < account_types.length; j++){
+ // if(item_rows[k].account_id == account_types[j].id){
+ // // Discount Items
+ // dis_amount = 0 - ((item_rows[k].price * amount)/100);
+ // var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
+ // $("#order-items-table tbody").append(discount_item_row);
+ // total_discount = total_discount + dis_amount;
+ // }
+ // }
+ // }
+ // }
+ // else {
+ // alert("No Items!");
+ // }
+ // }
}
$("#order-sub-total").text(sub_total);
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 8b613409..73959b5b 100644
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -469,8 +469,24 @@ $('#request_bills').click(function() {
url: ajax_url,
// data: 'order_id='+ order_id,
success:function(result){
-
- location.reload();
+ if(!result.status){
+ $.confirm({
+ title: 'Infomation!',
+ content: result.error_message,
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ window.location.href = '/origami';
+ }
+ }
+ }
+ });
+ }
+ else {
+ location.reload();
+ }
}
});
});
diff --git a/app/views/origami/payments/create.json.jbuilder b/app/views/origami/payments/create.json.jbuilder
index 08bf292c..f1dd8cad 100644
--- a/app/views/origami/payments/create.json.jbuilder
+++ b/app/views/origami/payments/create.json.jbuilder
@@ -1 +1,2 @@
json.status true
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 9b04e38e..7c608fcb 100644
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -119,7 +119,7 @@
<%= @other %>
<% else %>
-
+
<% end %>
@@ -351,16 +351,17 @@ $( document ).ready(function() {
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
- localStorage.removeItem("cash");
+ localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
- }else{
+ }
+ else{
var msg = '';
}
if($('#balance').text() < 0){
$.confirm({
- title: 'Hi!',
+ title: 'Infomation!',
content: 'Changed amount ' + $('#balance').text() * (-1),
buttons: {
confirm: {
@@ -372,12 +373,11 @@ $( document ).ready(function() {
}
}
});
- }else{
-
+ }
+ else{
$('#pay').text("Pay")
-
$.confirm({
- title: 'Hi!',
+ title: 'Infomation!',
content: 'Thank you !',
buttons: {
confirm: {
diff --git a/app/views/origami/request_bills/print.json.jbuilder b/app/views/origami/request_bills/print.json.jbuilder
index 08bf292c..332a9cec 100644
--- a/app/views/origami/request_bills/print.json.jbuilder
+++ b/app/views/origami/request_bills/print.json.jbuilder
@@ -1 +1,7 @@
-json.status true
+if @status == true
+ #show invoice number and stuff
+ json.status @status
+else
+ json.status @status
+ json.error_message @error_message
+end
diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb
index 9b681fe1..66a48522 100644
--- a/app/views/origami/rooms/show.html.erb
+++ b/app/views/origami/rooms/show.html.erb
@@ -457,8 +457,24 @@ $('#request_bills').click(function() {
url: ajax_url,
// data: 'order_id='+ order_id,
success:function(result){
-
- location.reload();
+ if(!result.status){
+ $.confirm({
+ title: 'Infomation!',
+ content: result.error_message,
+ buttons: {
+ confirm: {
+ text: 'Ok',
+ btnClass: 'btn-green',
+ action: function(){
+ window.location.href = '/origami';
+ }
+ }
+ }
+ });
+ }
+ else {
+ location.reload();
+ }
}
});
});
diff --git a/app/views/reports/dailysale/_shift_sale_report_filter.html.erb b/app/views/reports/dailysale/_shift_sale_report_filter.html.erb
index 9b89858a..28706731 100644
--- a/app/views/reports/dailysale/_shift_sale_report_filter.html.erb
+++ b/app/views/reports/dailysale/_shift_sale_report_filter.html.erb
@@ -19,17 +19,7 @@
-
+
From
diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb
index 64565fb5..d01463b7 100644
--- a/app/views/reports/dailysale/index.html.erb
+++ b/app/views/reports/dailysale/index.html.erb
@@ -70,7 +70,7 @@
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% paypar += sale[:paypar_amount] %>
- <% cash += sale[:cash_amount] %>
+ <% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
@@ -86,7 +86,7 @@
<%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%>
<%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%>
<%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%>
- <%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%>
+ <%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%>
<%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%>
<%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>
(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)
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
index 1b4082f5..8e1de8e2 100644
--- a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb
+++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb
@@ -18,6 +18,7 @@
Last year
+
Select Type
@@ -29,16 +30,20 @@
Other Amount Only
-
-
\ 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 dc7d05ee..d30d6154 100644
--- a/app/views/reports/receipt_no/index.html.erb
+++ b/app/views/reports/receipt_no/index.html.erb
@@ -1,115 +1,209 @@
- <%= render :partial=>'shift_sale_report_filter',
- :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
+ <%= render :partial=>'shift_sale_report_filter',
+ :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_receipt_no_index_path} %>
-
+
-
-
-
- Date
- Receipt No
- Cashier Name
- Gross Sales
- Discount
- Total Sales
- <% TaxProfile.all.each do |r|%>
- <%=r.name%>
- <% end %>
- Nett Sales
-
-
+
+
+ <% if !params[:from].blank?%>
+
+ From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
+
+ <% end %>
+ <% if @shift_from %>
+
+ <% if @shift.employee %>
+ <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
+ <% end %>
+ Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
+
+ <% end %>
-
- <% 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 ''%>
- <%=Employee.find(sale.cashier_id).name 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 => ',') %>
- <% sale.sale_taxes.each do |sale|%>
- <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %>
- <% end %>
-
- <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
-
- <% end %>
-
-
-
+
+ Recipt No
+ Cashier Name
+ Total Amount
+ Discount Amount
+ Tax Amount
+
+ Grand Total
+ Rounding Adj.
+ Grand Total +
+ Rounding Adj.
+
+
+
+
+ <% grand_total = 0 %>
+ <% old_grand_total = 0 %>
+ <% total_tax = 0 %>
+ <% guest_count = 0 %>
+ <% total_sum = 0 %>
+ <% discount_amt = 0 %>
+ <% other_amt = 0 %>
+ <% total_nett = 0 %>
+ <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
+
+ <%
+ if @sale_data!=nil
+ @sale_data.each do |result| %>
+
+ <% grand_total = grand_total.to_f + result.grand_total.to_f %>
+ <% old_grand_total = old_grand_total.to_f + result.old_grand_total.to_f %>
+ <% total_tax += result.total_tax.to_f %>
+ <% total_sum += result.total_amount.to_f %>
+ <% discount_amt += result.total_discount.to_f %>
+ <% rounding_adj += result.rounding_adjustment.to_f %>
+
+
+
+ <%= result.receipt_no rescue '-' %>
+ <%= result.cashier_name rescue '-' %>
+ <%= result.total_amount rescue '-' %>
+ <%= result.total_discount rescue '-' %>
+ <%= sprintf "%.2f",result.total_tax rescue '-' %>
+
+
+ <%= result.grand_total %>
+ <%= result.rounding_adjustment.to_f rescue '-' %>
+ <%= result.grand_total_after_rounding() rescue '-'%>
+
+
+ <%
+ end
+ end
+ %>
+
+
+ <%= total_sum rescue '-'%>
+ <%= discount_amt rescue '-'%>
+ <%= sprintf "%.2f",total_tax rescue '-'%>
+
+ <%= grand_total.to_f.round(2) rescue '-'%>
+ <%= rounding_adj rescue '-'%>
+ <%= old_grand_total.to_f.round + rounding_adj %>
+
+
+
+ Total Amount
+ Discount Amount
+ Tax Amount
+ Grand Total
+ Rounding Adj.
+ Grand Total +
+ Rounding Adj.
+
+
+
+
+
-<%= 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
index 5befb18a..b55a40c4 100644
--- a/app/views/reports/receipt_no/index.xls.erb
+++ b/app/views/reports/receipt_no/index.xls.erb
@@ -1,43 +1,91 @@
-
-
+
+
+
+
+ <% if !params[:from].blank?%>
+
+ From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%>
+
+ <% end %>
+ <% if @shift_from %>
+
+ <% if @shift.employee %>
+ <% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
+ <% end %>
+ Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )
+
+ <% end %>
-
-
-
- Date
- Receipt No
- Cashier Name
- Gross Sales
- Discount
- Total Sales
- <% TaxProfile.all.each do |r|%>
- <%=r.name%>
- <% end %>
- Nett Sales
-
-
+
+ Recipt No
+ Cashier Name
+ Total Amount
+ Discount Amount
+ Tax Amount
+
+ Grand Total
+ Rounding Adj.
+ Grand Total +
+ Rounding Adj.
+
+
+
+
+ <% grand_total = 0 %>
+ <% total_tax = 0 %>
+ <% guest_count = 0 %>
+ <% total_sum = 0 %>
+ <% discount_amt = 0 %>
+ <% other_amt = 0 %>
+ <% total_nett = 0 %>
+ <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
-
- <% 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 ''%>
- <%=Employee.find(sale.cashier_id).name 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 => ',') %>
- <% sale.sale_taxes.each do |sale|%>
- <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %>
- <% end %>
-
- <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
-
- <% end %>
-
-
-
+ <% @sale_data.each do |result| %>
+
+ <% grand_total = grand_total.to_f + result.grand_total.to_f %>
+ <% total_tax += result.total_tax.to_f %>
+ <% total_sum += result.total_amount.to_f %>
+ <% discount_amt += result.total_discount.to_f %>
+ <% rounding_adj += result.rounding_adjustment.to_f %>
+
+
+
+ <%= result.receipt_no rescue '-' %>
+ <%= result.cashier_name rescue '-' %>
+ <%= result.total_amount rescue '-' %>
+ <%= result.total_discount rescue '-' %>
+ <%= sprintf "%.2f",result.total_tax rescue '-' %>
+
+
+ <%= result.grand_total %>
+ <%= result.rounding_adjustment.to_f rescue '-' %>
+ <%= result.grand_total_after_rounding() rescue '-'%>
+
+
+ <% end %>
+
+
+ <%= total_sum rescue '-'%>
+ <%= discount_amt rescue '-'%>
+ <%= sprintf "%.2f",total_tax rescue '-'%>
+
+ <%= grand_total.to_f.round(2) rescue '-'%>
+ <%= rounding_adj rescue '-'%>
+ <%= grand_total.to_f.round + rounding_adj %>
+
+
+
+ Total Amount
+ Discount Amount
+ Tax Amount
+ Grand Total
+ Rounding Adj.
+ Grand Total +
+ Rounding Adj.
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/reports/receipt_no/indexback.html.erb b/app/views/reports/receipt_no/indexback.html.erb
new file mode 100644
index 00000000..dc7d05ee
--- /dev/null
+++ b/app/views/reports/receipt_no/indexback.html.erb
@@ -0,0 +1,115 @@
+
+
+
+ <%= render :partial=>'shift_sale_report_filter',
+ :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
+
+
+
+
+
+
+
+
+
+
+ Date
+ Receipt No
+ Cashier Name
+ Gross Sales
+ Discount
+ Total Sales
+ <% TaxProfile.all.each do |r|%>
+ <%=r.name%>
+ <% end %>
+ 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 ''%>
+ <%=Employee.find(sale.cashier_id).name 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 => ',') %>
+ <% sale.sale_taxes.each do |sale|%>
+ <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %>
+ <% end %>
+
+ <%= 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/indexback.xls.erb b/app/views/reports/receipt_no/indexback.xls.erb
new file mode 100644
index 00000000..5befb18a
--- /dev/null
+++ b/app/views/reports/receipt_no/indexback.xls.erb
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ Date
+ Receipt No
+ Cashier Name
+ Gross Sales
+ Discount
+ Total Sales
+ <% TaxProfile.all.each do |r|%>
+ <%=r.name%>
+ <% end %>
+ 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 ''%>
+ <%=Employee.find(sale.cashier_id).name 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 => ',') %>
+ <% sale.sale_taxes.each do |sale|%>
+ <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %>
+ <% end %>
+
+ <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %>
+
+ <% end %>
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index f4dd5b13..3320bdc6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -105,7 +105,7 @@ Rails.application.routes.draw do
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
# Discount for Member
- post "/:id/member_discount" => "discounts#member_discount"
+ # post "/:id/member_discount" => "discounts#member_discount"
get "/:id/request_bills" => "request_bills#print",:as => "request_bill"
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
@@ -271,10 +271,12 @@ Rails.application.routes.draw do
#--------- Reports Controller Sections ------------#
namespace :reports do
- resources :receipt_no, :only => [:index, :show]
+ resources :receipt_no
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
+
+ get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
# resources :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show]
diff --git a/dump.rdb b/dump.rdb
index 3ac76616..abdaadff 100644
Binary files a/dump.rdb and b/dump.rdb differ