cxml-ruby 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +23 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +175 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE +18 -0
  8. data/README.md +94 -0
  9. data/Rakefile +6 -0
  10. data/cxml-ruby.gemspec +27 -0
  11. data/lib/cxml/accounting.rb +27 -0
  12. data/lib/cxml/additional_cost.rb +10 -0
  13. data/lib/cxml/additional_deduction.rb +12 -0
  14. data/lib/cxml/address.rb +16 -0
  15. data/lib/cxml/bill_to.rb +10 -0
  16. data/lib/cxml/browser_form_post.rb +13 -0
  17. data/lib/cxml/charge.rb +9 -0
  18. data/lib/cxml/classification.rb +9 -0
  19. data/lib/cxml/confirmation_header.rb +16 -0
  20. data/lib/cxml/confirmation_item.rb +14 -0
  21. data/lib/cxml/confirmation_request.rb +25 -0
  22. data/lib/cxml/confirmation_status.rb +32 -0
  23. data/lib/cxml/contact.rb +16 -0
  24. data/lib/cxml/country.rb +9 -0
  25. data/lib/cxml/credential.rb +49 -0
  26. data/lib/cxml/credential_mac.rb +26 -0
  27. data/lib/cxml/deducted_price.rb +9 -0
  28. data/lib/cxml/deduction_amount.rb +9 -0
  29. data/lib/cxml/description.rb +9 -0
  30. data/lib/cxml/discount.rb +10 -0
  31. data/lib/cxml/discount_percent.rb +9 -0
  32. data/lib/cxml/distribution.rb +11 -0
  33. data/lib/cxml/document.rb +71 -0
  34. data/lib/cxml/document_node.rb +126 -0
  35. data/lib/cxml/document_reference.rb +9 -0
  36. data/lib/cxml/due_amount.rb +9 -0
  37. data/lib/cxml/email.rb +10 -0
  38. data/lib/cxml/errors.rb +7 -0
  39. data/lib/cxml/extrinsic.rb +10 -0
  40. data/lib/cxml/from.rb +9 -0
  41. data/lib/cxml/gross_amount.rb +9 -0
  42. data/lib/cxml/header.rb +29 -0
  43. data/lib/cxml/id_reference.rb +13 -0
  44. data/lib/cxml/invoice_detail_discount.rb +13 -0
  45. data/lib/cxml/invoice_detail_header_indicator.rb +11 -0
  46. data/lib/cxml/invoice_detail_header_order.rb +24 -0
  47. data/lib/cxml/invoice_detail_item.rb +55 -0
  48. data/lib/cxml/invoice_detail_item_reference.rb +17 -0
  49. data/lib/cxml/invoice_detail_line_indicator.rb +14 -0
  50. data/lib/cxml/invoice_detail_line_shipping.rb +11 -0
  51. data/lib/cxml/invoice_detail_line_special_handling.rb +11 -0
  52. data/lib/cxml/invoice_detail_order.rb +24 -0
  53. data/lib/cxml/invoice_detail_order_info.rb +10 -0
  54. data/lib/cxml/invoice_detail_order_summary.rb +32 -0
  55. data/lib/cxml/invoice_detail_request.rb +40 -0
  56. data/lib/cxml/invoice_detail_request_header.rb +54 -0
  57. data/lib/cxml/invoice_detail_shipping.rb +27 -0
  58. data/lib/cxml/invoice_detail_summary.rb +18 -0
  59. data/lib/cxml/invoice_id_info.rb +10 -0
  60. data/lib/cxml/invoice_partner.rb +10 -0
  61. data/lib/cxml/item_detail.rb +27 -0
  62. data/lib/cxml/item_id.rb +10 -0
  63. data/lib/cxml/item_in.rb +14 -0
  64. data/lib/cxml/item_out.rb +17 -0
  65. data/lib/cxml/master_agreement_reference.rb +9 -0
  66. data/lib/cxml/message.rb +13 -0
  67. data/lib/cxml/modification.rb +15 -0
  68. data/lib/cxml/modification_detail.rb +16 -0
  69. data/lib/cxml/modifications.rb +23 -0
  70. data/lib/cxml/money.rb +35 -0
  71. data/lib/cxml/name.rb +9 -0
  72. data/lib/cxml/net_amount.rb +9 -0
  73. data/lib/cxml/order_reference.rb +12 -0
  74. data/lib/cxml/order_request.rb +33 -0
  75. data/lib/cxml/order_request_header.rb +66 -0
  76. data/lib/cxml/parser.rb +37 -0
  77. data/lib/cxml/payment_term.rb +28 -0
  78. data/lib/cxml/period.rb +10 -0
  79. data/lib/cxml/postal_address.rb +35 -0
  80. data/lib/cxml/protocol.rb +57 -0
  81. data/lib/cxml/punch_out_order_message.rb +33 -0
  82. data/lib/cxml/punch_out_order_message_header.rb +20 -0
  83. data/lib/cxml/punch_out_setup_request.rb +31 -0
  84. data/lib/cxml/punch_out_setup_response.rb +9 -0
  85. data/lib/cxml/request.rb +21 -0
  86. data/lib/cxml/response.rb +20 -0
  87. data/lib/cxml/segment.rb +12 -0
  88. data/lib/cxml/sender.rb +10 -0
  89. data/lib/cxml/ship_to.rb +10 -0
  90. data/lib/cxml/shipping.rb +10 -0
  91. data/lib/cxml/shipping_amount.rb +10 -0
  92. data/lib/cxml/special_handling_amount.rb +11 -0
  93. data/lib/cxml/start_page.rb +13 -0
  94. data/lib/cxml/state.rb +9 -0
  95. data/lib/cxml/status.rb +27 -0
  96. data/lib/cxml/subtotal_amount.rb +9 -0
  97. data/lib/cxml/supplier_setup.rb +13 -0
  98. data/lib/cxml/tax.rb +42 -0
  99. data/lib/cxml/tax_adjustment_amount.rb +9 -0
  100. data/lib/cxml/tax_amount.rb +9 -0
  101. data/lib/cxml/tax_detail.rb +44 -0
  102. data/lib/cxml/tax_location.rb +9 -0
  103. data/lib/cxml/taxable_amount.rb +9 -0
  104. data/lib/cxml/to.rb +9 -0
  105. data/lib/cxml/total.rb +10 -0
  106. data/lib/cxml/total_allowances.rb +9 -0
  107. data/lib/cxml/total_amount_without_tax.rb +9 -0
  108. data/lib/cxml/total_charges.rb +9 -0
  109. data/lib/cxml/unit_price.rb +9 -0
  110. data/lib/cxml/version.rb +5 -0
  111. data/lib/cxml.rb +39 -0
  112. data/spec/credential_spec.rb +37 -0
  113. data/spec/cxml_spec.rb +6 -0
  114. data/spec/document_spec.rb +155 -0
  115. data/spec/fixtures/.gitkeep +0 -0
  116. data/spec/fixtures/envelope.xml +31 -0
  117. data/spec/fixtures/envelope2.xml +36 -0
  118. data/spec/fixtures/invoice_backed_and_unbacked_by_pos.xml +106 -0
  119. data/spec/fixtures/invoice_backed_by_multiple_pos.xml +97 -0
  120. data/spec/fixtures/invoice_taxes_at_line.xml +82 -0
  121. data/spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml +403 -0
  122. data/spec/fixtures/invoice_taxes_at_total.xml +78 -0
  123. data/spec/fixtures/item_in.xml +11 -0
  124. data/spec/fixtures/order_request.cxml +121 -0
  125. data/spec/fixtures/punch_out_order_message_doc.xml +32 -0
  126. data/spec/fixtures/punch_out_setup_request_doc.xml +32 -0
  127. data/spec/fixtures/punch_out_setup_request_doc_coupa.xml +42 -0
  128. data/spec/fixtures/punch_out_setup_request_doc_with_ship_to.xml +46 -0
  129. data/spec/fixtures/purchase_order_request_200.xml +132 -0
  130. data/spec/fixtures/request_doc.xml +79 -0
  131. data/spec/fixtures/response_status_200.xml +11 -0
  132. data/spec/fixtures/response_status_400.xml +5 -0
  133. data/spec/header_spec.rb +54 -0
  134. data/spec/invoice_detail_request_spec.rb +88 -0
  135. data/spec/item_detail_spec.rb +44 -0
  136. data/spec/item_id_spec.rb +40 -0
  137. data/spec/item_in_spec.rb +41 -0
  138. data/spec/money_spec.rb +44 -0
  139. data/spec/parser_spec.rb +6 -0
  140. data/spec/protocol_spec.rb +16 -0
  141. data/spec/punch_out_order_message_header_spec.rb +36 -0
  142. data/spec/punch_out_order_message_spec.rb +43 -0
  143. data/spec/punch_out_setup_request_spec.rb +60 -0
  144. data/spec/purchase_order_request_spec.rb +40 -0
  145. data/spec/request_spec.rb +36 -0
  146. data/spec/response_spec.rb +58 -0
  147. data/spec/sender_spec.rb +32 -0
  148. data/spec/spec_helper.rb +21 -0
  149. data/spec/status_spec.rb +44 -0
  150. data/spec/support/helpers.rb +5 -0
  151. metadata +317 -0
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The CredentialMac element is used for the Message Authentication Code (MAC)
4
+ # authentication method. This authentication method is used in situations where the
5
+ # sender must prove to the receiver that it has been authenticated by shared secret by a
6
+ # trusted third party. For example, a direct PunchOut request can travel directly from a
7
+ # buyer to a supplier without going through a network commerce hub, because it
8
+ # contains a MAC (generated by the network commerce hub) that allows the supplier to
9
+ # authenticate it.
10
+ # The trusted third party computes the MAC and transfers it to the sender through the
11
+ # Profile transaction. The MAC is opaque to the sender (it is secure and non-reversible).
12
+ # To see how the MAC is transmitted from the trusted third party to the sender, see
13
+ # "ProfileResponse" on page 63.
14
+ #
15
+ # Page 45 cXML reference
16
+
17
+ module CXML
18
+ class CredentialMac < DocumentNode
19
+ accessible_attributes %i[
20
+ type
21
+ algorithm
22
+ creation_date
23
+ expiration_date
24
+ ]
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class DeductedPrice < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class DeductionAmount < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Description < DocumentNode
5
+ accessible_attributes %i[
6
+ xml_lang
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Discount < DocumentNode
5
+ accessible_nodes %i[
6
+ discount_percent
7
+ discount_due_days
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class DiscountPercent < DocumentNode
5
+ accessible_attributes %i[
6
+ percent
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # accounting info for ItemOut
5
+ class Distribution < DocumentNode
6
+ accessible_nodes %i[
7
+ accounting
8
+ charge
9
+ ]
10
+ end
11
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('time')
4
+
5
+ module CXML
6
+ class Document < DocumentNode
7
+ accessible_attributes %i[
8
+ version
9
+ payload_id
10
+ xml_lang
11
+ timestamp
12
+ ]
13
+ accessible_nodes %i[
14
+ header
15
+ message
16
+ request
17
+ response
18
+ ]
19
+
20
+ def initialize_timestamp(value)
21
+ @timestamp = Time.parse(value)
22
+ end
23
+
24
+ def timestamp
25
+ @timestamp ||= Time.now.utc
26
+ end
27
+
28
+ def version
29
+ @version ||= '1.2.037'
30
+ end
31
+
32
+ def from_xml(xml_string)
33
+ initialize(Parser.new.parse(xml_string))
34
+ self
35
+ end
36
+
37
+ # Check if document is request
38
+ # @return [Boolean]
39
+ def request?
40
+ !request.nil?
41
+ end
42
+
43
+ # Check if document is a response
44
+ # @return [Boolean]
45
+ def response?
46
+ !response.nil?
47
+ end
48
+
49
+ # Check if document is a message
50
+ # @return [Boolean]
51
+ def message?
52
+ !message.nil?
53
+ end
54
+
55
+ def render
56
+ node = CXML.builder
57
+ node.doc.create_internal_subset(
58
+ 'cXML',
59
+ nil,
60
+ "http://xml.cxml.org/schemas/cXML/#{version}/cXML.dtd"
61
+ )
62
+ node.cXML(node_attributes) do |doc|
63
+ header&.render(doc)
64
+ request&.render(doc)
65
+ response&.render(doc)
66
+ message&.render(doc)
67
+ end
68
+ node
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # base class for document nodes
5
+ class DocumentNode
6
+ attr_accessor :content
7
+
8
+ def self.accessible_attributes(attrs)
9
+ raise(ArgumentError) unless attrs.is_a?(Array)
10
+
11
+ @attributes = attrs
12
+ attr_accessor(*attrs)
13
+ end
14
+
15
+ def self.attributes
16
+ @attributes || []
17
+ end
18
+
19
+ def self.accessible_nodes(new_nodes)
20
+ raise(ArgumentError) unless new_nodes.is_a?(Array)
21
+
22
+ @nodes = new_nodes
23
+ attr_accessor(*new_nodes)
24
+ end
25
+
26
+ def self.nodes
27
+ @nodes || []
28
+ end
29
+
30
+ def initialize(data = {})
31
+ if data.is_a?(String)
32
+ @content = data
33
+ return
34
+ end
35
+ data = data.serializable_hash if data.is_a?(self.class)
36
+ return unless data.is_a?(Hash)
37
+
38
+ data.each(&method(:initialize_attribute))
39
+ end
40
+
41
+ def serializable_hash
42
+ (self.class.attributes + self.class.nodes + [:content]).each_with_object({}) do |attr, obj|
43
+ value = send(attr)
44
+ value = value.iso8601 if value.is_a?(Time)
45
+ next if value.respond_to?(:empty?) ? value.empty? : !value
46
+
47
+ obj[attr] = value.is_a?(DocumentNode) ? value.serializable_hash : value
48
+ end
49
+ end
50
+
51
+ def render(node = CXML.builder)
52
+ node.send(self.class.name.split('::').last, node_attributes) do |n|
53
+ n.text(content) if content
54
+ render_nodes(n)
55
+ end
56
+ node
57
+ end
58
+
59
+ def render_nodes(node)
60
+ self.class.nodes.each do |child_node_name|
61
+ child_value = send(child_node_name)
62
+ if child_value.is_a?(Array)
63
+ child_value.each do |child_value_n|
64
+ render_child_node(node, child_node_name, child_value_n)
65
+ end
66
+ else
67
+ render_child_node(node, child_node_name, child_value)
68
+ end
69
+ end
70
+ end
71
+
72
+ private
73
+
74
+ def render_child_node(node, name, value)
75
+ return if value.respond_to?(:empty?) ? value.empty? : !value
76
+
77
+ if value.is_a?(DocumentNode)
78
+ value.render(node)
79
+ else
80
+ node.send(camelize(name), value)
81
+ end
82
+ end
83
+
84
+ def node_attributes
85
+ self.class.attributes.each_with_object({}) do |attr, obj|
86
+ value = send(attr)
87
+ value = value.iso8601 if value.is_a?(Time)
88
+ next if value.respond_to?(:empty?) ? value.empty? : !value
89
+
90
+ string_attr = if attr.to_sym == :xml_lang
91
+ 'xml:lang'
92
+ else
93
+ camelize(attr, false)
94
+ end
95
+ obj[string_attr] = value
96
+ end
97
+ end
98
+
99
+ def initialize_attribute(key, val)
100
+ return send("initialize_#{key}", val) if respond_to?("initialize_#{key}")
101
+ return send("#{key}=", val) if self.class.attributes.include?(key)
102
+
103
+ klass = "CXML::#{camelize(key)}"
104
+ send("#{key}=", Object.const_get(klass).new(val))
105
+ rescue NoMethodError => e
106
+ raise(UnknownAttributeError, e) if CXML.raise_unknown_elements
107
+
108
+ CXML.logger.warn(e)
109
+ rescue NameError => e
110
+ raise(e) unless e.to_s.match?(klass)
111
+
112
+ send("#{key}=", val)
113
+ end
114
+
115
+ def camelize(string, uppercase_first_letter = true)
116
+ string = if uppercase_first_letter
117
+ string.to_s.sub(/^[a-z\d]*/, &:capitalize)
118
+ else
119
+ string.to_s.sub(/^(?:(?=\b|[A-Z_])|\w)/, &:downcase)
120
+ end
121
+ string.gsub(/_id(_)?$/, '_ID\1').gsub(%r{(?:_|(/))([a-z\d]*)}) do
122
+ "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}"
123
+ end.gsub('/', '::')
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class DocumentReference < DocumentNode
5
+ accessible_attributes %i[
6
+ payload_id
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class DueAmount < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ ]
8
+ end
9
+ end
data/lib/cxml/email.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # address, typically in a purchase order message
5
+ class Email < DocumentNode
6
+ accessible_attributes %i[
7
+ name
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Error < StandardError; end
5
+ class ParseError < Error; end
6
+ class UnknownAttributeError < ParseError; end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # class for extrinsic data in punchout setup request
5
+ class Extrinsic < DocumentNode
6
+ accessible_attributes %i[
7
+ name
8
+ ]
9
+ end
10
+ end
data/lib/cxml/from.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class From < DocumentNode
5
+ accessible_nodes %i[
6
+ credential
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class GrossAmount < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The Header element contains addressing and authentication information. The Header
4
+ # element is the same regardless of the specific Request or Response within the body of
5
+ # the cXML message. Applications need the requestor's identity, but not validation that
6
+ # the information provided for identity is correct.
7
+ #
8
+ # The From and To elements are synonymous with From and To in SMTP mail
9
+ # messages; they are the logical source and destination of the messages. Sender is the
10
+ # party that opens the HTTP connection and sends the cXML document.
11
+ # Sender contains the Credential element, which allows the receiving party to authenticate
12
+ # the sending party. This credential allows strong authentication without requiring a
13
+ # public-key end-to-end digital certificate infrastructure. Only a user name and
14
+ # password need to be issued by the receiving party to allow the sending party to
15
+ # perform Requests.
16
+ #
17
+ # When the document is initially sent, Sender and From are the same, However, if the
18
+ # cXML document travels through e-commerce network hubs, the Sender element
19
+ # changes to indicate current sending party.
20
+
21
+ module CXML
22
+ class Header < DocumentNode
23
+ accessible_nodes %i[
24
+ from
25
+ to
26
+ sender
27
+ ]
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class IdReference < DocumentNode
5
+ accessible_attributes %i[
6
+ domain
7
+ identifier
8
+ ]
9
+ accessible_nodes %i[
10
+ description
11
+ ]
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailDiscount < DocumentNode
5
+ accessible_attributes %i[
6
+ percentage_rate
7
+ ]
8
+ accessible_nodes %i[
9
+ money
10
+ distribution
11
+ ]
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailHeaderIndicator < DocumentNode
5
+ accessible_attributes %i[
6
+ is_header_invoice
7
+ is_vat_recoverable
8
+ price_based_line_level_credit_memo
9
+ ]
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailHeaderOrder < DocumentNode
5
+ accessible_nodes %i[
6
+ invoice_detail_order_info
7
+ invoice_detail_order_summaries
8
+ ]
9
+
10
+ def initialize_invoice_detail_order_summary(value)
11
+ value = [value] unless value.is_a?(Array)
12
+ @invoice_detail_order_summaries = value.map do |item|
13
+ InvoiceDetailOrderSummary.new(item)
14
+ end
15
+ end
16
+
17
+ def initialize_invoice_detail_order_summaries(value)
18
+ value = [value] unless value.is_a?(Array)
19
+ @invoice_detail_order_summaries = value.map do |item|
20
+ InvoiceDetailOrderSummary.new(item)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailItem < DocumentNode
5
+ accessible_attributes %i[
6
+ composite_item_type
7
+ inspection_date
8
+ invoice_line_number
9
+ is_ad_hoc
10
+ item_type
11
+ parent_invoice_line_number
12
+ quantity
13
+ reason
14
+ reference_date
15
+ ]
16
+ accessible_nodes %i[
17
+ comments
18
+ distribution
19
+ extrinsics
20
+ gross_amount
21
+ invoice_detail_discount
22
+ invoice_detail_item_industry
23
+ invoice_detail_item_reference
24
+ invoice_detail_line_shipping
25
+ invoice_detail_line_special_handling
26
+ invoice_item_modifications
27
+ net_amount
28
+ packaging
29
+ price_basis_quantity
30
+ ship_notice_id_info
31
+ ship_notice_line_item_reference
32
+ subtotal_amount
33
+ tax
34
+ total_allowances
35
+ total_amount_without_tax
36
+ total_charges
37
+ unit_of_measure
38
+ unit_price
39
+ ]
40
+
41
+ def initialize_extrinsic(value)
42
+ value = [value] unless value.is_a?(Array)
43
+ @extrinsics = value.map do |item|
44
+ Extrinsic.new(item)
45
+ end
46
+ end
47
+
48
+ def initialize_extrinsics(value)
49
+ value = [value] unless value.is_a?(Array)
50
+ @extrinsics = value.map do |item|
51
+ Extrinsic.new(item)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailItemReference < DocumentNode
5
+ accessible_attributes %i[
6
+ line_number
7
+ ]
8
+ accessible_nodes %i[
9
+ description
10
+ item_id
11
+ classification
12
+ manufacturer_part_id
13
+ manufacturer_name
14
+ country
15
+ ]
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailLineIndicator < DocumentNode
5
+ accessible_attributes %i[
6
+ is_tax_in_line
7
+ is_special_handling_in_line
8
+ is_shipping_in_line
9
+ is_discount_in_line
10
+ is_accounting_in_line
11
+ is_price_adjustment_in_line
12
+ ]
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailLineShipping < DocumentNode
5
+ accessible_nodes %i[
6
+ invoice_detail_shipping
7
+ money
8
+ distribution
9
+ ]
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailLineSpecialHandling < DocumentNode
5
+ accessible_nodes %i[
6
+ description
7
+ money
8
+ distribution
9
+ ]
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailOrder < DocumentNode
5
+ accessible_nodes %i[
6
+ invoice_detail_order_info
7
+ invoice_detail_items
8
+ ]
9
+
10
+ def initialize_invoice_detail_item(value)
11
+ value = [value] unless value.is_a?(Array)
12
+ @invoice_detail_items = value.map do |item|
13
+ InvoiceDetailItem.new(item)
14
+ end
15
+ end
16
+
17
+ def initialize_invoice_detail_items(value)
18
+ value = [value] unless value.is_a?(Array)
19
+ @invoice_detail_items = value.map do |item|
20
+ InvoiceDetailItem.new(item)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailOrderInfo < DocumentNode
5
+ accessible_nodes %i[
6
+ order_reference
7
+ master_agreement_reference
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailOrderSummary < DocumentNode
5
+ accessible_attributes %i[
6
+ invoice_line_number
7
+ inspection_date
8
+ ]
9
+ accessible_nodes %i[
10
+ subtotal_amount
11
+ period
12
+ tax
13
+ invoice_detail_line_special_handling
14
+ invoice_detail_line_shipping
15
+ gross_amount
16
+ ]
17
+
18
+ def initialize_invoice_detail_order_summary(value)
19
+ value = [value] unless value.is_a?(Array)
20
+ @invoice_detail_order_summaries = value.map do |item|
21
+ InvoiceDetailOrderSummary.new(item)
22
+ end
23
+ end
24
+
25
+ def initialize_invoice_detail_order_summaries(value)
26
+ value = [value] unless value.is_a?(Array)
27
+ @invoice_detail_order_summaries = value.map do |item|
28
+ InvoiceDetailOrderSummary.new(item)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class InvoiceDetailRequest < DocumentNode
5
+ accessible_nodes %i[
6
+ invoice_detail_request_header
7
+ invoice_detail_header_orders
8
+ invoice_detail_orders
9
+ invoice_detail_summary
10
+ ]
11
+
12
+ def initialize_invoice_detail_orders(value)
13
+ value = [value] unless value.is_a?(Array)
14
+ @invoice_detail_orders = value.map do |item|
15
+ InvoiceDetailOrder.new(item)
16
+ end
17
+ end
18
+
19
+ def initialize_invoice_detail_order(value)
20
+ value = [value] unless value.is_a?(Array)
21
+ @invoice_detail_orders = value.map do |item|
22
+ InvoiceDetailOrder.new(item)
23
+ end
24
+ end
25
+
26
+ def initialize_invoice_detail_header_orders(value)
27
+ value = [value] unless value.is_a?(Array)
28
+ @invoice_detail_header_orders = value.map do |item|
29
+ InvoiceDetailHeaderOrder.new(item)
30
+ end
31
+ end
32
+
33
+ def initialize_invoice_detail_header_order(value)
34
+ value = [value] unless value.is_a?(Array)
35
+ @invoice_detail_header_orders = value.map do |item|
36
+ InvoiceDetailHeaderOrder.new(item)
37
+ end
38
+ end
39
+ end
40
+ end