Merge branch 'master' into discount

This commit is contained in:
Yan
2017-07-10 12:08:03 +06:30
23 changed files with 1079 additions and 387 deletions

View File

@@ -50,10 +50,13 @@ class Origami::DiscountsController < BaseOrigamiController
# Re-calc All Amount in Sale # 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 end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json render :json => result.to_json
end end
# Remove selected discount Items # Remove selected discount Items
@@ -78,11 +81,12 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.save # sale.save
# Re-calc All Amount in Sale # Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
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 end
dining = {:table_id => table_id, :table_type => table_type } render :json => result.to_json
render :json => dining.to_json
end end
# Remove all discount Items # Remove all discount Items
@@ -108,11 +112,12 @@ class Origami::DiscountsController < BaseOrigamiController
# Re-calc All Amount in Sale # Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0) sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
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 end
dining = {:table_id => table_id, :table_type => table_type } render :json => result.to_json
render :json => dining.to_json
end end
# Member Discount # Member Discount

View File

@@ -68,8 +68,6 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) 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") 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
end end

View File

@@ -5,6 +5,7 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale = Sale.new @sale = Sale.new
sale_order=SaleOrder.new sale_order=SaleOrder.new
if ShiftSale.current_open_shift(current_user.id)
order_id = params[:id] # order_id order_id = params[:id] # order_id
bk_order = BookingOrder.find_by_order_id(order_id) bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id)
@@ -19,6 +20,10 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale_data = Sale.find_by_sale_id(check_booking.sale_id) @sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end end
else
@status = false
@error_message = "No Current Open Shift for This Employee"
end
# Not Use for these printed bill cannot give customer # Not Use for these printed bill cannot give customer
# unique_code = "ReceiptBillPdf" # unique_code = "ReceiptBillPdf"

View File

@@ -5,6 +5,9 @@ class Reports::DailysaleController < BaseReportController
from, to ,report_type = get_date_range_from_params from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to) @sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to) @tax = SaleTax.get_tax(from,to)
puts from
puts to
puts "sssssssss"
respond_to do |format| respond_to do |format|
format.html format.html
format.xls format.xls

View File

@@ -1,13 +1,36 @@
class Reports::ReceiptNoController < BaseReportController class Reports::ReceiptNoController < BaseReportController
authorize_resource :class => false authorize_resource :class => false
def index def index
from, to = get_date_range_from_params from, to, report_type = get_date_range_from_params
puts "from..." # if to.blank?
puts from # @shift = ShiftSale.where('shift_started_at <= ? and shift_closed_at is NULL',from).take
puts "to..." # else
puts to # @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take
@sale_data = Sale.get_receipt_no_list(from,to) # end
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50) # 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| respond_to do |format|
format.html format.html
format.xls format.xls
@@ -15,6 +38,231 @@ authorize_resource :class => false
end end
def show 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 end
return from, to,report_type
end
end end

View File

@@ -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, 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 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 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='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") 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) .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 old_grand_total = sale.old_grand_total
total_discount = sale.total_discount total_discount = sale.total_discount
void_amount = sale.void_amount void_amount = sale.void_amount
total_change_amount = sale.total_change_amount
total = {:sale_date => pay.sale_date, total = {:sale_date => pay.sale_date,
:mpu_amount => pay.mpu_amount, :mpu_amount => pay.mpu_amount,
:master_amount => pay.master_amount, :master_amount => pay.master_amount,
@@ -464,6 +466,7 @@ class Sale < ApplicationRecord
:credit_amount => pay.credit_amount, :credit_amount => pay.credit_amount,
:foc_amount => pay.foc_amount, :foc_amount => pay.foc_amount,
:total_discount => total_discount, :total_discount => total_discount,
:total_change_amount => total_change_amount,
:grand_total => grand_total, :grand_total => grand_total,
:old_grand_total => old_grand_total, :old_grand_total => old_grand_total,
:void_amount => void_amount, :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") 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) return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end 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') # 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") # .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) # .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") # void = Sale.select("SUM(sales.grand_total) AS grand_total")
# .joins("join shift_sales sh on sh.id = sales.shift_sale_id") # .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) # .sum(:grand_total)
# cash = all_total.select('sr.payment_type') # cash = all_total.select('sr.payment_type')
# .where('sr.payment_type = "cash"') # .where('sr.payment_type = "cash"')
# .sum(:amount) # .sum(:amount)
# credit = all_total.where('sr.payment_type = "credit"') # credit = all_total.where('sr.payment_type = "creditnote"')
# .sum(:amount) # .sum(:amount)
# accept_credit = all_total.select('ci.amout') # accept_credit = all_total.select('ci.amout')
# .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id") # .joins("INNER JOIN credit_items ci ON ci.sale_id = sales.id")
# .where('sr.payment_type = "credit"') # .where('sr.payment_type = "creditnote"')
# .sum(:amout) # .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) # .sum(:grand_total)
# card = all_total.select('payment_type') # card = all_total.select('payment_type')
@@ -571,6 +574,31 @@ end
# return sale_arr # return sale_arr
# end # 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 def get_cash_amount
cash = 0.0 cash = 0.0
self.sale_payments.each do |pay| self.sale_payments.each do |pay|
@@ -616,8 +644,4 @@ end
def generate_custom_id def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
end end
def self.get_receipt_no_list(from,to)
sale = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
end
end end

View File

@@ -118,6 +118,23 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.closing_balance}", :size => self.item_font_size, :align => :right text "#{shift_sale.closing_balance}", :size => self.item_font_size, :align => :right
end 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 y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Net Sales:", :size => self.item_font_size, :align => :right text "Net Sales:", :size => self.item_font_size, :align => :right

View File

@@ -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 text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end end
# old = balance + redeem old = balance + redeem
# move_down 5 move_down 5
# y_position = cursor 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.item_description_width, :height => self.item_height) do
# text "Old Balance", :size => self.item_font_size,:align => :left text "Old Balance", :size => self.item_font_size,:align => :left
# end end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do 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 text "#{number_with_precision(old, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
# end end
end end
end end
@@ -386,10 +386,10 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor y_position = cursor
item_price_by_accounts.each do |ipa| item_price_by_accounts.each do |ipa|
y_position = cursor 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 text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end 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 text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end end
end end

View File

@@ -190,8 +190,8 @@
<button id="remove-item-discount" class="btn btn-warning btn-block action-btn">RemoveItem Discount</button> <button id="remove-item-discount" class="btn btn-warning btn-block action-btn">RemoveItem Discount</button>
<button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button> <button id="remove-all" class="btn btn-warning btn-block action-btn">Remove All</button>
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button> <button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
<hr /> <!-- <hr />
<button id="member-discount" class="btn btn-success btn-block action-btn">Member Discount</button> <button id="member-discount" class="btn btn-success btn-block action-btn">Member Discount</button> -->
</div> </div>
</div> </div>
</div> </div>
@@ -283,7 +283,7 @@ $(document).ready(function(){
$("#net").on('click', function(e){ $("#net").on('click', function(e){
e.preventDefault(); e.preventDefault();
var sale_id = $('#sale-id').text(); 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"; var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items // Selected Items
@@ -330,10 +330,15 @@ $(document).ready(function(){
// Remove selected discount items // Remove selected discount items
$("#remove-item").on('click', function(e){ $("#remove-item").on('click', function(e){
e.preventDefault(); e.preventDefault();
var origin_sub_total = parseFloat($("#order-sub-total").text());
var total = 0;
$('.discount-item-row.selected-item').each(function(i){ $('.discount-item-row.selected-item').each(function(i){
var amount = parseFloat($(this).find('#item-total-price').text());
total = total + Math.abs(amount);
$(this).remove(); $(this).remove();
}); });
$("#order-sub-total").text(origin_sub_total + total);
}); });
// Pay Discount for Payment // Pay Discount for Payment
@@ -352,7 +357,14 @@ $(document).ready(function(){
url: ajax_url, url: ajax_url,
data: params, data: params,
success:function(result){ success:function(result){
alert("Successfully Discount!"); $.confirm({
title: 'Infomation!',
content: result.status,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
if(result.table_type == "Table"){ if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id window.location.href = "/origami/table/" + result.table_id
} }
@@ -360,6 +372,10 @@ $(document).ready(function(){
window.location.href = "/origami/room/" + result.table_id window.location.href = "/origami/room/" + result.table_id
} }
} }
}
}
});
}
}); });
}); });
@@ -372,19 +388,41 @@ $(document).ready(function(){
// Selected Items // Selected Items
var sale_items = get_selected_sale_items(); var sale_items = get_selected_sale_items();
if(sale_items.length == 0){ if(sale_items.length == 0){
alert("You have no selected item!"); $.confirm({
title: 'Infomation!',
content: "You have no selected item!",
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
return; return;
} }
}
}
});
}
for(var i=0;i < sale_items.length;i++){ for(var i=0;i < sale_items.length;i++){
if(sale_items[i].price < 0){ if(sale_items[i].price < 0){
discount_items.push(sale_items[i]); discount_items.push(sale_items[i]);
} }
else { else {
alert("You have selected no discount item!"); $.confirm({
title: 'Infomation!',
content: "You have selected no discount item!!",
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
return; return;
} }
} }
}
});
}
}
var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) }; var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) };
$.ajax({ $.ajax({
@@ -392,7 +430,14 @@ $(document).ready(function(){
url: "/origami/" + sale_id + "/remove_discount_items", url: "/origami/" + sale_id + "/remove_discount_items",
data: params, data: params,
success: function(result){ success: function(result){
alert('Removed Discount'); $.confirm({
title: 'Infomation!',
content: result.status,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
if(result.table_type == "Table"){ if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id window.location.href = "/origami/table/" + result.table_id
} }
@@ -400,6 +445,10 @@ $(document).ready(function(){
window.location.href = "/origami/room/" + result.table_id window.location.href = "/origami/room/" + result.table_id
} }
} }
}
}
});
}
}); });
}); });
@@ -410,7 +459,14 @@ $(document).ready(function(){
type: "GET", type: "GET",
url: "/origami/" + sale_id + "/remove_all_discount", url: "/origami/" + sale_id + "/remove_all_discount",
success: function(result){ success: function(result){
alert('Removed All Discount'); $.confirm({
title: 'Infomation!',
content: result.status,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
if(result.table_type == "Table"){ if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id window.location.href = "/origami/table/" + result.table_id
} }
@@ -418,35 +474,39 @@ $(document).ready(function(){
window.location.href = "/origami/room/" + result.table_id window.location.href = "/origami/room/" + result.table_id
} }
} }
}
}
});
}
}); });
}); });
// Pay Discount for membership // Pay Discount for membership
$("#member-discount").on('click', function(e){ // $("#member-discount").on('click', function(e){
e.preventDefault(); // e.preventDefault();
var sale_id = $('#sale-id').text(); // var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text(); // var sub_total = $('#order-sub-total').text();
var ajax_url = "/origami/" + sale_id + "/member_discount"; // var ajax_url = "/origami/" + sale_id + "/member_discount";
// Selected Account // // Selected Account
var account_types = JSON.stringify(get_selected_account_types()); // var account_types = JSON.stringify(get_selected_account_types());
var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types }; // var params = {'sale_id':sale_id, 'sub_total':sub_total, 'account_types':account_types };
$.ajax({ // $.ajax({
type: "POST", // type: "POST",
url: ajax_url, // url: ajax_url,
data: params, // data: params,
success:function(result){ // success:function(result){
alert("Successfully Discount!"); // alert("Successfully Discount!");
if(result.table_type == "Table"){ // if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id // window.location.href = "/origami/table/" + result.table_id
} // }
else { // else {
window.location.href = "/origami/room/" + result.table_id // window.location.href = "/origami/room/" + result.table_id
} // }
} // }
}); // });
}); // });
}); });
/* Remove Selection */ /* Remove Selection */
@@ -540,11 +600,24 @@ function calculate_overall_discount(type, amount){
// For Percentage Pay // For Percentage Pay
if(type == 1){ if(type == 1){
if(amount > 100 ){ if(amount > 100 ){
aler("Percentage Value over 100!"); $.confirm({
title: 'Infomation!',
content: "Percentage Value over 100!",
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
return; return;
} }
}
}
});
}
else{
total_discount = (origin_sub_total * amount)/100; total_discount = (origin_sub_total * amount)/100;
} }
}
$("#order-discount").text(total_discount); $("#order-discount").text(total_discount);
} }
@@ -560,42 +633,43 @@ function calculate_item_discount(type, amount, sale_items, account_types){
dis_amount = (0 - amount); dis_amount = (0 - amount);
if(sale_items.length > 0){ if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){ for(var i=0;i < sale_items.length;i++){
if(account_types.length > 0){ // if(account_types.length > 0){
for(var j=0; j < account_types.length; j++){ // for(var j=0; j < account_types.length; j++){
if(sale_items[i].account_id != account_types[j].id){ // if(sale_items[i].account_id == account_types[j].id){
// Discount Items // // 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); var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row); $("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount; 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){ // No Needs For Auto Selected
var item_rows=get_item_rows(); // if(account_types.length > 0){
if(item_rows.length > 0){ // var item_rows=get_item_rows();
for(var k=0; k < item_rows.length; k++){ // if(item_rows.length > 0){
for(var j=0; j < account_types.length; j++){ // for(var k=0; k < item_rows.length; k++){
if(item_rows[k].account_id == account_types[j].id){ // for(var j=0; j < account_types.length; j++){
// Discount Items // if(item_rows[k].account_id == account_types[j].id){
var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount); // // Discount Items
$("#order-items-table tbody").append(discount_item_row); // var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
total_discount = total_discount + amount; // $("#order-items-table tbody").append(discount_item_row);
} // total_discount = total_discount + amount;
} // }
} // }
} // }
else { // }
alert("No Items!"); // else {
} // alert("No Items!");
} // }
// }
sub_total = origin_sub_total - total_discount; sub_total = origin_sub_total - total_discount;
} }
@@ -603,58 +677,68 @@ function calculate_item_discount(type, amount, sale_items, account_types){
// For Percentage Pay // For Percentage Pay
if(type == 1){ if(type == 1){
if(amount > 100 ){ if(amount > 100 ){
aler("Percentage Value over 100!"); $.confirm({
title: 'Infomation!',
content: "Percentage Value over 100!",
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
return; return;
} }
}
}
});
}
else{
// Check sale items exists // Check sale items exists
if(sale_items.length > 0){ if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){ for(var i=0;i < sale_items.length;i++){
if(account_types.length > 0){ // if(account_types.length > 0){
for(var j=0; j < account_types.length; j++){ // for(var j=0; j < account_types.length; j++){
if(sale_items[i].account_id != account_types[j].id){ // if(sale_items[i].account_id == account_types[j].id){
// Discount Items // // 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); dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount); var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row); $("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + dis_amount; 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;
}
}
}
// 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; 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!");
// }
// }
}
$("#order-sub-total").text(sub_total); $("#order-sub-total").text(sub_total);
} }

View File

@@ -469,8 +469,24 @@ $('#request_bills').click(function() {
url: ajax_url, url: ajax_url,
// data: 'order_id='+ order_id, // data: 'order_id='+ order_id,
success:function(result){ success:function(result){
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(); location.reload();
}
} }
}); });
}); });

View File

@@ -1 +1,2 @@
json.status true json.status true

View File

@@ -119,7 +119,7 @@
<div class="col-md-4" id="others"><%= @other %></div> <div class="col-md-4" id="others"><%= @other %></div>
</div> </div>
<% else %> <% else %>
<div class="row payment other-payment-color" id="card_payment" style="line-height:30px;height: 30px;margin-bottom: 0px;" > <div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-12">Other Payments</div> <div class="col-md-12">Other Payments</div>
</div> </div>
<% end %> <% end %>
@@ -354,13 +354,14 @@ $( document ).ready(function() {
localStorage.removeItem("cash"); localStorage.removeItem("cash");
if (result.status) { if (result.status) {
var msg = result.message; var msg = result.message;
}else{ }
else{
var msg = ''; var msg = '';
} }
if($('#balance').text() < 0){ if($('#balance').text() < 0){
$.confirm({ $.confirm({
title: 'Hi!', title: 'Infomation!',
content: 'Changed amount ' + $('#balance').text() * (-1), content: 'Changed amount ' + $('#balance').text() * (-1),
buttons: { buttons: {
confirm: { confirm: {
@@ -372,12 +373,11 @@ $( document ).ready(function() {
} }
} }
}); });
}else{ }
else{
$('#pay').text("Pay") $('#pay').text("Pay")
$.confirm({ $.confirm({
title: 'Hi!', title: 'Infomation!',
content: 'Thank you !', content: 'Thank you !',
buttons: { buttons: {
confirm: { confirm: {

View File

@@ -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

View File

@@ -457,9 +457,25 @@ $('#request_bills').click(function() {
url: ajax_url, url: ajax_url,
// data: 'order_id='+ order_id, // data: 'order_id='+ order_id,
success:function(result){ success:function(result){
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(); location.reload();
} }
}
}); });
}); });

View File

@@ -19,17 +19,7 @@
</select> </select>
</div> </div>
<input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type"> <input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type">
<!-- <div class="form-group col-md-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="0">All Sale Type</option>
<option value="1">Revenue Only</option>
<option value="2">Discount Only</option>
<option value="3">Void Only</option>
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</option>
</select>
</div> -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<!-- <label class="">Select Shift Period</label> --> <!-- <label class="">Select Shift Period</label> -->
<label class="">From</label> <label class="">From</label>

View File

@@ -70,7 +70,7 @@
<% visa += sale[:visa_amount] %> <% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %> <% jcb += sale[:jcb_amount] %>
<% paypar += sale[:paypar_amount] %> <% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount] %> <% cash += sale[:cash_amount]-sale[:total_change_amount] %>
<% credit += sale[:credit_amount] %> <% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %> <% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %> <% discount += sale[:total_discount] %>
@@ -86,7 +86,7 @@
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td> <td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td> <td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>

View File

@@ -18,6 +18,7 @@
<option value="9">Last year</option> <option value="9">Last year</option>
</select> </select>
</div> </div>
<input type="hidden" name="report_type" value="shift_item" id="sel_receipt_no">
<div class="form-group col-md-2"> <div class="form-group col-md-2">
<label>Select Type</label> <label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control"> <select name="sale_type" id="sel_sale_type" class="form-control">
@@ -29,16 +30,20 @@
<option value="5">Other Amount Only</option> <option value="5">Other Amount Only</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-2">
<!-- <label class="">Select Shift Period</label> --> <!-- <label class="">Select Shift Period</label> -->
<label class="">From</label> <label class="">From</label>
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date"> <input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-2">
<label class="">To</label> <label class="">To</label>
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date"> <input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
</div> </div>
<div class="form-group col-md-2 margin-top-20"> <div class="form-group col-md-2">
<label class="">All Shift</label>
<select name="shift_name" id="shift_name" class="form-control"></select>
</div>
<div class="form-group col-md-1 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'> <input type="submit" value="Generate Report" class='btn btn-primary'>
</div> </div>
</div> </div>
@@ -70,11 +75,7 @@
<%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %> <%= select_tag "payment_type", options_for_select(@payments, :selected => params[:payment_type]), :class => "form-control" %>
<% end %> <% end %>
<% if defined? shift_name %>
<!-- Temporary no needs
<select name="shift_name" id="shift_name"></select>
-->
<% end %>
<% if defined? cashiers %> <% if defined? cashiers %>
<%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %> <%= select_tag "cashier", options_from_collection_for_select(@cashiers,"id","name"),:prompt => "All Cashier Stations", :class => "form-control" %>
@@ -116,22 +117,6 @@
</div> </div>
</div> </div>
<!--
<div class = "row">
<div class = "span3">
<input type="button" value="Filter by Shift" class='btn' onclick = "select_shift(this)">
</div>
<div class = "span3">
<select name="shift" id="shift">
<option value="">All Shift</option>
</select>
</div>
<div class = "span3">
</div>
</div>
-->
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
@@ -165,20 +150,12 @@ $(function(){
} }
}); });
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>"); // $("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to]%>"); // $("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period]%>); // $("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>); // $("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %> <% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked"); $("#rd_period_type_1").attr("checked","checked");

View File

@@ -7,85 +7,135 @@
<div class="container"> <div class="container">
<%= render :partial=>'shift_sale_report_filter', <%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %> :locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_receipt_no_index_path} %>
<hr /> <hr />
</div> </div>
<div class="container"> <!-- <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12 text-right"> <div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a> <a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div> </div>
</div> </div>
</div> </div> -->
<div class="container margin-top-20"> <div class="container margin-top-20">
<div class="card row"> <div class="card row">
<table class="table table-striped"> <table class="table table-striped" border="0">
<thead> <thead>
<% if !params[:from].blank?%>
<tr> <tr>
<th style='text-align:center;'>Date</th> <th colspan="7">From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%></th>
<th style='text-align:center;'>Receipt No</th> </tr>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %> <% end %>
<th style='text-align:center;'>Nett Sales</th> <% if @shift_from %>
<tr>
<% if @shift.employee %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<tr>
<th>Recipt No</th>
<th>Cashier Name</th>
<th>Total Amount</th>
<th>Discount Amount </th>
<th>Tax Amount</th>
<!-- <th>Other Amount</th> -->
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total +<br/>
Rounding Adj.
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% total_sales = 0 %> <% grand_total = 0 %>
<% net_sales = 0 %> <% old_grand_total = 0 %>
<% @sale_data.each do |sale| %> <% total_tax = 0 %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> <% guest_count = 0 %>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%> <% total_sum = 0 %>
<tr> <% discount_amt = 0 %>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td> <% other_amt = 0 %>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td> <% total_nett = 0 %>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td> <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td> <%
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 %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr>
<%
end
end
%>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= sprintf "%.2f",total_tax rescue '-'%></b></td><!--
<td><b><%= sprintf "%.2f",service_charge rescue '-'%></b></td> -->
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= old_grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>Total Amount</td>
<td>Discount Amount</td>
<td>Tax Amount</td>
<td>Grand Total</td>
<td>Rounding Adj.</td>
<td>Grand Total +<br/>
Rounding Adj.
</td>
</tr> </tr>
<% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<%= paginate @sale_data %>
<script> <script>
$(function(){ $(function(){
var check_arr = []; var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){ $('#sel_period').change(function(){
search_by_period(); search_by_period();
}); });
function search_by_period(){ function search_by_period(){
var period = $('#sel_period').val(); var period = $('#sel_period').val();
var period_type = 0; var period_type = 0;
var from = ""; var from = "";
var to = ""; var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
} }
$('#from').change(function(){ $('#from').change(function(){
@@ -95,21 +145,65 @@ $(function(){
$('#to').change(function(){ $('#to').change(function(){
search_by_date(); search_by_date();
}); });
function search_by_date(){ function search_by_date(){
var from = $('#from').val(); var from = $('#from').val();
var to = $('#to').val(); var to = $('#to').val();
var period = 0; var period = 0;
var period_type = 1; var period_type = 1;
if(to != '' && from != ''){ if(to != '' && from != ''){
shift_name = from + ',' + to; shift_name = from + ',' + to;
check_arr.push(to); check_arr.push(to);
// console.log(check_arr.length)
console.log(check_arr.length)
if(check_arr.length == 1){ if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
} }
if(check_arr.length == 3){ if(check_arr.length == 3){
check_arr = []; check_arr = [];
} }
} }
} }
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
shift.empty();
var str = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
url = '<%= reports_get_shift_by_date_path %>';
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
if(param_shift != ''){
if(sh_date == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}else{
selected = '';
}
str += '<option value="'+ sh_date +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
}); });
</script> </script>

View File

@@ -1,42 +1,90 @@
<div class="span12"> <div class="container margin-top-20">
<div class="table-responsive"> <div class="card row">
<table class="table table-striped" border="0">
<table class="table table-striped">
<thead> <thead>
<% if !params[:from].blank?%>
<tr> <tr>
<th style='text-align:center;'>Date</th> <th colspan="7">From Date : <%= params[:from] rescue '-' %> , To Date : <%= params[:to] rescue '-'%></th>
<th style='text-align:center;'>Receipt No</th> </tr>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %> <% end %>
<th style='text-align:center;'>Nett Sales</th> <% if @shift_from %>
<tr>
<% if @shift.employee %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>
<% end %>
<tr>
<th>Recipt No</th>
<th>Cashier Name</th>
<th>Total Amount</th>
<th>Discount Amount </th>
<th>Tax Amount</th>
<!-- <th>Other Amount</th> -->
<th>Grand Total</th>
<th>Rounding Adj.</th>
<th>Grand Total +<br/>
Rounding Adj.
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% total_sales = 0 %> <% grand_total = 0 %>
<% net_sales = 0 %> <% total_tax = 0 %>
<% @sale_data.each do |sale| %> <% guest_count = 0 %>
<% total_sales = sale.total_amount.to_f - sale.total_discount.to_f%> <% total_sum = 0 %>
<% net_sales = total_sales.to_f + sale.total_tax.to_f%> <% discount_amt = 0 %>
<tr> <% other_amt = 0 %>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td> <% total_nett = 0 %>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td> <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td> <% @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 %>
<tr>
<td><%= result.receipt_no rescue '-' %> </td>
<td><%= result.cashier_name rescue '-' %></td>
<td><%= result.total_amount rescue '-' %></td>
<td><%= result.total_discount rescue '-' %></td>
<td><%= sprintf "%.2f",result.total_tax rescue '-' %></td>
<td><%= result.grand_total %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr> </tr>
<% end %> <% end %>
<tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td>
<td><b><%= discount_amt rescue '-'%></b></td>
<td><b><%= sprintf "%.2f",total_tax rescue '-'%></b></td><!--
<td><b><%= sprintf "%.2f",service_charge rescue '-'%></b></td> -->
<!-- <td><b><%= other_amt rescue '-'%></b></td> -->
<td><b><%= grand_total.to_f.round(2) rescue '-'%></b></td>
<td><b><%= rounding_adj rescue '-'%></b></td>
<td><b><%= grand_total.to_f.round + rounding_adj %></b></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>Total Amount</td>
<td>Discount Amount</td>
<td>Tax Amount</td>
<td>Grand Total</td>
<td>Rounding Adj.</td>
<td>Grand Total +<br/>
Rounding Adj.
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@@ -0,0 +1,115 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Receipt List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% 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%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= paginate @sale_data %>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -0,0 +1,43 @@
<div class="span12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Receipt No</th>
<th style='text-align:center;'>Cashier Name</th>
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
<tbody>
<% 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%>
<tr>
<td style='text-align:center;'><%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %></td>
<td style='text-align:center;'><%=sale.receipt_no.to_s rescue ''%></td>
<td style='text-align:center;'><%=Employee.find(sale.cashier_id).name rescue ''%></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -105,7 +105,7 @@ Rails.application.routes.draw do
post "/:id/remove_discount_items" => "discounts#remove_discount_items" post "/:id/remove_discount_items" => "discounts#remove_discount_items"
# Discount for Member # 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 "/:id/request_bills" => "request_bills#print",:as => "request_bill"
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
@@ -271,10 +271,12 @@ Rails.application.routes.draw do
#--------- Reports Controller Sections ------------# #--------- Reports Controller Sections ------------#
namespace :reports do namespace :reports do
resources :receipt_no, :only => [:index, :show] resources :receipt_no
resources :dailysale, :only => [:index, :show] resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show] resources :saleitem, :only => [:index, :show]
resources :shiftsale, :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 :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show] # resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show] # resources :customers, :only => [:index, :show]

BIN
dump.rdb

Binary file not shown.