diff --git a/app/models/sale.rb b/app/models/sale.rb index 82b9b781..b23c630b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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 diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 335ab131..a5bf5976 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -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 diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb index b008f5e8..4e33c27d 100644 --- a/app/views/reports/void_sale/index.html.erb +++ b/app/views/reports/void_sale/index.html.erb @@ -31,8 +31,8 @@ <% end %> <% if @shift_from %>