mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 08:34:49 +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 RepositoryValueWithReminders
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
attr_accessor :comment
|
attribute :comment, :text
|
||||||
|
|
||||||
belongs_to :repository_stock_unit_item, optional: true
|
belongs_to :repository_stock_unit_item, optional: true
|
||||||
belongs_to :created_by, class_name: 'User', optional: true, inverse_of: :created_repository_stock_values
|
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])
|
.find(new_data[:unit_item_id])
|
||||||
self.last_modified_by = user
|
self.last_modified_by = user
|
||||||
delta = new_data[:amount].to_d - amount.to_d
|
delta = new_data[:amount].to_d - amount.to_d
|
||||||
|
self.comment = new_data[:comment].presence
|
||||||
repository_ledger_records.create!(
|
repository_ledger_records.create!(
|
||||||
user: last_modified_by,
|
user: last_modified_by,
|
||||||
amount: delta,
|
amount: delta,
|
||||||
balance: amount,
|
balance: amount,
|
||||||
reference: repository_cell.repository_column.repository,
|
reference: repository_cell.repository_column.repository,
|
||||||
comment: new_data[:comment].presence
|
comment: comment
|
||||||
)
|
)
|
||||||
self.amount = BigDecimal(new_data[:amount].to_s)
|
self.amount = BigDecimal(new_data[:amount].to_s)
|
||||||
save!
|
save!
|
||||||
|
|
Loading…
Add table
Reference in a new issue