diff --git a/lib/syspro.rb b/lib/syspro.rb
index 50fd057..70de608 100644
--- a/lib/syspro.rb
+++ b/lib/syspro.rb
@@ -24,23 +24,38 @@ require 'syspro/version'
require 'syspro/api_operations/request'
require 'syspro/api_operations/query'
require 'syspro/api_operations/transaction'
+require 'syspro/api_operations/setup'
require 'syspro/business_objects/combrw'
require 'syspro/business_objects/comfch'
require 'syspro/business_objects/comfnd'
require 'syspro/business_objects/sorqry'
require 'syspro/business_objects/portor'
+require 'syspro/business_objects/portoi'
require 'syspro/business_objects/porqry'
+require 'syspro/business_objects/comsfm'
require 'syspro/business_objects/models/sor'
require 'syspro/business_objects/models/sor_detail'
require 'syspro/business_objects/models/por_detail'
+require 'syspro/business_objects/models/purchase_order'
+require 'syspro/business_objects/models/purchase_orders/header'
+require 'syspro/business_objects/models/purchase_orders/order_details'
+require 'syspro/business_objects/models/purchase_orders/stock_line'
+require 'syspro/business_objects/models/purchase_orders/freight_line'
+require 'syspro/business_objects/models/purchase_orders/misc_charge_line'
+require 'syspro/business_objects/models/purchase_orders/comment_line'
+
+require 'syspro/business_objects/models/comsfm_item'
+
require 'syspro/business_objects/parsers/combrw_parser'
require 'syspro/business_objects/parsers/comfch_parser'
require 'syspro/business_objects/parsers/comfnd_parser'
require 'syspro/business_objects/parsers/sorqry_parser'
require 'syspro/business_objects/parsers/portor_parser'
+require 'syspro/business_objects/parsers/portoi_parser'
+require 'syspro/business_objects/parsers/comsfm_parser'
# Main Module
module Syspro
diff --git a/lib/syspro/api_operations/setup.rb b/lib/syspro/api_operations/setup.rb
new file mode 100644
index 0000000..fa77dd5
--- /dev/null
+++ b/lib/syspro/api_operations/setup.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module Syspro
+ module ApiOperations
+ module Setup
+ module ClassMethods
+ def add(params)
+ request(:get, '/Setup/Add', params)
+ end
+
+ def update(params)
+ request(:get, '/Setup/Update', params)
+ end
+
+ def delete(params)
+ request(:get, '/Setup/Delete', params)
+ end
+
+ private
+
+ def warn_on_opts_in_params(params)
+ Util::OPTS_USER_SPECIFIED.each do |opt|
+ if params.key?(opt)
+ warn("WARNING: #{opt} should be in opts instead of params.")
+ end
+ end
+ end
+ end # ClassMethods
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ protected
+
+ 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/comsfm.rb b/lib/syspro/business_objects/comsfm.rb
new file mode 100644
index 0000000..8d337fc
--- /dev/null
+++ b/lib/syspro/business_objects/comsfm.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'syspro/business_objects/parsers/comsfm_parser'
+require 'erb'
+
+module Syspro
+ module BusinessObjects
+ class ComsFm < ApiResource
+ include Syspro::ApiOperations::Setup
+ include Syspro::BusinessObjects::Parsers
+
+ attr_accessor :validate_only,
+ :items
+
+ def call(user_id)
+ xml_parameters = params_template.result(binding)
+ xml_in = template.result(binding)
+ business_object = 'COMSFM'
+ params = { 'UserId' => user_id,
+ 'BusinessObject' => business_object,
+ 'XmlParameters' => xml_parameters,
+ 'XmlIn' => xml_in }
+ resp = ComsFm.add(params)
+
+ parse_response(resp)
+ end
+
+ def template
+ ERB.new File.read(File.expand_path('schemas/comsfm_doc.xml.erb', File.dirname(__FILE__))), nil, '%'
+ end
+
+ def params_template
+ ERB.new File.read(File.expand_path('schemas/comsfm.xml.erb', File.dirname(__FILE__))), nil, '%'
+ end
+
+ def parse_response(resp)
+ handle_errors(resp)
+ parser = ComsFmParser.new(resp[0].data)
+ parser.parse
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/comsfm_item.rb b/lib/syspro/business_objects/models/comsfm_item.rb
new file mode 100644
index 0000000..3488fea
--- /dev/null
+++ b/lib/syspro/business_objects/models/comsfm_item.rb
@@ -0,0 +1,12 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ class ComsFmItem
+ attr_accessor :form_type,
+ :key_field,
+ :field_name,
+ :alpha_value
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_order.rb b/lib/syspro/business_objects/models/purchase_order.rb
new file mode 100644
index 0000000..698297a
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_order.rb
@@ -0,0 +1,13 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ class PurchaseOrder
+ attr_accessor :error_numbers,
+ :purchase_order,
+ :item_number,
+ :order_action_type,
+ :supplier
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_orders/comment_line.rb b/lib/syspro/business_objects/models/purchase_orders/comment_line.rb
new file mode 100644
index 0000000..f8c60c5
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/comment_line.rb
@@ -0,0 +1,16 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ module PurchaseOrders
+ class CommentLine
+ attr_accessor :purchase_order_line,
+ :line_action_type,
+ :comment,
+ :attached_to_stk_line_number,
+ :delete_attached_comment_lines,
+ :change_single_comment_line
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_orders/freight_line.rb b/lib/syspro/business_objects/models/purchase_orders/freight_line.rb
new file mode 100644
index 0000000..81fbeb3
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/freight_line.rb
@@ -0,0 +1,16 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ module PurchaseOrders
+ class FreightLine
+ attr_accessor :purchase_order_line,
+ :line_action_type,
+ :freight_value,
+ :freight_tax_code,
+ :freight_taxable
+ :freight_f_loc
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_orders/header.rb b/lib/syspro/business_objects/models/purchase_orders/header.rb
new file mode 100644
index 0000000..a9e5f05
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/header.rb
@@ -0,0 +1,44 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ module PurchaseOrders
+ class Header
+ attr_accessor :order_action_type,
+ :supplier,
+ :exch_rate_fixed,
+ :exchange_rate,
+ :order_type,
+ :customer,
+ :tax_status,
+ :payment_terms,
+ :invoice_terms,
+ :customer_po_number,
+ :shipping_instrs,
+ :order_date,
+ :due_date,
+ :memo_date,
+ :apply_due_date_to_lines,
+ :memo_code,
+ :buyer,
+ :delivery_name,
+ :delivery_addr1,
+ :delivery_addr2,
+ :delivery_addr3,
+ :delivery_addr4,
+ :delivery_addr5,
+ :postal_code,
+ :warehouse,
+ :discount_less_plus,
+ :disc_percent1,
+ :disc_percent2,
+ :disc_percent3,
+ :purchase_order,
+ :chg_po_stat_to_ready_to_print
+ end
+ end
+ 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
new file mode 100644
index 0000000..4d0adca
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb
@@ -0,0 +1,18 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ module PurchaseOrders
+ class MiscChargeLine
+ attr_accessor :purchase_order_line,
+ :line_action_type,
+ :misc_charge_value,
+ :misc_charge_tax,
+ :misc_taxable,
+ :misc_charge_f_loc,
+ :misc_description,
+ :misc_comment_code
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_orders/order_details.rb b/lib/syspro/business_objects/models/purchase_orders/order_details.rb
new file mode 100644
index 0000000..2d56a94
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/order_details.rb
@@ -0,0 +1,34 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ module PurchaseOrders
+ class OrderDetails
+ attr_accessor :stock_lines,
+ :comment_lines,
+ :misc_charge_lines,
+ :freight_lines
+
+ def has_data
+ has_stock || has_comment || has_misc_charge || has_freight
+ end
+
+ def has_stock
+ (stock_lines && stock_lines.length)
+ end
+
+ def has_comment
+ (comment_lines && comment_lines.length)
+ end
+
+ def has_misc_charge
+ (misc_charge_lines && misc_charge_lines.length)
+ end
+
+ def has_freight
+ (freight_lines && freight_lines.length)
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/syspro/business_objects/models/purchase_orders/stock_line.rb b/lib/syspro/business_objects/models/purchase_orders/stock_line.rb
new file mode 100644
index 0000000..cb6f1ed
--- /dev/null
+++ b/lib/syspro/business_objects/models/purchase_orders/stock_line.rb
@@ -0,0 +1,48 @@
+module Syspro
+ module BusinessObjects
+ module Models
+ 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
+ end
+ end
+ end
+ end
+end
+
+
+
diff --git a/lib/syspro/business_objects/parsers/comsfm_parser.rb b/lib/syspro/business_objects/parsers/comsfm_parser.rb
new file mode 100644
index 0000000..e90ccb1
--- /dev/null
+++ b/lib/syspro/business_objects/parsers/comsfm_parser.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module Syspro
+ module BusinessObjects
+ module Parsers
+ class ComsFmParser
+ attr_reader :doc
+
+ def initialize(doc)
+ @doc = doc
+ end
+
+ def parse
+ error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text}
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/syspro/business_objects/parsers/portoi_parser.rb b/lib/syspro/business_objects/parsers/portoi_parser.rb
new file mode 100644
index 0000000..44421ff
--- /dev/null
+++ b/lib/syspro/business_objects/parsers/portoi_parser.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Syspro
+ module BusinessObjects
+ module Parsers
+ class PorToiParser
+ attr_reader :doc
+
+ def initialize(doc)
+ @doc = doc
+ end
+
+ def parse
+ po = Syspro::BusinessObjects::Models::PurchaseOrder.new()
+
+ po.error_numbers = doc.xpath("//ErrorNumber").map{|e| e.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
+
+ PorToiObject = Struct.new(:key, :receipts)
+ end
+ end
+ end
+end
+
diff --git a/lib/syspro/business_objects/portoi.rb b/lib/syspro/business_objects/portoi.rb
new file mode 100644
index 0000000..048f8f8
--- /dev/null
+++ b/lib/syspro/business_objects/portoi.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+require 'syspro/business_objects/parsers/portoi_parser'
+require 'erb'
+
+module Syspro
+ module BusinessObjects
+ class PorToi < ApiResource
+ include Syspro::ApiOperations::Transaction
+ include Syspro::BusinessObjects::Parsers
+
+ # 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
+
+ def call(user_id)
+ xml_parameters = params_template.result(binding)
+ xml_in = template.result(binding)
+ business_object = 'PORTOI'
+ params = { 'UserId' => user_id,
+ 'BusinessObject' => business_object,
+ 'XmlParameters' => xml_parameters,
+ 'XmlIn' => xml_in }
+ resp = PorToi.post(params)
+
+ parse_response(resp)
+ end
+
+ def template
+ ERB.new File.read(File.expand_path('schemas/portoi_doc.xml.erb', File.dirname(__FILE__))), nil, '%'
+ end
+
+ def params_template
+ ERB.new File.read(File.expand_path('schemas/portoi.xml.erb', File.dirname(__FILE__))), nil, '%'
+ end
+
+ def parse_response(resp)
+ handle_errors(resp)
+ parser = PorToiParser.new(resp[0].data)
+ parser.parse
+ end
+
+ def render_xml(inner_text)
+ inner_text ? inner_text.to_s : ''
+ end
+ end
+ end
+end
+
diff --git a/lib/syspro/business_objects/schemas/comsfm.xml.erb b/lib/syspro/business_objects/schemas/comsfm.xml.erb
new file mode 100644
index 0000000..8f21bc5
--- /dev/null
+++ b/lib/syspro/business_objects/schemas/comsfm.xml.erb
@@ -0,0 +1,5 @@
+
+
+ <%= @validate_only ? "Y" : "N" %>
+
+
\ No newline at end of file
diff --git a/lib/syspro/business_objects/schemas/comsfm_doc.xml.erb b/lib/syspro/business_objects/schemas/comsfm_doc.xml.erb
new file mode 100644
index 0000000..68d6d75
--- /dev/null
+++ b/lib/syspro/business_objects/schemas/comsfm_doc.xml.erb
@@ -0,0 +1,12 @@
+
+<% @items.each do |item| %>
+ -
+
+ <%= item.form_type %>
+ <%= item.key_field %>
+ <%= item.field_name %>
+
+ <%= item.alpha_value ? "Y" : "N" %>
+
+<% end %>
+
\ No newline at end of file
diff --git a/lib/syspro/business_objects/schemas/portoi.xml.erb b/lib/syspro/business_objects/schemas/portoi.xml.erb
new file mode 100644
index 0000000..11b4f56
--- /dev/null
+++ b/lib/syspro/business_objects/schemas/portoi.xml.erb
@@ -0,0 +1,20 @@
+
+
+
+ <%= @validate_only ? @validate_only : "N" %>
+ <%= @ignore_warnings ? @ignore_warnings : "N" %>
+ <%= @allow_non_stock_items ? @allow_non_stock_items : "N" %>
+ <%= @allow_zero_price ? @allow_zero_price : "N" %>
+ <%= @validate_working_days ? @validate_working_days : "N" %>
+ <%= @allow_po_when_blanket_po ? @allow_po_when_blanket_po : "N" %>
+ <%= @default_memo_code ? default_memo_code.to_s : "" %>
+ <%= @fixed_exchange_rate ? @fixed_exchange_rate : "N" %>
+ <%= @default_memo_days ? @default_memo_days.to_s : "0" %>
+ <%= @allow_blank_ledger_code ? @allow_blank_ledger_code : "N" %>
+
+ <%= @calc_due_date ? @calc_due_date : "N" %>
+ <%= @insert_dangerous_goods_text ? @insert_dangerous_goods_text : "N" %>
+ <%= @insert_additional_po_text ? @insert_additional_po_text : "N" %>
+ <%= @status ? status.to_s : "1" %>
+
+
\ No newline at end of file
diff --git a/lib/syspro/business_objects/schemas/portoi_doc.xml.erb b/lib/syspro/business_objects/schemas/portoi_doc.xml.erb
new file mode 100644
index 0000000..27dff48
--- /dev/null
+++ b/lib/syspro/business_objects/schemas/portoi_doc.xml.erb
@@ -0,0 +1,138 @@
+
+
+
+
+ <%= render_xml(@purchase_order_header.order_action_type) %>
+ <%= render_xml(@purchase_order_header.supplier) %>
+ <%= render_xml(@purchase_order_header.exch_rate_fixed) %>
+ <%= render_xml(@purchase_order_header.exchange_rate) %>
+ <%= render_xml(@purchase_order_header.order_type) %>
+ <%= render_xml(@purchase_order_header.customer) %>
+ <%= render_xml(@purchase_order_header.tax_status) %>
+ <%= render_xml(@purchase_order_header.payment_terms) %>
+ <%= render_xml(@purchase_order_header.invoice_terms) %>
+ <%= render_xml(@purchase_order_header.customer_po_number) %>
+ <%= render_xml(@purchase_order_header.shipping_instrs) %>
+ <%= render_xml(@purchase_order_header.order_date) %>
+ <%= render_xml(@purchase_order_header.due_date) %>
+ <%= render_xml(@purchase_order_header.memo_date) %>
+ <%= render_xml(@purchase_order_header.apply_due_date_to_lines) %>
+ <%= render_xml(@purchase_order_header.memo_code) %>
+ <%= render_xml(@purchase_order_header.buyer) %>
+ <%= render_xml(@purchase_order_header.delivery_name) %>
+ <%= render_xml(@purchase_order_header.delivery_addr1) %>
+ <%= render_xml(@purchase_order_header.delivery_addr2) %>
+ <%= render_xml(@purchase_order_header.delivery_addr3) %>
+ <%= render_xml(@purchase_order_header.delivery_addr4) %>
+ <%= render_xml(@purchase_order_header.delivery_addr5) %>
+ <%= render_xml(@purchase_order_header.postal_code) %>
+ <%= render_xml(@purchase_order_header.warehouse) %>
+ <%= render_xml(@purchase_order_header.discount_less_plus) %>
+ <%= render_xml(@purchase_order_header.disc_percent1) %>
+ <%= render_xml(@purchase_order_header.disc_percent2) %>
+ <%= render_xml(@purchase_order_header.disc_percent3) %>
+ <%= render_xml(@purchase_order_header.purchase_order) %>
+ <%= render_xml(@purchase_order_header.chg_po_stat_to_ready_to_print) %>
+
+ <%
+ if @order_details && @order_details.has_data
+ %>
+
+ <%
+ if @order_details.has_stock
+ @order_details.stock_lines.each do |stock_line|
+ %>
+
+ <%= render_xml(stock_line.purchase_order_line) %>
+ <%= render_xml(stock_line.line_action_type)%>
+ <%= render_xml(stock_line.stock_code)%>
+ <%= render_xml(stock_line.stock_description)%>
+ <%= render_xml(stock_line.warehouse)%>
+ <%= render_xml(stock_line.sup_catalogue)%>
+ <%= render_xml(stock_line.order_qty)%>
+ <%= render_xml(stock_line.order_uom)%>
+ <%= render_xml(stock_line.units)%>
+ <%= render_xml(stock_line.pieces)%>
+ <%= render_xml(stock_line.price_method)%>
+ <%= render_xml(stock_line.supplier_contract)%>
+ <%= render_xml(stock_line.price)%>
+ <%= render_xml(stock_line.price_uom)%>
+ <%= render_xml(stock_line.line_disc_type)%>
+ <%= render_xml(stock_line.line_disc_less_plus)%>
+ <%= render_xml(stock_line.line_disc_percent1)%>
+ <%= render_xml(stock_line.line_disc_percent2)%>
+ <%= render_xml(stock_line.line_disc_percent3)%>
+ <%= render_xml(stock_line.line_disc_value)%>
+ <%= render_xml(stock_line.taxable)%>
+ <%= render_xml(stock_line.tax_codev)%>
+ <%= render_xml(stock_line.job)%>
+ <%= render_xml(stock_line.version)%>
+ <%= render_xml(stock_line.release)%>
+ <%= render_xml(stock_line.latest_due_date)%>
+ <%= render_xml(stock_line.original_due_date)%>
+ <%= render_xml(stock_line.reschedule_due_date)%>
+ <%= render_xml(stock_line.ledger_code)%>
+ <%= render_xml(stock_line.password_for_ledger_code)%>
+ <%= render_xml(stock_line.subcontract_op)%>
+ <%= render_xml(stock_line.inspection_reqd)%>
+ <%= render_xml(stock_line.product_class)%>
+ <%= render_xml(stock_line.nons_unit_mass)%>
+ <%= render_xml(stock_line.nons_unit_vol)%>
+
+ <%
+ end
+ end
+
+ if @order_details.has_comment
+ @order_details.comment_lines.each do |comment_line|
+ %>
+
+ <%= render_xml(comment_line.purchase_order_line)%>
+ <%= render_xml(comment_line.line_action_type)%>
+ <%= render_xml(comment_line.comment)%>
+ <%= render_xml(comment_line.attached_to_stk_line_number)%>
+ <%= render_xml(comment_line.delete_attached_comment_lines)%>
+ <%= render_xml(comment_line.change_single_comment_line)%>
+
+ <%
+ end
+ end
+
+ if @order_details.has_misc_charge
+ @order_details.misc_charge_lines.each do |misc_charge_line|
+ %>
+
+ <%= render_xml(misc_charge_line.purchase_order_line)%>
+ <%= render_xml(misc_charge_line.line_action_type)%>
+ <%= render_xml(misc_charge_line.misc_charge_value)%>
+ <%= render_xml(misc_charge_line.misc_charge_tax)%>
+ <%= render_xml(misc_charge_line.misc_taxable)%>
+ <%= render_xml(misc_charge_line.misc_charge_f_loc)%>
+ <%= render_xml(misc_charge_line.misc_description)%>
+ <%= render_xml(misc_charge_line.misc_comment_code)%>
+
+ <%
+ end
+ end
+
+ if @order_details.has_freight
+ @order_details.freight_lines.each do |freight_line|
+ %>
+
+ <%= render_xml(freight_line.purchase_order_line)%>
+ <%= render_xml(freight_line.line_action_type)%>
+ <%= render_xml(freight_line.freight_value)%>
+ <%= render_xml(freight_line.freight_tax_code)%>
+ <%= render_xml(freight_line.freight_taxable)%>
+ <%= render_xml(freight_line.freight_f_loc)%>
+
+ <%
+ end
+ end
+ %>
+
+ <%
+ end
+ %>
+
+
\ No newline at end of file
diff --git a/test/comsfm_test.rb b/test/comsfm_test.rb
new file mode 100644
index 0000000..32e1708
--- /dev/null
+++ b/test/comsfm_test.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class ComsFmTest < Minitest::Test
+ extend Minitest::Spec::DSL
+
+ let(:username) { ENV['SYSPRO_USERNAME'] }
+ let(:password) { ENV['SYSPRO_PASSWORD'] }
+ let(:company) { ENV['SYSPRO_COMPANY'] }
+ let(:company_password) { '' }
+ let(:user_id) do
+ Syspro::Logon.logon(username, password, company, company_password)
+ end
+
+ def test_comsfm
+ cust_item = Syspro::BusinessObjects::Models::ComsFmItem.new
+ cust_item.form_type = "POR"
+ cust_item.key_field = "U03421"
+ cust_item.field_name = "TempPO"
+ cust_item.alpha_value = "Y"
+
+ cust_form = Syspro::BusinessObjects::ComsFm.new
+ cust_form.validate_only = "Y"
+ cust_form.items = [cust_item]
+
+ errors = cust_form.call(user_id.guid)
+
+ assert_equal errors.length, 0
+ end
+end
\ No newline at end of file
diff --git a/test/portoi_test.rb b/test/portoi_test.rb
new file mode 100644
index 0000000..6daad24
--- /dev/null
+++ b/test/portoi_test.rb
@@ -0,0 +1,78 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class PorToiTest < Minitest::Test
+ extend Minitest::Spec::DSL
+
+ let(:username) { ENV['SYSPRO_USERNAME'] }
+ let(:password) { ENV['SYSPRO_PASSWORD'] }
+ let(:company) { ENV['SYSPRO_COMPANY'] }
+ let(:company_password) { '' }
+ let(:user_id) do
+ Syspro::Logon.logon(username, password, company, company_password)
+ end
+
+ def test_portoi
+ po = Syspro::BusinessObjects::PorToi.new
+ 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.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"
+
+ # 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.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.price = 0
+ 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"
+
+ po.order_details = Syspro::BusinessObjects::Models::PurchaseOrders::OrderDetails.new
+ po.order_details.stock_lines = [line1]
+ binding.pry
+
+ syspro_po = po.call(user_id.guid)
+
+ assert_equal syspro_po.error_numbers.length, 0
+ end
+end
\ No newline at end of file
diff --git a/test/test_helper.rb b/test/test_helper.rb
index ab490aa..22b4853 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -11,6 +11,7 @@ require 'webmock'
VCR.configure do |c|
c.cassette_library_dir = 'test/cassettes'
c.hook_into :webmock
+ c.allow_http_connections_when_no_cassette = true
c.filter_sensitive_data('') { ENV['SYSPRO_USERNAME'] }
c.filter_sensitive_data('') { ENV['SYSPRO_PASSWORD'] }
c.filter_sensitive_data('') { ENV['SYSPRO_COMPANY'] }
--
libgit2 0.21.4