Commit d9a9cb5d7c94bd0e9446633c1cd1a98b02804098
Committed by
GitHub
1 parent
23108441
Add portoi and comsfm bus obj (#11)
* WIP * Added ComsFn for custom form data and finished off PorToi to send new Purchase Orders * Finished Add Purchase Order with header and lines Fixes #752 in LMT 2.0
Showing
21 changed files
with
702 additions
and
0 deletions
Show diff stats
lib/syspro.rb
| ... | ... | @@ -24,23 +24,38 @@ require 'syspro/version' |
| 24 | 24 | require 'syspro/api_operations/request' |
| 25 | 25 | require 'syspro/api_operations/query' |
| 26 | 26 | require 'syspro/api_operations/transaction' |
| 27 | +require 'syspro/api_operations/setup' | |
| 27 | 28 | |
| 28 | 29 | require 'syspro/business_objects/combrw' |
| 29 | 30 | require 'syspro/business_objects/comfch' |
| 30 | 31 | require 'syspro/business_objects/comfnd' |
| 31 | 32 | require 'syspro/business_objects/sorqry' |
| 32 | 33 | require 'syspro/business_objects/portor' |
| 34 | +require 'syspro/business_objects/portoi' | |
| 33 | 35 | require 'syspro/business_objects/porqry' |
| 36 | +require 'syspro/business_objects/comsfm' | |
| 34 | 37 | |
| 35 | 38 | require 'syspro/business_objects/models/sor' |
| 36 | 39 | require 'syspro/business_objects/models/sor_detail' |
| 37 | 40 | require 'syspro/business_objects/models/por_detail' |
| 38 | 41 | |
| 42 | +require 'syspro/business_objects/models/purchase_order' | |
| 43 | +require 'syspro/business_objects/models/purchase_orders/header' | |
| 44 | +require 'syspro/business_objects/models/purchase_orders/order_details' | |
| 45 | +require 'syspro/business_objects/models/purchase_orders/stock_line' | |
| 46 | +require 'syspro/business_objects/models/purchase_orders/freight_line' | |
| 47 | +require 'syspro/business_objects/models/purchase_orders/misc_charge_line' | |
| 48 | +require 'syspro/business_objects/models/purchase_orders/comment_line' | |
| 49 | + | |
| 50 | +require 'syspro/business_objects/models/comsfm_item' | |
| 51 | + | |
| 39 | 52 | require 'syspro/business_objects/parsers/combrw_parser' |
| 40 | 53 | require 'syspro/business_objects/parsers/comfch_parser' |
| 41 | 54 | require 'syspro/business_objects/parsers/comfnd_parser' |
| 42 | 55 | require 'syspro/business_objects/parsers/sorqry_parser' |
| 43 | 56 | require 'syspro/business_objects/parsers/portor_parser' |
| 57 | +require 'syspro/business_objects/parsers/portoi_parser' | |
| 58 | +require 'syspro/business_objects/parsers/comsfm_parser' | |
| 44 | 59 | |
| 45 | 60 | # Main Module |
| 46 | 61 | module Syspro | ... | ... |
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +module Syspro | |
| 4 | + module ApiOperations | |
| 5 | + module Setup | |
| 6 | + module ClassMethods | |
| 7 | + def add(params) | |
| 8 | + request(:get, '/Setup/Add', params) | |
| 9 | + end | |
| 10 | + | |
| 11 | + def update(params) | |
| 12 | + request(:get, '/Setup/Update', params) | |
| 13 | + end | |
| 14 | + | |
| 15 | + def delete(params) | |
| 16 | + request(:get, '/Setup/Delete', params) | |
| 17 | + end | |
| 18 | + | |
| 19 | + private | |
| 20 | + | |
| 21 | + def warn_on_opts_in_params(params) | |
| 22 | + Util::OPTS_USER_SPECIFIED.each do |opt| | |
| 23 | + if params.key?(opt) | |
| 24 | + warn("WARNING: #{opt} should be in opts instead of params.") | |
| 25 | + end | |
| 26 | + end | |
| 27 | + end | |
| 28 | + end # ClassMethods | |
| 29 | + | |
| 30 | + def self.included(base) | |
| 31 | + base.extend(ClassMethods) | |
| 32 | + end | |
| 33 | + | |
| 34 | + protected | |
| 35 | + | |
| 36 | + def request(method, url, params = {}, opts ={}) | |
| 37 | + opts = @opts.merge(Util.normalize_opts(opts)) | |
| 38 | + Request.request(method, url, params, opts) | |
| 39 | + end | |
| 40 | + end | |
| 41 | + end | |
| 42 | +end | |
| 43 | + | ... | ... |
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +require 'syspro/business_objects/parsers/comsfm_parser' | |
| 4 | +require 'erb' | |
| 5 | + | |
| 6 | +module Syspro | |
| 7 | + module BusinessObjects | |
| 8 | + class ComsFm < ApiResource | |
| 9 | + include Syspro::ApiOperations::Setup | |
| 10 | + include Syspro::BusinessObjects::Parsers | |
| 11 | + | |
| 12 | + attr_accessor :validate_only, | |
| 13 | + :items | |
| 14 | + | |
| 15 | + def call(user_id) | |
| 16 | + xml_parameters = params_template.result(binding) | |
| 17 | + xml_in = template.result(binding) | |
| 18 | + business_object = 'COMSFM' | |
| 19 | + params = { 'UserId' => user_id, | |
| 20 | + 'BusinessObject' => business_object, | |
| 21 | + 'XmlParameters' => xml_parameters, | |
| 22 | + 'XmlIn' => xml_in } | |
| 23 | + resp = ComsFm.add(params) | |
| 24 | + | |
| 25 | + parse_response(resp) | |
| 26 | + end | |
| 27 | + | |
| 28 | + def template | |
| 29 | + ERB.new File.read(File.expand_path('schemas/comsfm_doc.xml.erb', File.dirname(__FILE__))), nil, '%' | |
| 30 | + end | |
| 31 | + | |
| 32 | + def params_template | |
| 33 | + ERB.new File.read(File.expand_path('schemas/comsfm.xml.erb', File.dirname(__FILE__))), nil, '%' | |
| 34 | + end | |
| 35 | + | |
| 36 | + def parse_response(resp) | |
| 37 | + handle_errors(resp) | |
| 38 | + parser = ComsFmParser.new(resp[0].data) | |
| 39 | + parser.parse | |
| 40 | + end | |
| 41 | + end | |
| 42 | + end | |
| 43 | +end | |
| 0 | 44 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/models/comsfm_item.rb
0 โ 100644
lib/syspro/business_objects/models/purchase_order.rb
0 โ 100644
lib/syspro/business_objects/models/purchase_orders/comment_line.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class CommentLine | |
| 6 | + attr_accessor :purchase_order_line, | |
| 7 | + :line_action_type, | |
| 8 | + :comment, | |
| 9 | + :attached_to_stk_line_number, | |
| 10 | + :delete_attached_comment_lines, | |
| 11 | + :change_single_comment_line | |
| 12 | + end | |
| 13 | + end | |
| 14 | + end | |
| 15 | + end | |
| 16 | +end | |
| 0 | 17 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/models/purchase_orders/freight_line.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class FreightLine | |
| 6 | + attr_accessor :purchase_order_line, | |
| 7 | + :line_action_type, | |
| 8 | + :freight_value, | |
| 9 | + :freight_tax_code, | |
| 10 | + :freight_taxable | |
| 11 | + :freight_f_loc | |
| 12 | + end | |
| 13 | + end | |
| 14 | + end | |
| 15 | + end | |
| 16 | +end | |
| 0 | 17 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/models/purchase_orders/header.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class Header | |
| 6 | + attr_accessor :order_action_type, | |
| 7 | + :supplier, | |
| 8 | + :exch_rate_fixed, | |
| 9 | + :exchange_rate, | |
| 10 | + :order_type, | |
| 11 | + :customer, | |
| 12 | + :tax_status, | |
| 13 | + :payment_terms, | |
| 14 | + :invoice_terms, | |
| 15 | + :customer_po_number, | |
| 16 | + :shipping_instrs, | |
| 17 | + :order_date, | |
| 18 | + :due_date, | |
| 19 | + :memo_date, | |
| 20 | + :apply_due_date_to_lines, | |
| 21 | + :memo_code, | |
| 22 | + :buyer, | |
| 23 | + :delivery_name, | |
| 24 | + :delivery_addr1, | |
| 25 | + :delivery_addr2, | |
| 26 | + :delivery_addr3, | |
| 27 | + :delivery_addr4, | |
| 28 | + :delivery_addr5, | |
| 29 | + :postal_code, | |
| 30 | + :warehouse, | |
| 31 | + :discount_less_plus, | |
| 32 | + :disc_percent1, | |
| 33 | + :disc_percent2, | |
| 34 | + :disc_percent3, | |
| 35 | + :purchase_order, | |
| 36 | + :chg_po_stat_to_ready_to_print | |
| 37 | + end | |
| 38 | + end | |
| 39 | + end | |
| 40 | + end | |
| 41 | +end | |
| 42 | + | |
| 43 | + | |
| 44 | + | ... | ... |
lib/syspro/business_objects/models/purchase_orders/misc_charge_line.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class MiscChargeLine | |
| 6 | + attr_accessor :purchase_order_line, | |
| 7 | + :line_action_type, | |
| 8 | + :misc_charge_value, | |
| 9 | + :misc_charge_tax, | |
| 10 | + :misc_taxable, | |
| 11 | + :misc_charge_f_loc, | |
| 12 | + :misc_description, | |
| 13 | + :misc_comment_code | |
| 14 | + end | |
| 15 | + end | |
| 16 | + end | |
| 17 | + end | |
| 18 | +end | |
| 0 | 19 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/models/purchase_orders/order_details.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class OrderDetails | |
| 6 | + attr_accessor :stock_lines, | |
| 7 | + :comment_lines, | |
| 8 | + :misc_charge_lines, | |
| 9 | + :freight_lines | |
| 10 | + | |
| 11 | + def has_data | |
| 12 | + has_stock || has_comment || has_misc_charge || has_freight | |
| 13 | + end | |
| 14 | + | |
| 15 | + def has_stock | |
| 16 | + (stock_lines && stock_lines.length) | |
| 17 | + end | |
| 18 | + | |
| 19 | + def has_comment | |
| 20 | + (comment_lines && comment_lines.length) | |
| 21 | + end | |
| 22 | + | |
| 23 | + def has_misc_charge | |
| 24 | + (misc_charge_lines && misc_charge_lines.length) | |
| 25 | + end | |
| 26 | + | |
| 27 | + def has_freight | |
| 28 | + (freight_lines && freight_lines.length) | |
| 29 | + end | |
| 30 | + end | |
| 31 | + end | |
| 32 | + end | |
| 33 | + end | |
| 34 | +end | |
| 0 | 35 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/models/purchase_orders/stock_line.rb
0 โ 100644
| 1 | +module Syspro | |
| 2 | + module BusinessObjects | |
| 3 | + module Models | |
| 4 | + module PurchaseOrders | |
| 5 | + class StockLine | |
| 6 | + attr_accessor :purchase_order_line, | |
| 7 | + :line_action_type, | |
| 8 | + :stock_code, | |
| 9 | + :stock_description, | |
| 10 | + :warehouse, | |
| 11 | + :sup_catalogue, | |
| 12 | + :order_qty, | |
| 13 | + :order_uom, | |
| 14 | + :units, | |
| 15 | + :pieces, | |
| 16 | + :price_method, | |
| 17 | + :supplier_contract, | |
| 18 | + :price, | |
| 19 | + :price_uom, | |
| 20 | + :line_disc_type, | |
| 21 | + :line_disc_less_plus, | |
| 22 | + :line_disc_percent1, | |
| 23 | + :line_disc_percent2, | |
| 24 | + :line_disc_percent3, | |
| 25 | + :line_disc_value, | |
| 26 | + :taxable, | |
| 27 | + :tax_codev, | |
| 28 | + :job, | |
| 29 | + :version, | |
| 30 | + :release, | |
| 31 | + :latest_due_date, | |
| 32 | + :original_due_date, | |
| 33 | + :reschedule_due_date, | |
| 34 | + :ledger_code, | |
| 35 | + :password_for_ledger_code, | |
| 36 | + :subcontract_op, | |
| 37 | + :inspection_reqd, | |
| 38 | + :product_class, | |
| 39 | + :nons_unit_mass, | |
| 40 | + :nons_unit_vol | |
| 41 | + end | |
| 42 | + end | |
| 43 | + end | |
| 44 | + end | |
| 45 | +end | |
| 46 | + | |
| 47 | + | |
| 48 | + | ... | ... |
lib/syspro/business_objects/parsers/comsfm_parser.rb
0 โ 100644
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +module Syspro | |
| 4 | + module BusinessObjects | |
| 5 | + module Parsers | |
| 6 | + class ComsFmParser | |
| 7 | + attr_reader :doc | |
| 8 | + | |
| 9 | + def initialize(doc) | |
| 10 | + @doc = doc | |
| 11 | + end | |
| 12 | + | |
| 13 | + def parse | |
| 14 | + error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} | |
| 15 | + end | |
| 16 | + end | |
| 17 | + end | |
| 18 | + end | |
| 19 | +end | |
| 20 | + | ... | ... |
lib/syspro/business_objects/parsers/portoi_parser.rb
0 โ 100644
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +module Syspro | |
| 4 | + module BusinessObjects | |
| 5 | + module Parsers | |
| 6 | + class PorToiParser | |
| 7 | + attr_reader :doc | |
| 8 | + | |
| 9 | + def initialize(doc) | |
| 10 | + @doc = doc | |
| 11 | + end | |
| 12 | + | |
| 13 | + def parse | |
| 14 | + po = Syspro::BusinessObjects::Models::PurchaseOrder.new() | |
| 15 | + | |
| 16 | + po.error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} | |
| 17 | + | |
| 18 | + po.purchase_order = doc.first_element_child.xpath('Order/Key/PurchaseOrder').text | |
| 19 | + po.item_number = doc.first_element_child.xpath('Order/ItemNumber').text | |
| 20 | + po.order_action_type = doc.first_element_child.xpath('Order/OrderActionType').text | |
| 21 | + po.supplier = doc.first_element_child.xpath('Order/Supplier').text | |
| 22 | + | |
| 23 | + po | |
| 24 | + end | |
| 25 | + | |
| 26 | + PorToiObject = Struct.new(:key, :receipts) | |
| 27 | + end | |
| 28 | + end | |
| 29 | + end | |
| 30 | +end | |
| 31 | + | ... | ... |
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +require 'syspro/business_objects/parsers/portoi_parser' | |
| 4 | +require 'erb' | |
| 5 | + | |
| 6 | +module Syspro | |
| 7 | + module BusinessObjects | |
| 8 | + class PorToi < ApiResource | |
| 9 | + include Syspro::ApiOperations::Transaction | |
| 10 | + include Syspro::BusinessObjects::Parsers | |
| 11 | + | |
| 12 | + # input params | |
| 13 | + attr_accessor :purchase_order_header, | |
| 14 | + :order_details, | |
| 15 | + :validate_only, | |
| 16 | + :ignore_warnings, | |
| 17 | + :allow_non_stock_items, | |
| 18 | + :allow_zero_price, | |
| 19 | + :validate_working_days, | |
| 20 | + :allow_po_when_blanket_po, | |
| 21 | + :default_memo_code, | |
| 22 | + :fixed_exchange_rate, | |
| 23 | + :default_memo_days, | |
| 24 | + :allow_blank_ledger_code, | |
| 25 | + :calc_due_date, | |
| 26 | + :default_delivery_address, | |
| 27 | + :insert_dangerous_goods_text, | |
| 28 | + :insert_additional_po_text, | |
| 29 | + :status | |
| 30 | + | |
| 31 | + def call(user_id) | |
| 32 | + xml_parameters = params_template.result(binding) | |
| 33 | + xml_in = template.result(binding) | |
| 34 | + business_object = 'PORTOI' | |
| 35 | + params = { 'UserId' => user_id, | |
| 36 | + 'BusinessObject' => business_object, | |
| 37 | + 'XmlParameters' => xml_parameters, | |
| 38 | + 'XmlIn' => xml_in } | |
| 39 | + resp = PorToi.post(params) | |
| 40 | + | |
| 41 | + parse_response(resp) | |
| 42 | + end | |
| 43 | + | |
| 44 | + def template | |
| 45 | + ERB.new File.read(File.expand_path('schemas/portoi_doc.xml.erb', File.dirname(__FILE__))), nil, '%' | |
| 46 | + end | |
| 47 | + | |
| 48 | + def params_template | |
| 49 | + ERB.new File.read(File.expand_path('schemas/portoi.xml.erb', File.dirname(__FILE__))), nil, '%' | |
| 50 | + end | |
| 51 | + | |
| 52 | + def parse_response(resp) | |
| 53 | + handle_errors(resp) | |
| 54 | + parser = PorToiParser.new(resp[0].data) | |
| 55 | + parser.parse | |
| 56 | + end | |
| 57 | + | |
| 58 | + def render_xml(inner_text) | |
| 59 | + inner_text ? inner_text.to_s : '' | |
| 60 | + end | |
| 61 | + end | |
| 62 | + end | |
| 63 | +end | |
| 64 | + | ... | ... |
lib/syspro/business_objects/schemas/comsfm.xml.erb
0 โ 100644
lib/syspro/business_objects/schemas/comsfm_doc.xml.erb
0 โ 100644
| 1 | +<SetupCustomForm xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="COMSFMDOC.XSD"> | |
| 2 | +<% @items.each do |item| %> | |
| 3 | + <Item> | |
| 4 | + <Key> | |
| 5 | + <FormType><%= item.form_type %></FormType> | |
| 6 | + <KeyField><%= item.key_field %></KeyField> | |
| 7 | + <FieldName><%= item.field_name %></FieldName> | |
| 8 | + </Key> | |
| 9 | + <AlphaValue><%= item.alpha_value ? "Y" : "N" %></AlphaValue> | |
| 10 | + </Item> | |
| 11 | +<% end %> | |
| 12 | +</SetupCustomForm> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/schemas/portoi.xml.erb
0 โ 100644
| 1 | +<?xml version="1.0" encoding="Windows-1252"?> | |
| 2 | +<PostPurchaseOrders xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="PORTOI.XSD"> | |
| 3 | + <Parameters> | |
| 4 | + <ValidateOnly><%= @validate_only ? @validate_only : "N" %></ValidateOnly> | |
| 5 | + <IgnoreWarnings><%= @ignore_warnings ? @ignore_warnings : "N" %></IgnoreWarnings> | |
| 6 | + <AllowNonStockItems><%= @allow_non_stock_items ? @allow_non_stock_items : "N" %></AllowNonStockItems> | |
| 7 | + <AllowZeroPrice><%= @allow_zero_price ? @allow_zero_price : "N" %></AllowZeroPrice> | |
| 8 | + <ValidateWorkingDays><%= @validate_working_days ? @validate_working_days : "N" %></ValidateWorkingDays> | |
| 9 | + <AllowPoWhenBlanketPo><%= @allow_po_when_blanket_po ? @allow_po_when_blanket_po : "N" %></AllowPoWhenBlanketPo> | |
| 10 | + <DefaultMemoCode><%= @default_memo_code ? default_memo_code.to_s : "" %></DefaultMemoCode> | |
| 11 | + <FixedExchangeRate><%= @fixed_exchange_rate ? @fixed_exchange_rate : "N" %></FixedExchangeRate> | |
| 12 | + <DefaultMemoDays><%= @default_memo_days ? @default_memo_days.to_s : "0" %></DefaultMemoDays> | |
| 13 | + <AllowBlankLedgerCode><%= @allow_blank_ledger_code ? @allow_blank_ledger_code : "N" %></AllowBlankLedgerCode> | |
| 14 | + <DefaultDeliveryAddress/> | |
| 15 | + <CalcDueDate><%= @calc_due_date ? @calc_due_date : "N" %></CalcDueDate> | |
| 16 | + <InsertDangerousGoodsText><%= @insert_dangerous_goods_text ? @insert_dangerous_goods_text : "N" %></InsertDangerousGoodsText> | |
| 17 | + <InsertAdditionalPOText><%= @insert_additional_po_text ? @insert_additional_po_text : "N" %></InsertAdditionalPOText> | |
| 18 | + <Status><%= @status ? status.to_s : "1" %></Status> | |
| 19 | + </Parameters> | |
| 20 | +</PostPurchaseOrders> | |
| 0 | 21 | \ No newline at end of file | ... | ... |
lib/syspro/business_objects/schemas/portoi_doc.xml.erb
0 โ 100644
| 1 | +<?xml version="1.0" encoding="Windows-1252"?> | |
| 2 | +<PostPurchaseOrders xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="PORTOIDOC.XSD"> | |
| 3 | + <Orders> | |
| 4 | + <OrderHeader> | |
| 5 | + <OrderActionType><%= render_xml(@purchase_order_header.order_action_type) %></OrderActionType> | |
| 6 | + <Supplier><%= render_xml(@purchase_order_header.supplier) %></Supplier> | |
| 7 | + <ExchRateFixed><%= render_xml(@purchase_order_header.exch_rate_fixed) %></ExchRateFixed> | |
| 8 | + <ExchangeRate><%= render_xml(@purchase_order_header.exchange_rate) %></ExchangeRate> | |
| 9 | + <OrderType><%= render_xml(@purchase_order_header.order_type) %></OrderType> | |
| 10 | + <Customer><%= render_xml(@purchase_order_header.customer) %></Customer> | |
| 11 | + <TaxStatus><%= render_xml(@purchase_order_header.tax_status) %></TaxStatus> | |
| 12 | + <PaymentTerms><%= render_xml(@purchase_order_header.payment_terms) %></PaymentTerms> | |
| 13 | + <InvoiceTerms><%= render_xml(@purchase_order_header.invoice_terms) %></InvoiceTerms> | |
| 14 | + <CustomerPoNumber><%= render_xml(@purchase_order_header.customer_po_number) %></CustomerPoNumber> | |
| 15 | + <ShippingInstrs><%= render_xml(@purchase_order_header.shipping_instrs) %></ShippingInstrs> | |
| 16 | + <OrderDate><%= render_xml(@purchase_order_header.order_date) %></OrderDate> | |
| 17 | + <DueDate><%= render_xml(@purchase_order_header.due_date) %></DueDate> | |
| 18 | + <MemoDate><%= render_xml(@purchase_order_header.memo_date) %></MemoDate> | |
| 19 | + <ApplyDueDateToLines><%= render_xml(@purchase_order_header.apply_due_date_to_lines) %></ApplyDueDateToLines> | |
| 20 | + <MemoCode><%= render_xml(@purchase_order_header.memo_code) %></MemoCode> | |
| 21 | + <Buyer><%= render_xml(@purchase_order_header.buyer) %></Buyer> | |
| 22 | + <DeliveryName><%= render_xml(@purchase_order_header.delivery_name) %></DeliveryName> | |
| 23 | + <DeliveryAddr1><%= render_xml(@purchase_order_header.delivery_addr1) %></DeliveryAddr1> | |
| 24 | + <DeliveryAddr2><%= render_xml(@purchase_order_header.delivery_addr2) %></DeliveryAddr2> | |
| 25 | + <DeliveryAddr3><%= render_xml(@purchase_order_header.delivery_addr3) %></DeliveryAddr3> | |
| 26 | + <DeliveryAddr4><%= render_xml(@purchase_order_header.delivery_addr4) %></DeliveryAddr4> | |
| 27 | + <DeliveryAddr5><%= render_xml(@purchase_order_header.delivery_addr5) %></DeliveryAddr5> | |
| 28 | + <PostalCode><%= render_xml(@purchase_order_header.postal_code) %></PostalCode> | |
| 29 | + <Warehouse><%= render_xml(@purchase_order_header.warehouse) %></Warehouse> | |
| 30 | + <DiscountLessPlus><%= render_xml(@purchase_order_header.discount_less_plus) %></DiscountLessPlus> | |
| 31 | + <DiscPercent1><%= render_xml(@purchase_order_header.disc_percent1) %></DiscPercent1> | |
| 32 | + <DiscPercent2><%= render_xml(@purchase_order_header.disc_percent2) %></DiscPercent2> | |
| 33 | + <DiscPercent3><%= render_xml(@purchase_order_header.disc_percent3) %></DiscPercent3> | |
| 34 | + <PurchaseOrder><%= render_xml(@purchase_order_header.purchase_order) %></PurchaseOrder> | |
| 35 | + <ChgPOStatToReadyToPrint><%= render_xml(@purchase_order_header.chg_po_stat_to_ready_to_print) %></ChgPOStatToReadyToPrint> | |
| 36 | + </OrderHeader> | |
| 37 | + <% | |
| 38 | + if @order_details && @order_details.has_data | |
| 39 | + %> | |
| 40 | + <OrderDetails> | |
| 41 | + <% | |
| 42 | + if @order_details.has_stock | |
| 43 | + @order_details.stock_lines.each do |stock_line| | |
| 44 | + %> | |
| 45 | + <StockLine> | |
| 46 | + <PurchaseOrderLine><%= render_xml(stock_line.purchase_order_line) %></PurchaseOrderLine> | |
| 47 | + <LineActionType><%= render_xml(stock_line.line_action_type)%></LineActionType> | |
| 48 | + <StockCode><%= render_xml(stock_line.stock_code)%></StockCode> | |
| 49 | + <StockDescription><%= render_xml(stock_line.stock_description)%></StockDescription> | |
| 50 | + <Warehouse><%= render_xml(stock_line.warehouse)%></Warehouse> | |
| 51 | + <SupCatalogue><%= render_xml(stock_line.sup_catalogue)%></SupCatalogue> | |
| 52 | + <OrderQty><%= render_xml(stock_line.order_qty)%></OrderQty> | |
| 53 | + <OrderUom><%= render_xml(stock_line.order_uom)%></OrderUom> | |
| 54 | + <Units><%= render_xml(stock_line.units)%></Units> | |
| 55 | + <Pieces><%= render_xml(stock_line.pieces)%></Pieces> | |
| 56 | + <PriceMethod><%= render_xml(stock_line.price_method)%></PriceMethod> | |
| 57 | + <SupplierContract><%= render_xml(stock_line.supplier_contract)%></SupplierContract> | |
| 58 | + <Price><%= render_xml(stock_line.price)%></Price> | |
| 59 | + <PriceUom><%= render_xml(stock_line.price_uom)%></PriceUom> | |
| 60 | + <LineDiscType><%= render_xml(stock_line.line_disc_type)%></LineDiscType> | |
| 61 | + <LineDiscLessPlus><%= render_xml(stock_line.line_disc_less_plus)%></LineDiscLessPlus> | |
| 62 | + <LineDiscPercent1><%= render_xml(stock_line.line_disc_percent1)%></LineDiscPercent1> | |
| 63 | + <LineDiscPercent2><%= render_xml(stock_line.line_disc_percent2)%></LineDiscPercent2> | |
| 64 | + <LineDiscPercent3><%= render_xml(stock_line.line_disc_percent3)%></LineDiscPercent3> | |
| 65 | + <LineDiscValue><%= render_xml(stock_line.line_disc_value)%></LineDiscValue> | |
| 66 | + <Taxable><%= render_xml(stock_line.taxable)%></Taxable> | |
| 67 | + <TaxCode><%= render_xml(stock_line.tax_codev)%></TaxCode> | |
| 68 | + <Job><%= render_xml(stock_line.job)%></Job> | |
| 69 | + <Version><%= render_xml(stock_line.version)%></Version> | |
| 70 | + <Release><%= render_xml(stock_line.release)%></Release> | |
| 71 | + <LatestDueDate><%= render_xml(stock_line.latest_due_date)%></LatestDueDate> | |
| 72 | + <OriginalDueDate><%= render_xml(stock_line.original_due_date)%></OriginalDueDate> | |
| 73 | + <RescheduleDueDate><%= render_xml(stock_line.reschedule_due_date)%></RescheduleDueDate> | |
| 74 | + <LedgerCode><%= render_xml(stock_line.ledger_code)%></LedgerCode> | |
| 75 | + <PasswordForLedgerCode><%= render_xml(stock_line.password_for_ledger_code)%></PasswordForLedgerCode> | |
| 76 | + <SubcontractOp><%= render_xml(stock_line.subcontract_op)%></SubcontractOp> | |
| 77 | + <InspectionReqd><%= render_xml(stock_line.inspection_reqd)%></InspectionReqd> | |
| 78 | + <ProductClass><%= render_xml(stock_line.product_class)%></ProductClass> | |
| 79 | + <NonsUnitMass><%= render_xml(stock_line.nons_unit_mass)%></NonsUnitMass> | |
| 80 | + <NonsUnitVol><%= render_xml(stock_line.nons_unit_vol)%></NonsUnitVol> | |
| 81 | + </StockLine> | |
| 82 | + <% | |
| 83 | + end | |
| 84 | + end | |
| 85 | + | |
| 86 | + if @order_details.has_comment | |
| 87 | + @order_details.comment_lines.each do |comment_line| | |
| 88 | + %> | |
| 89 | + <CommentLine> | |
| 90 | + <PurchaseOrderLine><%= render_xml(comment_line.purchase_order_line)%></PurchaseOrderLine> | |
| 91 | + <LineActionType><%= render_xml(comment_line.line_action_type)%></LineActionType> | |
| 92 | + <Comment><%= render_xml(comment_line.comment)%></Comment> | |
| 93 | + <AttachedToStkLineNumber><%= render_xml(comment_line.attached_to_stk_line_number)%></AttachedToStkLineNumber> | |
| 94 | + <DeleteAttachedCommentLines><%= render_xml(comment_line.delete_attached_comment_lines)%></DeleteAttachedCommentLines> | |
| 95 | + <ChangeSingleCommentLine><%= render_xml(comment_line.change_single_comment_line)%></ChangeSingleCommentLine> | |
| 96 | + </CommentLine> | |
| 97 | + <% | |
| 98 | + end | |
| 99 | + end | |
| 100 | + | |
| 101 | + if @order_details.has_misc_charge | |
| 102 | + @order_details.misc_charge_lines.each do |misc_charge_line| | |
| 103 | + %> | |
| 104 | + <MiscChargeLine> | |
| 105 | + <PurchaseOrderLine><%= render_xml(misc_charge_line.purchase_order_line)%></PurchaseOrderLine> | |
| 106 | + <LineActionType><%= render_xml(misc_charge_line.line_action_type)%></LineActionType> | |
| 107 | + <MiscChargeValue><%= render_xml(misc_charge_line.misc_charge_value)%></MiscChargeValue> | |
| 108 | + <MiscChargeTax><%= render_xml(misc_charge_line.misc_charge_tax)%></MiscChargeTax> | |
| 109 | + <MiscTaxable><%= render_xml(misc_charge_line.misc_taxable)%></MiscTaxable> | |
| 110 | + <MiscChargeFLoc><%= render_xml(misc_charge_line.misc_charge_f_loc)%></MiscChargeFLoc> | |
| 111 | + <MiscDescription><%= render_xml(misc_charge_line.misc_description)%></MiscDescription> | |
| 112 | + <MiscCommentCode><%= render_xml(misc_charge_line.misc_comment_code)%></MiscCommentCode> | |
| 113 | + </MiscChargeLine> | |
| 114 | + <% | |
| 115 | + end | |
| 116 | + end | |
| 117 | + | |
| 118 | + if @order_details.has_freight | |
| 119 | + @order_details.freight_lines.each do |freight_line| | |
| 120 | + %> | |
| 121 | + <FreightLine> | |
| 122 | + <PurchaseOrderLine><%= render_xml(freight_line.purchase_order_line)%></PurchaseOrderLine> | |
| 123 | + <LineActionType><%= render_xml(freight_line.line_action_type)%></LineActionType> | |
| 124 | + <FreightValue><%= render_xml(freight_line.freight_value)%></FreightValue> | |
| 125 | + <FreightTaxCode><%= render_xml(freight_line.freight_tax_code)%></FreightTaxCode> | |
| 126 | + <FreightTaxable><%= render_xml(freight_line.freight_taxable)%></FreightTaxable> | |
| 127 | + <FreightFLoc><%= render_xml(freight_line.freight_f_loc)%></FreightFLoc> | |
| 128 | + </FreightLine> | |
| 129 | + <% | |
| 130 | + end | |
| 131 | + end | |
| 132 | + %> | |
| 133 | + </OrderDetails> | |
| 134 | + <% | |
| 135 | + end | |
| 136 | + %> | |
| 137 | + </Orders> | |
| 138 | +</PostPurchaseOrders> | |
| 0 | 139 | \ No newline at end of file | ... | ... |
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +require 'test_helper' | |
| 4 | + | |
| 5 | +class ComsFmTest < Minitest::Test | |
| 6 | + extend Minitest::Spec::DSL | |
| 7 | + | |
| 8 | + let(:username) { ENV['SYSPRO_USERNAME'] } | |
| 9 | + let(:password) { ENV['SYSPRO_PASSWORD'] } | |
| 10 | + let(:company) { ENV['SYSPRO_COMPANY'] } | |
| 11 | + let(:company_password) { '' } | |
| 12 | + let(:user_id) do | |
| 13 | + Syspro::Logon.logon(username, password, company, company_password) | |
| 14 | + end | |
| 15 | + | |
| 16 | + def test_comsfm | |
| 17 | + cust_item = Syspro::BusinessObjects::Models::ComsFmItem.new | |
| 18 | + cust_item.form_type = "POR" | |
| 19 | + cust_item.key_field = "U03421" | |
| 20 | + cust_item.field_name = "TempPO" | |
| 21 | + cust_item.alpha_value = "Y" | |
| 22 | + | |
| 23 | + cust_form = Syspro::BusinessObjects::ComsFm.new | |
| 24 | + cust_form.validate_only = "Y" | |
| 25 | + cust_form.items = [cust_item] | |
| 26 | + | |
| 27 | + errors = cust_form.call(user_id.guid) | |
| 28 | + | |
| 29 | + assert_equal errors.length, 0 | |
| 30 | + end | |
| 31 | +end | |
| 0 | 32 | \ No newline at end of file | ... | ... |
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 3 | +require 'test_helper' | |
| 4 | + | |
| 5 | +class PorToiTest < Minitest::Test | |
| 6 | + extend Minitest::Spec::DSL | |
| 7 | + | |
| 8 | + let(:username) { ENV['SYSPRO_USERNAME'] } | |
| 9 | + let(:password) { ENV['SYSPRO_PASSWORD'] } | |
| 10 | + let(:company) { ENV['SYSPRO_COMPANY'] } | |
| 11 | + let(:company_password) { '' } | |
| 12 | + let(:user_id) do | |
| 13 | + Syspro::Logon.logon(username, password, company, company_password) | |
| 14 | + end | |
| 15 | + | |
| 16 | + def test_portoi | |
| 17 | + po = Syspro::BusinessObjects::PorToi.new | |
| 18 | + po.purchase_order_header = Syspro::BusinessObjects::Models::PurchaseOrders::Header.new | |
| 19 | + | |
| 20 | + # Setup the PORTOI params | |
| 21 | + po.validate_only = "N" | |
| 22 | + po.ignore_warnings = "N" | |
| 23 | + po.allow_non_stock_items = "N" | |
| 24 | + po.allow_zero_price = "Y" | |
| 25 | + po.validate_working_days = "N" | |
| 26 | + po.allow_po_when_blanket_po = "N" | |
| 27 | + po.default_memo_code = "" | |
| 28 | + po.fixed_exchange_rate = "N" | |
| 29 | + po.default_memo_days = 0 | |
| 30 | + po.allow_blank_ledger_code = "Y" | |
| 31 | + po.default_delivery_address = "" | |
| 32 | + po.calc_due_date = "N" | |
| 33 | + po.insert_dangerous_goods_text = "N" | |
| 34 | + po.insert_additional_po_text = "N" | |
| 35 | + po.status = "1" | |
| 36 | + | |
| 37 | + # Setup the purchase order header data attributes | |
| 38 | + po.purchase_order_header.order_action_type = "A" | |
| 39 | + po.purchase_order_header.order_type = "L" | |
| 40 | + po.purchase_order_header.supplier = "WYC001" | |
| 41 | + po.purchase_order_header.customer_po_number = "H01993-1" | |
| 42 | + po.purchase_order_header.buyer = "PCD" | |
| 43 | + po.purchase_order_header.warehouse = "P0" | |
| 44 | + po.purchase_order_header.tax_status = "N" | |
| 45 | + po.purchase_order_header.invoice_terms = "X" | |
| 46 | + po.purchase_order_header.order_date = Time.now.strftime("%Y-%m-%d") | |
| 47 | + po.purchase_order_header.apply_due_date_to_lines = "A" | |
| 48 | + po.purchase_order_header.disc_percent1 = 0 | |
| 49 | + po.purchase_order_header.disc_percent2 = 0 | |
| 50 | + po.purchase_order_header.disc_percent3 = 0 | |
| 51 | + | |
| 52 | + line1 = Syspro::BusinessObjects::Models::PurchaseOrders::StockLine.new | |
| 53 | + line1.purchase_order_line = 1 | |
| 54 | + line1.line_action_type = "A" | |
| 55 | + line1.stock_code = "8801" | |
| 56 | + line1.warehouse = "P0" | |
| 57 | + line1.order_qty = "100" | |
| 58 | + line1.order_uom = "KG" | |
| 59 | + line1.pieces = "0" | |
| 60 | + line1.price_method = "M" | |
| 61 | + line1.price = 0 | |
| 62 | + line1.line_disc_type = "P" | |
| 63 | + line1.line_disc_less_plus = "L" | |
| 64 | + line1.line_disc_percent1 = 0 | |
| 65 | + line1.line_disc_percent2 = 0 | |
| 66 | + line1.line_disc_percent3 = 0 | |
| 67 | + line1.line_disc_value = 0 | |
| 68 | + line1.taxable = "N" | |
| 69 | + | |
| 70 | + po.order_details = Syspro::BusinessObjects::Models::PurchaseOrders::OrderDetails.new | |
| 71 | + po.order_details.stock_lines = [line1] | |
| 72 | + binding.pry | |
| 73 | + | |
| 74 | + syspro_po = po.call(user_id.guid) | |
| 75 | + | |
| 76 | + assert_equal syspro_po.error_numbers.length, 0 | |
| 77 | + end | |
| 78 | +end | |
| 0 | 79 | \ No newline at end of file | ... | ... |
test/test_helper.rb
| ... | ... | @@ -11,6 +11,7 @@ require 'webmock' |
| 11 | 11 | VCR.configure do |c| |
| 12 | 12 | c.cassette_library_dir = 'test/cassettes' |
| 13 | 13 | c.hook_into :webmock |
| 14 | + c.allow_http_connections_when_no_cassette = true | |
| 14 | 15 | c.filter_sensitive_data('<syspro_username>') { ENV['SYSPRO_USERNAME'] } |
| 15 | 16 | c.filter_sensitive_data('<syspro_password>') { ENV['SYSPRO_PASSWORD'] } |
| 16 | 17 | c.filter_sensitive_data('<syspro_company>') { ENV['SYSPRO_COMPANY'] } | ... | ... |