inventory development
This commit is contained in:
@@ -1,2 +1,24 @@
|
||||
class StockJournal < ApplicationRecord
|
||||
|
||||
SALES_TRANS = "sale"
|
||||
STOCK_CHECK_TRANS = "stock_check"
|
||||
|
||||
def add_to_journal(item, balance, stock_message, inventory_definition)
|
||||
|
||||
balance = calculate_balance(balance, item.qty)
|
||||
|
||||
journal = StockJournal.new
|
||||
journal.item_code = item.item_code
|
||||
journal.inventory_definition_id = inventory_definition.id
|
||||
journal.debit = item.qty
|
||||
journal.balance = balance
|
||||
journal.remark = stock_message
|
||||
journal.trans_ref = item.id
|
||||
journal.trans_type = StockJournal::SALES_TRANS
|
||||
end
|
||||
|
||||
def self.calculate_balance(balance, qty)
|
||||
return balance.to_i - qty.to_i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user