diff --git a/app/models/sale.rb b/app/models/sale.rb
index 4b2acadc..073760c3 100755
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -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)
diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb
index 09a238d3..2b781a13 100755
--- a/app/views/reports/shiftsale/index.html.erb
+++ b/app/views/reports/shiftsale/index.html.erb
@@ -54,8 +54,8 @@
<%= t("views.right_panel.detail.cash_payment") %> |
<%= t("views.right_panel.detail.credit_payment") %> |
-
<%= t("views.btn.other_payment") %> |
+ <%= t("views.btn.foc") %> <%= t :payment %> |
@@ -74,37 +74,42 @@
<% g_total = 0 %>
<% @sale_data.each do |result|%>
-
- |
- <%= result.cashier_terminal.name rescue '-'%>
- |
-
- <%= result.employee.name rescue '-'%>
- |
- <%= result.shift_started_at.strftime("%e %b %I:%M%p") rescue '-' %> -
- <%= result.shift_closed_at.strftime("%e %b %I:%M%p") rescue '-' %>
- |
-
- <%= sprintf "%.2f",result.cash_sales.to_f.to_d rescue '-'%> |
- <%= sprintf "%.2f",result.credit_sales.to_f.to_d rescue '-'%> |
-
-
- <%= sprintf "%.2f",result.other_sales.to_f.to_d rescue '-'%> |
- <%= sprintf "%.2f",result.grand_total.to_f.to_d rescue '-'%> |
+
+
+ |
+ <%= result[:cashier_terminal_name] rescue '-'%>
+ |
+
+ <%= result[:employee_name] rescue '-'%>
+ |
+ <%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
+ <%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
+ |
+
+ <%= sprintf "%.2f",result[:cash_sales].to_f.to_d rescue '-'%> |
+ <%= sprintf "%.2f",result[:credit_sales].to_f.to_d rescue '-'%> |
+
+
+ <%= sprintf "%.2f",result[:other_sales].to_f.to_d rescue '-'%> |
+
+ <%= sprintf "%.2f",result[:foc_sales].to_f.to_d rescue '-'%>
+ |
+ <%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%> |
-
- <% grand_total = result.grand_total.to_f %>
-
+
+ <% grand_total = result[:grand_total].to_f %>
+
- <% 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 %>
|
@@ -114,6 +119,7 @@
<%= sprintf("%.2f",card) rescue '-'%> |
+ <%= sprintf("%.2f",foc) rescue '-'%> |
<%= sprintf("%.2f",g_total) rescue '-'%> |
diff --git a/config/locales/en.yml b/config/locales/en.yml
index ce493bc5..80eab3c5 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -69,6 +69,7 @@ en:
inventory_definitions: "Inventory Definitions"
sale_audits: "Sale Audits"
bottom: "Bottom"
+ payment: "Payment"
views:
btn: