update receipt no twice and sale order double and report changes

This commit is contained in:
Aung Myo
2017-07-31 09:39:34 +06:30
parent 78d383f5ec
commit 6ac35bb874
3 changed files with 12 additions and 12 deletions

View File

@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
add_item(item)
end
link_order_sale(order.id)
# link_order_sale(order.id)
end
self.save!
@@ -352,7 +352,7 @@ class Sale < ApplicationRecord
if saleOrder.nil?
sale_order = SaleOrder.new
sale_order.create_sale_order(self.id, order_id)
sale = sale_order.create_sale_order(self.id, order_id)
end
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
@@ -662,18 +662,18 @@ end
def self.get_void_sale(shift,from,to)
sale_arr = Array.new
account= Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
.joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
.where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
if shift.present?
query = query.where("sales.sale_status = 'void' and s.shift_sale_id in (?)",shift.to_a)
query = query.where("sales.sale_status = 'void' and sales.shift_sale_id in (?)",shift.to_a)
else
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
query = query.where("sales.sale_status = 'void' and sales.receipt_date between ? and ? ",from,to)
end
out = {:items => account}
out = {:items => query}
sale_arr.push(out)
return sale_arr
end

View File

@@ -35,7 +35,7 @@ class SeedGenerator < ApplicationRecord
else
current_no = seed.next
seed.next = seed.next + seed.increase_by
seed.next = seed.next
seed.current = current_no
seed.save
end

View File

@@ -31,8 +31,8 @@
<% end %>
<% if @shift_from %>
<tr>
<% if @shift.cashier_id %>
<% cashier_name = !@shift.nil? ? @shift.employee.name : '-' %>
<% if @shift %>
<% cashier_name = !@shift.nil? ? @shift[0].employee.name : '-' %>
<% end %>
<th colspan="3">Shift Name = <%= @shift_from rescue '-'%> - <%= @shift_to rescue '-'%> ( <%= cashier_name rescue '-'%> )</th>
</tr>