Commit facadda7da1d676d5d3b783f25e6638ef3e83feb

Authored by Nathan-O
1 parent 1fce007e

added ship-weight to business model calculated from sale order lines in xml

lib/syspro/business_objects/models/sor_detail.rb
@@ -20,7 +20,7 @@ module Syspro @@ -20,7 +20,7 @@ module Syspro
20 :jobs_exist_flag, :alternate_key, :hierarchy_flag, :deposit_flag, :edi_source, :mult_ship_code, 20 :jobs_exist_flag, :alternate_key, :hierarchy_flag, :deposit_flag, :edi_source, :mult_ship_code,
21 :company_tax_no, :last_operator, :operator, :state, :county_zip, :extended_tax_code, :web_created, 21 :company_tax_no, :last_operator, :operator, :state, :county_zip, :extended_tax_code, :web_created,
22 :quote, :dispatches_made, :live_disp_exist, :num_dispatches, :include_in_mrp, :header_text, 22 :quote, :dispatches_made, :live_disp_exist, :num_dispatches, :include_in_mrp, :header_text,
23 - :header_notes, :commissions, :sales_order_lines 23 + :header_notes, :commissions, :sales_order_lines, :ship_weight
24 end 24 end
25 end 25 end
26 end 26 end
lib/syspro/business_objects/parsers/sorqry_parser.rb
@@ -7,6 +7,7 @@ module Syspro @@ -7,6 +7,7 @@ module Syspro
7 attr_reader :doc 7 attr_reader :doc
8 8
9 def initialize(doc) 9 def initialize(doc)
  10 + @calculated_weight = 0
10 @doc = doc 11 @doc = doc
11 end 12 end
12 13
@@ -124,6 +125,7 @@ module Syspro @@ -124,6 +125,7 @@ module Syspro
124 # Inner Nested Structure Parsing 125 # Inner Nested Structure Parsing
125 sor.commissions = parse_commissions(doc) 126 sor.commissions = parse_commissions(doc)
126 sor.sales_order_lines = parse_sales_order_lines(doc) 127 sor.sales_order_lines = parse_sales_order_lines(doc)
  128 + sor.ship_weight = @calculated_weight
127 129
128 sor 130 sor
129 end 131 end
@@ -140,6 +142,7 @@ module Syspro @@ -140,6 +142,7 @@ module Syspro
140 sales_order_lines = doc.first_element_child.xpath("SalesOrderLine") 142 sales_order_lines = doc.first_element_child.xpath("SalesOrderLine")
141 sales_order_lines_obj = {} 143 sales_order_lines_obj = {}
142 144
  145 +
143 sales_order_lines.children.each do |el| 146 sales_order_lines.children.each do |el|
144 next if el.name == "text" 147 next if el.name == "text"
145 148
@@ -183,6 +186,15 @@ module Syspro @@ -183,6 +186,15 @@ module Syspro
183 merchandise_arr = el.children.map do |el_child| 186 merchandise_arr = el.children.map do |el_child|
184 next if el_child.name == "text" 187 next if el_child.name == "text"
185 188
  189 + if el_child.name == "MOrderQty"
  190 + @calculated_weight = @calculated_weight + el_child.text.split(' ')[0].split(',').join().to_f
  191 +
  192 + {
  193 + name: el_child.name,
  194 + text: el_child.text
  195 + }
  196 + end
  197 +
186 # NOTE: These first three in the following 198 # NOTE: These first three in the following
187 # conditionals are "Merchandise" elements with 199 # conditionals are "Merchandise" elements with
188 # thier own nested structure that need parsed 200 # thier own nested structure that need parsed