Blame view

test/portoi_test.rb 2.49 KB
d9a9cb5d   chadzink   Add portoi and co...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  # 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"
2120daaf   Nathan-O   removed a binding...
69
  
d9a9cb5d   chadzink   Add portoi and co...
70
71
      po.order_details = Syspro::BusinessObjects::Models::PurchaseOrders::OrderDetails.new
      po.order_details.stock_lines = [line1]
2120daaf   Nathan-O   removed a binding...
72
  
d9a9cb5d   chadzink   Add portoi and co...
73
      syspro_po = po.call(user_id.guid)
2120daaf   Nathan-O   removed a binding...
74
  
d9a9cb5d   chadzink   Add portoi and co...
75
76
      assert_equal syspro_po.error_numbers.length, 0
    end
2120daaf   Nathan-O   removed a binding...
77
  end