Class: Eancom::Edifact::PRI

Inherits:
Segment
  • Object
show all
Defined in:
lib/eancom/edifact/segments/pri.rb

Constant Summary collapse

TAG =
'PRI'.freeze
TYPE =
:body.freeze

Instance Attribute Summary collapse

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

#array, initialize_by_components, #is_body?, #is_footer?, #is_header?, #item_group_name, #starts_item?, #starts_location?, #starts_message?, #structure, #tag?, #to_edi, #to_hash, #to_s, #validate_structure

Constructor Details

#initialize(tag: nil, price_code_qualifier:, price_amount:, price_type_code: nil, price_specification_code: nil, unit_price_basis_value: nil, measurment_unit_code: nil, subline_item_price_change_operation_code: nil) ⇒ PRI

Returns a new instance of PRI.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/eancom/edifact/segments/pri.rb', line 9

def initialize(
  tag: nil,

  price_code_qualifier:,
  price_amount:,
  price_type_code: nil,
  price_specification_code: nil,
  unit_price_basis_value: nil,
  measurment_unit_code: nil,
  subline_item_price_change_operation_code: nil
)
  @tag = tag

  @price_code_qualifier = price_code_qualifier
  @price_amount = price_amount
  @price_type_code = price_type_code
  @price_specification_code = price_specification_code
  @unit_price_basis_value = unit_price_basis_value
  @measurment_unit_code = measurment_unit_code
  @subline_item_price_change_operation_code = subline_item_price_change_operation_code

  super(tag: tag || TAG)
end

Instance Attribute Details

#segment_typeObject (readonly)

Returns the value of attribute segment_type.



7
8
9
# File 'lib/eancom/edifact/segments/pri.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#group_nameObject



44
45
46
# File 'lib/eancom/edifact/segments/pri.rb', line 44

def group_name
  'prices'
end

#to_json_hashObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/eancom/edifact/segments/pri.rb', line 33

def to_json_hash
  hash = {}
  hash.merge!(price_code_qualifier: find_identifier(:price_code_qualifier)) if @price_code_qualifier
  hash.merge!(price_amount: @price_amount) if @price_amount
  hash.merge!(price_type_code: find_identifier(:price_type_code)) if @price_type_code
  hash.merge!(price_specification_code: find_identifier(:price_specification_code)) if @price_specification_code
  hash.merge!(unit_price_basis_value: @unit_price_basis_value) if @unit_price_basis_value
  hash.merge!(measurment_unit_code: find_identifier(:measurment_unit_code)) if @measurment_unit_code
  { price: hash }
end