Module: Descriptivo::DescriptivoTrazabilidad

Defined in:
lib/descriptivo.rb

Instance Method Summary collapse

Instance Method Details

#etiqueta_stringObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/descriptivo.rb', line 23

def etiqueta_string
  item = composicion.item
  pedido = item.pedido
  componente = self.componente || self.elemento.try(:componente)

  pedido_string = pedido.id.to_s.rjust(7, '0')
  item_string = item.cardinalidad.to_s.rjust(3, '0')
  item_medida_string = self.item_medida.cardinalidad.to_s.rjust(3, '0')

  if self.elemento
    componente_string = componente.orden.to_s
    elemento_string = self.elemento.orden.to_s.rjust(2, '0')
  else
    if self.componente
      componente_string = self.componente.orden.to_s
      elemento_string = "00"
    else
      componente_string = "0"
      elemento_string = "00"
    end
  end

  "#{pedido_string}-#{item_string}-#{item_medida_string}-#{componente_string}-#{elemento_string}"

end