stock check report
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
class StockCheck < ApplicationRecord
|
||||
|
||||
has_many :stock_check_items
|
||||
|
||||
def create(user, reason, item_list)
|
||||
@@ -7,11 +6,11 @@ class StockCheck < ApplicationRecord
|
||||
self.check_by = user.id
|
||||
self.check_start = Time.now
|
||||
self.check_end = Time.now
|
||||
self.save
|
||||
save
|
||||
item_list.each do |item|
|
||||
stockItem = StockCheckItem.new
|
||||
stockItem.create(self.id,item)
|
||||
stockItem.create(id, item)
|
||||
end
|
||||
return self
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class StockCheckItem < ApplicationRecord
|
||||
|
||||
belongs_to :stock_check
|
||||
|
||||
def create(stock_id, item)
|
||||
@@ -33,4 +32,15 @@ class StockCheckItem < ApplicationRecord
|
||||
return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_transaction(from, to, item_code)
|
||||
transaction = all
|
||||
if !from.nil? && !to.nil?
|
||||
transaction = transaction.where('created_at between ? and ?', from, to)
|
||||
end
|
||||
if item_code.present?
|
||||
transaction = transaction.where(item_code: item_code)
|
||||
end
|
||||
transaction
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user