Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
25
README.md
25
README.md
@@ -108,6 +108,31 @@ sudo cat /etc/sudoers
|
|||||||
### cope and parse
|
### cope and parse
|
||||||
%superuser ALL=(ALL) NOPASSWD: ALL
|
%superuser ALL=(ALL) NOPASSWD: ALL
|
||||||
|
|
||||||
|
<---- Extra Fields Script ----->
|
||||||
|
DROP TABLE IF EXISTS `display_images`;
|
||||||
|
CREATE TABLE `display_images` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`shop_id` int(11) DEFAULT NULL,
|
||||||
|
`image` blob,
|
||||||
|
`created_by` varchar(255) DEFAULT NULL,
|
||||||
|
`created_at` datetime NOT NULL,
|
||||||
|
`updated_at` datetime NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
ALTER TABLE customers
|
||||||
|
ADD COLUMN image_path VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE employees
|
||||||
|
ADD COLUMN image_path VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE commissioners
|
||||||
|
ADD COLUMN image_path VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE sales
|
||||||
|
ADD COLUMN equal_persons INT(11) after rebate_status;
|
||||||
|
<---- Extra Fields Script ----->
|
||||||
|
|
||||||
* ToDo list
|
* ToDo list
|
||||||
|
|
||||||
1. Migration
|
1. Migration
|
||||||
|
|||||||
3
app/assets/javascripts/reports/product_sale.coffee
Normal file
3
app/assets/javascripts/reports/product_sale.coffee
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
# All this logic will automatically be available in application.js.
|
||||||
|
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||||
3
app/assets/stylesheets/reports/product_sale.scss
Normal file
3
app/assets/stylesheets/reports/product_sale.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the reports/ProductSale controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
@@ -62,57 +62,59 @@ class HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dashboard
|
def dashboard
|
||||||
|
@from, @to = get_date_range_from_params
|
||||||
|
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|
||||||
today = DateTime.now.strftime('%Y-%m-%d')
|
today = DateTime.now.strftime('%Y-%m-%d')
|
||||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||||
|
|
||||||
@top_products = Sale.top_products(today).sum('i.qty')
|
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
|
||||||
@bottom_products = Sale.bottom_products(today).sum('i.qty')
|
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
|
||||||
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
|
||||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||||
# .sum(:grand_total)
|
# .sum(:grand_total)
|
||||||
@employee_sales = Sale.employee_sales(today)
|
@employee_sales = Sale.employee_sales(today,@from,@to)
|
||||||
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||||
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
|
||||||
|
|
||||||
@total_sale = Sale.total_sale(today)
|
@total_sale = Sale.total_sale(today,current_user,@from,@to)
|
||||||
@total_count = Sale.total_count(today)
|
@total_count = Sale.total_count(today,current_user,@from,@to)
|
||||||
@total_card = Sale.total_card_sale(today)
|
@total_card = Sale.total_card_sale(today,current_user,@from,@to)
|
||||||
@total_credit = Sale.credit_payment(today)
|
@total_credit = Sale.credit_payment(today,current_user,@from,@to)
|
||||||
|
|
||||||
@sale_data = Array.new
|
@sale_data = Array.new
|
||||||
@total_payment_methods = Sale.total_payment_methods(today)
|
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
|
||||||
|
|
||||||
@total_payment_methods.each do |payment|
|
@total_payment_methods.each do |payment|
|
||||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||||
pay = Sale.payment_sale('card', today)
|
pay = Sale.payment_sale('card', today, current_user,@from,@to)
|
||||||
@sale_data.push({'card' => pay.payment_amount})
|
@sale_data.push({'card' => pay.payment_amount})
|
||||||
else
|
else
|
||||||
pay = Sale.payment_sale(payment.payment_method, today)
|
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
|
||||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@summ_sale = Sale.summary_sale_receipt(today)
|
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
|
||||||
@total_customer = Sale.total_customer(today)
|
@total_customer = Sale.total_customer(today,current_user,@from,@to)
|
||||||
@total_dinein = Sale.total_dinein(today)
|
@total_dinein = Sale.total_dinein(today,current_user,@from,@to)
|
||||||
@total_takeaway = Sale.total_takeaway(today)
|
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to)
|
||||||
@total_other_customer = Sale.total_other_customer(today)
|
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to)
|
||||||
@total_membership = Sale.total_membership(today)
|
@total_membership = Sale.total_membership(today,current_user,@from,@to)
|
||||||
|
|
||||||
@total_order = Sale.total_order(today)
|
@total_order = Sale.total_order(today,current_user,@from,@to)
|
||||||
@total_accounts = Sale.total_account(today)
|
@total_accounts = Sale.total_account(today,current_user,@from,@to)
|
||||||
@account_data = Array.new
|
@account_data = Array.new
|
||||||
@total_accounts.each do |account|
|
@total_accounts.each do |account|
|
||||||
acc = Sale.account_data(account.account_id, today)
|
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
|
||||||
if !acc.nil?
|
if !acc.nil?
|
||||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@top_items = Sale.top_items(today)
|
@top_items = Sale.top_items(today,current_user,@from,@to)
|
||||||
@total_foc_items = Sale.total_foc_items(today)
|
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
@print_settings = PrintSetting.get_precision_delimiter()
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
@@ -162,4 +164,20 @@ class HomeController < ApplicationController
|
|||||||
redirect_to reports_dailysale_index_path
|
redirect_to reports_dailysale_index_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_date_range_from_params
|
||||||
|
from = params[:from]
|
||||||
|
to = params[:to]
|
||||||
|
|
||||||
|
if from.present? && to.present?
|
||||||
|
f_date = DateTime.parse(from)
|
||||||
|
t_date = DateTime.parse(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
|
||||||
|
|
||||||
|
return from, to
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ class Oqs::HomeController < BaseOqsController
|
|||||||
@queue_stations = OrderQueueStation.all
|
@queue_stations = OrderQueueStation.all
|
||||||
|
|
||||||
@queue_completed_item = completed_order(@filter)
|
@queue_completed_item = completed_order(@filter)
|
||||||
# if !@queue_completed_item.empty?
|
if !@queue_completed_item.empty?
|
||||||
# @queue_completed_item.each do |queue_item|
|
@queue_completed_item.each do |queue_item|
|
||||||
# if !queue_item.set_menu_items.nil?
|
if !queue_item.set_menu_items.nil?
|
||||||
# instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
|
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
|
||||||
# arr_instance_item_sets = Array.new
|
arr_instance_item_sets = Array.new
|
||||||
# instance_item_sets.each do |instance_item|
|
instance_item_sets.each do |instance_item|
|
||||||
# item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||||
# arr_instance_item_sets.push(item_instance_name)
|
arr_instance_item_sets.push(item_instance_name)
|
||||||
# end
|
end
|
||||||
# queue_item.set_menu_items = arr_instance_item_sets
|
queue_item.set_menu_items = arr_instance_item_sets
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
if !@filter.nil?
|
if !@filter.nil?
|
||||||
@count = queue_items_count_query(false,@filter)
|
@count = queue_items_count_query(false,@filter)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
sale_item.product_name = di["name"]
|
sale_item.product_name = di["name"]
|
||||||
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
||||||
sale_item.product_alt_name = ""
|
sale_item.product_alt_name = ""
|
||||||
sale_item.remark = "Discount"
|
sale_item.status = "Discount"
|
||||||
|
|
||||||
sale_item.qty = -1
|
sale_item.qty = -1
|
||||||
sale_item.unit_price = di["price"].to_f * (-1)
|
sale_item.unit_price = di["price"].to_f * (-1)
|
||||||
@@ -123,7 +123,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
discount_items = []
|
discount_items = []
|
||||||
#destroy all discount sale item
|
#destroy all discount sale item
|
||||||
sale.sale_items.each do |si|
|
sale.sale_items.each do |si|
|
||||||
if si.remark == "Discount" && si.price < 0
|
if si.status == "Discount" && si.price < 0
|
||||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||||
discount_items.push(si)
|
discount_items.push(si)
|
||||||
end
|
end
|
||||||
@@ -277,7 +277,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
# sale_item.sale_id = sale_id
|
# sale_item.sale_id = sale_id
|
||||||
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||||
# sale_item.product_name = product_name
|
# sale_item.product_name = product_name
|
||||||
# sale_item.remark = remark
|
# sale_item.status = remark
|
||||||
|
|
||||||
# sale_item.qty = 1
|
# sale_item.qty = 1
|
||||||
# sale_item.unit_price = (0-discount_amount.to_f)
|
# sale_item.unit_price = (0-discount_amount.to_f)
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
@order_items.push(item)
|
@order_items.push(item)
|
||||||
end
|
end
|
||||||
|
@account_arr = Array.new
|
||||||
|
if @customer.tax_profiles
|
||||||
accounts = @customer.tax_profiles
|
accounts = @customer.tax_profiles
|
||||||
puts accounts.to_json
|
puts accounts.to_json
|
||||||
puts "sssssssssss"
|
puts "sssssssssss"
|
||||||
@@ -100,6 +102,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@status_order = 'order'
|
@status_order = 'order'
|
||||||
else
|
else
|
||||||
sale = Sale.find(booking.sale_id)
|
sale = Sale.find(booking.sale_id)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
|||||||
sale_item.product_code = "Other Charges"
|
sale_item.product_code = "Other Charges"
|
||||||
sale_item.product_name = "*" + di["name"]
|
sale_item.product_name = "*" + di["name"]
|
||||||
sale_item.product_alt_name = ""
|
sale_item.product_alt_name = ""
|
||||||
sale_item.remark = "Other Charges"
|
sale_item.status = "Other Charges"
|
||||||
|
|
||||||
sale_item.qty = 1
|
sale_item.qty = 1
|
||||||
sale_item.unit_price = di["price"]
|
sale_item.unit_price = di["price"]
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, @usercurrent_user.name, cash, "cash")
|
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||||
|
|
||||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
|
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
@@ -313,6 +313,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
|
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
saleObj.update_attributes(rounding_adjustment: 0)
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
# create item void. make duplicate old record and update qty and price
|
# create item void. make duplicate old record and update qty and price
|
||||||
def item_void
|
def item_void
|
||||||
saleitemId = params[:sale_item_id]
|
saleitemId = params[:sale_item_id]
|
||||||
|
remark = params[:remark]
|
||||||
saleitemObj = SaleItem.find(saleitemId)
|
saleitemObj = SaleItem.find(saleitemId)
|
||||||
saleitemObj.remark = 'void'
|
saleitemObj.status = 'void'
|
||||||
|
saleitemObj.remark = remark
|
||||||
saleitemObj.save
|
saleitemObj.save
|
||||||
@newsaleitem = SaleItem.new
|
@newsaleitem = SaleItem.new
|
||||||
@newsaleitem = saleitemObj.dup
|
@newsaleitem = saleitemObj.dup
|
||||||
@@ -21,6 +23,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem.is_taxable = 1
|
@newsaleitem.is_taxable = 1
|
||||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||||
|
@newsaleitem.remark = remark
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
|
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
@@ -36,8 +39,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
|
|
||||||
def item_foc
|
def item_foc
|
||||||
saleitemId = params[:sale_item_id]
|
saleitemId = params[:sale_item_id]
|
||||||
|
remark = params[:remark]
|
||||||
saleitemObj = SaleItem.find(saleitemId)
|
saleitemObj = SaleItem.find(saleitemId)
|
||||||
saleitemObj.remark = 'foc'
|
saleitemObj.status = 'foc'
|
||||||
|
saleitemObj.remark = remark
|
||||||
saleitemObj.save
|
saleitemObj.save
|
||||||
@newsaleitem = SaleItem.new
|
@newsaleitem = SaleItem.new
|
||||||
@newsaleitem = saleitemObj.dup
|
@newsaleitem = saleitemObj.dup
|
||||||
@@ -47,6 +52,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||||
@newsaleitem.price = saleitemObj.price * -1
|
@newsaleitem.price = saleitemObj.price * -1
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||||
|
@newsaleitem.remark = remark
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
|
|
||||||
# re-calc tax
|
# re-calc tax
|
||||||
@@ -65,7 +71,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
# update_qty = params[:update_qty]
|
# update_qty = params[:update_qty]
|
||||||
# update_price = params[:update_price]
|
# update_price = params[:update_price]
|
||||||
# saleitemObj = SaleItem.find(saleitemId)
|
# saleitemObj = SaleItem.find(saleitemId)
|
||||||
# saleitemObj.remark = 'void'
|
# saleitemObj.status = 'void'
|
||||||
# saleitemObj.save
|
# saleitemObj.save
|
||||||
# @newsaleitem = SaleItem.new
|
# @newsaleitem = SaleItem.new
|
||||||
# @newsaleitem = saleitemObj.dup
|
# @newsaleitem = saleitemObj.dup
|
||||||
@@ -117,7 +123,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
||||||
both.each do |item|
|
both.each do |item|
|
||||||
if item.qty.to_i > 0
|
if item.qty.to_i > 0
|
||||||
item.remark = nil
|
item.status = nil
|
||||||
item.save
|
item.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -142,7 +148,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
if item.qty.to_i < 0
|
if item.qty.to_i < 0
|
||||||
item.destroy
|
item.destroy
|
||||||
else
|
else
|
||||||
item.remark = nil
|
item.status = nil
|
||||||
end
|
end
|
||||||
item.save
|
item.save
|
||||||
ProductCommission.remove_product_commission(item)
|
ProductCommission.remove_product_commission(item)
|
||||||
|
|||||||
@@ -61,7 +61,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
|
||||||
|
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||||
unique_code = "CloseCashierPdf"
|
unique_code = "CloseCashierPdf"
|
||||||
|
|
||||||
|
if !close_cashier_pdf.empty?
|
||||||
|
close_cashier_pdf.each do |close_cashier|
|
||||||
|
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||||
|
if close_cashier[1] == '1'
|
||||||
|
unique_code="CloseCashierCustomisePdf"
|
||||||
|
else
|
||||||
|
unique_code="CloseCashierPdf"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
shop_details = Shop.find(1)
|
shop_details = Shop.find(1)
|
||||||
#get tax
|
#get tax
|
||||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||||
@@ -73,12 +87,16 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||||
|
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||||
|
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||||
|
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
#byebug
|
||||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||||
|
|
||||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
|
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Employee.logout(session[:session_token])
|
Employee.logout(session[:session_token])
|
||||||
@@ -103,7 +121,6 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
21
app/controllers/reports/product_sale_controller.rb
Normal file
21
app/controllers/reports/product_sale_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
class Reports::ProductSaleController < BaseReportController
|
||||||
|
authorize_resource :class => false
|
||||||
|
|
||||||
|
def index
|
||||||
|
@order_by = 'desc'
|
||||||
|
if !params[:order_by].nil?
|
||||||
|
@order_by = params[:order_by]
|
||||||
|
end
|
||||||
|
|
||||||
|
@sale_data = Sale.get_menu_item_query(@order_by)
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json
|
||||||
|
format.xls
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/reports/product_sale_helper.rb
Normal file
2
app/helpers/reports/product_sale_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module Reports::ProductSaleHelper
|
||||||
|
end
|
||||||
@@ -22,18 +22,44 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
# def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
|
||||||
|
# #Use CUPS service
|
||||||
|
# #Generate PDF
|
||||||
|
# #Print
|
||||||
|
# cashier = shift_sale.employee.name
|
||||||
|
# shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||||
|
|
||||||
|
# pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
|
||||||
|
# filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||||
|
# pdf.render_file filename
|
||||||
|
# self.print(filename, cashier_terminal.printer_name)
|
||||||
|
# end
|
||||||
|
|
||||||
|
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
|
||||||
|
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
cashier = shift_sale.employee.name
|
cashier = shift_sale.employee.name
|
||||||
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||||
|
|
||||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
|
||||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||||
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
||||||
|
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||||
|
|
||||||
|
if !close_cashier_pdf.empty?
|
||||||
|
close_cashier_pdf.each do |close_cashier|
|
||||||
|
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||||
|
if close_cashier[1] == '1'
|
||||||
|
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
|
||||||
|
else
|
||||||
|
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
self.print(filename, cashier_terminal.printer_name)
|
self.print(filename, cashier_terminal.printer_name)
|
||||||
end
|
end
|
||||||
|
#sqa
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Sale < ApplicationRecord
|
|||||||
self.cashier_id = open_cashier[0].id
|
self.cashier_id = open_cashier[0].id
|
||||||
self.cashier_name = open_cashier[0].name
|
self.cashier_name = open_cashier[0].name
|
||||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||||
self.shift_sale_id = shift_id.id
|
self.shift_sale_id = current_shift.id
|
||||||
else
|
else
|
||||||
self.cashier_id = current_shift.employee_id
|
self.cashier_id = current_shift.employee_id
|
||||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||||
@@ -227,7 +227,7 @@ class Sale < ApplicationRecord
|
|||||||
sale_item.product_name = item.item_name
|
sale_item.product_name = item.item_name
|
||||||
sale_item.product_alt_name = item.alt_name
|
sale_item.product_alt_name = item.alt_name
|
||||||
sale_item.account_id = item.account_id
|
sale_item.account_id = item.account_id
|
||||||
sale_item.remark = item.remark
|
sale_item.status = item.remark
|
||||||
|
|
||||||
sale_item.qty = item.qty
|
sale_item.qty = item.qty
|
||||||
sale_item.unit_price = item.price
|
sale_item.unit_price = item.price
|
||||||
@@ -255,7 +255,7 @@ class Sale < ApplicationRecord
|
|||||||
sale_item.product_name = instance.item_instance_name
|
sale_item.product_name = instance.item_instance_name
|
||||||
sale_item.product_alt_name = menu_item.alt_name
|
sale_item.product_alt_name = menu_item.alt_name
|
||||||
sale_item.account_id = menu_item.account_id
|
sale_item.account_id = menu_item.account_id
|
||||||
sale_item.remark = nil
|
sale_item.status = nil
|
||||||
|
|
||||||
sale_item.qty = item["quantity"]
|
sale_item.qty = item["quantity"]
|
||||||
sale_item.unit_price = item["price"]
|
sale_item.unit_price = item["price"]
|
||||||
@@ -381,7 +381,7 @@ class Sale < ApplicationRecord
|
|||||||
rounding_adjustment = 0
|
rounding_adjustment = 0
|
||||||
|
|
||||||
sales_items.each do |item|
|
sales_items.each do |item|
|
||||||
if item.remark != 'void' && item.remark != 'foc'
|
if item.status != 'void' && item.status != 'foc'
|
||||||
#compute each item and added to total
|
#compute each item and added to total
|
||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
|
|
||||||
@@ -417,6 +417,7 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
customer = Customer.find(sale.customer_id)
|
customer = Customer.find(sale.customer_id)
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
|
if sale.payment_status != 'foc'
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
customer.tax_profiles.each do |cus_tax|
|
customer.tax_profiles.each do |cus_tax|
|
||||||
if cus_tax.to_i == tax.id
|
if cus_tax.to_i == tax.id
|
||||||
@@ -445,7 +446,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
sale.total_tax = total_tax_amount
|
sale.total_tax = total_tax_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -757,7 +758,7 @@ end
|
|||||||
def self.get_item_query()
|
def self.get_item_query()
|
||||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
|
||||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
|
||||||
"i.remark as status_type,"+
|
"i.status as status_type,"+
|
||||||
" i.unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
" i.unit_price,i.price as price,i.product_name as product_name, mc.name as" +
|
||||||
" menu_category_name,mc.id as menu_category_id ")
|
" menu_category_name,mc.id as menu_category_id ")
|
||||||
|
|
||||||
@@ -776,7 +777,7 @@ end
|
|||||||
def self.get_other_charges()
|
def self.get_other_charges()
|
||||||
query = Sale.select("i.account_id as account_id, " +
|
query = Sale.select("i.account_id as account_id, " +
|
||||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
"i.remark as status_type,"+
|
"i.status as status_type,"+
|
||||||
" i.unit_price as unit_price,i.product_name as product_name")
|
" i.unit_price as unit_price,i.product_name as product_name")
|
||||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||||
query = query.where("i.item_instance_code IS NULL AND i.product_code = 'Other Charges'")
|
query = query.where("i.item_instance_code IS NULL AND i.product_code = 'Other Charges'")
|
||||||
@@ -785,7 +786,6 @@ end
|
|||||||
|
|
||||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||||
|
|
||||||
query = self.get_item_query()
|
query = self.get_item_query()
|
||||||
|
|
||||||
discount_query = 0
|
discount_query = 0
|
||||||
@@ -861,6 +861,27 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
|||||||
return query,other_charges, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
return query,other_charges, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#product sale report query
|
||||||
|
def self.get_menu_item_query(order_by)
|
||||||
|
query = MenuItem.unscoped.select("acc.id as account_id,
|
||||||
|
acc.title as account_name,
|
||||||
|
mii.item_instance_code as item_code, " +
|
||||||
|
"(CASE WHEN si.qty > 0 THEN SUM(si.qty) ELSE 0 END) as total_item," +
|
||||||
|
"(CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END) as unit_price," +
|
||||||
|
"(CASE WHEN (si.qty * si.unit_price) > 0 THEN (si.qty * si.unit_price) ELSE 0 END) as grand_total," +
|
||||||
|
"mii.price as unit_price, menu_items.name as product_name,
|
||||||
|
mc.name as" +
|
||||||
|
" menu_category_name,mc.id as menu_category_id, si.remark as status_type, si.price as price ")
|
||||||
|
.joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" +
|
||||||
|
" LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" +
|
||||||
|
" LEFT JOIN accounts acc ON acc.id = menu_items.account_id" +
|
||||||
|
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
|
||||||
|
" LEFT JOIN sales s ON s.sale_id = si.sale_id")
|
||||||
|
.group("mc.id, menu_items.name, si.qty, (CASE WHEN si.unit_price > 0 THEN si.unit_price ELSE mii.price END)")
|
||||||
|
.order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}")
|
||||||
|
end
|
||||||
|
#product sale report query
|
||||||
|
|
||||||
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
|
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
|
||||||
## => left join -> show all sales although no orders
|
## => left join -> show all sales although no orders
|
||||||
if payment_type.blank?
|
if payment_type.blank?
|
||||||
@@ -1068,82 +1089,340 @@ end
|
|||||||
return tax
|
return tax
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.top_products(today)
|
def self.top_products(today,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
|
" i.price as unit_price,mi.name as product_name")
|
||||||
|
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||||
|
.where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+
|
||||||
|
"and payment_status='paid' and sale_status= 'completed'")
|
||||||
|
.group('mi.name')
|
||||||
|
.order("SUM(i.qty) DESC").limit(20)
|
||||||
|
else
|
||||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
" i.price as unit_price,mi.name as product_name")
|
" i.price as unit_price,mi.name as product_name")
|
||||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||||
"and payment_status='paid' and sale_status= 'completed'")
|
"and payment_status='paid' and sale_status= 'completed'")
|
||||||
.group('mi.name')
|
.group('mi.name')
|
||||||
.order("SUM(i.qty) DESC").limit(10)
|
.order("SUM(i.qty) DESC").limit(20)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.bottom_products(today)
|
def self.bottom_products(today,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
|
" i.price as unit_price,mi.name as product_name")
|
||||||
|
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||||
|
.where("(i.qty > 0 and i.price > 0) and receipt_date between '#{from}' and '#{to}'"+
|
||||||
|
"and payment_status='paid' and sale_status= 'completed'")
|
||||||
|
.group('mi.name')
|
||||||
|
.order("SUM(i.qty) ASC").limit(20)
|
||||||
|
else
|
||||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||||
" i.price as unit_price,mi.name as product_name")
|
" i.price as unit_price,mi.name as product_name")
|
||||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||||
"and payment_status='paid' and sale_status= 'completed'")
|
"and payment_status='paid' and sale_status= 'completed'")
|
||||||
.group('mi.name')
|
.group('mi.name')
|
||||||
.order("SUM(i.qty) ASC").limit(10)
|
.order("SUM(i.qty) ASC").limit(20)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.hourly_sales(today)
|
def self.hourly_sales(today,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
query= Sale.select("grand_total")
|
||||||
|
.where('payment_status="paid" and sale_status = "completed" and receipt_date between ? and ?',from,to)
|
||||||
|
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
|
||||||
|
.order('receipt_date')
|
||||||
|
else
|
||||||
query= Sale.select("grand_total")
|
query= Sale.select("grand_total")
|
||||||
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
|
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
|
||||||
.order('receipt_date')
|
.order('receipt_date')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.employee_sales(today)
|
def self.employee_sales(today,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
|
||||||
|
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
||||||
|
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between '#{from}' and '#{to}'")
|
||||||
|
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name")
|
||||||
|
.order("e.name")
|
||||||
|
else
|
||||||
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
|
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
|
||||||
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
||||||
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
|
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
|
||||||
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name")
|
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name")
|
||||||
.order("e.name")
|
.order("e.name")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.total_sale(today)
|
def self.total_sale(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and sales.receipt_date between ? and ? and shift_sale_id=?',from,to,shift.id)
|
||||||
|
.sum("grand_total")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
|
||||||
|
.sum("grand_total")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_count(today)
|
def self.total_count(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and receipt_date between ? and ? and shift_sale_id = ?',from,to,shift.id).count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id = ?',today,shift.id).count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_card_sale(today)
|
def self.total_card_sale(today,current_user=nil,from,to)
|
||||||
payment_type = " and payment_method = 'mpu' or payment_method = 'visa' or payment_method = 'master' or payment_method = 'jcb' or payment_method = 'unionpay' "
|
if !from.nil? && !to.nil?
|
||||||
# query = Sale.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
if current_user.nil?
|
||||||
# .where('sale_status = "completed" #{payment_type} and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
|
||||||
# .joins("join sale_payments on sale_id = sales.sale_id")
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
# .group("sales.sale_id")
|
.sum("sp.payment_amount")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
|
||||||
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
|
.sum("sp.payment_amount")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay") and shift_sale_id=?',from,to,shift.id)
|
||||||
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
|
.sum("sp.payment_amount")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
||||||
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
.sum("sp.payment_amount")
|
.sum("sp.payment_amount")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
||||||
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
|
.sum("sp.payment_amount")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay") and shift_sale_id=?',today,shift.id)
|
||||||
|
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||||
|
.sum("sp.payment_amount")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.credit_payment(today)
|
def self.credit_payment(today,current_user=nil,from,to)
|
||||||
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to)
|
||||||
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.sum("payment_amount")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to)
|
||||||
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.sum("payment_amount")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ? and s.shift_sale_id=?',from,to,shift.id)
|
||||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
.sum("payment_amount")
|
.sum("payment_amount")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.sum("payment_amount")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.sum("payment_amount")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ? and s.shift_sale_id=?',today,shift.id)
|
||||||
|
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
||||||
|
.sum("payment_amount")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.summary_sale_receipt(today)
|
def self.summary_sale_receipt(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
|
.where('sale_status = "completed" and receipt_date between ? and ?',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
|
.where('sale_status = "completed" and receipt_date between ? and ?',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
|
.where('sale_status = "completed" and receipt_date between ? and ? and shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
|
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
|
||||||
|
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_payment_methods(today)
|
def self.total_payment_methods(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("distinct sp.payment_method")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("distinct sp.payment_method")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("distinct sp.payment_method")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("distinct sp.payment_method")
|
query = Sale.select("distinct sp.payment_method")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("distinct sp.payment_method")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("distinct sp.payment_method")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.payment_sale(payment_method, today)
|
def self.payment_sale(payment_method, today, current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
if payment_method == 'card'
|
||||||
|
query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
|
||||||
|
else
|
||||||
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
end
|
||||||
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
if payment_method == 'card'
|
||||||
|
query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to)
|
||||||
|
else
|
||||||
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
end
|
||||||
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
if payment_method == 'card'
|
||||||
|
query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay") and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
else
|
||||||
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and sales.receipt_date between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
|
||||||
|
end
|
||||||
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
if payment_method == 'card'
|
if payment_method == 'card'
|
||||||
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
||||||
@@ -1151,12 +1430,35 @@ end
|
|||||||
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
end
|
end
|
||||||
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
if payment_method == 'card'
|
||||||
|
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today)
|
||||||
|
else
|
||||||
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
|
end
|
||||||
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
|
||||||
|
if payment_method == 'card'
|
||||||
|
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay") and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
else
|
||||||
|
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
|
||||||
|
end
|
||||||
|
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_customer(today)
|
def self.total_customer(today,current_user=nil,from,to)
|
||||||
dinein_cnt = self.total_dinein(today)
|
dinein_cnt = self.total_dinein(today,current_user,from,to)
|
||||||
takeaway_cnt = self.total_takeaway(today)
|
takeaway_cnt = self.total_takeaway(today,current_user,from,to)
|
||||||
membership_cnt = self.total_membership(today)
|
membership_cnt = self.total_membership(today,current_user,from,to)
|
||||||
|
|
||||||
total_cus = 0
|
total_cus = 0
|
||||||
if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
|
if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
|
||||||
@@ -1166,69 +1468,448 @@ end
|
|||||||
return total_cus
|
return total_cus
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_dinein(today)
|
def self.total_dinein(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_dinein_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_takeaway(today)
|
def self.total_takeaway(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_take_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_membership(today)
|
def self.total_membership(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_other_customer(today)
|
def self.total_other_customer(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(sales.customer_id) as total_cus")
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(sales.customer_id) as total_cus")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_order(today)
|
def self.total_order(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
|
.where('b.status = "billed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
|
.where('b.status = "billed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
|
.where('b.status = "billed" and sales.receipt_date between ? and ? and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(distinct a.order_id) as total_order")
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
.where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
.where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
|
.where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(distinct a.order_id) as total_order")
|
||||||
|
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN orders as b ON b.order_id = a.order_id")
|
||||||
|
.where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_account(today)
|
def self.total_account(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to)
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
|
.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and sales.shift_sale_id=?',from,to,shift.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("distinct b.id as account_id, b.title as title")
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.joins("JOIN accounts as b ON b.id = a.account_id")
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("distinct b.id as account_id, b.title as title")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.joins("JOIN accounts as b ON b.id = a.account_id")
|
||||||
|
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.account_data(account_id, today)
|
def self.account_data(account_id, today, current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.top_items(today)
|
def self.top_items(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.group("a.product_code")
|
||||||
|
.order("SUM(a.qty) DESC")
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.group("a.product_code")
|
||||||
|
.order("SUM(a.qty) DESC")
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
|
||||||
|
.group("a.product_code")
|
||||||
|
.order("SUM(a.qty) DESC")
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
.group("a.product_code")
|
.group("a.product_code")
|
||||||
.order("SUM(a.qty) DESC")
|
.order("SUM(a.qty) DESC")
|
||||||
.first()
|
.first()
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
|
.group("a.product_code")
|
||||||
|
.order("SUM(a.qty) DESC")
|
||||||
|
.first()
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||||
|
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
|
||||||
|
.group("a.product_code")
|
||||||
|
.order("SUM(a.qty) DESC")
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.total_foc_items(today)
|
def self.total_foc_items(today,current_user=nil,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
if current_user.nil?
|
||||||
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.sum("a.qty")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to)
|
||||||
|
.sum("a.qty")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ? and sales.shift_sale_id=?",from,to,shift.id)
|
||||||
|
.sum("a.qty")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_user.nil?
|
||||||
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
.sum("a.qty")
|
.sum("a.qty")
|
||||||
|
else
|
||||||
|
if current_user.role == 'administrator'
|
||||||
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||||
|
.sum("a.qty")
|
||||||
|
else
|
||||||
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
|
if !shift.nil?
|
||||||
|
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||||
|
.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id)
|
||||||
|
.sum("a.qty")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#card sale trans data
|
#card sale trans data
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class SaleItem < ApplicationRecord
|
|||||||
|
|
||||||
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
|
||||||
# Original Item to add remark
|
# Original Item to add remark
|
||||||
item.remark = type
|
item.status = type
|
||||||
item.save
|
item.save
|
||||||
|
|
||||||
sale_item = SaleItem.new
|
sale_item = SaleItem.new
|
||||||
@@ -37,7 +37,7 @@ class SaleItem < ApplicationRecord
|
|||||||
sale_item.product_name = item.product_name + " (#{type.upcase})"
|
sale_item.product_name = item.product_name + " (#{type.upcase})"
|
||||||
sale_item.product_alt_name = item.product_alt_name
|
sale_item.product_alt_name = item.product_alt_name
|
||||||
sale_item.account_id = item.account_id
|
sale_item.account_id = item.account_id
|
||||||
sale_item.remark = type
|
sale_item.status = type
|
||||||
if type == "foc" || type == "promotion" || type == "void"
|
if type == "foc" || type == "promotion" || type == "void"
|
||||||
sale_item.qty = qty * (-1)
|
sale_item.qty = qty * (-1)
|
||||||
else
|
else
|
||||||
@@ -99,7 +99,7 @@ class SaleItem < ApplicationRecord
|
|||||||
discount_account = {:name => a.title, :price => 0}
|
discount_account = {:name => a.title, :price => 0}
|
||||||
|
|
||||||
# Check for actual sale items
|
# Check for actual sale items
|
||||||
sale_items.where("remark = 'Discount'").find_each do |si|
|
sale_items.where("status = 'Discount'").find_each do |si|
|
||||||
if si.account_id == a.id
|
if si.account_id == a.id
|
||||||
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
|
discount_account[:price] = (discount_account[:price].abs + si.price.abs) * (1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class SalePayment < ApplicationRecord
|
|||||||
payment_status = false
|
payment_status = false
|
||||||
|
|
||||||
# add to sale item with foc
|
# add to sale item with foc
|
||||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
|
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and status is null")
|
||||||
|
|
||||||
sale_items.each do|item|
|
sale_items.each do|item|
|
||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
|
|||||||
@@ -135,6 +135,27 @@ class ShiftSale < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_total_dinein(shift)
|
||||||
|
query = Sale.select("sum(sales.grand_total) as total_dinein_amount")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Dinein" and c.membership_id is null',shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_total_takeway(shift)
|
||||||
|
query = Sale.select("sum(sales.grand_total) as total_takeway_amount")
|
||||||
|
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
|
||||||
|
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Takeaway" and c.membership_id is null',shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_total_other_charges(shift)
|
||||||
|
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
|
||||||
|
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
|
||||||
|
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
|
||||||
|
.first()
|
||||||
|
end
|
||||||
|
|
||||||
def self.search(filter,from,to)
|
def self.search(filter,from,to)
|
||||||
if filter.blank?
|
if filter.blank?
|
||||||
keyword = ''
|
keyword = ''
|
||||||
|
|||||||
@@ -36,12 +36,20 @@ class StockJournal < ApplicationRecord
|
|||||||
journal.save
|
journal.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.inventory_balances(today)
|
def self.inventory_balances(today,from,to)
|
||||||
|
if !from.nil? && !to.nil?
|
||||||
|
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||||
|
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||||
|
.where("stock_journals.created_at between '#{from}' and '#{to}'")
|
||||||
|
.group("mii.item_instance_name")
|
||||||
|
.order("mii.item_instance_name ASC")
|
||||||
|
else
|
||||||
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
query = StockJournal.select("mii.item_instance_name as item_instance_name,balance")
|
||||||
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
.joins("join menu_item_instances mii on mii.item_instance_code=stock_journals.item_code")
|
||||||
.where("DATE_FORMAT(stock_journals.created_at,'%Y-%m-%d') = '#{today}'")
|
.where("DATE_FORMAT(stock_journals.created_at,'%Y-%m-%d') = '#{today}'")
|
||||||
.group("mii.item_instance_name")
|
.group("mii.item_instance_name")
|
||||||
.order("mii.item_instance_name ASC")
|
.order("mii.item_instance_name ASC")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
496
app/pdf/close_cashier_customise_pdf.rb
Normal file
496
app/pdf/close_cashier_customise_pdf.rb
Normal file
@@ -0,0 +1,496 @@
|
|||||||
|
class CloseCashierCustomisePdf < Prawn::Document
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
|
||||||
|
|
||||||
|
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges)
|
||||||
|
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
|
||||||
|
self.page_height = printer_settings.page_height
|
||||||
|
self.margin = 5
|
||||||
|
self.price_width = 60
|
||||||
|
self.qty_width = 20
|
||||||
|
self.total_width = 40
|
||||||
|
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
|
||||||
|
self.item_height = 15
|
||||||
|
self.item_description_width = (self.page_width-20) / 2
|
||||||
|
self.label_width = 100
|
||||||
|
|
||||||
|
self.text_width = (self.page_width - 80) - self.price_width / 3
|
||||||
|
# @item_width = self.page_width.to_i / 2
|
||||||
|
# @qty_width = @item_width.to_i / 3
|
||||||
|
# @double = @qty_width * 1.3
|
||||||
|
# @half_qty = @qty_width / 2
|
||||||
|
#setting page margin and width
|
||||||
|
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||||
|
|
||||||
|
# db font setup
|
||||||
|
if printer_settings.font != ""
|
||||||
|
font_families.update("#{printer_settings.font}" => {
|
||||||
|
:normal => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:italic => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold => "public/fonts/#{printer_settings.font}.ttf",
|
||||||
|
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
|
||||||
|
})
|
||||||
|
|
||||||
|
font "#{printer_settings.font}"
|
||||||
|
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||||
|
end
|
||||||
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
|
# font "public/fonts/padauk.ttf"
|
||||||
|
self.header_font_size = 10
|
||||||
|
self.item_font_size = 8
|
||||||
|
|
||||||
|
#precision checked
|
||||||
|
if printer_settings.precision.to_i > 2
|
||||||
|
printer_settings.precision = 2
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if printer_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
header( shop_details)
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_dinein,total_takeway,total_other_charges)
|
||||||
|
end
|
||||||
|
|
||||||
|
def header (shop_details)
|
||||||
|
move_down 7
|
||||||
|
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
|
||||||
|
# move_down self.item_height
|
||||||
|
move_down 5
|
||||||
|
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
|
||||||
|
move_down 5
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
end
|
||||||
|
|
||||||
|
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges)
|
||||||
|
move_down 7
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Cashier : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.employee.name}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Cashier Station : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Opening Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Closing Date : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Opening Float : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||||
|
text "Closing Float : ", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
|
||||||
|
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
|
||||||
|
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||||
|
text "Shift Sale Summary", :size => self.header_font_size, :align => :center
|
||||||
|
end
|
||||||
|
move_down 10
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Received Amount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :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 "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :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 "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_discount_account = 0
|
||||||
|
total_discount_by_account.each do |amount|
|
||||||
|
|
||||||
|
total_discount_account = total_discount_account.to_f + amount.total_price.to_f
|
||||||
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
#start total FOC amount
|
||||||
|
@total_foc = 0
|
||||||
|
other_payment.each do |other|
|
||||||
|
@total_foc = other.foc_amount.round(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
#end total FOC amount
|
||||||
|
total_grand_total = shift_sale.grand_total + @total_foc.to_f + shift_sale.total_void.to_f - total_discount_account.to_f
|
||||||
|
# @total_grand_total = @shift_sale.grand_total + @overall + @total_foc + @shift_sale.total_void
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Grand Total :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(total_grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_discount_by_account.each do |amount|
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total FOC :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
if @total_foc.nil?
|
||||||
|
@total_foc = 0
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :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 "Total Void :", :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.total_void})", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
@total_foc = 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Cash Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Credit Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
#start other payment details
|
||||||
|
if shift_sale.other_sales > 0
|
||||||
|
other_payment.each do |other|
|
||||||
|
@total_foc = other.foc_amount.round(2)
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "MPU Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :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 "VISA Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Master Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :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 "JCB Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Reedem Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Other Payment :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Rounding Adjustments :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Gross Sale :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
# end other payment details
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
# start Dinein and Takeaway
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Dinein :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
if total_dinein.nil?
|
||||||
|
total_dinein = 0
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_dinein, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Total Takeaway :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
if total_takeway.nil?
|
||||||
|
total_takeway = 0
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_takeway, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# stop Dinein and Takeaway
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
#start service charges and commercial tax
|
||||||
|
sale_taxes.each do |tax|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :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 "Total Taxes :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :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 :", :style => :bold, :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
|
||||||
|
end
|
||||||
|
#end for service charges and commercial tax
|
||||||
|
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Total Sale :", :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.total_revenue}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
# total_discount_by_account.each do |amount|
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
# text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
# y_position = cursor
|
||||||
|
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
# text "Grand Total :", :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.grand_total}", :size => self.item_font_size, :align => :right
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
#start total amount by Account Like Food / Beverage /..
|
||||||
|
total_amount_by_account.each do |amount|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end total amount by Account
|
||||||
|
|
||||||
|
#start total other charges amount
|
||||||
|
if total_other_charges.present?
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Other Charges :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(total_other_charges, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#end total other charges amount
|
||||||
|
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
|
||||||
|
#start total over all discount
|
||||||
|
if total_member_discount[0].member_discount.present?
|
||||||
|
@member_discount = total_member_discount[0].member_discount rescue 0.0
|
||||||
|
@overall = shift_sale.total_discounts - @member_discount
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Member Discount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@overall = shift_sale.total_discounts
|
||||||
|
end
|
||||||
|
|
||||||
|
if @overall > 0
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
|
text "-#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
move_down -5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 7
|
||||||
|
end
|
||||||
|
#end total over all discount
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
|
||||||
|
text "Total Dine-in Count :", :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.dining_count}", :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 "Total Takeaway Count :", :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.takeaway_count}", :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 "Total Receipts :", :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.total_receipt}", :size => self.item_font_size, :align => :right
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
|
|
||||||
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 "Reedem Payment :", :size => self.item_font_size, :align => :right
|
text "Redeem Payment :", :size => self.item_font_size, :align => :right
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
|
||||||
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
|
||||||
@@ -395,4 +395,3 @@ class CloseCashierPdf < Prawn::Document
|
|||||||
move_down 5
|
move_down 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
<h2><%= t :dashboard %></h2>
|
<!-- <h2><%= t :dashboard %></h2> -->
|
||||||
|
<h2><%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></h2>
|
||||||
</div>
|
</div>
|
||||||
<% if @print_settings.precision.to_i > 0
|
<% if @print_settings.precision.to_i > 0
|
||||||
precision = @print_settings.precision
|
precision = @print_settings.precision
|
||||||
@@ -65,8 +66,28 @@
|
|||||||
<!-- #END# Widgets -->
|
<!-- #END# Widgets -->
|
||||||
<!-- CPU Usage -->
|
<!-- CPU Usage -->
|
||||||
|
|
||||||
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
<!-- Date range for dashboard -->
|
||||||
|
<div class="row clearfix">
|
||||||
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
|
||||||
|
<span id="fromErr" style="color:red;"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
|
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
|
||||||
|
<span id="toErr" style="color:red;"></span>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||||
|
<label></label><br>
|
||||||
|
<input type="button" value="Generate" class='btn btn-primary btn_generate'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<!-- Date range for dashboard -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
|
<div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||||
@@ -122,10 +143,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
<% end %>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'cashier' %>
|
||||||
<% if !@summ_sale.nil? %>
|
<% if !@summ_sale.nil? %>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t :sale %></h6>
|
<h6><%= t :sale %></h6>
|
||||||
@@ -136,19 +165,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t :sale %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_amount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%></td>
|
<td align="right"><%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.grand_total") %> : </td>
|
<td><%= t("views.right_panel.detail.grand_total") %> : </td>
|
||||||
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%></td>
|
<td align="right"><%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@@ -161,7 +190,7 @@
|
|||||||
<td align="right">
|
<td align="right">
|
||||||
<% @sale_data.each do |data| %>
|
<% @sale_data.each do |data| %>
|
||||||
<% pay_mth = payment.payment_method %>
|
<% pay_mth = payment.payment_method %>
|
||||||
<%= data[""+pay_mth+""] %>
|
<%= number_with_precision(data[""+pay_mth+""], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -174,7 +203,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
|
<td><%= t("views.right_panel.detail.card_sale") %> : </td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<%= total_card["card"].to_f %>
|
<%= number_with_precision(total_card["card"], precision: precision.to_i ,delimiter: delimiter) rescue number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -184,11 +213,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t :customer %></h6>
|
<h6><%= t :customer %></h6>
|
||||||
@@ -227,10 +262,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
|
<% else %>
|
||||||
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
|
<% end %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h6><%= t("views.right_panel.detail.order") %></h6>
|
<h6><%= t("views.right_panel.detail.order") %></h6>
|
||||||
@@ -274,6 +315,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
var from = '<%= @from.strftime('%d-%m-%Y') rescue '' %>';
|
||||||
|
var to = '<%= @to.strftime('%d-%m-%Y') rescue '' %>';
|
||||||
|
|
||||||
|
if((from!=undefined) && (from != null) && (from != '')){
|
||||||
|
$('#from').val(from);
|
||||||
|
}
|
||||||
|
if((to!=undefined) && (to != null) && (to != '')){
|
||||||
|
$('#to').val(to);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btn_generate').on('click',function(){
|
||||||
|
var from = $("#from").val();
|
||||||
|
var to = $("#to").val();
|
||||||
|
if((from=='') && (to=='')){
|
||||||
|
$('#fromErr').html("can't be blank");
|
||||||
|
$('#toErr').html("can't be blank");
|
||||||
|
}else if((from!='') && (to=='')){
|
||||||
|
$('#fromErr').html("");
|
||||||
|
$('#toErr').html("can't be blank");
|
||||||
|
}else if((from=='') && (to!='')){
|
||||||
|
$('#fromErr').html("can't be blank");
|
||||||
|
$('#toErr').html("");
|
||||||
|
}else{
|
||||||
|
$('#fromErr').html("");
|
||||||
|
$('#toErr').html("");
|
||||||
|
}
|
||||||
|
if((from!='') && (to!='')){
|
||||||
|
window.location.href = '/dashboard?from='+from+'&to='+to;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -122,6 +122,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
|
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="<%= reports_receipt_no_index_path %>">Receipt</a>
|
<a href="<%= reports_receipt_no_index_path %>">Receipt</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -83,13 +83,13 @@
|
|||||||
<span class="order-qty">
|
<span class="order-qty">
|
||||||
<%= qid.qty %>
|
<%= qid.qty %>
|
||||||
</span> ]
|
</span> ]
|
||||||
<% if !qid.set_menu_items.nil?
|
<% if !qid.set_menu_items.nil? %>
|
||||||
qid.set_menu_items.each do |item_instance|%>
|
<% qid.set_menu_items.each do |item_instance|%>
|
||||||
<br><span class="font-12">
|
<br><span class="font-12">
|
||||||
<%= item_instance %>
|
<%= item_instance %>
|
||||||
</span>
|
</span>
|
||||||
<% end
|
<% end %>
|
||||||
end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<% @sale_data.sale_items.each do |sale_item| %>
|
<% @sale_data.sale_items.each do |sale_item| %>
|
||||||
<%
|
<%
|
||||||
sub_total += sale_item.qty*sale_item.unit_price
|
sub_total += sale_item.qty*sale_item.unit_price
|
||||||
if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc"
|
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
|
||||||
%>
|
%>
|
||||||
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
|
||||||
<td style="width:60%; text-align:left">
|
<td style="width:60%; text-align:left">
|
||||||
|
|||||||
@@ -411,8 +411,10 @@
|
|||||||
<%= t("views.btn.back") %>
|
<%= t("views.btn.back") %>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
|
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
|
||||||
<% if current_login_employee.role != "waiter" %>
|
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
|
||||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
||||||
|
<% end %>
|
||||||
|
<% if current_login_employee.role != "waiter" %>
|
||||||
<% if @dining.status != "available" %>
|
<% if @dining.status != "available" %>
|
||||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||||
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
|
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
|
||||||
|
|||||||
@@ -441,7 +441,7 @@
|
|||||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
||||||
var total = $('#amount_due').text();
|
var total = $('#amount_due').text();
|
||||||
var amt = parseFloat(total) - parseFloat(othertotal);
|
var amt = parseFloat(total) - parseFloat(othertotal);
|
||||||
$('#cash').text(parseFloat(amt).toFixed(1));
|
$('#cash').text(parseFloat(amt).toFixed(2));
|
||||||
update_balance();
|
update_balance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -382,7 +382,10 @@
|
|||||||
<!-- Waiter Buttons -->
|
<!-- Waiter Buttons -->
|
||||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button>
|
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button>
|
||||||
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
|
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
|
||||||
|
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
|
||||||
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
|
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
|
||||||
|
<% end %>
|
||||||
|
<% if current_login_employee.role != "waiter" %>
|
||||||
<% if @room.bookings.length >= 1 %>
|
<% if @room.bookings.length >= 1 %>
|
||||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||||
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
|
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
|
||||||
@@ -453,6 +456,7 @@
|
|||||||
|
|
||||||
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
|
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<td class="p-2" width="20%">
|
<td class="p-2" width="20%">
|
||||||
<%= sale_item.product_name %>
|
<%= sale_item.product_name %>
|
||||||
</td>
|
</td>
|
||||||
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
|
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
|
||||||
<td class="p-1" width="5%">
|
<td class="p-1" width="5%">
|
||||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
|
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
|
||||||
</td>
|
</td>
|
||||||
@@ -69,11 +69,12 @@
|
|||||||
</td> -->
|
</td> -->
|
||||||
<td class="p-1" width="25%">
|
<td class="p-1" width="25%">
|
||||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
||||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
|
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
|
||||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
|
|
||||||
|
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
|
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
|
||||||
<td class="p-1" width="5%">
|
<td class="p-1" width="5%">
|
||||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||||
</td>
|
</td>
|
||||||
@@ -157,9 +158,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer ">
|
||||||
|
<div class="row p-r-20">
|
||||||
|
<div class="col-md-5">
|
||||||
|
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
// Bill Request
|
// Bill Request
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$('.editModal').on('click', function () {
|
||||||
|
$("#action").attr('data-type', $(this).attr('data-type'));
|
||||||
|
$("#action").attr('data-id', $(this).attr('data-id'));
|
||||||
|
$("#action").text($(this).attr('data-type'))
|
||||||
|
})
|
||||||
|
|
||||||
$(".update").on('click', function () {
|
$(".update").on('click', function () {
|
||||||
var sale_item_id = $(this).attr('data-id');
|
var sale_item_id = $(this).attr('data-id');
|
||||||
@@ -182,13 +213,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.void').on('click', function () {
|
/*$('.void').on('click', function () {
|
||||||
var sale_item_id = $(this).attr('data-id');
|
var sale_item_id = $(this).attr('data-id');
|
||||||
|
var remark = $("#remark").val();
|
||||||
var ajax_url = "/origami/item_void";
|
var ajax_url = "/origami/item_void";
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'sale_item_id=' + sale_item_id,
|
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
@@ -201,7 +233,27 @@
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'sale_item_id=' + sale_item_id,
|
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||||
|
success: function (result) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})*/
|
||||||
|
|
||||||
|
$('#action').on('click', function () {
|
||||||
|
var sale_item_id = $(this).attr('data-id');
|
||||||
|
var type = $(this).attr('data-type');
|
||||||
|
var remark = $("#remark").val();
|
||||||
|
if (type=='foc') {
|
||||||
|
var ajax_url = "/origami/item_foc";
|
||||||
|
}else{
|
||||||
|
var ajax_url = "/origami/item_void";
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: ajax_url,
|
||||||
|
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
@@ -224,6 +276,7 @@
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$('#back').on('click', function () {
|
$('#back').on('click', function () {
|
||||||
var table_id = '<%= @table_id %>'
|
var table_id = '<%= @table_id %>'
|
||||||
window.location.href = '/origami/table/' + table_id;
|
window.location.href = '/origami/table/' + table_id;
|
||||||
|
|||||||
@@ -91,37 +91,37 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style='text-align:right;'><%= count %></td>
|
<td style='text-align:right;'><%= count %></td>
|
||||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||||
<td style='color:red;text-align:right;'><%= number_with_precision(sale[:void_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='color:red;text-align:right;'><%= number_with_precision(sale[:void_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:mpu_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:master_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:visa_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:jcb_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:paypar_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision, delimiter: delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:foc_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(sale[:grand_total], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% count = count + 1 %>
|
<% count = count + 1 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="3" style='text-align:center;'>Total</td>
|
<td colspan="3" style='text-align:center;'>Total</td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(mpu , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(master, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(visa, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(visa, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(jcb, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(paypar, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_with_precision(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(total, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(grand_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% total_tax = 0 %>
|
<% total_tax = 0 %>
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
<% total_tax += tax.tax_amount.to_f %>
|
<% total_tax += tax.tax_amount.to_f %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td colspan="2"> </td>
|
<td colspan="2"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
<% net = total - total_tax %>
|
<% net = total - total_tax %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="12" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
<td colspan="12" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
<td style='text-align:right;'><%= number_with_precision(net, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_with_precision(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td colspan="2"> </td>
|
<td colspan="2"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
113
app/views/reports/product_sale/index.html.erb
Normal file
113
app/views/reports/product_sale/index.html.erb
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<div class="page-header">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||||
|
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.sale_item_report") %></li>
|
||||||
|
<span class="float-right">
|
||||||
|
<%= link_to 'Back', dashboard_path %>
|
||||||
|
</span>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="text-right">
|
||||||
|
<a href="javascript:export_to('<%=reports_product_sale_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="margin-top-20">
|
||||||
|
<div class="card">
|
||||||
|
<div class="p-l-20 p-t-20 p-b-20">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="font-16" for="order_by">Order by Qty</label>
|
||||||
|
<select name="order_by" id="order_by" class="form-control" style="width:10%">
|
||||||
|
<option value="asc">ASC</option>
|
||||||
|
<option value="desc">DESC</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<% if @print_settings.precision.to_i > 0
|
||||||
|
precision = @print_settings.precision
|
||||||
|
else
|
||||||
|
precision = 0
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if @print_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end %>
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbd_data">
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
|
||||||
|
<% grand_total = 0 %>
|
||||||
|
<% total_qty = 0 %>
|
||||||
|
|
||||||
|
<% @sale_data.each do |sale| %>
|
||||||
|
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
||||||
|
total_qty += sale.total_item
|
||||||
|
grand_total += sale.grand_total
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
|
total_qty += sale.total_item
|
||||||
|
grand_total += sale.grand_total
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
|
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"></td>
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td><strong><%= total_qty %></strong></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></strong></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
$('#order_by').val('<%= @order_by %>');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#order_by').on('change', function(){
|
||||||
|
var order_by = $("#order_by").val();
|
||||||
|
window.location.href = "?order_by=" + order_by;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
64
app/views/reports/product_sale/index.xls.erb
Executable file
64
app/views/reports/product_sale/index.xls.erb
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="margin-top-20">
|
||||||
|
<div class="card">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
<% grand_total = 0 %>
|
||||||
|
<% total_qty = 0 %>
|
||||||
|
|
||||||
|
<% @sale_data.each do |sale| %>
|
||||||
|
<% if sale.status_type != "Discount" && sale.status_type != "foc"
|
||||||
|
total_qty += sale.total_item
|
||||||
|
grand_total += sale.grand_total
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
|
total_qty += sale.total_item
|
||||||
|
grand_total += sale.grand_total
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
|
<td><%= sale.unit_price rescue '-' %></td>
|
||||||
|
<td><%= sale.grand_total rescue '-' %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"></td>
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td><strong><%= total_qty %></strong></td>
|
||||||
|
<td></td>
|
||||||
|
<td><strong><%= grand_total rescue '-' %></strong></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<% @totalByAccount.each do |account, total| %>
|
<% @totalByAccount.each do |account, total| %>
|
||||||
<% if sale.account_id == account %>
|
<% if sale.account_id == account %>
|
||||||
<b><%= number_with_precision(total, precision:precision,delimiter:delimiter) %></b>
|
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||||
<% grand_total += total %>
|
<% grand_total += total %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -120,8 +120,8 @@
|
|||||||
<td><%= sale.item_code rescue '-' %></td>
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
<td><%= sale.product_name rescue '-' %></td>
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
<td><%= sale.total_item rescue '-' %></td>
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
<td><%= number_with_precision(sale.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td><%= number_with_precision(sale.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- sub total -->
|
<!-- sub total -->
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
||||||
<td><b><%= sub_qty %></b></td>
|
<td><b><%= sub_qty %></b></td>
|
||||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision,delimiter:delimiter)%> </span></td>
|
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% sub_total = 0.0%>
|
<% sub_total = 0.0%>
|
||||||
<% sub_qty = 0 %>
|
<% sub_qty = 0 %>
|
||||||
@@ -168,8 +168,8 @@
|
|||||||
<td><%= other.item_code rescue '-' %></td>
|
<td><%= other.item_code rescue '-' %></td>
|
||||||
<td><%= other.product_name rescue '-' %></td>
|
<td><%= other.product_name rescue '-' %></td>
|
||||||
<td><%= other.total_item rescue '-' %></td>
|
<td><%= other.total_item rescue '-' %></td>
|
||||||
<td> <%= number_with_precision(other.unit_price , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td> <%= number_with_precision(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td> <%= number_with_precision(other.grand_total , precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td> <%= number_with_precision(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- sub total -->
|
<!-- sub total -->
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
<td ><span><%= number_with_precision(other_sub_total , precision:precision,delimiter:delimiter)%></span></td>
|
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%end%>
|
<%end%>
|
||||||
<!-- End Other Charges -->
|
<!-- End Other Charges -->
|
||||||
@@ -188,29 +188,35 @@
|
|||||||
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||||
<td><span><%= total_qty%></span></td>
|
<td><span><%= total_qty%></span></td>
|
||||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision,delimiter:delimiter)%></span></td>
|
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td><%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %></td>
|
<td><%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
<td><span><%= number_with_precision(total_item_foc , precision:precision,delimiter:delimiter) %></span></td>
|
<td><span><%= number_with_precision(total_item_foc , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision,delimiter:delimiter) %></span></td>
|
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(total_item_dis , precision:precision.to_i,delimiter:delimiter) %></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td><%= t("views.right_panel.detail.foc_sales") %></td>
|
<td><%= t("views.right_panel.detail.foc_sales") %></td>
|
||||||
<td><span><%= number_with_precision(@foc_data , precision:precision,delimiter:delimiter) %></span></td>
|
<td>
|
||||||
|
<span><%= number_with_precision(@foc_data, precision:precision.to_i, delimiter:delimiter) %></span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(@discount_data , precision:precision,delimiter:delimiter) %></span></td>
|
<td style="border-bottom:2px solid grey;">
|
||||||
|
<span>
|
||||||
|
<%= number_with_precision(@discount_data , precision: precision.to_i,delimiter: delimiter) %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% @sale_taxes.each do |tax| %>
|
<% @sale_taxes.each do |tax| %>
|
||||||
@@ -226,7 +232,7 @@
|
|||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
<td style="border-top:2px solid grey;">Net Amount</td>
|
<td style="border-top:2px solid grey;">Net Amount</td>
|
||||||
<!-- <td><span class="double_underline"><%= grand_total.to_f - @discount_data.to_f%></span></td> -->
|
<!-- <td><span class="double_underline"><%= grand_total.to_f - @discount_data.to_f%></span></td> -->
|
||||||
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision,delimiter:delimiter)%></td>
|
<td style="border-top:2px solid grey;"><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision.to_i,delimiter:delimiter)%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- <tr>
|
<!-- <tr>
|
||||||
<td colspan="5"> </td>
|
<td colspan="5"> </td>
|
||||||
|
|||||||
@@ -98,16 +98,16 @@
|
|||||||
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
|
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
|
||||||
</td>
|
</td>
|
||||||
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
|
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
|
||||||
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision,delimiter:delimiter) %></td>
|
<td><%= number_with_precision(result[:cash_sales].to_f, precision:precision.to_i,delimiter:delimiter) %></td>
|
||||||
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
|
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
|
||||||
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
|
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
|
||||||
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
||||||
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td>
|
<td>
|
||||||
<%= number_with_precision(result[:foc_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%>
|
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
||||||
</td>
|
</td>
|
||||||
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision,delimiter:delimiter) rescue '-'%></td>
|
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
|
||||||
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
|
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
|
||||||
<% grand_total = result[:grand_total].to_f %>
|
<% grand_total = result[:grand_total].to_f %>
|
||||||
@@ -126,15 +126,15 @@
|
|||||||
<tr style="border-top: 3px solid grey;">
|
<tr style="border-top: 3px solid grey;">
|
||||||
<td colspan="3"></td>
|
<td colspan="3"></td>
|
||||||
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
|
<!-- <td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td> -->
|
||||||
<td><b><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
|
<td><b><%= number_with_precision(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||||
<td><b><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
|
<td><b><%= number_with_precision(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||||
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
|
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
|
||||||
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
|
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
|
||||||
<td><b><%= number_with_precision(card, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
|
<td><b><%= number_with_precision(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||||
<td><b><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
|
<td><b><%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||||
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
|
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
|
||||||
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
||||||
<td><b><%= number_with_precision(g_total, precision:precision,delimiter:delimiter) rescue '-'%></b></td>
|
<td><b><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -28,6 +28,18 @@
|
|||||||
<div class="margin-top-20">
|
<div class="margin-top-20">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
|
<% if @print_settings.precision.to_i > 0
|
||||||
|
precision = @print_settings.precision
|
||||||
|
else
|
||||||
|
precision = 0
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if @print_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
%>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -63,7 +75,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= result.stock_count rescue '-' %></td>
|
<td><%= result.stock_count rescue '-' %></td>
|
||||||
<td><%= result.stock_balance rescue '-' %></td>
|
<td><%= number_with_precision(result.stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
|
||||||
<td><%= result.different rescue '-' %></td>
|
<td><%= result.different rescue '-' %></td>
|
||||||
<td><%= result.remark rescue '-' %></td>
|
<td><%= result.remark rescue '-' %></td>
|
||||||
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
|
<td><%= result.created_at.strftime('%e %b %Y %I:%M %p') rescue '-' %></td>
|
||||||
@@ -76,7 +88,7 @@
|
|||||||
<tr style="border-top: 3px solid grey;">
|
<tr style="border-top: 3px solid grey;">
|
||||||
<td colspan="3"></td>
|
<td colspan="3"></td>
|
||||||
<td><b><%= total_stock_count rescue '-' %></b></td>
|
<td><b><%= total_stock_count rescue '-' %></b></td>
|
||||||
<td><b><%= total_stock_balance rescue '-' %></b></td>
|
<td><b><%= number_with_precision(total_stock_balance, precision:precision.to_i,delimiter:delimiter) rescue '-' %></b></td>
|
||||||
<td><b><%= total_different rescue '-' %></b></td>
|
<td><b><%= total_different rescue '-' %></b></td>
|
||||||
<td colspan="2"></td>
|
<td colspan="2"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ en:
|
|||||||
bottom: "Bottom"
|
bottom: "Bottom"
|
||||||
payment: "Payment"
|
payment: "Payment"
|
||||||
backend: "Backend"
|
backend: "Backend"
|
||||||
|
date_time: "DateTime"
|
||||||
|
|
||||||
views:
|
views:
|
||||||
btn:
|
btn:
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ mm:
|
|||||||
bottom: "အရောင်းအနဲဆုံး"
|
bottom: "အရောင်းအနဲဆုံး"
|
||||||
payment: "ငွေပေးချေမှု"
|
payment: "ငွေပေးချေမှု"
|
||||||
backend: "Backend"
|
backend: "Backend"
|
||||||
|
date_time: "DateTime"
|
||||||
|
|
||||||
views:
|
views:
|
||||||
btn:
|
btn:
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
application_path = '/home/superuser/Application/production/sxrestaurant'
|
application_path = '/home/superuser/Application/sxrestaurant'
|
||||||
directory application_path
|
directory application_path
|
||||||
environment ENV.fetch("RAILS_ENV") { "development" }
|
environment ENV.fetch("RAILS_ENV") { "production" }
|
||||||
daemonize true
|
|
||||||
pidfile "#{application_path}/tmp/puma/pid"
|
pidfile "#{application_path}/tmp/puma/pid"
|
||||||
state_path "#{application_path}/tmp/puma/state"
|
state_path "#{application_path}/tmp/puma/state"
|
||||||
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
||||||
|
|||||||
@@ -373,6 +373,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
resources :commission, :only => [:index, :show]
|
resources :commission, :only => [:index, :show]
|
||||||
resources :stock_check, :only => [:index, :show]
|
resources :stock_check, :only => [:index, :show]
|
||||||
resources :payment_method
|
resources :payment_method
|
||||||
|
resources :product_sale, :only => [:index, :show]
|
||||||
|
|
||||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
development:
|
development:
|
||||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||||
sx_provision_url: 192.168.1.125:3002/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
sx_provision_url: 192.168.1.125:3002/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||||
server_mode: cloud
|
server_mode: application
|
||||||
cipher_type: AES-256-CBC
|
cipher_type: AES-256-CBC
|
||||||
sx_key: Wh@t1$C2L
|
sx_key: Wh@t1$C2L
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ test:
|
|||||||
production:
|
production:
|
||||||
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
|
||||||
sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api
|
sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api
|
||||||
server_mode: application
|
server_mode: cloud
|
||||||
cipher_type: AES-256-CBC
|
cipher_type: AES-256-CBC
|
||||||
sx_key: Wh@t1$C2L
|
sx_key: Wh@t1$C2L
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class CreateEmployees < ActiveRecord::Migration[5.1]
|
|||||||
t.datetime :session_expiry
|
t.datetime :session_expiry
|
||||||
t.datetime :session_last_login
|
t.datetime :session_last_login
|
||||||
t.string :created_by
|
t.string :created_by
|
||||||
|
t.string :image_path
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
|
|||||||
t.string :membership_authentication_code
|
t.string :membership_authentication_code
|
||||||
t.string :customer_type, :default => "Dinein"
|
t.string :customer_type, :default => "Dinein"
|
||||||
t.json :tax_profiles
|
t.json :tax_profiles
|
||||||
|
t.string :image_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class CreateCommissioners < ActiveRecord::Migration[5.1]
|
|||||||
t.datetime :joined_date
|
t.datetime :joined_date
|
||||||
t.datetime :resigned_date
|
t.datetime :resigned_date
|
||||||
t.boolean :is_active, default: true
|
t.boolean :is_active, default: true
|
||||||
|
t.string :image_path
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
class AddImagePathToEmployees < ActiveRecord::Migration[5.1]
|
|
||||||
def change
|
|
||||||
add_column :employees, :image_path, :string
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_column :image_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
class AddImagePathToCustomers < ActiveRecord::Migration[5.1]
|
|
||||||
def change
|
|
||||||
add_column :customers, :image_path, :string
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_column :image_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
class AddImagePathToCommissioners < ActiveRecord::Migration[5.1]
|
|
||||||
def change
|
|
||||||
add_column :commissioners, :image_path, :string
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_column :image_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
5
spec/controllers/reports/product_sale_controller_spec.rb
Normal file
5
spec/controllers/reports/product_sale_controller_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Reports::ProductSaleController, type: :controller do
|
||||||
|
|
||||||
|
end
|
||||||
15
spec/helpers/reports/product_sale_helper_spec.rb
Normal file
15
spec/helpers/reports/product_sale_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the Reports::ProductSaleHelper. For example:
|
||||||
|
#
|
||||||
|
# describe Reports::ProductSaleHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe Reports::ProductSaleHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user