updated for receipt rpt for shift

This commit is contained in:
Yan
2017-07-08 18:20:42 +06:30
parent 9158f0e93a
commit 94555bc325
3 changed files with 19 additions and 12 deletions

View File

@@ -7,17 +7,19 @@ authorize_resource :class => false
# else # else
# @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take # @shift = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to).take
# end # end
puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z" # puts "2017-07-07T10:46:09.000Z - 2017-07-07T11:12:51.000Z"
puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC" # puts "2017-06-25 17:30:00 UTC 2017-07-02 17:29:59 UTC"
puts params[:shift_name] # puts params[:shift_name]
puts from.utc # puts from.utc
puts to.utc # puts to.utc
if params[:shift_name].to_i != 0 if params[:shift_name].to_i != 0
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at =?',from,to).take @shift = ShiftSale.where('shift_started_at >= ? and shift_closed_at <= ?',from,to).take
puts @shift.to_json # puts @shift.to_json
@sale_data = Sale.where('shift_sale_id = ? ',@shift.id) if @shift.present?
@sale_taxes = Sale.get_separate_tax(from,to) @sale_data = Sale.where('shift_sale_id = ? ',@shift.id)
@sale_taxes = Sale.get_separate_tax(from,to)
end
else else
@sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc) @sale_data = Sale.where("sale_status=? and receipt_date between ? and ?","completed",from.utc,to.utc)
@sale_taxes = Sale.get_separate_tax(from.utc,to.utc) @sale_taxes = Sale.get_separate_tax(from.utc,to.utc)

View File

@@ -583,7 +583,7 @@ def self.get_by_shift_sale(from,to,status)
" grand_total AS grand_total, cash_sales AS cash," + " grand_total AS grand_total, cash_sales AS cash," +
"total_taxes AS total_tax,total_discounts As total_discount") "total_taxes AS total_tax,total_discounts As total_discount")
.order("shift_sales.id DESC") .order("shift_sales.id DESC")
return query = query.where("shift_sales.shift_started_at between ? and ?" + " or shift_sales.shift_closed_at between ? and ?",from,to ,from,to ) return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to)
end end
def self.get_separate_tax(from,to,payment_type=nil) def self.get_separate_tax(from,to,payment_type=nil)

View File

@@ -61,7 +61,9 @@
<% total_nett = 0 %> <% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %> <% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<% @sale_data.each do |result| %> <%
if @sale_data!=nil
@sale_data.each do |result| %>
<% grand_total = grand_total.to_f + result.grand_total.to_f %> <% grand_total = grand_total.to_f + result.grand_total.to_f %>
<% total_tax += result.total_tax.to_f %> <% total_tax += result.total_tax.to_f %>
@@ -83,7 +85,10 @@
<td><%= result.grand_total_after_rounding() rescue '-'%></td> <td><%= result.grand_total_after_rounding() rescue '-'%></td>
</tr> </tr>
<% end %> <%
end
end
%>
<tr style="border-top:4px double #666;"> <tr style="border-top:4px double #666;">
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
<td><b><%= total_sum rescue '-'%></b></td> <td><b><%= total_sum rescue '-'%></b></td>