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
|
class MyModuleRepositoryRow < ApplicationRecord
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
attr_accessor :last_modified_by
|
attr_accessor :last_modified_by
|
||||||
attr_accessor :comment
|
attr_accessor :comment
|
||||||
|
|
||||||
|
@ -33,6 +35,16 @@ class MyModuleRepositoryRow < ApplicationRecord
|
||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
def nulify_stock_consumption
|
def nulify_stock_consumption
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
<div class="sci-input-container" data-error-text="<%= t('repository_stock_values.manage_modal.amount_error') %>">
|
<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.label :stock_consumption, t('my_modules.repository.stock_modal.amount') %>
|
||||||
<%= f.text_field :stock_consumption,
|
<%= f.text_field :stock_consumption,
|
||||||
value: @module_repository_row.stock_consumption,
|
value: @module_repository_row.formated_stock_consumption,
|
||||||
tabindex: 1,
|
tabindex: 1,
|
||||||
placeholder: t('my_modules.repository.stock_modal.consumed') ,
|
placeholder: t('my_modules.repository.stock_modal.consumed') ,
|
||||||
class: 'sci-input-field',
|
class: 'sci-input-field',
|
||||||
data: {initial_value: (@module_repository_row.stock_consumption || 0),
|
data: {initial_value: (@module_repository_row.stock_consumption || 0),
|
||||||
initial_stock: @stock_value.amount,
|
initial_stock: @stock_value.amount,
|
||||||
decimals: @stock_value.repository_cell.repository_column.metadata['decimals'] } %>
|
decimals: @stock_value.repository_cell.repository_column.metadata['decimals'] } %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<div class="stock-update-view">
|
<div class="stock-update-view">
|
||||||
<div class="stock-initial-container">
|
<div class="stock-initial-container">
|
||||||
<span class="subtitle"><%= t('repository_stock_values.manage_modal.current_stock') %></span>
|
<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>
|
<span class="units"><%= @stock_value.repository_stock_unit_item&.data %></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="stock-arrow">
|
<div class="stock-arrow">
|
||||||
|
|
Loading…
Reference in a new issue