Skip to content

Commit

Permalink
NATACC-1203 Add custom classification to item detail
Browse files Browse the repository at this point in the history
  • Loading branch information
ImogenCampbellCEF committed Dec 12, 2024
1 parent 2f3a514 commit a1179c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions lib/cxml/item_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@

module CXML
class ItemDetail
attr_accessor :description
attr_accessor :unit_of_measure
attr_accessor :unit_price
attr_accessor :unspsc
attr_accessor :manufacturer_part_id
attr_accessor :manufacturer_name
attr_accessor :lead_time
attr_accessor :extrinsics
attr_accessor :description, :unit_of_measure, :unit_price, :unspsc, :manufacturer_part_id,
:manufacturer_name, :lead_time, :extrinsics, :custom_classification

def initialize(data={})
if data.kind_of?(Hash) && !data.empty?
@unit_price = CXML::Money.new(data['UnitPrice']['Money'])
@description = data['Description']
@unit_of_measure = data['UnitOfMeasure']
@unspsc = data['ClassificationUnspsc']
@custom_classification = data['ClassificationCustom']
@manufacturer_part_id = data['ManufacturerPartID']
@manufacturer_name = data['ManufacturerName']
@lead_time = data['LeadTime']
Expand All @@ -31,9 +26,10 @@ def initialize(data={})
def render(node)
node.ItemDetail do
node.UnitPrice{unit_price.render(node)}
node.Description(description, {'xml:lang' => 'en'})
node.Description(description, { 'xml:lang' => 'en' })
node.UnitOfMeasure(unit_of_measure)
node.Classification(unspsc, {'domain' => 'UNSPSC'}) unless unspsc.blank?
node.Classification(unspsc, { 'domain' => 'UNSPSC' }) unless unspsc.blank?
node.Classification(custom_classification, { 'domain' => 'CUSTOM' }) unless custom_classification.blank?
node.ManufacturerPartID(manufacturer_part_id) if manufacturer_part_id.present?
node.ManufacturerName(manufacturer_name) if manufacturer_name.present?
node.LeadTime(lead_time) if lead_time.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/cxml/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CXML
VERSION = '0.2.8'
VERSION = '0.2.9'
end

0 comments on commit a1179c9

Please sign in to comment.