Commit facadda7da1d676d5d3b783f25e6638ef3e83feb
1 parent
1fce007e
added ship-weight to business model calculated from sale order lines in xml
Showing
2 changed files
with
13 additions
and
1 deletions
 
Show diff stats
lib/syspro/business_objects/models/sor_detail.rb
| ... | ... | @@ -20,7 +20,7 @@ module Syspro | 
| 20 | 20 | :jobs_exist_flag, :alternate_key, :hierarchy_flag, :deposit_flag, :edi_source, :mult_ship_code, | 
| 21 | 21 | :company_tax_no, :last_operator, :operator, :state, :county_zip, :extended_tax_code, :web_created, | 
| 22 | 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 | 24 | end | 
| 25 | 25 | end | 
| 26 | 26 | end | ... | ... | 
lib/syspro/business_objects/parsers/sorqry_parser.rb
| ... | ... | @@ -7,6 +7,7 @@ module Syspro | 
| 7 | 7 | attr_reader :doc | 
| 8 | 8 | |
| 9 | 9 | def initialize(doc) | 
| 10 | + @calculated_weight = 0 | |
| 10 | 11 | @doc = doc | 
| 11 | 12 | end | 
| 12 | 13 | |
| ... | ... | @@ -124,6 +125,7 @@ module Syspro | 
| 124 | 125 | # Inner Nested Structure Parsing | 
| 125 | 126 | sor.commissions = parse_commissions(doc) | 
| 126 | 127 | sor.sales_order_lines = parse_sales_order_lines(doc) | 
| 128 | + sor.ship_weight = @calculated_weight | |
| 127 | 129 | |
| 128 | 130 | sor | 
| 129 | 131 | end | 
| ... | ... | @@ -140,6 +142,7 @@ module Syspro | 
| 140 | 142 | sales_order_lines = doc.first_element_child.xpath("SalesOrderLine") | 
| 141 | 143 | sales_order_lines_obj = {} | 
| 142 | 144 | |
| 145 | + | |
| 143 | 146 | sales_order_lines.children.each do |el| | 
| 144 | 147 | next if el.name == "text" | 
| 145 | 148 | |
| ... | ... | @@ -183,6 +186,15 @@ module Syspro | 
| 183 | 186 | merchandise_arr = el.children.map do |el_child| | 
| 184 | 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 | 198 | # NOTE: These first three in the following | 
| 187 | 199 | # conditionals are "Merchandise" elements with | 
| 188 | 200 | # thier own nested structure that need parsed | ... | ... |