add staff meal

This commit is contained in:
NyanLinHtut
2019-11-18 09:57:55 +06:30
parent 891995f531
commit 0d9e363648
13 changed files with 1291 additions and 199 deletions

View File

@@ -0,0 +1,133 @@
class Reports::StaffMealController < BaseReportController
authorize_resource :class => false
def index
@account = Account.all
from, to = get_date_range_from_params
shift_sale_range = ''
shift = ''
if params[:shift_name].to_i != 0
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
if shift_sale.shift_closed_at.blank?
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
else
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
end
staff = Customer.where(customer_type: 'staff')
customer_id = Array.new
staff.each { |s|
customer_id.push(s.customer_id)
}
account_type = params[:account_type]
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_staff_meal_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,account_type,customer_id)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if shift.present?
shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
def get_period_name(period)
period_name = '-'
unless period.nil? or period.blank?
case period.to_i
when PERIOD["today"]
period_name = "Today"
when PERIOD["yesterday"]
period_name = "Yesterday"
when PERIOD["this_week"]
period_name = "This Week"
when PERIOD["last_week"]
period_name = "Last Week"
when PERIOD["last_7"]
period_name = "Last 7 days"
when PERIOD["this_month"]
period_name = "This Month"
when PERIOD["last_month"]
period_name = "Last Month"
when PERIOD["last_30"]
period_name = "Last 30 Days"
when PERIOD["this_year"]
period_name = "This Year"
when PERIOD["last_year"]
period_name = "Last Year"
end
end
return period_name
end
end

View File

@@ -23,7 +23,20 @@ class InventoryDefinition < ApplicationRecord
end
end
def self.find_product_in_inventory(item)
def self.find_product_in_inventory(item,instance_code)
unless instance_code.empty?
instance_code = instance_code.to_s
instance_code[0] = ""
instance_code = instance_code.chomp("]")
else
instance_code = '"0"'
end
if prod = InventoryDefinition.where("item_code IN(#{instance_code})")
puts "found prodcut+++++++++++++++++++++++++++++++++++==="
puts prod.to_json
end
if product = InventoryDefinition.find_by_item_code(item.item_instance_code)
if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code)
return true, product

View File

@@ -125,8 +125,18 @@ class OrderItem < ApplicationRecord
end
def update_stock_journal
if self.set_menu_items.present?
puts "set menu itemsssssssss???????????????????????????????"
puts items = JSON.parse(self.set_menu_items)
instance_code = Array.new
count = 0
items.each { |i|
instance_code.push(i["item_instance_code"])
}
print instance_code
end
if self.qty != self.qty_before_last_save
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self,instance_code)
if found
InventoryDefinition.check_balance(self, inventory_definition)
end

View File

@@ -942,6 +942,28 @@ def self.get_item_query(type)
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
end
def self.get_staff_meal_query()
sale_type = "foc"
query = Sale.select("cus.name as staff_name,sales.sale_id,acc.title as account_name,
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," +
"i.status as status_type,i.remark as remark,"+
"i.unit_price,i.price as price,i.product_name as product_name, " +
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
"date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')
as date_format")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id " +
"JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id " +
"JOIN customers cus ON cus.customer_id = sales.customer_id ")
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
# query = query.where("#{sale_type}")
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.item_instance_code asc, SUM(i.qty) desc, i.unit_price asc")
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
end
def self.get_other_charges()
query = Sale.select("i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
@@ -1048,6 +1070,111 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_type,customer_id)
# date_type_selection = get_sql_function_for_report_type(report_type)
if account_type.blank?
account_type = ''
else
account_type = " and acc.title = '#{account_type}'"
end
unless customer_id.empty?
customer_id = customer_id.to_s
customer_id[0] = ""
customer_id = customer_id.chomp("]")
else
customer_id = '"CUS-000000000000"'
end
query = self.get_staff_meal_query()
discount_query = 0
total_card_amount = 0
total_cash_amount = 0
total_credit_amount = 0
total_foc_amount = 0
total_grand_total = 0
other_charges = 0
# if type.nil? || type == 'all' || type == "other"
# other_charges = self.get_other_charges()
# end
product = self.get_product_sale()
if shift.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift.to_a)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
# end
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
### => get all sales range in shift_sales
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",shift_sale_range.to_a)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
# end
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to)
# if type.nil? || type == 'all' || type == "other"
# other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
# end
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
end
return query, other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
def self.get_product_sale()
query = Sale.select("i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
@@ -1478,13 +1605,6 @@ end
end
def self.hourly_sales(today,current_user,from,to,from_time,to_time)
logger.debug 'hourly_sales<<<<<<<<<<<<<<<<<<<<<<<<'
logger.debug today
logger.debug current_user.to_json
logger.debug from
logger.debug to
logger.debug from_time
logger.debug to_time
if (!from.nil? && !to.nil?) && (from != "" && to!="")
if current_user.nil?
query = Sale.hourly_sale_data(today,nil,from,to,from_time,to_time)

View File

@@ -225,6 +225,59 @@ class SaleItem < ApplicationRecord
return sale_items
end
# Loader Service SFTP Start
# Detail Sale Data
def self.get_detail_sale_data(transaction_date)
query = SaleItem.select("
sale_items.sale_item_id as id,
sale_items.sale_id as parent_id,
s.receipt_no as check_num,
s.receipt_date as business_date,
s.receipt_date as transaction_date,
'' as item_seq,
sale_items.menu_category_code as category_code,
sale_items.menu_category_name as category_name,
'' as sub_category_code,
'' as sub_category_name,
'' as report_group_code,
'' as report_group_name,
sale_items.product_code as item_id,
sale_items.product_name as item_name,
sale_items.qty as qty,
CASE
WHEN s.sale_status = 'completed' OR s.sale_status = 'void' THEN 'Sales'
WHEN s.sale_status = 'waste' THEN 'Waste'
WHEN s.sale_status = 'spoile' THEN 'Spoil'
END as transaction_type,
sale_items.price as gross_sales,
'' as discount_code,
CASE
WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0
END as discount_amt,
(sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) as sales,
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21) as tax_amt,
'' as service_charges,
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) - ((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21)) as net_sales,
'0' as is_set_item,
'0' as is_staff_meal,
'0' as is_raw_wastage,
'0' as is_semi_wastage,
CASE WHEN s.sale_status = 'waste' THEN 1 ELSE 0 END as is_wastage,
CASE WHEN s.sale_status = 'spoile' THEN 1 ELSE 0 END as is_spoilage,
'0' as is_sampling,
'1' as tax_able,
CASE
WHEN s.sale_status = 'void' THEN 1 ELSE 0
END as is_void
")
.joins("LEFT JOIN sales s ON s.sale_id = sale_items.sale_id")
.joins("LEFT JOIN sale_items i ON sale_items.sale_id = i.sale_id AND sale_items.item_instance_code = i.item_instance_code AND i.status = 'Discount' AND sale_items.qty = abs(i.qty)")
.where("DATE(s.receipt_date) = ? AND s.sale_status != 'void' AND (sale_items.status NOT IN('Discount', 'void','foc') OR sale_items.status IS NULL)", transaction_date)
.order("s.receipt_no")
end
# Loader Service SFTP End
private
def generate_custom_id
if self.sale_item_id.nil?
@@ -293,58 +346,4 @@ class SaleItem < ApplicationRecord
end
end
end
# Loader Service SFTP Start
# Detail Sale Data
def self.get_detail_sale_data(transaction_date)
query = SaleItem.select("
sale_items.sale_item_id as id,
sale_items.sale_id as parent_id,
s.receipt_no as check_num,
s.receipt_date as business_date,
s.receipt_date as transaction_date,
'' as item_seq,
sale_items.menu_category_code as category_code,
sale_items.menu_category_name as category_name,
'' as sub_category_code,
'' as sub_category_name,
'' as report_group_code,
'' as report_group_name,
sale_items.product_code as item_id,
sale_items.product_name as item_name,
sale_items.qty as qty,
CASE
WHEN s.sale_status = 'completed' OR s.sale_status = 'void' THEN 'Sales'
WHEN s.sale_status = 'waste' THEN 'Waste'
WHEN s.sale_status = 'spoile' THEN 'Spoil'
END as transaction_type,
sale_items.price as gross_sales,
'' as discount_code,
CASE
WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0
END as discount_amt,
(sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) as sales,
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21) as tax_amt,
'' as service_charges,
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) - ((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21)) as net_sales,
'0' as is_set_item,
'0' as is_staff_meal,
'0' as is_raw_wastage,
'0' as is_semi_wastage,
CASE WHEN s.sale_status = 'waste' THEN 1 ELSE 0 END as is_wastage,
CASE WHEN s.sale_status = 'spoile' THEN 1 ELSE 0 END as is_spoilage,
'0' as is_sampling,
'1' as tax_able,
CASE
WHEN s.sale_status = 'void' THEN 1 ELSE 0
END as is_void
")
.joins("LEFT JOIN sales s ON s.sale_id = sale_items.sale_id")
.joins("LEFT JOIN sale_items i ON sale_items.sale_id = i.sale_id AND sale_items.item_instance_code = i.item_instance_code AND i.status = 'Discount' AND sale_items.qty = abs(i.qty)")
.where("DATE(s.receipt_date) = ? AND s.sale_status != 'void' AND (sale_items.status NOT IN('Discount', 'void','foc') OR sale_items.status IS NULL)", transaction_date)
.order("s.receipt_no")
end
# Loader Service SFTP End
end

View File

@@ -138,6 +138,9 @@
<li>
<a href="<%= reports_induty_index_path %>">Induty</a>
</li>
<li>
<a href="<%= reports_staff_meal_index_path %>">Staff Meal</a>
</li>
<li>
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
</li>
@@ -324,6 +327,9 @@
<li>
<a href="<%= reports_induty_index_path %>">Induty</a>
</li>
<li>
<a href="<%= reports_staff_meal_index_path %>">Staff Meal</a>
</li>
<li>
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
</li>

View File

@@ -56,9 +56,9 @@
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 mbl-right-btn">
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20 mbl-right-btn" style="margin-top: 4px;">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary float_right'>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>

View File

@@ -10,7 +10,7 @@
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
<%= render :partial=>'hourly_saleitem_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_hourly_saleitem_index_path} %>
<hr />
<div class="text-right">

View File

@@ -5,142 +5,139 @@
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<div class="table-responsive">
<div class="margin-top-20">
<div class="card">
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<% time_arr = Array.new %>
<% acc_arr = Array.new %>
<% sale_item_count =0 %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% total_qty = 0 %>
<% time_count = 0 %>
<% grand_total = 0 %>
<% @sale_data.each do |sale| %>
<% if !time_arr.include?(sale.date_format) %>
<% sale_item_count =1 %>
<% time_count = time_count + 1 %>
<thead>
<td>&nbsp;</td>
<tr>
<td>
<strong>Time :<%= sale.date_format %></strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong></strong></td>
</tr>
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% time_arr.push(sale.date_format) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<% else %>
<% sale_item_count =sale_item_count +1 %>
<% end %>
<tbody>
<% 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
%>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<table class="table table-striped" border="0">
<% time_arr = Array.new %>
<% acc_arr = Array.new %>
<% sale_item_count =0 %>
<% menu_cat_arr = Array.new %>
<% footer_arr = Array.new %>
<% count = 0 %>
<% waste_and_spoil_item_count = 0%>
<% total_qty = 0 %>
<% time_count = 0 %>
<% grand_total = 0 %>
<% @sale_data.each do |sale| %>
<% if !time_arr.include?(sale.date_format) %>
<% sale_item_count =1 %>
<% time_count = time_count + 1 %>
<thead>
<td>&nbsp;</td>
<tr>
<td>
<strong>Time :<%= sale.date_format %></strong>
</td>
<td></td>
<td></td>
<td colspan="3" style="text-align:right"><strong></strong></td>
</tr>
<tr>
<td><strong>Menu Category</strong></td>
<td><strong>Item Code</strong></td>
<td><strong>Item Name</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
</thead>
<% time_arr.push(sale.date_format) %>
<% menu_cat_arr.clear %>
<% count = 0 %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "promotion" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% grand_total += sale.grand_total %>
<% if !sale.item_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<tr>
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
<td><%= sale.menu_category_name %></td>
<% menu_cat_arr.push(sale.menu_category_name) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code %></td>
<td><%= sale.product_name %></td>
<td><%= sale.total_item.to_i %></td>
<td><%= number_with_precision(sale.unit_price.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
<td><%= number_with_precision(sale.grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></td>
<!-- <td><%= sale.date_format %></td> -->
</tr>
<% end %>
<!-- new tr -->
<% count = count + 1 %>
<% @hourly_total_qty.each do |hr| %>
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
<tr>
<td></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td>
<span class="underline" style="text-align:right">
<strong><%= total_qty.to_i %></strong>
<% total_qty = 0%>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= number_with_precision(grand_total.to_i, precision:precision.to_i,delimiter:delimiter) %></strong>
<% grand_total = 0 %>
</span>
</td>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% else %>
<% sale_item_count =sale_item_count +1 %>
<% end %>
<tbody>
<% 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
%>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% if sale.status_type == "promotion" && sale.grand_total < 0
grand_total += sale.grand_total*(-1)
end %>
<% grand_total += sale.grand_total %>
<% if !sale.item_code.nil?%>
<% waste_and_spoil_item_count += sale.qty.to_i %>
<tr>
<% if !menu_cat_arr.include?(sale.menu_category_name) %>
<td><%= sale.menu_category_name %></td>
<% menu_cat_arr.push(sale.menu_category_name) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code %></td>
<td><%= sale.product_name %></td>
<td><%= sale.total_item.to_i %></td>
<td><%= sale.unit_price.to_i %></td>
<td><%= sale.grand_total.to_i %></td>
<td><%= sale.date_format %></td>
</tr>
<% end %>
<!-- new tr -->
<% count = count + 1 %>
<% @hourly_total_qty.each do |hr| %>
<% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%>
<tr>
<td></td>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td>
<span class="underline" style="text-align:right">
<strong><%= total_qty.to_i %></strong>
<% total_qty = 0%>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= grand_total.to_i %></strong>
<% grand_total = 0 %>
</span>
</td>
</tr>
<% footer_arr.push(sale.sale_id) %>
<% else %>
<% end %>
<% end %>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,146 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl">Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="">Select Type</option>
<option value="revenue" selected>Revenue Only</option>
<option value="all">All Type</option>
<option value="discount">Discount Only</option>
<option value="void">Void Only</option>
<option value="foc">Foc Only</option>
<option value="promotion">Promotion Only</option>
<option value="other">Other Amount Only</option>
</select>
</div> -->
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_account") %></label>
<select name="account_type" id="account_type" class="form-control">
<option value = "">Select Account</option>
<% @account.each do |acc| %>
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
<%end %>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
<label class="font-14 mbl_lbl">All Shift</label>
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20 mbl-right-btn" style="margin-top: 27px;">
<!-- <br> -->
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
$("#account_type").val("<%=params[:account_type]%>");
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
var sale_type = "<%=params[:sale_type]%>";
$("#sel_sale_type").val(sale_type);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,390 @@
<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.staff_meal_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'staff_meal_report_filter',
:locals=>{ :period_type => true, :shift_name => true, :report_path =>reports_staff_meal_index_path} %>
<hr />
<div class="text-right">
<!-- <button class="btn btn-info wave-effects" onclick="print_sale_items()">Print</button> -->
<a href="javascript:export_to('<%=reports_staff_meal_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="table-responsive">
<table class="table table-striped" id="items_table" border="0">
<thead>
<tr>
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>&nbsp;</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.revenue") %></th>
</tr>
</thead>
<tbody>
<% 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
%>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% p_qty = 0 %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% product_sub_total = 0 %>
<% count = 0 %>
<% row_count = 0 %>
<% total_price = 0 %>
<% cate_count = 0 %>
<% acc_count = 0 %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_amount = 0 %>
<% discount = 0 %>
<% total_item_foc = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<% row_count += 1 %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
<td colspan="4">&nbsp;</td>
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
</td>
</tr>
<% acc_arr.push(sale.account_id) %>
<% end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<% if sale.status_type != "Discount" %>
<td><%= sale.total_item rescue '-' %></td>
<%else%>
<td><%= sale.total_item*(-1) rescue '-' %></td>
<% end %>
<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 -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
sub_qty += sale.total_item
end %>
<% if sale.status_type =="Discount"
sub_qty += sale.total_item*(-1)
end %>
<% if sale.status_type == "promotion" && @type == "promotion"
sub_qty += sale.total_item*(-1)
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<!--Product Sale -->
<% if @product.present?%>
<tr>
<td><b>Product</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @product.each do |product| %>
<% if product.total_item > 0
total_qty += product.total_item
end %>
<% grand_total +=product.grand_total
p_qty += product.total_item%>
<tr>
<td>&nbsp;</td>
<td>Product</td>
<td><%= product.product_code rescue '-' %></td>
<td><%= product.product_name rescue '-' %></td>
<td><%= product.total_item rescue '-' %></td>
<td> <%= number_with_precision(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% product_sub_total += product.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total Product Qty </b> </td>
<td><b><%= p_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Product Sale -->
<!--Other Charges -->
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<% if @type =="" || @type =="all" || @type.nil? %>
<!-- <tr class="foc_payment">
<td colspan="5">&nbsp;</td>
<td>Total FOC Amount</td>
<td><span><%= number_with_precision(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr> -->
<!-- <tr class="foc_payment" style="border-top:2px solid grey;border-bottom:2px solid grey;">
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr> -->
<% end %>
<% end %>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item 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.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
show_shift_name(period,period_type,from,to,'shift_item');
}
// OK button is clicked
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
from = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#from').val(from)
search_by_date();
});
$('#to').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
new_date = new Date(date) ;
month = parseInt(new_date.getMonth()+1)
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
function search_by_date(){
from = $("#from").val();
to = $("#to").val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
console.log(check_arr.length)
if(check_arr.length == 1){
show_shift_name(period,period_type,from,to,'shift_item');
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
function show_shift_name(period,period_type,from,to,shift_item){
var shift = $('#shift_name');
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
shift.empty();
var selected = '';
var str = '';
var param_shift = '<%= params[:shift_name]%>';
url = '<%= reports_get_shift_by_sale_item_path %>';
console.log(url)
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
console.log(data)
str = '<option value="0">--- All Shift ---</option>';
$(data.message).each(function(index){
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
var shift_id = data.message[index].shift_id ;
if(param_shift != ''){
if(shift_id == param_shift){
selected = 'selected = "selected"';
}
else{
selected = '';
}
}
else{
selected = '';
}
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
// console.log(sh_date)
})
shift.append(str);
});
}
});
</script>

View File

@@ -0,0 +1,277 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<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 colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
</tr>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>&nbsp;</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.revenue") %></th>
</tr>
</thead>
<tbody>
<% 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
%>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% p_qty = 0 %>
<% sub_qty = 0 %>
<% sub_total = 0 %>
<% other_sub_total = 0 %>
<% product_sub_total = 0 %>
<% count = 0 %>
<% row_count = 0 %>
<% total_price = 0 %>
<% cate_count = 0 %>
<% acc_count = 0 %>
<% grand_total = 0 %>
<% total_qty = 0 %>
<% total_amount = 0 %>
<% discount = 0 %>
<% total_item_foc = 0 %>
<% total_item_dis = 0.0 %>
<% total_tax = 0 %>
<% unless @sale_data.blank? %>
<% @sale_data.each do |sale| %>
<% row_count += 1 %>
<!-- all total qty sum -->
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
total_qty += sale.total_item
end %>
<% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item
end %>
<% if sale.status_type == "Discount"
total_qty += sale.total_item*(-1)
end %>
<% if sale.status_type =="promotion" && @type == "promotion"
total_qty += sale.total_item*(-1)
end %>
<!-- end all total qty -->
<% if sale.status_type == "foc" && sale.grand_total < 0
total_item_foc += sale.grand_total*(-1)
end %>
<% if sale.status_type == "Discount" && sale.grand_total < 0
total_item_dis += sale.grand_total*(-1)
end %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
<td colspan="4">&nbsp;</td>
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= number_with_precision(total, precision:precision.to_i,delimiter:delimiter) %></b>
<% grand_total += total %>
<% end %>
<% end %>
</td>
</tr>
<% acc_arr.push(sale.account_id) %>
<% end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<% if sale.status_type != "Discount" %>
<td><%= sale.total_item rescue '-' %></td>
<%else%>
<td><%= sale.total_item*(-1) rescue '-' %></td>
<% end %>
<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 -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.account_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% #sub_qty += sale.total_item %>
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
sub_qty += sale.total_item
end %>
<% if sale.status_type =="Discount"
sub_qty += sale.total_item*(-1)
end %>
<% if sale.status_type == "promotion" && @type == "promotion"
sub_qty += sale.total_item*(-1)
end %>
<% if count == value %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total <%= sale.account_name %> Qty </b> </td>
<td><b><%= sub_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span class="underline"><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
</tr>
<% sub_total = 0.0%>
<% sub_qty = 0 %>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% end %>
<!--Product Sale -->
<% if @product.present?%>
<tr>
<td><b>Product</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @product.each do |product| %>
<% if product.total_item > 0
total_qty += product.total_item
end %>
<% grand_total +=product.grand_total
p_qty += product.total_item%>
<tr>
<td>&nbsp;</td>
<td>Product</td>
<td><%= product.product_code rescue '-' %></td>
<td><%= product.product_name rescue '-' %></td>
<td><%= product.total_item rescue '-' %></td>
<td> <%= number_with_precision(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td> <%= number_with_precision(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% product_sub_total += product.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="3">&nbsp;</td>
<td><b>Total Product Qty </b> </td>
<td><b><%= p_qty %></b></td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
<!-- End Product Sale -->
<!--Other Charges -->
<!-- End Other Charges -->
<tr style="border-top:2px solid grey;">
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
<td><span><%= total_qty%></span></td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><span><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<% if @type =="" || @type =="all" || @type.nil? %>
<!-- <tr class="foc_payment">
<td colspan="5">&nbsp;</td>
<td>Total FOC Amount</td>
<td><span><%= number_with_precision(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr> -->
<!-- <tr class="foc_payment" style="border-top:2px solid grey;border-bottom:2px solid grey;">
<td colspan="5">&nbsp;</td>
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
<td style="border-bottom:2px solid grey;"><span><%= number_with_precision(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr> -->
<% end %>
<% end %>
<% if @type == "other"%>
<tr>
<td><b>Other Charges</b></td>
<td colspan="4">&nbsp;</td>
<td></td>
</tr>
<% @other_charges.each do |other| %>
<% if other.total_item > 0
total_qty += other.total_item
end %>
<% grand_total +=other.grand_total%>
<tr>
<td>&nbsp;</td>
<td>Other Charges</td>
<td><%= other.item_code rescue '-' %></td>
<td><%= other.product_name rescue '-' %></td>
<td><%= other.total_item 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.to_i,delimiter:delimiter) rescue '-'%></td>
</tr>
<!-- sub total -->
<% other_sub_total += other.grand_total %>
<!-- end sub total -->
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td><%= t("views.right_panel.detail.sub_total") %></td>
<td ><span><%= number_with_precision(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
</tr>
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
$(function(){
var type =<%=@type %>;
console.log(type);
$('.foc_payment').hide();
if (type =="" || type =="all" ){
$('.foc_payment').show();
}
else{
$('.foc_payment').hide();
}
});
</script>

View File

@@ -532,6 +532,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show]
resources :hourly_saleitem, :only => [:index, :show]
resources :staff_meal, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :only => [:index, :show]