mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Fix decimals in stock consumption modal [SCI-6732]
This commit is contained in:
parent
6b309871a3
commit
441f6b977d
2 changed files with 17 additions and 5 deletions
|
@ -1,4 +1,6 @@
|
|||
class MyModuleRepositoryRow < ApplicationRecord
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
attr_accessor :last_modified_by
|
||||
attr_accessor :comment
|
||||
|
||||
|
@ -33,6 +35,16 @@ class MyModuleRepositoryRow < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def formated_stock_consumption
|
||||
if stock_consumption
|
||||
number_with_precision(
|
||||
stock_consumption,
|
||||
precision: (repository_row.repository.repository_stock_column.metadata['decimals'].to_i || 0),
|
||||
strip_insignificant_zeros: true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def nulify_stock_consumption
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<div class="sci-input-container" data-error-text="<%= t('repository_stock_values.manage_modal.amount_error') %>">
|
||||
<%= f.label :stock_consumption, t('my_modules.repository.stock_modal.amount') %>
|
||||
<%= f.text_field :stock_consumption,
|
||||
value: @module_repository_row.stock_consumption,
|
||||
value: @module_repository_row.formated_stock_consumption,
|
||||
tabindex: 1,
|
||||
placeholder: t('my_modules.repository.stock_modal.consumed') ,
|
||||
class: 'sci-input-field',
|
||||
|
@ -32,7 +32,7 @@
|
|||
<div class="stock-update-view">
|
||||
<div class="stock-initial-container">
|
||||
<span class="subtitle"><%= t('repository_stock_values.manage_modal.current_stock') %></span>
|
||||
<span class="value"><%= @stock_value.amount %></span>
|
||||
<span class="value"><%= @stock_value.formatted_value %></span>
|
||||
<span class="units"><%= @stock_value.repository_stock_unit_item&.data %></span>
|
||||
</div>
|
||||
<div class="stock-arrow">
|
||||
|
|
Loading…
Reference in a new issue