From facadda7da1d676d5d3b783f25e6638ef3e83feb Mon Sep 17 00:00:00 2001 From: Nathan-O Date: Wed, 5 Dec 2018 17:14:41 -0800 Subject: [PATCH] added ship-weight to business model calculated from sale order lines in xml --- lib/syspro/business_objects/models/sor_detail.rb | 2 +- lib/syspro/business_objects/parsers/sorqry_parser.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/syspro/business_objects/models/sor_detail.rb b/lib/syspro/business_objects/models/sor_detail.rb index 52f3e2f..8cc5a8b 100644 --- a/lib/syspro/business_objects/models/sor_detail.rb +++ b/lib/syspro/business_objects/models/sor_detail.rb @@ -20,7 +20,7 @@ module Syspro :jobs_exist_flag, :alternate_key, :hierarchy_flag, :deposit_flag, :edi_source, :mult_ship_code, :company_tax_no, :last_operator, :operator, :state, :county_zip, :extended_tax_code, :web_created, :quote, :dispatches_made, :live_disp_exist, :num_dispatches, :include_in_mrp, :header_text, - :header_notes, :commissions, :sales_order_lines + :header_notes, :commissions, :sales_order_lines, :ship_weight end end end diff --git a/lib/syspro/business_objects/parsers/sorqry_parser.rb b/lib/syspro/business_objects/parsers/sorqry_parser.rb index 34082ae..cd5bcf6 100644 --- a/lib/syspro/business_objects/parsers/sorqry_parser.rb +++ b/lib/syspro/business_objects/parsers/sorqry_parser.rb @@ -7,6 +7,7 @@ module Syspro attr_reader :doc def initialize(doc) + @calculated_weight = 0 @doc = doc end @@ -124,6 +125,7 @@ module Syspro # Inner Nested Structure Parsing sor.commissions = parse_commissions(doc) sor.sales_order_lines = parse_sales_order_lines(doc) + sor.ship_weight = @calculated_weight sor end @@ -140,6 +142,7 @@ module Syspro sales_order_lines = doc.first_element_child.xpath("SalesOrderLine") sales_order_lines_obj = {} + sales_order_lines.children.each do |el| next if el.name == "text" @@ -183,6 +186,15 @@ module Syspro merchandise_arr = el.children.map do |el_child| next if el_child.name == "text" + if el_child.name == "MOrderQty" + @calculated_weight = @calculated_weight + el_child.text.split(' ')[0].split(',').join().to_f + + { + name: el_child.name, + text: el_child.text + } + end + # NOTE: These first three in the following # conditionals are "Merchandise" elements with # thier own nested structure that need parsed -- libgit2 0.21.4