diff --git a/lib/syspro.rb b/lib/syspro.rb index 8af8aba..a915ce2 100644 --- a/lib/syspro.rb +++ b/lib/syspro.rb @@ -94,7 +94,7 @@ module Syspro end def api_base=(url) - warn "[DEPRECATION] `api_base=` is deprecated. Please use `configuration.server_url=` instead." + warn '[DEPRECATION] `api_base=` is deprecated. Please use `configuration.server_url=` instead.' @api_base = url end diff --git a/lib/syspro/api_operations/setup.rb b/lib/syspro/api_operations/setup.rb index fa77dd5..fed9d21 100644 --- a/lib/syspro/api_operations/setup.rb +++ b/lib/syspro/api_operations/setup.rb @@ -33,11 +33,10 @@ module Syspro protected - def request(method, url, params = {}, opts ={}) + def request(method, url, params = {}, opts = {}) opts = @opts.merge(Util.normalize_opts(opts)) Request.request(method, url, params, opts) end end end end - diff --git a/lib/syspro/api_operations/transaction.rb b/lib/syspro/api_operations/transaction.rb index 5cbb82e..058d440 100644 --- a/lib/syspro/api_operations/transaction.rb +++ b/lib/syspro/api_operations/transaction.rb @@ -25,11 +25,10 @@ module Syspro protected - def request(method, url, params = {}, opts ={}) + def request(method, url, params = {}, opts = {}) opts = @opts.merge(Util.normalize_opts(opts)) Request.request(method, url, params, opts) end end end end - diff --git a/lib/syspro/business_objects/combrw.rb b/lib/syspro/business_objects/combrw.rb index 6ec521d..9b3b34a 100644 --- a/lib/syspro/business_objects/combrw.rb +++ b/lib/syspro/business_objects/combrw.rb @@ -16,10 +16,10 @@ module Syspro xml_in = template.result(binding) params = { 'UserId' => user_id, 'XmlIn' => xml_in } resp = ComBrw.browse(params) - unless raw - parse_response(resp) - else + if raw resp + else + parse_response(resp) end end diff --git a/lib/syspro/business_objects/comsfm.rb b/lib/syspro/business_objects/comsfm.rb index 158e2f5..4022906 100644 --- a/lib/syspro/business_objects/comsfm.rb +++ b/lib/syspro/business_objects/comsfm.rb @@ -17,9 +17,9 @@ module Syspro xml_in = template.result(binding) business_object = 'COMSFM' params = { 'UserId' => user_id, - 'BusinessObject' => business_object, - 'XmlParameters' => xml_parameters, - 'XmlIn' => xml_in } + 'BusinessObject' => business_object, + 'XmlParameters' => xml_parameters, + 'XmlIn' => xml_in } resp = ComsFm.add(params) parse_response(resp) @@ -40,4 +40,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/invqry.rb b/lib/syspro/business_objects/invqry.rb index 00c5222..db1e97f 100644 --- a/lib/syspro/business_objects/invqry.rb +++ b/lib/syspro/business_objects/invqry.rb @@ -32,7 +32,7 @@ module Syspro parser.parse end - def render_xml(inner_text, dflt_value = "") + def render_xml(inner_text, dflt_value = '') inner_text ? inner_text.to_s : dflt_value end end diff --git a/lib/syspro/business_objects/invsws.rb b/lib/syspro/business_objects/invsws.rb index 765d46d..fdd2366 100644 --- a/lib/syspro/business_objects/invsws.rb +++ b/lib/syspro/business_objects/invsws.rb @@ -20,9 +20,9 @@ module Syspro xml_in = template.result(binding) business_object = 'INVSWS' params = { 'UserId' => user_id, - 'BusinessObject' => business_object, - 'XmlParameters' => xml_parameters, - 'XmlIn' => xml_in } + 'BusinessObject' => business_object, + 'XmlParameters' => xml_parameters, + 'XmlIn' => xml_in } resp = InvSws.add(params) parse_response(resp) @@ -42,7 +42,7 @@ module Syspro parser.parse end - def render_xml(inner_text, dflt_value = "") + def render_xml(inner_text, dflt_value = '') inner_text ? inner_text.to_s : dflt_value end end diff --git a/lib/syspro/business_objects/models/comsfm_item.rb b/lib/syspro/business_objects/models/comsfm_item.rb index 3488fea..f114473 100644 --- a/lib/syspro/business_objects/models/comsfm_item.rb +++ b/lib/syspro/business_objects/models/comsfm_item.rb @@ -9,4 +9,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/inv.rb b/lib/syspro/business_objects/models/inv.rb index b66d33e..1537e83 100644 --- a/lib/syspro/business_objects/models/inv.rb +++ b/lib/syspro/business_objects/models/inv.rb @@ -9,7 +9,7 @@ module Syspro def initialize @warehouse_totals = WarehouseTotals.new - @warehouse_items = [] + @warehouse_items = [] @stock_item = StockItem.new @system_information = SystemInformation.new end @@ -19,7 +19,7 @@ module Syspro # copy hash items that match into new warehouse item new_hash.keys.each do |k| - w.send("#{k.to_s}=", new_hash[k]) if w.methods.include? k + w.send("#{k}=", new_hash[k]) if w.methods.include? k end @warehouse_items.push(w) @@ -29,7 +29,7 @@ module Syspro class WarehouseTotals attr_accessor :qty_on_hand, :available_qty - + # Not all xml parsed, see https://infozone.syspro.com/Support/businessobjectslibrary/INVQRYOUT.XML end @@ -80,4 +80,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/models/inv_qry_options.rb b/lib/syspro/business_objects/models/inv_qry_options.rb index 3196029..90da301 100644 --- a/lib/syspro/business_objects/models/inv_qry_options.rb +++ b/lib/syspro/business_objects/models/inv_qry_options.rb @@ -25,11 +25,7 @@ module Syspro :include_movement_dispatch_notes, :include_ecc, :xsl_stylesheet - end end end end - - - diff --git a/lib/syspro/business_objects/models/inventory_inspection.rb b/lib/syspro/business_objects/models/inventory_inspection.rb index 3928874..bcb5650 100644 --- a/lib/syspro/business_objects/models/inventory_inspection.rb +++ b/lib/syspro/business_objects/models/inventory_inspection.rb @@ -12,4 +12,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/invsws_item.rb b/lib/syspro/business_objects/models/invsws_item.rb index 30367a8..29ea630 100644 --- a/lib/syspro/business_objects/models/invsws_item.rb +++ b/lib/syspro/business_objects/models/invsws_item.rb @@ -39,9 +39,9 @@ module Syspro :e_signature end - class InvSwsItemKey - attr_accessor - end + class InvSwsItemKey + attr_accessor + end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/por_detail.rb b/lib/syspro/business_objects/models/por_detail.rb index ccee1c3..3cf3593 100644 --- a/lib/syspro/business_objects/models/por_detail.rb +++ b/lib/syspro/business_objects/models/por_detail.rb @@ -94,35 +94,33 @@ module Syspro :edit_default_price, :default_prum, :costing_methods_available - end # end of class MerchandiseDetail class CostingMethodsAvailable attr_accessor :manual_method_code, - :manual_method_desc, - :manual_method_price, - :edit__manual_method_price, - :manual_method_costing_prum, - :total_cost_method_code, - :total_cost_method_desc, - :total_cost_method_price, - :edit__total_cost_method_price, - :total_cost_costing_prum, - :purchase_price_method_code, - :purchase_price_method_desc, - :purchase_price_method_price, - :edit__purchase_price_method_price, - :purchase_price_costing_prum, - :price_tax_method_code, - :price_tax_method_desc, - :price_tax_method_price, - :edit__price_tax_method_price, - :price_tax_costing_prum + :manual_method_desc, + :manual_method_price, + :edit__manual_method_price, + :manual_method_costing_prum, + :total_cost_method_code, + :total_cost_method_desc, + :total_cost_method_price, + :edit__total_cost_method_price, + :total_cost_costing_prum, + :purchase_price_method_code, + :purchase_price_method_desc, + :purchase_price_method_price, + :edit__purchase_price_method_price, + :purchase_price_costing_prum, + :price_tax_method_code, + :price_tax_method_desc, + :price_tax_method_price, + :edit__price_tax_method_price, + :price_tax_costing_prum end # end of class CostingMethodsAvailable class PurchaseOrderTotals attr_accessor :local_values, :current_values, :first_receipt_date, :order_complete_date - end class PurchaseOrderTotalsLocalValues @@ -136,7 +134,6 @@ module Syspro :edited_current_order_value, :edited_current_received_to_date_value, :edited_current_outstanding_value end - end end end diff --git a/lib/syspro/business_objects/models/purchase_order.rb b/lib/syspro/business_objects/models/purchase_order.rb index 698297a..0847fc9 100644 --- a/lib/syspro/business_objects/models/purchase_order.rb +++ b/lib/syspro/business_objects/models/purchase_order.rb @@ -10,4 +10,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/purchase_orders/comment_line.rb b/lib/syspro/business_objects/models/purchase_orders/comment_line.rb index f8c60c5..84af090 100644 --- a/lib/syspro/business_objects/models/purchase_orders/comment_line.rb +++ b/lib/syspro/business_objects/models/purchase_orders/comment_line.rb @@ -13,4 +13,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/purchase_orders/freight_line.rb b/lib/syspro/business_objects/models/purchase_orders/freight_line.rb index 81fbeb3..1738a00 100644 --- a/lib/syspro/business_objects/models/purchase_orders/freight_line.rb +++ b/lib/syspro/business_objects/models/purchase_orders/freight_line.rb @@ -8,9 +8,9 @@ module Syspro :freight_value, :freight_tax_code, :freight_taxable - :freight_f_loc + :freight_f_loc end end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/purchase_orders/header.rb b/lib/syspro/business_objects/models/purchase_orders/header.rb index a9e5f05..e426b6e 100644 --- a/lib/syspro/business_objects/models/purchase_orders/header.rb +++ b/lib/syspro/business_objects/models/purchase_orders/header.rb @@ -39,6 +39,3 @@ module Syspro end end end - - - diff --git a/lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb b/lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb index 4d0adca..be46ab2 100644 --- a/lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb +++ b/lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb @@ -15,4 +15,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/purchase_orders/order_details.rb b/lib/syspro/business_objects/models/purchase_orders/order_details.rb index 2d56a94..444e14f 100644 --- a/lib/syspro/business_objects/models/purchase_orders/order_details.rb +++ b/lib/syspro/business_objects/models/purchase_orders/order_details.rb @@ -31,4 +31,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/purchase_orders/stock_line.rb b/lib/syspro/business_objects/models/purchase_orders/stock_line.rb index cb6f1ed..ef2fa16 100644 --- a/lib/syspro/business_objects/models/purchase_orders/stock_line.rb +++ b/lib/syspro/business_objects/models/purchase_orders/stock_line.rb @@ -4,45 +4,42 @@ module Syspro module PurchaseOrders class StockLine attr_accessor :purchase_order_line, - :line_action_type, - :stock_code, - :stock_description, - :warehouse, - :sup_catalogue, - :order_qty, - :order_uom, - :units, - :pieces, - :price_method, - :supplier_contract, - :price, - :price_uom, - :line_disc_type, - :line_disc_less_plus, - :line_disc_percent1, - :line_disc_percent2, - :line_disc_percent3, - :line_disc_value, - :taxable, - :tax_codev, - :job, - :version, - :release, - :latest_due_date, - :original_due_date, - :reschedule_due_date, - :ledger_code, - :password_for_ledger_code, - :subcontract_op, - :inspection_reqd, - :product_class, - :nons_unit_mass, - :nons_unit_vol + :line_action_type, + :stock_code, + :stock_description, + :warehouse, + :sup_catalogue, + :order_qty, + :order_uom, + :units, + :pieces, + :price_method, + :supplier_contract, + :price, + :price_uom, + :line_disc_type, + :line_disc_less_plus, + :line_disc_percent1, + :line_disc_percent2, + :line_disc_percent3, + :line_disc_value, + :taxable, + :tax_codev, + :job, + :version, + :release, + :latest_due_date, + :original_due_date, + :reschedule_due_date, + :ledger_code, + :password_for_ledger_code, + :subcontract_op, + :inspection_reqd, + :product_class, + :nons_unit_mass, + :nons_unit_vol end end end end end - - - diff --git a/lib/syspro/business_objects/models/receipt_interospection.rb b/lib/syspro/business_objects/models/receipt_interospection.rb index bce19b7..3173061 100644 --- a/lib/syspro/business_objects/models/receipt_interospection.rb +++ b/lib/syspro/business_objects/models/receipt_interospection.rb @@ -29,4 +29,4 @@ module Syspro end end end -end \ No newline at end of file +end diff --git a/lib/syspro/business_objects/models/sor.rb b/lib/syspro/business_objects/models/sor.rb index e970e32..d5ab98d 100644 --- a/lib/syspro/business_objects/models/sor.rb +++ b/lib/syspro/business_objects/models/sor.rb @@ -13,4 +13,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/parsers/porqry_parser.rb b/lib/syspro/business_objects/parsers/porqry_parser.rb index fae8e52..5584caf 100644 --- a/lib/syspro/business_objects/parsers/porqry_parser.rb +++ b/lib/syspro/business_objects/parsers/porqry_parser.rb @@ -11,7 +11,7 @@ module Syspro end def parse - por = Syspro::BusinessObjects::Models::PorDetail.new() + por = Syspro::BusinessObjects::Models::PorDetail.new por.purchase_order = doc.first_element_child.xpath('PurchaseOrder').text por.supplier = doc.first_element_child.xpath('Supplier').text @@ -65,156 +65,152 @@ module Syspro por.document_format = doc.first_element_child.xpath('DocumentFormat').text por.include_in_mrp = doc.first_element_child.xpath('IncludeInMrp').text - por.customform_fields = doc.first_element_child.xpath("CustomForm").children.select{|item| item.name === "Field"}.map do |field_el| - if field_el && field_el.children.count > 0 - Syspro::BusinessObjects::Models::PorDetail::CustomFormField.new.tap do |field_obj| - field_obj.sequence = field_el.children.select{|el| el.name === "Sequence"}[0].children.text - field_obj.name = field_el.children.select{|el| el.name === "Name"}[0].children.text - field_obj.prompt = field_el.children.select{|el| el.name === "Prompt"}[0].children.text - field_obj.column = field_el.children.select{|el| el.name === "Column"}[0].children.text - field_obj.type = field_el.children.select{|el| el.name === "Type"}[0].children.text - field_obj.length = field_el.children.select{|el| el.name === "Length"}[0].children.text - field_obj.decimals = field_el.children.select{|el| el.name === "Decimals"}[0].children.text - field_obj.default = field_el.children.select{|el| el.name === "Default"}[0].children.text - field_obj.allow_null = field_el.children.select{|el| el.name === "AllowNull"}[0].children.text - field_obj.validation_type = field_el.children.select{|el| el.name === "ValidationType"}[0].children.text - field_obj.value_null = field_el.children.select{|el| el.name === "ValueNull"}[0].children.text - end + por.customform_fields = doc.first_element_child.xpath('CustomForm').children.select { |item| item.name === 'Field' }.map do |field_el| + next unless field_el && field_el.children.count > 0 + Syspro::BusinessObjects::Models::PorDetail::CustomFormField.new.tap do |field_obj| + field_obj.sequence = field_el.children.select { |el| el.name === 'Sequence' }[0].children.text + field_obj.name = field_el.children.select { |el| el.name === 'Name' }[0].children.text + field_obj.prompt = field_el.children.select { |el| el.name === 'Prompt' }[0].children.text + field_obj.column = field_el.children.select { |el| el.name === 'Column' }[0].children.text + field_obj.type = field_el.children.select { |el| el.name === 'Type' }[0].children.text + field_obj.length = field_el.children.select { |el| el.name === 'Length' }[0].children.text + field_obj.decimals = field_el.children.select { |el| el.name === 'Decimals' }[0].children.text + field_obj.default = field_el.children.select { |el| el.name === 'Default' }[0].children.text + field_obj.allow_null = field_el.children.select { |el| el.name === 'AllowNull' }[0].children.text + field_obj.validation_type = field_el.children.select { |el| el.name === 'ValidationType' }[0].children.text + field_obj.value_null = field_el.children.select { |el| el.name === 'ValueNull' }[0].children.text end end.compact - por.purchase_order_line_merchandise = doc.first_element_child.xpath("PurchaseOrderLine").children.select{|item| item.name === "Merchandise"}.map do |merch_el| - if merch_el && merch_el.children.count > 0 - Syspro::BusinessObjects::Models::PorDetail::Merchandise.new.tap do |merch_obj| - merch_obj.line = merch_el.children.select{|el| el.name === "Line"}[0].children.text - merch_obj.line_type = merch_el.children.select{|el| el.name === "LineType"}[0].children.text - merch_obj.line_Type_description = merch_el.children.select{|el| el.name === "LineTypeDescription"}[0].children.text - merch_obj.m_stock_code = merch_el.children.select{|el| el.name === "MStockCode"}[0].children.text - merch_obj.m_stock_des = merch_el.children.select{|el| el.name === "MStockDes"}[0].children.text - merch_obj.long_desc = merch_el.children.select{|el| el.name === "LongDesc"}[0].children.text - merch_obj.traceable_type = merch_el.children.select{|el| el.name === "TraceableType"}[0].children.text - merch_obj.mass = merch_el.children.select{|el| el.name === "Mass"}[0].children.text - merch_obj.volume = merch_el.children.select{|el| el.name === "Volume"}[0].children.text - merch_obj.receipt_into_flag = merch_el.children.select{|el| el.name === "ReceiptIntoFlag"}[0].children.text - merch_obj.m_warehouse = merch_el.children.select{|el| el.name === "MWarehouse"}[0].children.text - merch_obj.m_warehouse_desc = merch_el.children.select{|el| el.name === "MWarehouseDesc"}[0].children.text - merch_obj.m_outstanding_qty = merch_el.children.select{|el| el.name === "MOutstandingQty"}[0].children.text - merch_obj.unedited__m_outstanding_qty = merch_el.children.select{|el| el.name === "Unedited_MOutstandingQty"}[0].children.text - merch_obj.m_order_qty = merch_el.children.select{|el| el.name === "MOrderQty"}[0].children.text - merch_obj.unedited__m_order_qty = merch_el.children.select{|el| el.name === "Unedited_MOrderQty"}[0].children.text - merch_obj.m_received_qty = merch_el.children.select{|el| el.name === "MReceivedQty"}[0].children.text - merch_obj.unedited__m_received_qty = merch_el.children.select{|el| el.name === "Unedited_MReceivedQty"}[0].children.text - merch_obj.m_order_uom = merch_el.children.select{|el| el.name === "MOrderUom"}[0].children.text - merch_obj.m_complete_flag = merch_el.children.select{|el| el.name === "MCompleteFlag"}[0].children.text - merch_obj.m_job = merch_el.children.select{|el| el.name === "MJob"}[0].children.text - merch_obj.include_in_mrp = merch_el.children.select{|el| el.name === "IncludeInMrp"}[0].children.text - merch_obj.m_price = merch_el.children.select{|el| el.name === "MPrice"}[0].children.text - merch_obj.edit_m_price = merch_el.children.select{|el| el.name === "Edit_MPrice"}[0].children.text - merch_obj.order_value = merch_el.children.select{|el| el.name === "OrderValue"}[0].children.text - merch_obj.m_disc_pct1 = merch_el.children.select{|el| el.name === "MDiscPct1"}[0].children.text - merch_obj.m_disc_pct2 = merch_el.children.select{|el| el.name === "MDiscPct2"}[0].children.text - merch_obj.m_disc_pct3 = merch_el.children.select{|el| el.name === "MDiscPct3"}[0].children.text - merch_obj.m_disc_value = merch_el.children.select{|el| el.name === "MDiscValue"}[0].children.text - merch_obj.m_disc_val_flag = merch_el.children.select{|el| el.name === "MDiscValFlag"}[0].children.text - merch_obj.m_price_uom = merch_el.children.select{|el| el.name === "MPriceUom"}[0].children.text - merch_obj.m_latest_due_date = merch_el.children.select{|el| el.name === "MLatestDueDate"}[0].children.text - merch_obj.m_sup_catalogue = merch_el.children.select{|el| el.name === "MSupCatalogue"}[0].children.text - merch_obj.m_product_class = merch_el.children.select{|el| el.name === "MProductClass"}[0].children.text - merch_obj.m_product_class_description = merch_el.children.select{|el| el.name === "MProductClassDescription"}[0].children.text - merch_obj.m_stocking_uom = merch_el.children.select{|el| el.name === "MStockingUom"}[0].children.text - merch_obj.m_decimals_to_prt = merch_el.children.select{|el| el.name === "MDecimalsToPrt"}[0].children.text - merch_obj.m_conv_fact_prc_um = merch_el.children.select{|el| el.name === "MConvFactPrcUm"}[0].children.text - merch_obj.m_mul_div_prc = merch_el.children.select{|el| el.name === "MMulDivPrc"}[0].children.text - merch_obj.m_tax_code = merch_el.children.select{|el| el.name === "MTaxCode"}[0].children.text - merch_obj.m_tax_code_description = merch_el.children.select{|el| el.name === "MTaxCodeDescription"}[0].children.text - merch_obj.m_conv_fact_ord_um = merch_el.children.select{|el| el.name === "MConvFactOrdUm"}[0].children.text - merch_obj.m_mul_div_alloc = merch_el.children.select{|el| el.name === "MMulDivAlloc"}[0].children.text - merch_obj.m_gl_code = merch_el.children.select{|el| el.name === "MGlCode"}[0].children.text - merch_obj.m_gl_code_description = merch_el.children.select{|el| el.name === "MGlCodeDescription"}[0].children.text - merch_obj.m_orig_due_date = merch_el.children.select{|el| el.name === "MOrigDueDate"}[0].children.text - merch_obj.m_lct_confirmed = merch_el.children.select{|el| el.name === "MLctConfirmed"}[0].children.text - merch_obj.m_subcontract_op = merch_el.children.select{|el| el.name === "MSubcontractOp"}[0].children.text - merch_obj.m_version = merch_el.children.select{|el| el.name === "MVersion"}[0].children.text - merch_obj.m_release = merch_el.children.select{|el| el.name === "MRelease"}[0].children.text - merch_obj.asset_flag = merch_el.children.select{|el| el.name === "AssetFlag"}[0].children.text - merch_obj.capex_code = merch_el.children.select{|el| el.name === "CapexCode"}[0].children.text - merch_obj.asset_capex_line = merch_el.children.select{|el| el.name === "AssetCapexLine"}[0].children.text - merch_obj.discount = merch_el.children.select{|el| el.name === "Discount"}[0].children.text - merch_obj.last_receipt = merch_el.children.select{|el| el.name === "LastReceipt"}[0].children.text - merch_obj.ledger = merch_el.children.select{|el| el.name === "Ledger"}[0].children.text - merch_obj.requisition_line = merch_el.children.select{|el| el.name === "RequisitionLine"}[0].children.text - merch_obj.requisition_no = merch_el.children.select{|el| el.name === "RequisitionNo"}[0].children.text - merch_obj.requisition_user = merch_el.children.select{|el| el.name === "RequisitionUser"}[0].children.text - merch_obj.reschedule = merch_el.children.select{|el| el.name === "Reschedule"}[0].children.text - merch_obj.rev = merch_el.children.select{|el| el.name === "Rev"}[0].children.text - merch_obj.release = merch_el.children.select{|el| el.name === "Release"}[0].children.text - merch_obj.selection_code = merch_el.children.select{|el| el.name === "SelectionCode"}[0].children.text - merch_obj.selection_type = merch_el.children.select{|el| el.name === "SelectionType"}[0].children.text - merch_obj.currency = merch_el.children.select{|el| el.name === "Currency"}[0].children.text - merch_obj.m_inspection_reqd = merch_el.children.select{|el| el.name === "MInspectionReqd"}[0].children.text - merch_obj.inspected_received = merch_el.children.select{|el| el.name === "InspectedReceived"}[0].children.text - merch_obj.stock_and_alt_um = merch_el.children.select{|el| el.name === "StockAndAltUm"}[0].children.text - merch_obj.default_costing_method = merch_el.children.select{|el| el.name === "DefaultCostingMethod"}[0].children.text - merch_obj.default_price = merch_el.children.select{|el| el.name === "DefaultPrice"}[0].children.text - merch_obj.edit_default_price = merch_el.children.select{|el| el.name === "Edit_DefaultPrice"}[0].children.text - merch_obj.default_prum = merch_el.children.select{|el| el.name === "DefaultPrum"}[0].children.text - merch_obj.costing_methods_available = merch_el.children.select{|el| el.name === "CostingMethodsAvailable"}.map do |field_el_2| - if field_el_2 && field_el_2.children.count > 0 - Syspro::BusinessObjects::Models::PorDetail::CostingMethodsAvailable.new.tap do |avail_obj| - avail_obj.manual_method_code = field_el_2.children.select{|el_2| el_2.name === "ManualMethodCode"}[0].children.text - avail_obj.manual_method_desc = field_el_2.children.select{|el_2| el_2.name === "ManualMethodDesc"}[0].children.text - avail_obj.manual_method_price = field_el_2.children.select{|el_2| el_2.name === "ManualMethodPrice"}[0].children.text - avail_obj.edit__manual_method_price = field_el_2.children.select{|el_2| el_2.name === "Edit_ManualMethodPrice"}[0].children.text - avail_obj.manual_method_costing_prum = field_el_2.children.select{|el_2| el_2.name === "ManualMethodCostingPrum"}[0].children.text - avail_obj.total_cost_method_code = field_el_2.children.select{|el_2| el_2.name === "TotalCostMethodCode"}[0].children.text - avail_obj.total_cost_method_desc = field_el_2.children.select{|el_2| el_2.name === "TotalCostMethodDesc"}[0].children.text - avail_obj.total_cost_method_price = field_el_2.children.select{|el_2| el_2.name === "TotalCostMethodPrice"}[0].children.text - avail_obj.edit__total_cost_method_price = field_el_2.children.select{|el_2| el_2.name === "Edit_TotalCostMethodPrice"}[0].children.text - avail_obj.total_cost_costing_prum = field_el_2.children.select{|el_2| el_2.name === "TotalCostCostingPrum"}[0].children.text - avail_obj.purchase_price_method_code = field_el_2.children.select{|el_2| el_2.name === "PurchasePriceMethodCode"}[0].children.text - avail_obj.purchase_price_method_desc = field_el_2.children.select{|el_2| el_2.name === "PurchasePriceMethodDesc"}[0].children.text - avail_obj.purchase_price_method_price = field_el_2.children.select{|el_2| el_2.name === "PurchasePriceMethodPrice"}[0].children.text - avail_obj.edit__purchase_price_method_price = field_el_2.children.select{|el_2| el_2.name === "Edit_PurchasePriceMethodPrice"}[0].children.text - avail_obj.purchase_price_costing_prum = field_el_2.children.select{|el_2| el_2.name === "PurchasePriceCostingPrum"}[0].children.text - avail_obj.price_tax_method_code = field_el_2.children.select{|el_2| el_2.name === "PriceTaxMethodCode"}[0].children.text - avail_obj.price_tax_method_desc = field_el_2.children.select{|el_2| el_2.name === "PriceTaxMethodDesc"}[0].children.text - avail_obj.price_tax_method_price = field_el_2.children.select{|el_2| el_2.name === "PriceTaxMethodPrice"}[0].children.text - avail_obj.edit__price_tax_method_price = field_el_2.children.select{|el_2| el_2.name === "Edit_PriceTaxMethodPrice"}[0].children.text - avail_obj.price_tax_costing_prum = field_el_2.children.select{|el_2| el_2.name === "PriceTaxCostingPrum"}[0].children.text - end - end - end.compact - end + por.purchase_order_line_merchandise = doc.first_element_child.xpath('PurchaseOrderLine').children.select { |item| item.name === 'Merchandise' }.map do |merch_el| + next unless merch_el && merch_el.children.count > 0 + Syspro::BusinessObjects::Models::PorDetail::Merchandise.new.tap do |merch_obj| + merch_obj.line = merch_el.children.select { |el| el.name === 'Line' }[0].children.text + merch_obj.line_type = merch_el.children.select { |el| el.name === 'LineType' }[0].children.text + merch_obj.line_Type_description = merch_el.children.select { |el| el.name === 'LineTypeDescription' }[0].children.text + merch_obj.m_stock_code = merch_el.children.select { |el| el.name === 'MStockCode' }[0].children.text + merch_obj.m_stock_des = merch_el.children.select { |el| el.name === 'MStockDes' }[0].children.text + merch_obj.long_desc = merch_el.children.select { |el| el.name === 'LongDesc' }[0].children.text + merch_obj.traceable_type = merch_el.children.select { |el| el.name === 'TraceableType' }[0].children.text + merch_obj.mass = merch_el.children.select { |el| el.name === 'Mass' }[0].children.text + merch_obj.volume = merch_el.children.select { |el| el.name === 'Volume' }[0].children.text + merch_obj.receipt_into_flag = merch_el.children.select { |el| el.name === 'ReceiptIntoFlag' }[0].children.text + merch_obj.m_warehouse = merch_el.children.select { |el| el.name === 'MWarehouse' }[0].children.text + merch_obj.m_warehouse_desc = merch_el.children.select { |el| el.name === 'MWarehouseDesc' }[0].children.text + merch_obj.m_outstanding_qty = merch_el.children.select { |el| el.name === 'MOutstandingQty' }[0].children.text + merch_obj.unedited__m_outstanding_qty = merch_el.children.select { |el| el.name === 'Unedited_MOutstandingQty' }[0].children.text + merch_obj.m_order_qty = merch_el.children.select { |el| el.name === 'MOrderQty' }[0].children.text + merch_obj.unedited__m_order_qty = merch_el.children.select { |el| el.name === 'Unedited_MOrderQty' }[0].children.text + merch_obj.m_received_qty = merch_el.children.select { |el| el.name === 'MReceivedQty' }[0].children.text + merch_obj.unedited__m_received_qty = merch_el.children.select { |el| el.name === 'Unedited_MReceivedQty' }[0].children.text + merch_obj.m_order_uom = merch_el.children.select { |el| el.name === 'MOrderUom' }[0].children.text + merch_obj.m_complete_flag = merch_el.children.select { |el| el.name === 'MCompleteFlag' }[0].children.text + merch_obj.m_job = merch_el.children.select { |el| el.name === 'MJob' }[0].children.text + merch_obj.include_in_mrp = merch_el.children.select { |el| el.name === 'IncludeInMrp' }[0].children.text + merch_obj.m_price = merch_el.children.select { |el| el.name === 'MPrice' }[0].children.text + merch_obj.edit_m_price = merch_el.children.select { |el| el.name === 'Edit_MPrice' }[0].children.text + merch_obj.order_value = merch_el.children.select { |el| el.name === 'OrderValue' }[0].children.text + merch_obj.m_disc_pct1 = merch_el.children.select { |el| el.name === 'MDiscPct1' }[0].children.text + merch_obj.m_disc_pct2 = merch_el.children.select { |el| el.name === 'MDiscPct2' }[0].children.text + merch_obj.m_disc_pct3 = merch_el.children.select { |el| el.name === 'MDiscPct3' }[0].children.text + merch_obj.m_disc_value = merch_el.children.select { |el| el.name === 'MDiscValue' }[0].children.text + merch_obj.m_disc_val_flag = merch_el.children.select { |el| el.name === 'MDiscValFlag' }[0].children.text + merch_obj.m_price_uom = merch_el.children.select { |el| el.name === 'MPriceUom' }[0].children.text + merch_obj.m_latest_due_date = merch_el.children.select { |el| el.name === 'MLatestDueDate' }[0].children.text + merch_obj.m_sup_catalogue = merch_el.children.select { |el| el.name === 'MSupCatalogue' }[0].children.text + merch_obj.m_product_class = merch_el.children.select { |el| el.name === 'MProductClass' }[0].children.text + merch_obj.m_product_class_description = merch_el.children.select { |el| el.name === 'MProductClassDescription' }[0].children.text + merch_obj.m_stocking_uom = merch_el.children.select { |el| el.name === 'MStockingUom' }[0].children.text + merch_obj.m_decimals_to_prt = merch_el.children.select { |el| el.name === 'MDecimalsToPrt' }[0].children.text + merch_obj.m_conv_fact_prc_um = merch_el.children.select { |el| el.name === 'MConvFactPrcUm' }[0].children.text + merch_obj.m_mul_div_prc = merch_el.children.select { |el| el.name === 'MMulDivPrc' }[0].children.text + merch_obj.m_tax_code = merch_el.children.select { |el| el.name === 'MTaxCode' }[0].children.text + merch_obj.m_tax_code_description = merch_el.children.select { |el| el.name === 'MTaxCodeDescription' }[0].children.text + merch_obj.m_conv_fact_ord_um = merch_el.children.select { |el| el.name === 'MConvFactOrdUm' }[0].children.text + merch_obj.m_mul_div_alloc = merch_el.children.select { |el| el.name === 'MMulDivAlloc' }[0].children.text + merch_obj.m_gl_code = merch_el.children.select { |el| el.name === 'MGlCode' }[0].children.text + merch_obj.m_gl_code_description = merch_el.children.select { |el| el.name === 'MGlCodeDescription' }[0].children.text + merch_obj.m_orig_due_date = merch_el.children.select { |el| el.name === 'MOrigDueDate' }[0].children.text + merch_obj.m_lct_confirmed = merch_el.children.select { |el| el.name === 'MLctConfirmed' }[0].children.text + merch_obj.m_subcontract_op = merch_el.children.select { |el| el.name === 'MSubcontractOp' }[0].children.text + merch_obj.m_version = merch_el.children.select { |el| el.name === 'MVersion' }[0].children.text + merch_obj.m_release = merch_el.children.select { |el| el.name === 'MRelease' }[0].children.text + merch_obj.asset_flag = merch_el.children.select { |el| el.name === 'AssetFlag' }[0].children.text + merch_obj.capex_code = merch_el.children.select { |el| el.name === 'CapexCode' }[0].children.text + merch_obj.asset_capex_line = merch_el.children.select { |el| el.name === 'AssetCapexLine' }[0].children.text + merch_obj.discount = merch_el.children.select { |el| el.name === 'Discount' }[0].children.text + merch_obj.last_receipt = merch_el.children.select { |el| el.name === 'LastReceipt' }[0].children.text + merch_obj.ledger = merch_el.children.select { |el| el.name === 'Ledger' }[0].children.text + merch_obj.requisition_line = merch_el.children.select { |el| el.name === 'RequisitionLine' }[0].children.text + merch_obj.requisition_no = merch_el.children.select { |el| el.name === 'RequisitionNo' }[0].children.text + merch_obj.requisition_user = merch_el.children.select { |el| el.name === 'RequisitionUser' }[0].children.text + merch_obj.reschedule = merch_el.children.select { |el| el.name === 'Reschedule' }[0].children.text + merch_obj.rev = merch_el.children.select { |el| el.name === 'Rev' }[0].children.text + merch_obj.release = merch_el.children.select { |el| el.name === 'Release' }[0].children.text + merch_obj.selection_code = merch_el.children.select { |el| el.name === 'SelectionCode' }[0].children.text + merch_obj.selection_type = merch_el.children.select { |el| el.name === 'SelectionType' }[0].children.text + merch_obj.currency = merch_el.children.select { |el| el.name === 'Currency' }[0].children.text + merch_obj.m_inspection_reqd = merch_el.children.select { |el| el.name === 'MInspectionReqd' }[0].children.text + merch_obj.inspected_received = merch_el.children.select { |el| el.name === 'InspectedReceived' }[0].children.text + merch_obj.stock_and_alt_um = merch_el.children.select { |el| el.name === 'StockAndAltUm' }[0].children.text + merch_obj.default_costing_method = merch_el.children.select { |el| el.name === 'DefaultCostingMethod' }[0].children.text + merch_obj.default_price = merch_el.children.select { |el| el.name === 'DefaultPrice' }[0].children.text + merch_obj.edit_default_price = merch_el.children.select { |el| el.name === 'Edit_DefaultPrice' }[0].children.text + merch_obj.default_prum = merch_el.children.select { |el| el.name === 'DefaultPrum' }[0].children.text + merch_obj.costing_methods_available = merch_el.children.select { |el| el.name === 'CostingMethodsAvailable' }.map do |field_el_2| + next unless field_el_2 && field_el_2.children.count > 0 + Syspro::BusinessObjects::Models::PorDetail::CostingMethodsAvailable.new.tap do |avail_obj| + avail_obj.manual_method_code = field_el_2.children.select { |el_2| el_2.name === 'ManualMethodCode' }[0].children.text + avail_obj.manual_method_desc = field_el_2.children.select { |el_2| el_2.name === 'ManualMethodDesc' }[0].children.text + avail_obj.manual_method_price = field_el_2.children.select { |el_2| el_2.name === 'ManualMethodPrice' }[0].children.text + avail_obj.edit__manual_method_price = field_el_2.children.select { |el_2| el_2.name === 'Edit_ManualMethodPrice' }[0].children.text + avail_obj.manual_method_costing_prum = field_el_2.children.select { |el_2| el_2.name === 'ManualMethodCostingPrum' }[0].children.text + avail_obj.total_cost_method_code = field_el_2.children.select { |el_2| el_2.name === 'TotalCostMethodCode' }[0].children.text + avail_obj.total_cost_method_desc = field_el_2.children.select { |el_2| el_2.name === 'TotalCostMethodDesc' }[0].children.text + avail_obj.total_cost_method_price = field_el_2.children.select { |el_2| el_2.name === 'TotalCostMethodPrice' }[0].children.text + avail_obj.edit__total_cost_method_price = field_el_2.children.select { |el_2| el_2.name === 'Edit_TotalCostMethodPrice' }[0].children.text + avail_obj.total_cost_costing_prum = field_el_2.children.select { |el_2| el_2.name === 'TotalCostCostingPrum' }[0].children.text + avail_obj.purchase_price_method_code = field_el_2.children.select { |el_2| el_2.name === 'PurchasePriceMethodCode' }[0].children.text + avail_obj.purchase_price_method_desc = field_el_2.children.select { |el_2| el_2.name === 'PurchasePriceMethodDesc' }[0].children.text + avail_obj.purchase_price_method_price = field_el_2.children.select { |el_2| el_2.name === 'PurchasePriceMethodPrice' }[0].children.text + avail_obj.edit__purchase_price_method_price = field_el_2.children.select { |el_2| el_2.name === 'Edit_PurchasePriceMethodPrice' }[0].children.text + avail_obj.purchase_price_costing_prum = field_el_2.children.select { |el_2| el_2.name === 'PurchasePriceCostingPrum' }[0].children.text + avail_obj.price_tax_method_code = field_el_2.children.select { |el_2| el_2.name === 'PriceTaxMethodCode' }[0].children.text + avail_obj.price_tax_method_desc = field_el_2.children.select { |el_2| el_2.name === 'PriceTaxMethodDesc' }[0].children.text + avail_obj.price_tax_method_price = field_el_2.children.select { |el_2| el_2.name === 'PriceTaxMethodPrice' }[0].children.text + avail_obj.edit__price_tax_method_price = field_el_2.children.select { |el_2| el_2.name === 'Edit_PriceTaxMethodPrice' }[0].children.text + avail_obj.price_tax_costing_prum = field_el_2.children.select { |el_2| el_2.name === 'PriceTaxCostingPrum' }[0].children.text + end + end.compact end end.compact - por.purchase_order_totals = doc.first_element_child.xpath("PurchaseOrderTotals").map do |total_el| + por.purchase_order_totals = doc.first_element_child.xpath('PurchaseOrderTotals').map do |total_el| Syspro::BusinessObjects::Models::PorDetail::PurchaseOrderTotals.new.tap do |total_obj| - - total_obj.local_values = total_el.children.select{|el| el.name === "LocalValues"}.map do |loc_val_el| + total_obj.local_values = total_el.children.select { |el| el.name === 'LocalValues' }.map do |loc_val_el| Syspro::BusinessObjects::Models::PorDetail::PurchaseOrderTotalsLocalValues.new.tap do |loc_obj| - loc_obj.local_order_value = loc_val_el.children.select{|el_2| el_2.name === "LocalOrderValue"}[0].text - loc_obj.local_received_to_date_value = loc_val_el.children.select{|el_2| el_2.name === "LocalReceivedToDateValue"}[0].text - loc_obj.local_outstanding_value = loc_val_el.children.select{|el_2| el_2.name === "LocalOutstandingValue"}[0].text - loc_obj.edited_local_order_value = loc_val_el.children.select{|el_2| el_2.name === "Edited_LocalOrderValue"}[0].text - loc_obj.edited_local_received_to_date_value = loc_val_el.children.select{|el_2| el_2.name === "Edited_LocalReceivedToDateValue"}[0].text - loc_obj.edited_local_outstanding_value = loc_val_el.children.select{|el_2| el_2.name === "Edited_LocalOutstandingValue"}[0].text + loc_obj.local_order_value = loc_val_el.children.select { |el_2| el_2.name === 'LocalOrderValue' }[0].text + loc_obj.local_received_to_date_value = loc_val_el.children.select { |el_2| el_2.name === 'LocalReceivedToDateValue' }[0].text + loc_obj.local_outstanding_value = loc_val_el.children.select { |el_2| el_2.name === 'LocalOutstandingValue' }[0].text + loc_obj.edited_local_order_value = loc_val_el.children.select { |el_2| el_2.name === 'Edited_LocalOrderValue' }[0].text + loc_obj.edited_local_received_to_date_value = loc_val_el.children.select { |el_2| el_2.name === 'Edited_LocalReceivedToDateValue' }[0].text + loc_obj.edited_local_outstanding_value = loc_val_el.children.select { |el_2| el_2.name === 'Edited_LocalOutstandingValue' }[0].text end end - total_obj.current_values = total_el.children.select{|el| el.name === "CurrentValues"}.map do |cur_val_el| + total_obj.current_values = total_el.children.select { |el| el.name === 'CurrentValues' }.map do |cur_val_el| Syspro::BusinessObjects::Models::PorDetail::PurchaseOrderTotalsCurrentValues.new.tap do |cur_obj| - cur_obj.current_order_value = cur_val_el.children.select{|el_2| el_2.name === "CurrentOrderValue"}[0].text - cur_obj.current_received_to_date_value = cur_val_el.children.select{|el_2| el_2.name === "CurrentReceivedToDateValue"}[0].text - cur_obj.current_outstanding_value = cur_val_el.children.select{|el_2| el_2.name === "CurrentOutstandingValue"}[0].text - cur_obj.edited_current_order_value = cur_val_el.children.select{|el_2| el_2.name === "Edited_CurrentOrderValue"}[0].text - cur_obj.edited_current_received_to_date_value = cur_val_el.children.select{|el_2| el_2.name === "Edited_CurrentReceivedToDateValue"}[0].text - cur_obj.edited_current_outstanding_value = cur_val_el.children.select{|el_2| el_2.name === "Edited_CurrentOutstandingValue"}[0].text + cur_obj.current_order_value = cur_val_el.children.select { |el_2| el_2.name === 'CurrentOrderValue' }[0].text + cur_obj.current_received_to_date_value = cur_val_el.children.select { |el_2| el_2.name === 'CurrentReceivedToDateValue' }[0].text + cur_obj.current_outstanding_value = cur_val_el.children.select { |el_2| el_2.name === 'CurrentOutstandingValue' }[0].text + cur_obj.edited_current_order_value = cur_val_el.children.select { |el_2| el_2.name === 'Edited_CurrentOrderValue' }[0].text + cur_obj.edited_current_received_to_date_value = cur_val_el.children.select { |el_2| el_2.name === 'Edited_CurrentReceivedToDateValue' }[0].text + cur_obj.edited_current_outstanding_value = cur_val_el.children.select { |el_2| el_2.name === 'Edited_CurrentOutstandingValue' }[0].text end end - total_obj.first_receipt_date = total_el.children.select{|el| el.name === "FirstReceiptDate"}[0].text - total_obj.order_complete_date = total_el.children.select{|el| el.name === "OrderCompleteDate"}[0].text + total_obj.first_receipt_date = total_el.children.select { |el| el.name === 'FirstReceiptDate' }[0].text + total_obj.order_complete_date = total_el.children.select { |el| el.name === 'OrderCompleteDate' }[0].text end end.compact diff --git a/lib/syspro/business_objects/parsers/portii_parser.rb b/lib/syspro/business_objects/parsers/portii_parser.rb index 7b65a7f..c98f7c7 100644 --- a/lib/syspro/business_objects/parsers/portii_parser.rb +++ b/lib/syspro/business_objects/parsers/portii_parser.rb @@ -12,10 +12,10 @@ module Syspro def parse { - error_numbers: doc.xpath("//ErrorNumber").map{|e| e.text}, - grn_numbers: doc.xpath("//Item/Key/GRNNumber").map{|e| e.text}, - items_processed: doc.xpath("//StatusOfItems/ItemsProcessed").first.text, - items_invalid: doc.xpath("//StatusOfItems/ItemsInvalid").first.text + error_numbers: doc.xpath('//ErrorNumber').map(&:text), + grn_numbers: doc.xpath('//Item/Key/GRNNumber').map(&:text), + items_processed: doc.xpath('//StatusOfItems/ItemsProcessed').first.text, + items_invalid: doc.xpath('//StatusOfItems/ItemsInvalid').first.text } end @@ -24,4 +24,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/parsers/portoi_parser.rb b/lib/syspro/business_objects/parsers/portoi_parser.rb index 44421ff..740be50 100644 --- a/lib/syspro/business_objects/parsers/portoi_parser.rb +++ b/lib/syspro/business_objects/parsers/portoi_parser.rb @@ -11,15 +11,15 @@ module Syspro end def parse - po = Syspro::BusinessObjects::Models::PurchaseOrder.new() - - po.error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} + po = Syspro::BusinessObjects::Models::PurchaseOrder.new + + po.error_numbers = doc.xpath('//ErrorNumber').map(&:text) po.purchase_order = doc.first_element_child.xpath('Order/Key/PurchaseOrder').text po.item_number = doc.first_element_child.xpath('Order/ItemNumber').text po.order_action_type = doc.first_element_child.xpath('Order/OrderActionType').text po.supplier = doc.first_element_child.xpath('Order/Supplier').text - + po end @@ -28,4 +28,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/parsers/portor_parser.rb b/lib/syspro/business_objects/parsers/portor_parser.rb index 738daf6..f276c4c 100644 --- a/lib/syspro/business_objects/parsers/portor_parser.rb +++ b/lib/syspro/business_objects/parsers/portor_parser.rb @@ -11,7 +11,7 @@ module Syspro end def parse - error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} + error_numbers = doc.xpath('//ErrorNumber').map(&:text) gl_journal = doc.first_element_child.xpath('GlJournal') gl_journal_obj = gl_journal.children.map do |el| @@ -34,7 +34,7 @@ module Syspro receipts_obj = receipts.flat_map do |el| el.elements.map do |inner| [inner.name, - inner.value] + inner.value] end end.compact.to_h @@ -47,7 +47,7 @@ module Syspro ) end - grns = doc.xpath("//Grn").map{|e| e.text} + grns = doc.xpath('//Grn').map(&:text) { error_numbers: error_numbers, @@ -60,4 +60,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/parsers/sorqry_parser.rb b/lib/syspro/business_objects/parsers/sorqry_parser.rb index cd5bcf6..2e9b4cd 100644 --- a/lib/syspro/business_objects/parsers/sorqry_parser.rb +++ b/lib/syspro/business_objects/parsers/sorqry_parser.rb @@ -12,115 +12,115 @@ module Syspro end def parse - sor = Syspro::BusinessObjects::Models::SorDetail.new() - sor.sales_order = doc.first_element_child.xpath("SalesOrder").text - sor.document_type = doc.first_element_child.xpath("DocumentType").text - sor.document_type_desc = doc.first_element_child.xpath("DocumentTypeDesc").text - sor.inter_branch_transfer = doc.first_element_child.xpath("InterBranchTransfer").text - sor.inter_wh_sale = doc.first_element_child.xpath("InterWhSale").text - sor.source_warehouse = doc.first_element_child.xpath("SourceWarehouse").text - sor.target_warehouse = doc.first_element_child.xpath("TargetWarehouse").text - sor.gtr_reference = doc.first_element_child.xpath("GtrReference").text - sor.customer = doc.first_element_child.xpath("Customer").text - sor.customer_name = doc.first_element_child.xpath("CustomerName").text - sor.tax_status_code = doc.first_element_child.xpath("TaxStatusCode").text - sor.tax_status = doc.first_element_child.xpath("TaxStatus").text - sor.gst_tax_status_code = doc.first_element_child.xpath("GstTaxStatusCode").text - sor.gst_tax_status = doc.first_element_child.xpath("GstTaxStatus").text - sor.eu_flag = doc.first_element_child.xpath("EuFlag").text - sor.eu_flag_desc = doc.first_element_child.xpath("EuFlagDesc").text - sor.sold_to_name = doc.first_element_child.xpath("SoldToName").text - sor.sold_addr_1 = doc.first_element_child.xpath("SoldAddr1").text - sor.sold_addr_2 = doc.first_element_child.xpath("SoldAddr2").text - sor.sold_addr_3 = doc.first_element_child.xpath("SoldAddr3").text - sor.sold_addr_3_locality = doc.first_element_child.xpath("SoldAddr3Locality").text - sor.sold_addr_4 = doc.first_element_child.xpath("SoldAddr4").text - sor.sold_addr_5 = doc.first_element_child.xpath("SoldAddr5").text - sor.sold_postal_code = doc.first_element_child.xpath("SoldPostalCode").text - sor.sold_gps_lat = doc.first_element_child.xpath("SoldGpsLat").text - sor.sold_gps_long = doc.first_element_child.xpath("SoldGpsLong").text - sor.salesperson = doc.first_element_child.xpath("Salesperson").text - sor.scheduled_ord_flag = doc.first_element_child.xpath("ScheduledOrdFlag").text - sor.disc_pct_1 = doc.first_element_child.xpath("DiscPct1").text - sor.disc_pct_2 = doc.first_element_child.xpath("DiscPct2").text - sor.disc_pct_3 = doc.first_element_child.xpath("DiscPct3").text + sor = Syspro::BusinessObjects::Models::SorDetail.new + sor.sales_order = doc.first_element_child.xpath('SalesOrder').text + sor.document_type = doc.first_element_child.xpath('DocumentType').text + sor.document_type_desc = doc.first_element_child.xpath('DocumentTypeDesc').text + sor.inter_branch_transfer = doc.first_element_child.xpath('InterBranchTransfer').text + sor.inter_wh_sale = doc.first_element_child.xpath('InterWhSale').text + sor.source_warehouse = doc.first_element_child.xpath('SourceWarehouse').text + sor.target_warehouse = doc.first_element_child.xpath('TargetWarehouse').text + sor.gtr_reference = doc.first_element_child.xpath('GtrReference').text + sor.customer = doc.first_element_child.xpath('Customer').text + sor.customer_name = doc.first_element_child.xpath('CustomerName').text + sor.tax_status_code = doc.first_element_child.xpath('TaxStatusCode').text + sor.tax_status = doc.first_element_child.xpath('TaxStatus').text + sor.gst_tax_status_code = doc.first_element_child.xpath('GstTaxStatusCode').text + sor.gst_tax_status = doc.first_element_child.xpath('GstTaxStatus').text + sor.eu_flag = doc.first_element_child.xpath('EuFlag').text + sor.eu_flag_desc = doc.first_element_child.xpath('EuFlagDesc').text + sor.sold_to_name = doc.first_element_child.xpath('SoldToName').text + sor.sold_addr_1 = doc.first_element_child.xpath('SoldAddr1').text + sor.sold_addr_2 = doc.first_element_child.xpath('SoldAddr2').text + sor.sold_addr_3 = doc.first_element_child.xpath('SoldAddr3').text + sor.sold_addr_3_locality = doc.first_element_child.xpath('SoldAddr3Locality').text + sor.sold_addr_4 = doc.first_element_child.xpath('SoldAddr4').text + sor.sold_addr_5 = doc.first_element_child.xpath('SoldAddr5').text + sor.sold_postal_code = doc.first_element_child.xpath('SoldPostalCode').text + sor.sold_gps_lat = doc.first_element_child.xpath('SoldGpsLat').text + sor.sold_gps_long = doc.first_element_child.xpath('SoldGpsLong').text + sor.salesperson = doc.first_element_child.xpath('Salesperson').text + sor.scheduled_ord_flag = doc.first_element_child.xpath('ScheduledOrdFlag').text + sor.disc_pct_1 = doc.first_element_child.xpath('DiscPct1').text + sor.disc_pct_2 = doc.first_element_child.xpath('DiscPct2').text + sor.disc_pct_3 = doc.first_element_child.xpath('DiscPct3').text sor.salsls_name = doc.first_element_child.at_xpath('//SALSLS:Name').children.text - sor.order_status = doc.first_element_child.xpath("OrderStatus").text - sor.order_status_desc = doc.first_element_child.xpath("OrderStatusDesc").text - sor.customer_po_number = doc.first_element_child.xpath("CustomerPoNumber").text - sor.order_date = doc.first_element_child.xpath("OrderDate").text - sor.git_reference = doc.first_element_child.xpath("GITReference").text - sor.req_ship_date = doc.first_element_child.xpath("ReqShipDate").text - sor.shipping_instrs = doc.first_element_child.xpath("ShippingInstrs").text - sor.shipping_instrs_cod = doc.first_element_child.xpath("ShippingInstrsCod").text - sor.special_instrs = doc.first_element_child.xpath("SpecialInstrs").text - sor.inv_terms_override = doc.first_element_child.xpath("InvTermsOverride").text - sor.delivery_note = doc.first_element_child.xpath("DeliveryNote").text - sor.last_del_note = doc.first_element_child.xpath("LastDelNote").text - sor.time_del_prted_hh = doc.first_element_child.xpath("TimeDelPrtedHh").text - sor.time_del_prted_mm = doc.first_element_child.xpath("TimeDelPrtedMm").text - sor.last_invoice = doc.first_element_child.xpath("LastInvoice").text - sor.date_last_inv_prt = doc.first_element_child.xpath("DateLastInvPrt").text - sor.time_inv_prt_hh = doc.first_element_child.xpath("TimeInvPrtHh").text - sor.time_inv_prt_mm = doc.first_element_child.xpath("TimeInvPrtMm").text - sor.tblart_description = doc.first_element_child.xpath("//TBLART:Description").children.text - sor.branch = doc.first_element_child.xpath("Branch").text - sor.salbrn_description = doc.first_element_child.xpath("//SALBRN:Description").children.text - sor.ent_invoice = doc.first_element_child.xpath("EntInvoice").text - sor.order_type = doc.first_element_child.xpath("OrderType").text - sor.area = doc.first_element_child.xpath("Area").text - sor.salare_description = doc.first_element_child.xpath("//SALARE:Description").children.text - sor.tax_exempt_number = doc.first_element_child.xpath("TaxExemptNumber").text - sor.gst_exempt_number = doc.first_element_child.xpath("GstExemptNumber").text - sor.currency = doc.first_element_child.xpath("Currency").text - sor.tblcur_description = doc.first_element_child.xpath("//TBLCUR:Description").children.text - sor.ship_address_1 = doc.first_element_child.xpath("ShipAddress1").text - sor.ship_address_2 = doc.first_element_child.xpath("ShipAddress2").text - sor.ship_address_3 = doc.first_element_child.xpath("ShipAddress3").text - sor.ship_address_3_locality = doc.first_element_child.xpath("ShipAddress3Locality").text - sor.ship_address_4 = doc.first_element_child.xpath("ShipAddress4").text - sor.ship_address_5 = doc.first_element_child.xpath("ShipAddress5").text - sor.ship_postal_code = doc.first_element_child.xpath("ShipPostalCode").text - sor.ship_gps_lat = doc.first_element_child.xpath("ShipGpsLat").text - sor.ship_gps_long = doc.first_element_child.xpath("ShipGpsLong").text - sor.ship_complete = doc.first_element_child.xpath("ShipComplete").text - sor.email = doc.first_element_child.xpath("Email").text - sor.fix_exchange_rate = doc.first_element_child.xpath("FixExchangeRate").text - sor.exchange_rate = doc.first_element_child.xpath("ExchangeRate").text - sor.edited_exchange_rate = doc.first_element_child.xpath("EditedExchangeRate").text - sor.mul_div = doc.first_element_child.xpath("MulDiv").text - sor.consolidated_order = doc.first_element_child.xpath("ConsolidatedOrder").text - sor.gst_deduction = doc.first_element_child.xpath("GstDeduction").text - sor.credited_inv_date = doc.first_element_child.xpath("CreditedInvDate").text - sor.job = doc.first_element_child.xpath("Job").text - sor.serialized_flag = doc.first_element_child.xpath("SerializedFlag").text - sor.counter_sales_flag = doc.first_element_child.xpath("CounterSalesFlag").text - sor.nationality = doc.first_element_child.xpath("Nationality").text - sor.delivery_terms = doc.first_element_child.xpath("DeliveryTerms").text - sor.shipping_location = doc.first_element_child.xpath("ShippingLocation").text - sor.transaction_nature = doc.first_element_child.xpath("TransactionNature").text - sor.transport_mode = doc.first_element_child.xpath("TransportMode").text - sor.process_flag = doc.first_element_child.xpath("ProcessFlag").text - sor.jobs_exist_flag = doc.first_element_child.xpath("JobsExistFlag").text - sor.alternate_key = doc.first_element_child.xpath("AlternateKey").text - sor.hierarchy_flag = doc.first_element_child.xpath("HierarchyFlag").text - sor.deposit_flag = doc.first_element_child.xpath("DepositFlag").text - sor.edi_source = doc.first_element_child.xpath("EdiSource").text - sor.mult_ship_code = doc.first_element_child.xpath("MultShipCode").text - sor.company_tax_no = doc.first_element_child.xpath("CompanyTaxNo").text - sor.last_operator = doc.first_element_child.xpath("LastOperator").text - sor.operator = doc.first_element_child.xpath("Operator").text - sor.state = doc.first_element_child.xpath("State").text - sor.county_zip = doc.first_element_child.xpath("CountyZip").text - sor.extended_tax_code = doc.first_element_child.xpath("ExtendedTaxCode").text - sor.web_created = doc.first_element_child.xpath("WebCreated").text - sor.quote = doc.first_element_child.xpath("Quote").text - sor.dispatches_made = doc.first_element_child.xpath("DispatchesMade").text - sor.live_disp_exist = doc.first_element_child.xpath("LiveDispExist").text - sor.num_dispatches = doc.first_element_child.xpath("NumDispatches").text - sor.include_in_mrp = doc.first_element_child.xpath("IncludeInMrp").text - sor.header_text = doc.first_element_child.xpath("HeaderText").text - sor.header_notes = doc.first_element_child.xpath("HeaderNotes").text + sor.order_status = doc.first_element_child.xpath('OrderStatus').text + sor.order_status_desc = doc.first_element_child.xpath('OrderStatusDesc').text + sor.customer_po_number = doc.first_element_child.xpath('CustomerPoNumber').text + sor.order_date = doc.first_element_child.xpath('OrderDate').text + sor.git_reference = doc.first_element_child.xpath('GITReference').text + sor.req_ship_date = doc.first_element_child.xpath('ReqShipDate').text + sor.shipping_instrs = doc.first_element_child.xpath('ShippingInstrs').text + sor.shipping_instrs_cod = doc.first_element_child.xpath('ShippingInstrsCod').text + sor.special_instrs = doc.first_element_child.xpath('SpecialInstrs').text + sor.inv_terms_override = doc.first_element_child.xpath('InvTermsOverride').text + sor.delivery_note = doc.first_element_child.xpath('DeliveryNote').text + sor.last_del_note = doc.first_element_child.xpath('LastDelNote').text + sor.time_del_prted_hh = doc.first_element_child.xpath('TimeDelPrtedHh').text + sor.time_del_prted_mm = doc.first_element_child.xpath('TimeDelPrtedMm').text + sor.last_invoice = doc.first_element_child.xpath('LastInvoice').text + sor.date_last_inv_prt = doc.first_element_child.xpath('DateLastInvPrt').text + sor.time_inv_prt_hh = doc.first_element_child.xpath('TimeInvPrtHh').text + sor.time_inv_prt_mm = doc.first_element_child.xpath('TimeInvPrtMm').text + sor.tblart_description = doc.first_element_child.xpath('//TBLART:Description').children.text + sor.branch = doc.first_element_child.xpath('Branch').text + sor.salbrn_description = doc.first_element_child.xpath('//SALBRN:Description').children.text + sor.ent_invoice = doc.first_element_child.xpath('EntInvoice').text + sor.order_type = doc.first_element_child.xpath('OrderType').text + sor.area = doc.first_element_child.xpath('Area').text + sor.salare_description = doc.first_element_child.xpath('//SALARE:Description').children.text + sor.tax_exempt_number = doc.first_element_child.xpath('TaxExemptNumber').text + sor.gst_exempt_number = doc.first_element_child.xpath('GstExemptNumber').text + sor.currency = doc.first_element_child.xpath('Currency').text + sor.tblcur_description = doc.first_element_child.xpath('//TBLCUR:Description').children.text + sor.ship_address_1 = doc.first_element_child.xpath('ShipAddress1').text + sor.ship_address_2 = doc.first_element_child.xpath('ShipAddress2').text + sor.ship_address_3 = doc.first_element_child.xpath('ShipAddress3').text + sor.ship_address_3_locality = doc.first_element_child.xpath('ShipAddress3Locality').text + sor.ship_address_4 = doc.first_element_child.xpath('ShipAddress4').text + sor.ship_address_5 = doc.first_element_child.xpath('ShipAddress5').text + sor.ship_postal_code = doc.first_element_child.xpath('ShipPostalCode').text + sor.ship_gps_lat = doc.first_element_child.xpath('ShipGpsLat').text + sor.ship_gps_long = doc.first_element_child.xpath('ShipGpsLong').text + sor.ship_complete = doc.first_element_child.xpath('ShipComplete').text + sor.email = doc.first_element_child.xpath('Email').text + sor.fix_exchange_rate = doc.first_element_child.xpath('FixExchangeRate').text + sor.exchange_rate = doc.first_element_child.xpath('ExchangeRate').text + sor.edited_exchange_rate = doc.first_element_child.xpath('EditedExchangeRate').text + sor.mul_div = doc.first_element_child.xpath('MulDiv').text + sor.consolidated_order = doc.first_element_child.xpath('ConsolidatedOrder').text + sor.gst_deduction = doc.first_element_child.xpath('GstDeduction').text + sor.credited_inv_date = doc.first_element_child.xpath('CreditedInvDate').text + sor.job = doc.first_element_child.xpath('Job').text + sor.serialized_flag = doc.first_element_child.xpath('SerializedFlag').text + sor.counter_sales_flag = doc.first_element_child.xpath('CounterSalesFlag').text + sor.nationality = doc.first_element_child.xpath('Nationality').text + sor.delivery_terms = doc.first_element_child.xpath('DeliveryTerms').text + sor.shipping_location = doc.first_element_child.xpath('ShippingLocation').text + sor.transaction_nature = doc.first_element_child.xpath('TransactionNature').text + sor.transport_mode = doc.first_element_child.xpath('TransportMode').text + sor.process_flag = doc.first_element_child.xpath('ProcessFlag').text + sor.jobs_exist_flag = doc.first_element_child.xpath('JobsExistFlag').text + sor.alternate_key = doc.first_element_child.xpath('AlternateKey').text + sor.hierarchy_flag = doc.first_element_child.xpath('HierarchyFlag').text + sor.deposit_flag = doc.first_element_child.xpath('DepositFlag').text + sor.edi_source = doc.first_element_child.xpath('EdiSource').text + sor.mult_ship_code = doc.first_element_child.xpath('MultShipCode').text + sor.company_tax_no = doc.first_element_child.xpath('CompanyTaxNo').text + sor.last_operator = doc.first_element_child.xpath('LastOperator').text + sor.operator = doc.first_element_child.xpath('Operator').text + sor.state = doc.first_element_child.xpath('State').text + sor.county_zip = doc.first_element_child.xpath('CountyZip').text + sor.extended_tax_code = doc.first_element_child.xpath('ExtendedTaxCode').text + sor.web_created = doc.first_element_child.xpath('WebCreated').text + sor.quote = doc.first_element_child.xpath('Quote').text + sor.dispatches_made = doc.first_element_child.xpath('DispatchesMade').text + sor.live_disp_exist = doc.first_element_child.xpath('LiveDispExist').text + sor.num_dispatches = doc.first_element_child.xpath('NumDispatches').text + sor.include_in_mrp = doc.first_element_child.xpath('IncludeInMrp').text + sor.header_text = doc.first_element_child.xpath('HeaderText').text + sor.header_notes = doc.first_element_child.xpath('HeaderNotes').text # Inner Nested Structure Parsing sor.commissions = parse_commissions(doc) @@ -131,27 +131,25 @@ module Syspro end def parse_commissions(doc) - commissions = doc.first_element_child.xpath("Commissions") + commissions = doc.first_element_child.xpath('Commissions') commissions_obj = parse_children_elements(commissions) commissions_obj end - def parse_sales_order_lines(doc) - sales_order_lines = doc.first_element_child.xpath("SalesOrderLine") + 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" + next if el.name == 'text' serial_obj = {} bin_obj = {} attached_items_obj = {} lot_obj = {} - if el.name == "MiscCharge" + if el.name == 'MiscCharge' unless sales_order_lines_obj[:misc_charge] sales_order_lines_obj[:misc_charge] = [] end @@ -160,7 +158,7 @@ module Syspro sales_order_lines_obj[:misc_charge].push(misc_charge_arr) end - if el.name == "Freight" + if el.name == 'Freight' unless sales_order_lines_obj[:freight] sales_order_lines_obj[:freight] = [] end @@ -169,7 +167,7 @@ module Syspro sales_order_lines_obj[:freight].push(freight_arr) end - if el.name == "CommentLine" + if el.name == 'CommentLine' unless sales_order_lines_obj[:comment_line] sales_order_lines_obj[:comment_line] = [] end @@ -178,118 +176,109 @@ module Syspro sales_order_lines_obj[:comment_line].push(comment_line_arr) end - if el.name == "Merchandise" - unless sales_order_lines_obj[:merchandise] - sales_order_lines_obj[:merchandise] = [] + next unless el.name == 'Merchandise' + unless sales_order_lines_obj[:merchandise] + sales_order_lines_obj[:merchandise] = [] + end + + merchandise_arr = el.children.map do |el_child| + next if el_child.name == 'text' + + if el_child.name == 'MOrderQty' + @calculated_weight += el_child.text.split(' ')[0].split(',').join.to_f + + { + name: el_child.name, + text: el_child.text + } end - merchandise_arr = el.children.map do |el_child| - next if el_child.name == "text" + # NOTE: These first three in the following + # conditionals are "Merchandise" elements with + # thier own nested structure that need parsed + if el_child.name == 'Serial' + serial_obj[:serial] = [] unless serial_obj[:serial] - if el_child.name == "MOrderQty" - @calculated_weight = @calculated_weight + el_child.text.split(' ')[0].split(',').join().to_f + serial_arr = parse_children_elements(el_child) + serial_obj[:serial].push(serial_arr) + serial_obj - { - name: el_child.name, - text: el_child.text - } - end + elsif el_child.name == 'Bin' + bin_obj[:bin] = [] unless bin_obj[:bin] - # NOTE: These first three in the following - # conditionals are "Merchandise" elements with - # thier own nested structure that need parsed - if el_child.name == "Serial" - unless serial_obj[:serial] - serial_obj[:serial] = [] - end + bin_arr = parse_children_elements(el_child) + bin_obj[:bin].push(bin_arr) + bin_obj - serial_arr = parse_children_elements(el_child) - serial_obj[:serial].push(serial_arr) - serial_obj + elsif el_child.name == 'Lot' + lot_obj[:lot] = [] unless lot_obj[:lot] - elsif el_child.name == "Bin" - unless bin_obj[:bin] - bin_obj[:bin] = [] - end + lot_arr = parse_children_elements(el_child) + lot_obj[:lot].push(lot_arr) + lot_obj - bin_arr = parse_children_elements(el_child) - bin_obj[:bin].push(bin_arr) - bin_obj + elsif el_child.name == 'AttachedItems' + # NOTE: Like "Merchandise", "AttachedItems" is + # an element within "Merchandise" that contains + # elements with thier own nested structure that + # need parsed - elsif el_child.name == "Lot" - unless lot_obj[:lot] - lot_obj[:lot] = [] - end + sct_item_obj = {} + requisition_item_obj = {} + purchase_order_obj = {} + + unless attached_items_obj[:attached_items] + attached_items_obj[:attached_items] = [] + end - lot_arr = parse_children_elements(el_child) - lot_obj[:lot].push(lot_arr) - lot_obj + attached_items_arr = el_child.children.map do |attached_items_child| + next if attached_items_child.name == 'text' - elsif el_child.name == "AttachedItems" - # NOTE: Like "Merchandise", "AttachedItems" is - # an element within "Merchandise" that contains - # elements with thier own nested structure that - # need parsed + if attached_items_child.name == 'SctItem' + sct_item_obj[:sct_item] = [] unless sct_item_obj[:sct_item] - sct_item_obj = {} - requisition_item_obj = {} - purchase_order_obj = {} + sct_item_arr = parse_children_elements(attached_items_child) + sct_item_obj[:sct_item].push(sct_item_arr) + sct_item_obj - unless attached_items_obj[:attached_items] - attached_items_obj[:attached_items] = [] - end + elsif attached_items_child.name == 'RequisitionItem' + unless requisition_item_obj[:requisition_item] + requisition_item_obj[:requisition_item] = [] + end - attached_items_arr = el_child.children.map do |attached_items_child| - next if attached_items_child.name == "text" - - if attached_items_child.name == "SctItem" - unless sct_item_obj[:sct_item] - sct_item_obj[:sct_item] = [] - end - - sct_item_arr = parse_children_elements(attached_items_child) - sct_item_obj[:sct_item].push(sct_item_arr) - sct_item_obj - - elsif attached_items_child.name == "RequisitionItem" - unless requisition_item_obj[:requisition_item] - requisition_item_obj[:requisition_item] = [] - end - - requisition_item_arr = parse_children_elements(attached_items_child) - requisition_item_obj[:requisition_item].push(requisition_item_arr) - requisition_item_obj - - elsif attached_items_child.name == "PurchaseOrder" - unless purchase_order_obj[:purchase_order] - purchase_order_obj[:purchase_order] = [] - end - - purchase_order_arr = parse_children_elements(attached_items_child) - purchase_order_obj[:purchase_order].push(purchase_order_arr) - purchase_order_obj - - else - { - name: attached_items_child.name, - text: attached_items_child.text - } + requisition_item_arr = parse_children_elements(attached_items_child) + requisition_item_obj[:requisition_item].push(requisition_item_arr) + requisition_item_obj + + elsif attached_items_child.name == 'PurchaseOrder' + unless purchase_order_obj[:purchase_order] + purchase_order_obj[:purchase_order] = [] end - end.compact - attached_items_obj[:attached_items].push(attached_items_arr) - attached_items_obj + purchase_order_arr = parse_children_elements(attached_items_child) + purchase_order_obj[:purchase_order].push(purchase_order_arr) + purchase_order_obj - else - { - name: el_child.name, - text: el_child.text - } - end - end.compact + else + { + name: attached_items_child.name, + text: attached_items_child.text + } + end + end.compact - sales_order_lines_obj[:merchandise].push(merchandise_arr) - end + attached_items_obj[:attached_items].push(attached_items_arr) + attached_items_obj + + else + { + name: el_child.name, + text: el_child.text + } + end + end.compact + + sales_order_lines_obj[:merchandise].push(merchandise_arr) end sales_order_lines_obj @@ -297,7 +286,7 @@ module Syspro def parse_children_elements(el_child) obj_array = el_child.children.map do |el| - next if el.name == "text" + next if el.name == 'text' { name: el.name, text: el.text @@ -306,7 +295,6 @@ module Syspro obj_array end - end end end diff --git a/lib/syspro/business_objects/porqry.rb b/lib/syspro/business_objects/porqry.rb index 01ead07..c4fa3e6 100644 --- a/lib/syspro/business_objects/porqry.rb +++ b/lib/syspro/business_objects/porqry.rb @@ -10,10 +10,10 @@ module Syspro include Syspro::BusinessObjects::Parsers attr_accessor :purchase_order, :include_stocked_lines, :include_non_stocked_lines, - :include_freight_lines, :include_miscellaneous_lines, :include_comment_lines, - :include_completed_lines, :include_grns, :include_history, :include_lct_details, - :include_requisition_details, :include_requisition_routing, :include_sales_orders, - :include_custom_forms, :filter_type, :filter_value + :include_freight_lines, :include_miscellaneous_lines, :include_comment_lines, + :include_completed_lines, :include_grns, :include_history, :include_lct_details, + :include_requisition_details, :include_requisition_routing, :include_sales_orders, + :include_custom_forms, :filter_type, :filter_value def call(user_id) xml_in = template.result(binding) diff --git a/lib/syspro/business_objects/portii.rb b/lib/syspro/business_objects/portii.rb index 2de86ac..1f406b3 100644 --- a/lib/syspro/business_objects/portii.rb +++ b/lib/syspro/business_objects/portii.rb @@ -11,10 +11,10 @@ module Syspro # input params attr_accessor :transaction_date, - :ignore_warnings, - :apply_if_entire_document_valid, - :validate_only, - :item_inspected + :ignore_warnings, + :apply_if_entire_document_valid, + :validate_only, + :item_inspected def call(user_id) xml_parameters = params_template.result(binding) @@ -43,10 +43,9 @@ module Syspro parser.parse end - def render_xml(inner_text, dflt_value = "") + def render_xml(inner_text, dflt_value = '') inner_text ? inner_text.to_s : dflt_value end end end end - diff --git a/lib/syspro/business_objects/portoi.rb b/lib/syspro/business_objects/portoi.rb index 048f8f8..903e123 100644 --- a/lib/syspro/business_objects/portoi.rb +++ b/lib/syspro/business_objects/portoi.rb @@ -11,22 +11,22 @@ module Syspro # input params attr_accessor :purchase_order_header, - :order_details, - :validate_only, - :ignore_warnings, - :allow_non_stock_items, - :allow_zero_price, - :validate_working_days, - :allow_po_when_blanket_po, - :default_memo_code, - :fixed_exchange_rate, - :default_memo_days, - :allow_blank_ledger_code, - :calc_due_date, - :default_delivery_address, - :insert_dangerous_goods_text, - :insert_additional_po_text, - :status + :order_details, + :validate_only, + :ignore_warnings, + :allow_non_stock_items, + :allow_zero_price, + :validate_working_days, + :allow_po_when_blanket_po, + :default_memo_code, + :fixed_exchange_rate, + :default_memo_days, + :allow_blank_ledger_code, + :calc_due_date, + :default_delivery_address, + :insert_dangerous_goods_text, + :insert_additional_po_text, + :status def call(user_id) xml_parameters = params_template.result(binding) @@ -61,4 +61,3 @@ module Syspro end end end - diff --git a/lib/syspro/business_objects/portor.rb b/lib/syspro/business_objects/portor.rb index 5a17d90..08d459c 100644 --- a/lib/syspro/business_objects/portor.rb +++ b/lib/syspro/business_objects/portor.rb @@ -47,10 +47,9 @@ module Syspro parser.parse end - def render_xml(inner_text, dflt_value = "") + def render_xml(inner_text, dflt_value = '') inner_text ? inner_text.to_s : dflt_value end end end end - diff --git a/lib/syspro/configuration.rb b/lib/syspro/configuration.rb index 99129b7..c1fd90b 100644 --- a/lib/syspro/configuration.rb +++ b/lib/syspro/configuration.rb @@ -43,7 +43,7 @@ module Syspro private def deprecated_default_server_url - warn "[DEPRECATION] the default server url of `http://syspro.wildlandlabs.com:90` will be removed. Please update your application to configure this server url (see README for details)." + warn '[DEPRECATION] the default server url of `http://syspro.wildlandlabs.com:90` will be removed. Please update your application to configure this server url (see README for details).' 'http://syspro.wildlandlabs.com:90' end diff --git a/lib/syspro/util.rb b/lib/syspro/util.rb index 650c620..4516f4b 100644 --- a/lib/syspro/util.rb +++ b/lib/syspro/util.rb @@ -207,7 +207,6 @@ module Syspro end end - def logger Syspro.configuration.logger end diff --git a/lib/syspro/version.rb b/lib/syspro/version.rb index b92c68c..6799d81 100644 --- a/lib/syspro/version.rb +++ b/lib/syspro/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Syspro - VERSION = '1.0.0.alpha.2' + VERSION = '1.0.0.alpha.2'.freeze end diff --git a/test/comsfm_test.rb b/test/comsfm_test.rb index f54a94f..4aafc99 100644 --- a/test/comsfm_test.rb +++ b/test/comsfm_test.rb @@ -18,13 +18,13 @@ class ComsFmTest < Minitest::Test def test_comsfm cust_item = Syspro::BusinessObjects::Models::ComsFmItem.new - cust_item.form_type = "POR" - cust_item.key_field = "U03679" - cust_item.field_name = "TempPO" - cust_item.alpha_value = "Y" + cust_item.form_type = 'POR' + cust_item.key_field = 'U03679' + cust_item.field_name = 'TempPO' + cust_item.alpha_value = 'Y' cust_form = Syspro::BusinessObjects::ComsFm.new - cust_form.validate_only = "Y" + cust_form.validate_only = 'Y' cust_form.items = [cust_item] errors = cust_form.add(user_id.guid) diff --git a/test/invqry_test.rb b/test/invqry_test.rb index 800ad83..ca877d0 100644 --- a/test/invqry_test.rb +++ b/test/invqry_test.rb @@ -22,10 +22,10 @@ class InvQryTest < Minitest::Test invqry_req.key_stock_code = '1003' invqry_req.filter_warehouse_list = 'P0' invqry_req.option = Syspro::BusinessObjects::Models::InvQryOptions.new - invqry_req.option.include_lots = "Y" - + invqry_req.option.include_lots = 'Y' + invqry_rsp = invqry_req.call(user_id.guid) assert_kind_of Syspro::BusinessObjects::Models::Inv, invqry_rsp end -end \ No newline at end of file +end diff --git a/test/invsws_test.rb b/test/invsws_test.rb index 579369f..e2500d2 100644 --- a/test/invsws_test.rb +++ b/test/invsws_test.rb @@ -19,15 +19,15 @@ class InvSwsTest < Minitest::Test def test_invsws skip 'A new VCR cassette needs recorded for this test to pass' invsws_item = Syspro::BusinessObjects::Models::InvSwsItem.new - invsws_item.key_stock_code = "1004" - invsws_item.key_warehouse = "P0" - invsws_item.default_bin = "P0" + invsws_item.key_stock_code = '1004' + invsws_item.key_warehouse = 'P0' + invsws_item.default_bin = 'P0' invsws_req = Syspro::BusinessObjects::InvSws.new - invsws_req.validate_only = "Y" - invsws_req.apply_product_class_default = "BA" - invsws_req.ignore_warnings = "N" - invsws_req.apply_if_entire_document_valid = "Y" + invsws_req.validate_only = 'Y' + invsws_req.apply_product_class_default = 'BA' + invsws_req.ignore_warnings = 'N' + invsws_req.apply_if_entire_document_valid = 'Y' invsws_req.item = invsws_item invsws_resp = invsws_req.add(user_id.guid) diff --git a/test/logon_test.rb b/test/logon_test.rb index fb9f661..e6b18ba 100644 --- a/test/logon_test.rb +++ b/test/logon_test.rb @@ -25,13 +25,13 @@ class LogonTest < Minitest::Test end def test_logon_error - assert_raises(::Syspro::AuthenticationError) { + assert_raises(::Syspro::AuthenticationError) do logon_result = ::Syspro::SysproClient.new.logon( username, 'bad_password', company, company_password ) - } + end end end diff --git a/test/portii_test.rb b/test/portii_test.rb index 545acbd..988c230 100644 --- a/test/portii_test.rb +++ b/test/portii_test.rb @@ -15,16 +15,16 @@ class PorTiiTest < Minitest::Test def test_portii req = Syspro::BusinessObjects::PorTii.new - + req.item_inspected = Syspro::BusinessObjects::Models::InventoryInspection.new - req.item_inspected.grn_number = "P00012509" + req.item_inspected.grn_number = 'P00012509' req.item_inspected.quantity = 12.312 - req.item_inspected.inspection_completed = "Y" - + req.item_inspected.inspection_completed = 'Y' + resp = req.call(user_id.guid) - - assert_equal resp.has_key?(:grn_numbers), true - assert_equal resp.has_key?(:items_processed), true - assert_equal resp.has_key?(:items_invalid), true + + assert_equal resp.key?(:grn_numbers), true + assert_equal resp.key?(:items_processed), true + assert_equal resp.key?(:items_invalid), true end -end \ No newline at end of file +end diff --git a/test/portoi_test.rb b/test/portoi_test.rb index 3ddf648..4b0275b 100644 --- a/test/portoi_test.rb +++ b/test/portoi_test.rb @@ -18,60 +18,60 @@ class PorToiTest < Minitest::Test po.purchase_order_header = Syspro::BusinessObjects::Models::PurchaseOrders::Header.new # Setup the PORTOI params - po.validate_only = "N" - po.ignore_warnings = "N" - po.allow_non_stock_items = "N" - po.allow_zero_price = "Y" - po.validate_working_days = "N" - po.allow_po_when_blanket_po = "N" - po.default_memo_code = "" - po.fixed_exchange_rate = "N" + po.validate_only = 'N' + po.ignore_warnings = 'N' + po.allow_non_stock_items = 'N' + po.allow_zero_price = 'Y' + po.validate_working_days = 'N' + po.allow_po_when_blanket_po = 'N' + po.default_memo_code = '' + po.fixed_exchange_rate = 'N' po.default_memo_days = 0 - po.allow_blank_ledger_code = "Y" - po.default_delivery_address = "" - po.calc_due_date = "N" - po.insert_dangerous_goods_text = "N" - po.insert_additional_po_text = "N" - po.status = "1" + po.allow_blank_ledger_code = 'Y' + po.default_delivery_address = '' + po.calc_due_date = 'N' + po.insert_dangerous_goods_text = 'N' + po.insert_additional_po_text = 'N' + po.status = '1' # Setup the purchase order header data attributes - po.purchase_order_header.order_action_type = "A" - po.purchase_order_header.order_type = "L" - po.purchase_order_header.supplier = "WYC001" - po.purchase_order_header.customer_po_number = "H01993-1" - po.purchase_order_header.buyer = "PCD" - po.purchase_order_header.warehouse = "P0" - po.purchase_order_header.tax_status = "N" - po.purchase_order_header.invoice_terms = "X" - po.purchase_order_header.order_date = Time.now.strftime("%Y-%m-%d") - po.purchase_order_header.apply_due_date_to_lines = "A" + po.purchase_order_header.order_action_type = 'A' + po.purchase_order_header.order_type = 'L' + po.purchase_order_header.supplier = 'WYC001' + po.purchase_order_header.customer_po_number = 'H01993-1' + po.purchase_order_header.buyer = 'PCD' + po.purchase_order_header.warehouse = 'P0' + po.purchase_order_header.tax_status = 'N' + po.purchase_order_header.invoice_terms = 'X' + po.purchase_order_header.order_date = Time.now.strftime('%Y-%m-%d') + po.purchase_order_header.apply_due_date_to_lines = 'A' po.purchase_order_header.disc_percent1 = 0 po.purchase_order_header.disc_percent2 = 0 po.purchase_order_header.disc_percent3 = 0 line1 = Syspro::BusinessObjects::Models::PurchaseOrders::StockLine.new line1.purchase_order_line = 1 - line1.line_action_type = "A" - line1.stock_code = "8801" - line1.warehouse = "P0" - line1.order_qty = "100" - line1.order_uom = "KG" - line1.pieces = "0" - line1.price_method = "M" + line1.line_action_type = 'A' + line1.stock_code = '8801' + line1.warehouse = 'P0' + line1.order_qty = '100' + line1.order_uom = 'KG' + line1.pieces = '0' + line1.price_method = 'M' line1.price = 0 - line1.line_disc_type = "P" - line1.line_disc_less_plus = "L" + line1.line_disc_type = 'P' + line1.line_disc_less_plus = 'L' line1.line_disc_percent1 = 0 line1.line_disc_percent2 = 0 line1.line_disc_percent3 = 0 line1.line_disc_value = 0 - line1.taxable = "N" - + line1.taxable = 'N' + po.order_details = Syspro::BusinessObjects::Models::PurchaseOrders::OrderDetails.new po.order_details.stock_lines = [line1] - + syspro_po = po.call(user_id.guid) - + assert_equal syspro_po.error_numbers.length, 0 end -end \ No newline at end of file +end diff --git a/test/portor_test.rb b/test/portor_test.rb index 2dc20cb..bbcc50c 100644 --- a/test/portor_test.rb +++ b/test/portor_test.rb @@ -18,17 +18,17 @@ class PorTorTest < Minitest::Test def test_portor receipt_intero = Syspro::BusinessObjects::Models::ReceiptInterospection.new - receipt_intero.purchase_order = "Z01308" - receipt_intero.warehouse = "P0" - receipt_intero.stock_code = "8801" + receipt_intero.purchase_order = 'Z01308' + receipt_intero.warehouse = 'P0' + receipt_intero.stock_code = '8801' receipt_intero.quantity = 0.01 - receipt_intero.delivery_note = "DELIVER NOTE HERE-WL" - receipt_intero.certificate = "8/45-3" - receipt_intero.lot = "7097505" + receipt_intero.delivery_note = 'DELIVER NOTE HERE-WL' + receipt_intero.certificate = '8/45-3' + receipt_intero.lot = '7097505' req = Syspro::BusinessObjects::PorTor.new - req.transaction_date = Time.now.strftime("%Y-%m-%d") - req.ignore_warnings = "N" + req.transaction_date = Time.now.strftime('%Y-%m-%d') + req.ignore_warnings = 'N' req.receipt_interospections = [receipt_intero] resp = req.call(user_id.guid) -- libgit2 0.21.4