module Eancom module Edifact class CUX < Segment TAG = 'CUX'.freeze TYPE = :body.freeze attr_reader :segment_type def initialize( tag: nil, currency_usage_code_qualifier_1:, currency_identification_code_1:, currency_type_code_qualifier_1: nil, currency_rate_value_1: nil, currency_usage_code_qualifier_2: nil, currency_identification_code_2: nil, currency_type_code_qualifier_2: nil, currency_rate_value_2: nil, currency_exchange_rate: nil, exchange_rate_currency_market_identifier: nil ) @tag = tag @currency_usage_code_qualifier_1 = currency_usage_code_qualifier_1 @currency_identification_code_1 = currency_identification_code_1 @currency_type_code_qualifier_1 = currency_type_code_qualifier_1 @currency_rate_value_1 = currency_rate_value_1 @currency_usage_code_qualifier_2 = currency_usage_code_qualifier_2 @currency_identification_code_2 = currency_identification_code_2 @currency_type_code_qualifier_2 = currency_type_code_qualifier_2 @currency_rate_value_2 = currency_rate_value_2 @currency_exchange_rate = currency_exchange_rate @exchange_rate_currency_market_identifier = exchange_rate_currency_market_identifier super(tag: tag || TAG) end def to_json_hash hash = {} hash.merge!(currency_usage_code_qualifier_1: find_identifier(:currency_usage_code_qualifier_1)) if @currency_usage_code_qualifier_1 hash.merge!(currency_identification_code_1: @currency_identification_code_1) if @currency_identification_code_1 hash.merge!(currency_type_code_qualifier_1: find_identifier(:currency_type_code_qualifier_1)) if @currency_type_code_qualifier_1 hash.merge!(currency_rate_value_1: @currency_rate_value_1) if @currency_rate_value_1 hash.merge!(currency_usage_code_qualifier_2: find_identifier(:currency_usage_code_qualifier_2)) if @currency_usage_code_qualifier_2 hash.merge!(currency_identification_code_2: @currency_identification_code_2) if @currency_identification_code_2 hash.merge!(currency_type_code_qualifier_2: find_identifier(:currency_type_code_qualifier_2)) if @currency_type_code_qualifier_2 hash.merge!(currency_rate_value_2: @currency_rate_value_2) if @currency_rate_value_2 { currency: hash } end def item_group_name 'prices' end def segment_type TYPE end end end end