Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-12-01 14:07:38 +06:30
3 changed files with 68 additions and 32 deletions

View File

@@ -591,11 +591,40 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
end
def self.get_by_shiftsales(from,to,shift)
if !shift.blank?
ShiftSale.where("id =?",shift.id)
else
ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
if !shift.blank?
query = ShiftSale.where("shift_sales.id =?",shift.id)
else
query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
shift_sale_data = Hash.new
query.each do |shift_sale|
foc = 0
foc_data = Sale.select("SUM(sp.payment_amount) as foc_sales")
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
.where("sales.shift_sale_id=? and sp.payment_method='foc'",shift_sale.id)
.first()
if !foc_data.foc_sales.nil? && foc_data.foc_sales > 0
shift_sale.other_sales -= foc_data.foc_sales
foc = foc_data.foc_sales
end
shift_sale_data[shift_sale.id] = {
:cashier_terminal_name => shift_sale.cashier_terminal.name,
:employee_name => shift_sale.employee.name,
:shift_started_at => shift_sale.shift_started_at,
:shift_closed_at => shift_sale.shift_closed_at,
:cash_sales => shift_sale.cash_sales,
:credit_sales => shift_sale.credit_sales,
:other_sales => shift_sale.other_sales.to_f,
:foc_sales => foc,
:grand_total => shift_sale.grand_total
}
end
return shift_sale_data.values
end
def self.get_by_shift_sale(from,to,status)

View File

@@ -54,8 +54,8 @@
<th><%= t("views.right_panel.detail.cash_payment") %></th>
<!-- <th>Credit Charges</th> -->
<th><%= t("views.right_panel.detail.credit_payment") %></th>
<!-- <th>FOC Payment</th> -->
<th><%= t("views.btn.other_payment") %></th>
<th><%= t("views.btn.foc") %> <%= t :payment %></th>
<!-- <th>Grand Total
<br/>Rounding Adj</th> -->
<!-- <th>Rounding Adj</th> -->
@@ -74,37 +74,42 @@
<% g_total = 0 %>
<% @sale_data.each do |result|%>
<tr>
<td>
<%= result.cashier_terminal.name rescue '-'%>
</td>
<td>
<%= result.employee.name rescue '-'%>
</td>
<td><%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.credit_sales.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.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%></td>
<tr>
<td>
<%= result[:cashier_terminal_name] rescue '-'%>
</td>
<td>
<%= result[:employee_name] rescue '-'%>
</td>
<td><%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result[:cash_sales].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:credit_sales].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.card_amount.to_f.to_d rescue '-'%></td> -->
<td><%= sprintf "%.2f",result[:other_sales].to_f.to_d rescue '-'%></td>
<td>
<%= sprintf "%.2f",result[:foc_sales].to_f.to_d rescue '-'%>
</td>
<td><%= sprintf "%.2f",result[:grand_total].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 %>
<!-- <td><%= sprintf "%.2f",grand_tota.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 %>
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
</tr>
<% cash += result.cash_sales.to_f %>
<% credit += result.credit_sales.to_f %>
<% card += result.other_sales.to_f %>
<% cash += result[:cash_sales].to_f %>
<% credit += result[:credit_sales].to_f %>
<% card += result[:other_sales].to_f %>
<% foc += result[:foc_sales].to_f %>
<% total += result.grand_total.to_f %>
<% total += result[:grand_total].to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="3"></td>
@@ -114,6 +119,7 @@
<!-- <td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td>
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>

View File

@@ -69,6 +69,7 @@ en:
inventory_definitions: "Inventory Definitions"
sale_audits: "Sale Audits"
bottom: "Bottom"
payment: "Payment"
views:
btn: