mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-07 05:03:26 +08:00
Improve inventory stock saving with comment [SCI-6805]
This commit is contained in:
parent
bb067974b4
commit
f82c2af244
1 changed files with 3 additions and 2 deletions
|
@ -4,7 +4,7 @@ class RepositoryStockValue < ApplicationRecord
|
|||
include RepositoryValueWithReminders
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
attr_accessor :comment
|
||||
attribute :comment, :text
|
||||
|
||||
belongs_to :repository_stock_unit_item, optional: true
|
||||
belongs_to :created_by, class_name: 'User', optional: true, inverse_of: :created_repository_stock_values
|
||||
|
@ -112,12 +112,13 @@ class RepositoryStockValue < ApplicationRecord
|
|||
.find(new_data[:unit_item_id])
|
||||
self.last_modified_by = user
|
||||
delta = new_data[:amount].to_d - amount.to_d
|
||||
self.comment = new_data[:comment].presence
|
||||
repository_ledger_records.create!(
|
||||
user: last_modified_by,
|
||||
amount: delta,
|
||||
balance: amount,
|
||||
reference: repository_cell.repository_column.repository,
|
||||
comment: new_data[:comment].presence
|
||||
comment: comment
|
||||
)
|
||||
self.amount = BigDecimal(new_data[:amount].to_s)
|
||||
save!
|
||||
|
|
Loading…
Reference in a new issue