Add stock to storage locations [SCI-10921]

This commit is contained in:
Anton 2024-07-31 11:31:53 +02:00
parent 6ad8120e0d
commit b774c04f5b
2 changed files with 13 additions and 3 deletions

View file

@ -117,7 +117,7 @@ export default {
columnDefs() {
const columns = [{
field: 'position',
field: 'position_formatted',
headerName: this.i18n.t('storage_locations.show.table.position'),
sortable: true,
notSelectable: true,

View file

@ -4,7 +4,7 @@ module Lists
class StorageLocationRepositoryRowSerializer < ActiveModel::Serializer
include Canaid::Helpers::PermissionsHelper
attributes :created_by, :created_on, :position, :row_id, :row_name, :hidden
attributes :created_by, :created_on, :position, :row_id, :row_name, :hidden, :position_formatted, :stock
def row_id
object.repository_row.id unless hidden
@ -19,13 +19,23 @@ module Lists
end
def created_on
I18n.l(object.created_at, format: :full)
I18n.l(object.created_at, format: :full) unless hidden
end
def position
object.metadata['position']
end
def position_formatted
"#{('A'..'Z').to_a[position[0] - 1]}#{position[1]}" if position
end
def stock
if object.repository_row.repository.has_stock_management? && !hidden
object.repository_row.repository_cells.find_by(value_type: 'RepositoryStockValue')&.value&.formatted
end
end
def hidden
!can_read_repository?(object.repository_row.repository)
end