diff --git a/Gemfile b/Gemfile index e58a0b7..5cdc689 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } gemspec -group :test do +group :development, :test do + gem 'rubocop', require: false gem 'pry-byebug' gem 'rb-readline' end diff --git a/Gemfile.lock b/Gemfile.lock index a04fd46..a23ce02 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ DEPENDENCIES pry-byebug rake (~> 10.0) rb-readline - rubocop (~> 0.54.0) + rubocop syspro-ruby! webmock (~> 3.3.0) diff --git a/lib/syspro/business_objects/parsers/comsfm_parser.rb b/lib/syspro/business_objects/parsers/comsfm_parser.rb index e90ccb1..5f86f28 100644 --- a/lib/syspro/business_objects/parsers/comsfm_parser.rb +++ b/lib/syspro/business_objects/parsers/comsfm_parser.rb @@ -11,10 +11,9 @@ module Syspro end def parse - error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} + doc.xpath('//ErrorNumber').map(&:text) end end end end end - diff --git a/lib/syspro/business_objects/parsers/invsws_parser.rb b/lib/syspro/business_objects/parsers/invsws_parser.rb index ee00298..6ff7881 100644 --- a/lib/syspro/business_objects/parsers/invsws_parser.rb +++ b/lib/syspro/business_objects/parsers/invsws_parser.rb @@ -18,7 +18,23 @@ module Syspro }, "reacords_read": doc.xpath("//StatusOfItems/RecordsRead").map{|e| e.text}.first, "reacords_invalid": doc.xpath("//StatusOfItems/RecordsInvalid").map{|e| e.text}.first, - "error_numbers": doc.xpath("//ErrorNumber").map{|e| e.text} + "error_numbers": doc.xpath("//ErrorNumber").map{|e| e.text}, + "errors": map_errors + } + end + + def map_errors + doc.xpath('//ErrorNumber/..').map do |error_parent_node| + map_error_parent(error_parent_node) + end + end + + def map_error_parent(error_parent_node) + { + node_name: error_parent_node.name, + error_number: error_parent_node.xpath('//ErrorNumber').text, + error_desc: error_parent_node.xpath('//ErrorDescription').text, + value: error_parent_node.xpath('//Value').text } end end diff --git a/lib/syspro/business_objects/parsers/portor_parser.rb b/lib/syspro/business_objects/parsers/portor_parser.rb index f00affa..738daf6 100644 --- a/lib/syspro/business_objects/parsers/portor_parser.rb +++ b/lib/syspro/business_objects/parsers/portor_parser.rb @@ -12,7 +12,7 @@ module Syspro def parse error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} - + gl_journal = doc.first_element_child.xpath('GlJournal') gl_journal_obj = gl_journal.children.map do |el| next if el.name == 'text' @@ -29,7 +29,7 @@ module Syspro key[:entry_number] = doc.first_element_child.xpath('EntryNumber') key[:warehouse] = doc.first_element_child.xpath('Warehouse') key[:gl_journal] = gl_journal_obj - + receipts = doc.first_element_child.xpath('Receipt') receipts_obj = receipts.flat_map do |el| el.elements.map do |inner| @@ -48,7 +48,7 @@ module Syspro end grns = doc.xpath("//Grn").map{|e| e.text} - + { error_numbers: error_numbers, key: key, diff --git a/test/cassettes/test_comsfm.yml b/test/cassettes/test_comsfm.yml new file mode 100644 index 0000000..183a662 --- /dev/null +++ b/test/cassettes/test_comsfm.yml @@ -0,0 +1,71 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=&CompanyPassword=&Operator=&OperatorPassword= + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 17:59:57 GMT + Content-ength: + - '36' + body: + encoding: UTF-8 + string: '12E6D0C3129AAC4D940E264688A7D31500 ' + http_version: + recorded_at: Thu, 23 May 2019 17:59:55 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Setup/Add?BusinessObject=COMSFM&UserId=12E6D0C3129AAC4D940E264688A7D31500%20%20&XmlIn=%3CSetupCustomForm%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22COMSFMDOC.XSD%22%3E%0A%0A%20%20%3CItem%3E%0A%20%20%20%20%3CKey%3E%0A%20%20%20%20%20%20%3CFormType%3EPOR%3C/FormType%3E%0A%20%20%20%20%20%20%3CKeyField%3EU03679%3C/KeyField%3E%0A%20%20%20%20%20%20%3CFieldName%3ETempPO%3C/FieldName%3E%0A%20%20%20%20%3C/Key%3E%0A%20%20%20%20%3CAlphaValue%3EY%3C/AlphaValue%3E%0A%20%20%3C/Item%3E%0A%0A%3C/SetupCustomForm%3E&XmlParameters=%3CSetupCustomForm%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22COMSFM.XSD%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CValidateOnly%3EY%3C/ValidateOnly%3E%0A%20%20%3C/Parameters%3E%0A%3C/SetupCustomForm%3E + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 17:59:58 GMT + Content-ength: + - '417' + body: + encoding: UTF-8 + string: "\nanguage='05' anguage2='EN' CssStyle='' DecFormat='1' + DateFormat='01' Role='01' Version='7.0.008' OperatorPrimaryRole=' '>\n\n\nPOR\nU03679\nTempPO\n\n\n\n1\n0\n\n\n " + http_version: + recorded_at: Thu, 23 May 2019 17:59:55 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_invsws.yml b/test/cassettes/test_invsws.yml new file mode 100644 index 0000000..b3a0749 --- /dev/null +++ b/test/cassettes/test_invsws.yml @@ -0,0 +1,72 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=&CompanyPassword=&Operator=&OperatorPassword= + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 18:29:17 GMT + Content-ength: + - '36' + body: + encoding: UTF-8 + string: 'E913FB94AD039B419146258CFB1B0FFB00 ' + http_version: + recorded_at: Thu, 23 May 2019 18:29:15 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Setup/Add?BusinessObject=INVSWS&UserId=E913FB94AD039B419146258CFB1B0FFB00%20%20&XmlIn=%3CSetupInvWarehouse%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22INVSWSDOC.XSD%22%3E%0A%20%20%3CItem%3E%0A%20%20%20%20%3CKey%3E%0A%20%20%20%20%20%20%3CStockCode%3E1004%3C/StockCode%3E%0A%20%20%20%20%20%20%3CWarehouse%3EP0%3C/Warehouse%3E%0A%20%20%20%20%3C/Key%3E%0A%20%20%20%20%3CCostMultiplier%3E1.0%3C/CostMultiplier%3E%0A%20%20%20%20%3CMinimumQty%3E%3C/MinimumQty%3E%0A%20%20%20%20%3CMaximumQty%3E%3C/MaximumQty%3E%0A%20%20%20%20%3CUnitCost%3E%3C/UnitCost%3E%0A%20%20%20%20%3CDefaultBin%3EP0%3C/DefaultBin%3E%0A%20%20%20%20%3CSafetyStockQty%3E%3C/SafetyStockQty%3E%0A%20%20%20%20%3CReOrderQty%3E%3C/ReOrderQty%3E%0A%20%20%20%20%3CPalletQty%3E%3C/PalletQty%3E%0A%20%20%20%20%3CUserField1%3E%3C/UserField1%3E%0A%20%20%20%20%3CUserField2%3E%3C/UserField2%3E%0A%20%20%20%20%3CUserField3%3E%3C/UserField3%3E%0A%20%20%20%20%3COrderPolicy%3EC%3C/OrderPolicy%3E%0A%20%20%20%20%3CMajorOrderMult%3E%3C/MajorOrderMult%3E%0A%20%20%20%20%3CMinorOrderMult%3E%3C/MinorOrderMult%3E%0A%20%20%20%20%3COrderMinimum%3E%3C/OrderMinimum%3E%0A%20%20%20%20%3COrderMaximum%3E%3C/OrderMaximum%3E%0A%20%20%20%20%3COrderFixPeriod%3E01%3C/OrderFixPeriod%3E%0A%20%20%20%20%3CTrfSuppliedItem%3EN%3C/TrfSuppliedItem%3E%0A%20%20%20%20%3CDefaultSourceWh%3E%3C/DefaultSourceWh%3E%0A%20%20%20%20%3CTrfeadTime%3E0%3C/TrfeadTime%3E%0A%20%20%20%20%3CTrfCostGlCode%3E%3C/TrfCostGlCode%3E%0A%20%20%20%20%3CTrfCostMultiply%3E%3C/TrfCostMultiply%3E%0A%20%20%20%20%3CTrfReplenishWh%3E0%3C/TrfReplenishWh%3E%0A%20%20%20%20%3CTrfBuyingRule%3EA%3C/TrfBuyingRule%3E%0A%20%20%20%20%3CTrfDockToStock%3E%3C/TrfDockToStock%3E%0A%20%20%20%20%3CTrfFixTimePeriod%3E%3C/TrfFixTimePeriod%3E%0A%20%20%20%20%3CabourCost%3E%3C/abourCost%3E%0A%20%20%20%20%3CMaterialCost%3E%3C/MaterialCost%3E%0A%20%20%20%20%3CFixedOverhead%3E%3C/FixedOverhead%3E%0A%20%20%20%20%3CVariableOverhead%3E%3C/VariableOverhead%3E%0A%20%20%20%20%3CSubContractCost%3E%3C/SubContractCost%3E%0A%20%20%20%20%3CManualCostFlag%3EN%3C/ManualCostFlag%3E%0A%20%20%20%20%0A%20%20%3C/Item%3E%0A%3C/SetupInvWarehouse%3E&XmlParameters=%3CSetupInvWarehouse%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22INVSWS.XSD%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CApplyProductClassDefault%3EBA%3C/ApplyProductClassDefault%3E%0A%20%20%20%20%3CIgnoreWarnings%3EN%3C/IgnoreWarnings%3E%0A%20%20%20%20%3CApplyIfEntireDocumentValid%3EY%3C/ApplyIfEntireDocumentValid%3E%0A%20%20%20%20%3CValidateOnly%3EY%3C/ValidateOnly%3E%0A%20%20%3C/Parameters%3E%0A%3C/SetupInvWarehouse%3E%0A + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 18:29:18 GMT + Content-ength: + - '536' + body: + encoding: UTF-8 + string: "\nanguage='05' anguage2='EN' CssStyle='' DecFormat='1' + DateFormat='01' Role='01' Version='7.0.026' OperatorPrimaryRole=' '>\n\n\n1004\nP0\n\n\n1004\n240004\nStock + code '1004' not found\n\n\n\n1\n1\n\n\n " + http_version: + recorded_at: Thu, 23 May 2019 18:29:15 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_invsws_errors.yml b/test/cassettes/test_invsws_errors.yml new file mode 100644 index 0000000..245f5ac --- /dev/null +++ b/test/cassettes/test_invsws_errors.yml @@ -0,0 +1,72 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=&CompanyPassword=&Operator=&OperatorPassword= + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 24 May 2019 17:23:24 GMT + Content-ength: + - '36' + body: + encoding: UTF-8 + string: '0EDDFCFC88E5674AA78DD1C24F3CEEBE00 ' + http_version: + recorded_at: Fri, 24 May 2019 17:23:23 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Setup/Add?BusinessObject=INVSWS&UserId=0EDDFCFC88E5674AA78DD1C24F3CEEBE00%20%20&XmlIn=%3CSetupInvWarehouse%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22INVSWSDOC.XSD%22%3E%0A%20%20%3CItem%3E%0A%20%20%20%20%3CKey%3E%0A%20%20%20%20%20%20%3CStockCode%3E1004%3C/StockCode%3E%0A%20%20%20%20%20%20%3CWarehouse%3EP0%3C/Warehouse%3E%0A%20%20%20%20%3C/Key%3E%0A%20%20%20%20%3CCostMultiplier%3E1.0%3C/CostMultiplier%3E%0A%20%20%20%20%3CMinimumQty%3E%3C/MinimumQty%3E%0A%20%20%20%20%3CMaximumQty%3E%3C/MaximumQty%3E%0A%20%20%20%20%3CUnitCost%3E%3C/UnitCost%3E%0A%20%20%20%20%3CDefaultBin%3EP0%3C/DefaultBin%3E%0A%20%20%20%20%3CSafetyStockQty%3E%3C/SafetyStockQty%3E%0A%20%20%20%20%3CReOrderQty%3E%3C/ReOrderQty%3E%0A%20%20%20%20%3CPalletQty%3E%3C/PalletQty%3E%0A%20%20%20%20%3CUserField1%3E%3C/UserField1%3E%0A%20%20%20%20%3CUserField2%3E%3C/UserField2%3E%0A%20%20%20%20%3CUserField3%3E%3C/UserField3%3E%0A%20%20%20%20%3COrderPolicy%3EC%3C/OrderPolicy%3E%0A%20%20%20%20%3CMajorOrderMult%3E%3C/MajorOrderMult%3E%0A%20%20%20%20%3CMinorOrderMult%3E%3C/MinorOrderMult%3E%0A%20%20%20%20%3COrderMinimum%3E%3C/OrderMinimum%3E%0A%20%20%20%20%3COrderMaximum%3E%3C/OrderMaximum%3E%0A%20%20%20%20%3COrderFixPeriod%3E01%3C/OrderFixPeriod%3E%0A%20%20%20%20%3CTrfSuppliedItem%3EN%3C/TrfSuppliedItem%3E%0A%20%20%20%20%3CDefaultSourceWh%3E%3C/DefaultSourceWh%3E%0A%20%20%20%20%3CTrfeadTime%3E0%3C/TrfeadTime%3E%0A%20%20%20%20%3CTrfCostGlCode%3E%3C/TrfCostGlCode%3E%0A%20%20%20%20%3CTrfCostMultiply%3E%3C/TrfCostMultiply%3E%0A%20%20%20%20%3CTrfReplenishWh%3E0%3C/TrfReplenishWh%3E%0A%20%20%20%20%3CTrfBuyingRule%3EA%3C/TrfBuyingRule%3E%0A%20%20%20%20%3CTrfDockToStock%3E%3C/TrfDockToStock%3E%0A%20%20%20%20%3CTrfFixTimePeriod%3E%3C/TrfFixTimePeriod%3E%0A%20%20%20%20%3CabourCost%3E%3C/abourCost%3E%0A%20%20%20%20%3CMaterialCost%3E%3C/MaterialCost%3E%0A%20%20%20%20%3CFixedOverhead%3E%3C/FixedOverhead%3E%0A%20%20%20%20%3CVariableOverhead%3E%3C/VariableOverhead%3E%0A%20%20%20%20%3CSubContractCost%3E%3C/SubContractCost%3E%0A%20%20%20%20%3CManualCostFlag%3EN%3C/ManualCostFlag%3E%0A%20%20%20%20%0A%20%20%3C/Item%3E%0A%3C/SetupInvWarehouse%3E&XmlParameters=%3CSetupInvWarehouse%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22INVSWS.XSD%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CApplyProductClassDefault%3EBA%3C/ApplyProductClassDefault%3E%0A%20%20%20%20%3CIgnoreWarnings%3EN%3C/IgnoreWarnings%3E%0A%20%20%20%20%3CApplyIfEntireDocumentValid%3EY%3C/ApplyIfEntireDocumentValid%3E%0A%20%20%20%20%3CValidateOnly%3EY%3C/ValidateOnly%3E%0A%20%20%3C/Parameters%3E%0A%3C/SetupInvWarehouse%3E%0A + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Fri, 24 May 2019 17:23:24 GMT + Content-ength: + - '536' + body: + encoding: UTF-8 + string: "\nanguage='05' anguage2='EN' CssStyle='' DecFormat='1' + DateFormat='01' Role='01' Version='7.0.026' OperatorPrimaryRole=' '>\n\n\n1004\nP0\n\n\n1004\n240004\nStock + code '1004' not found\n\n\n\n1\n1\n\n\n " + http_version: + recorded_at: Fri, 24 May 2019 17:23:24 GMT +recorded_with: VCR 4.0.0 diff --git a/test/cassettes/test_portor.yml b/test/cassettes/test_portor.yml new file mode 100644 index 0000000..16bfbcb --- /dev/null +++ b/test/cassettes/test_portor.yml @@ -0,0 +1,71 @@ +--- +http_interactions: +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=&CompanyPassword=&Operator=&OperatorPassword= + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 16:43:21 GMT + Content-ength: + - '36' + body: + encoding: UTF-8 + string: '6D8139C868FDD74487FB2B80F8CC4EBD00 ' + http_version: + recorded_at: Thu, 23 May 2019 16:43:18 GMT +- request: + method: get + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Transaction/Post?BusinessObject=PORTOR&UserId=6D8139C868FDD74487FB2B80F8CC4EBD00%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22portordoc.xsd%22%3E%0A%20%20%0A%20%20%3CItem%3E%0A%20%20%20%20%3CReceiptIntoInspection%3E%0A%20%20%20%20%20%20%3CPurchaseOrder%3EZ01308%3C/PurchaseOrder%3E%0A%20%20%20%20%20%20%3CWarehouse%3EP0%3C/Warehouse%3E%0A%20%20%20%20%20%20%3CStockCode%3E8801%3C/StockCode%3E%0A%20%20%20%20%20%20%3CQuantity%3E0.01%3C/Quantity%3E%0A%20%20%20%20%20%20%3CCountedQuantityComplete%3EY%3C/CountedQuantityComplete%3E%0A%20%20%20%20%20%20%3CDeliveryNote%3EDEIVER%20NOTE%20HERE-W%3C/DeliveryNote%3E%0A%20%20%20%20%20%20%3CCertificate%3E8/45-3%3C/Certificate%3E%0A%20%20%20%20%20%20%3CNarration%3E%3C/Narration%3E%0A%20%20%20%20%20%20%3Cot%3E7097505%3C/ot%3E%0A%20%20%20%20%20%20%3CGRNNumber%3E%3C/GRNNumber%3E%0A%20%20%20%20%20%20%3CConcession%3E%3C/Concession%3E%0A%20%20%20%20%20%20%3CCostBasis%3E%3C/CostBasis%3E%0A%20%20%20%20%20%20%3CNotation%3E%3C/Notation%3E%0A%20%20%20%20%20%20%3CReference%3E%3C/Reference%3E%0A%20%20%20%20%20%20%3CGRNSource%3E%3C/GRNSource%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%3C/ReceiptIntoInspection%3E%0A%20%20%3C/Item%3E%0A%20%20%20%20%20%20%0A%3C/PostPurchaseOrderReceipts%3E&XmlParameters=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XMSchema-instance%22%20xsd:noNamespaceSchemaocation=%22portor.xsd%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CTransactionDate%3E2019-05-23%3C/TransactionDate%3E%0A%20%20%20%20%3CIgnoreWarnings%3EN%3C/IgnoreWarnings%3E%0A%20%20%20%20%3CNonStockedWhToUse%3E%3C/NonStockedWhToUse%3E%0A%20%20%20%20%3CGRNMatchingAction%3EA%3C/GRNMatchingAction%3E%0A%20%20%20%20%3CAllowBlankSupplier%3EN%3C/AllowBlankSupplier%3E%0A%20%20%20%20%3CApplyIfEntireDocumentValid%3EN%3C/ApplyIfEntireDocumentValid%3E%0A%20%20%20%20%3CValidateOnly%3EN%3C/ValidateOnly%3E%0A%20%20%20%20%3CManualSerialTransfersAllowed%3EN%3C/ManualSerialTransfersAllowed%3E%0A%20%20%20%20%3CIgnoreAnalysis%3EN%3C/IgnoreAnalysis%3E%0A%20%20%3C/Parameters%3E%0A%3C/PostPurchaseOrderReceipts%3E + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Syspro/7 RubyBindings/1.0.0.alpha.2 + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/octet-stream + Server: + - Microsoft-HTTPAPI/2.0 + Date: + - Thu, 23 May 2019 16:43:23 GMT + Content-ength: + - '397' + body: + encoding: UTF-8 + string: "\nanguage='05' anguage2='EN' CssStyle='' DecFormat='1' + DateFormat='01' Role='01' Version='7.0.111' OperatorPrimaryRole=' '>\n\n\nZ01308\n<ine>0002ine>\nP00013152\n<otNumber>7097505otNumber>\n\n000001\n\n\n " + http_version: + recorded_at: Thu, 23 May 2019 16:43:20 GMT +recorded_with: VCR 4.0.0 diff --git a/test/comsfm_test.rb b/test/comsfm_test.rb index c969b6c..f54a94f 100644 --- a/test/comsfm_test.rb +++ b/test/comsfm_test.rb @@ -5,6 +5,9 @@ require 'test_helper' class ComsFmTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } + let(:username) { ENV['SYSPRO_USERNAME'] } let(:password) { ENV['SYSPRO_PASSWORD'] } let(:company) { ENV['SYSPRO_COMPANY'] } @@ -16,7 +19,7 @@ class ComsFmTest < Minitest::Test def test_comsfm cust_item = Syspro::BusinessObjects::Models::ComsFmItem.new cust_item.form_type = "POR" - cust_item.key_field = "U03421" + cust_item.key_field = "U03679" cust_item.field_name = "TempPO" cust_item.alpha_value = "Y" @@ -28,4 +31,4 @@ class ComsFmTest < Minitest::Test assert_equal errors.length, 0 end -end \ No newline at end of file +end diff --git a/test/invsws_test.rb b/test/invsws_test.rb index c422872..579369f 100644 --- a/test/invsws_test.rb +++ b/test/invsws_test.rb @@ -2,9 +2,12 @@ require 'test_helper' -class ComsFmTest < Minitest::Test +class InvSwsTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } + let(:username) { ENV['SYSPRO_USERNAME'] } let(:password) { ENV['SYSPRO_PASSWORD'] } let(:company) { ENV['SYSPRO_COMPANY'] } @@ -14,8 +17,9 @@ class ComsFmTest < Minitest::Test end 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 = "1003" + invsws_item.key_stock_code = "1004" invsws_item.key_warehouse = "P0" invsws_item.default_bin = "P0" @@ -27,7 +31,25 @@ class ComsFmTest < Minitest::Test invsws_req.item = invsws_item invsws_resp = invsws_req.add(user_id.guid) - + assert_equal invsws_resp[:error_numbers].length, 0 end -end \ No newline at end of file + + def test_invsws_errors + invsws_item = Syspro::BusinessObjects::Models::InvSwsItem.new + 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.item = invsws_item + + invsws_resp = invsws_req.add(user_id.guid) + + assert_equal invsws_resp[:errors].length, 1 + end +end diff --git a/test/por_test.rb b/test/por_test.rb index d346fcf..2d921f3 100644 --- a/test/por_test.rb +++ b/test/por_test.rb @@ -2,6 +2,7 @@ require 'test_helper' class PorTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } after { VCR.eject_cassette } @@ -14,26 +15,10 @@ class PorTest < Minitest::Test Syspro::Logon.logon(username, password, company, company_password) end - #def test_por_transaction - #portor = Syspro::BusinessObjects::PorTor.new - - #portor.transaction_date = "2006-04-08" - #portor.ignore_warnings = "N" - #portor.grn_matching_action = "A" - #portor.allow_blank_supplier = "N" - #portor.apply_if_entire_document_valid = "Y" - #portor.validate_only = "N" - #portor.manual_serial_transfers_allowed = "N" - #portor.ignore_analysis = "Y" - - #por_result = portor.call(user_id.guid) - #assert_kind_of Syspro::BusinessObjects::Models::Por - #end - def test_por_query porqry = Syspro::BusinessObjects::PorQry.new - porqry.purchase_order = " 00001" + porqry.purchase_order = ' 00001' porqry.include_stocked_lines = false porqry.include_non_stocked_lines = false porqry.include_freight_lines = false @@ -47,8 +32,8 @@ class PorTest < Minitest::Test porqry.include_requisition_routing = false porqry.include_sales_orders = false porqry.include_custom_forms = false - porqry.filter_type = "A" - porqry.filter_value = "" + porqry.filter_type = 'A' + porqry.filter_value = '' por_result = porqry.call(user_id.guid) assert_kind_of(Syspro::BusinessObjects::Models::PorDetail, por_result) diff --git a/test/portor_test.rb b/test/portor_test.rb index 0507c3e..2dc20cb 100644 --- a/test/portor_test.rb +++ b/test/portor_test.rb @@ -5,6 +5,9 @@ require 'test_helper' class PorTorTest < Minitest::Test extend Minitest::Spec::DSL + before { VCR.insert_cassette name } + after { VCR.eject_cassette } + let(:username) { ENV['SYSPRO_USERNAME'] } let(:password) { ENV['SYSPRO_PASSWORD'] } let(:company) { ENV['SYSPRO_COMPANY'] } @@ -15,10 +18,10 @@ class PorTorTest < Minitest::Test def test_portor receipt_intero = Syspro::BusinessObjects::Models::ReceiptInterospection.new - receipt_intero.purchase_order = "Z01310" + receipt_intero.purchase_order = "Z01308" receipt_intero.warehouse = "P0" receipt_intero.stock_code = "8801" - receipt_intero.quantity = 10.21 + receipt_intero.quantity = 0.01 receipt_intero.delivery_note = "DELIVER NOTE HERE-WL" receipt_intero.certificate = "8/45-3" receipt_intero.lot = "7097505" @@ -32,4 +35,4 @@ class PorTorTest < Minitest::Test assert_equal resp[:error_numbers].length, 0 end -end \ No newline at end of file +end -- libgit2 0.21.4