tsubaiso-sdk 1.2.1 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +4 -3
- data/lib/tsubaiso_api.rb +67 -0
- data/lib/tsubaiso_sdk.rb +1511 -384
- data/sample.rb +120 -33
- data/test/stubbings/stub_register.rb +196 -0
- data/test/test_tsubaiso_api.rb +149 -0
- data/test/tsubaiso_sdk/common_setup_and_teardown.rb +23 -0
- data/test/tsubaiso_sdk/test_ap_reason_masters.rb +26 -0
- data/test/tsubaiso_sdk/test_api_history.rb +27 -0
- data/test/tsubaiso_sdk/test_ar_reason_masters.rb +26 -0
- data/test/tsubaiso_sdk/test_bank_account.rb +34 -0
- data/test/tsubaiso_sdk/test_bank_account_master.rb +119 -0
- data/test/tsubaiso_sdk/test_bank_account_transaction.rb +61 -0
- data/test/tsubaiso_sdk/test_bank_reason_master.rb +90 -0
- data/test/tsubaiso_sdk/test_bonus.rb +26 -0
- data/test/tsubaiso_sdk/test_corporate_master.rb +27 -0
- data/test/tsubaiso_sdk/test_customer.rb +71 -0
- data/test/tsubaiso_sdk/test_dept.rb +66 -0
- data/test/tsubaiso_sdk/test_fixed_assets.rb +18 -0
- data/test/tsubaiso_sdk/test_journal.rb +53 -0
- data/test/tsubaiso_sdk/test_journal_distribution.rb +29 -0
- data/test/tsubaiso_sdk/test_manual_journal.rb +84 -0
- data/test/tsubaiso_sdk/test_payrolles.rb +26 -0
- data/test/tsubaiso_sdk/test_petty_cash_reason_master.rb +72 -0
- data/test/tsubaiso_sdk/test_physical_inventory_master.rb +84 -0
- data/test/tsubaiso_sdk/test_purchase.rb +120 -0
- data/test/tsubaiso_sdk/test_reimbursement_reason_master.rb +27 -0
- data/test/tsubaiso_sdk/test_reimbursements.rb +90 -0
- data/test/tsubaiso_sdk/test_reimbursements_transactions.rb +75 -0
- data/test/tsubaiso_sdk/test_sale.rb +125 -0
- data/test/tsubaiso_sdk/test_scheduled_dates.rb +16 -0
- data/test/tsubaiso_sdk/test_staff.rb +26 -0
- data/test/tsubaiso_sdk/test_staff_data.rb +71 -0
- data/test/tsubaiso_sdk/test_staff_datum_master.rb +37 -0
- data/test/tsubaiso_sdk/test_tag.rb +53 -0
- data/test/tsubaiso_sdk/test_tax_master.rb +25 -0
- metadata +37 -6
- data/test/test_tsubaiso_sdk.rb +0 -807
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class PurchaseTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@purchase_201608 = {
|
9
|
+
price_including_tax: 5400,
|
10
|
+
year: 2016,
|
11
|
+
month: 8,
|
12
|
+
accrual_timestamp: '2016-08-01',
|
13
|
+
customer_master_code: '102',
|
14
|
+
dept_code: 'SETSURITSU',
|
15
|
+
reason_master_code: 'BUYING_IN',
|
16
|
+
dc: 'c',
|
17
|
+
memo: '',
|
18
|
+
tax_code: 1007,
|
19
|
+
port_type: 1,
|
20
|
+
data_partner: { link_url: 'www.example.com/3', id_code: '3', partner_code: 'Example' }
|
21
|
+
}
|
22
|
+
|
23
|
+
@purchase_201609 = {
|
24
|
+
price_including_tax: 5400,
|
25
|
+
year: 2016,
|
26
|
+
month: 9,
|
27
|
+
accrual_timestamp: '2016-09-01',
|
28
|
+
customer_master_code: '102',
|
29
|
+
dept_code: 'SETSURITSU',
|
30
|
+
reason_master_code: 'BUYING_IN',
|
31
|
+
dc: 'c',
|
32
|
+
memo: '',
|
33
|
+
tax_code: 1007,
|
34
|
+
port_type: 1,
|
35
|
+
data_partner: { link_url: 'www.example.com/4', id_code: '4' }
|
36
|
+
}
|
37
|
+
|
38
|
+
@purchase_201702 = {
|
39
|
+
price_including_tax: 5400,
|
40
|
+
year: 2017,
|
41
|
+
month: 2,
|
42
|
+
accrual_timestamp: '2017-02-28',
|
43
|
+
customer_master_code: '105',
|
44
|
+
reason_master_code: 'BUYING_IN',
|
45
|
+
dc: 'c',
|
46
|
+
memo: '',
|
47
|
+
tax_code: 18,
|
48
|
+
port_type: 1,
|
49
|
+
data_partner: { link_url: 'www.example.com/9', id_code: '9' }
|
50
|
+
}
|
51
|
+
super("ap_payments")
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_create_purchase
|
55
|
+
purchase = @api.create_purchase(@purchase_201608)
|
56
|
+
assert_equal 200, purchase[:status].to_i, purchase.inspect
|
57
|
+
assert_equal @purchase_201608[:dept_code], purchase[:json][:dept_code]
|
58
|
+
assert_equal @purchase_201608[:data_partner][:id_code], purchase[:json][:data_partner][:id_code]
|
59
|
+
assert_equal @purchase_201608[:data_partner][:partner_code], purchase[:json][:data_partner][:partner_code]
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_find_or_create_purchase
|
63
|
+
key_options = { key:
|
64
|
+
{ id_code: @purchase_201608[:data_partner][:id_code],
|
65
|
+
partner_code: @purchase_201608[:data_partner][:partner_code] } }
|
66
|
+
purchase1 = @api.find_or_create_purchase(@purchase_201608.merge(key_options))
|
67
|
+
|
68
|
+
assert_equal 200, purchase1[:status].to_i, purchase1.inspect
|
69
|
+
assert_equal @purchase_201608[:dept_code], purchase1[:json][:dept_code]
|
70
|
+
assert_equal @purchase_201608[:data_partner][:id_code], purchase1[:json][:data_partner][:id_code]
|
71
|
+
assert_equal @purchase_201608[:data_partner][:partner_code], purchase1[:json][:data_partner][:partner_code]
|
72
|
+
|
73
|
+
purchase2 = @api.find_or_create_purchase(@purchase_201608.merge(key_options))
|
74
|
+
assert_equal 200, purchase2[:status].to_i, purchase2.inspect
|
75
|
+
assert_equal purchase2[:json][:id], purchase1[:json][:id]
|
76
|
+
assert_equal purchase2[:json][:data_partner][:id_code], purchase1[:json][:data_partner][:id_code]
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_update_purchase
|
80
|
+
purchase = @api.create_purchase(@purchase_201702)
|
81
|
+
assert purchase[:json][:id], purchase
|
82
|
+
options = {
|
83
|
+
id: purchase[:json][:id].to_i,
|
84
|
+
price_including_tax: 50_000,
|
85
|
+
memo: 'Updated memo',
|
86
|
+
data_partner: { id_code: '300' }
|
87
|
+
}
|
88
|
+
|
89
|
+
updated_purchase = @api.update_purchase(options)
|
90
|
+
assert_equal 200, updated_purchase[:status].to_i, updated_purchase.inspect
|
91
|
+
assert_equal options[:id], updated_purchase[:json][:id]
|
92
|
+
assert_equal options[:memo], updated_purchase[:json][:memo]
|
93
|
+
assert_equal options[:price_including_tax], updated_purchase[:json][:price_including_tax]
|
94
|
+
assert_equal options[:data_partner][:id_code], updated_purchase[:json][:data_partner][:id_code]
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_show_purchase
|
98
|
+
purchase = @api.create_purchase(@purchase_201608)
|
99
|
+
|
100
|
+
get_purchase = @api.show_purchase("AP#{purchase[:json][:id]}")
|
101
|
+
assert_equal 200, get_purchase[:status].to_i, get_purchase.inspect
|
102
|
+
assert_equal purchase[:json][:id], get_purchase[:json][:id]
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_list_purchases_and_account_balances
|
106
|
+
# Without customer_master_code and ar_segment option parameters
|
107
|
+
balance_lists = @api.list_purchases_and_account_balances(2019, 12)
|
108
|
+
assert_equal 200, balance_lists[:status].to_i, balance_lists.inspect
|
109
|
+
assert_equal 3, balance_lists[:json].size
|
110
|
+
|
111
|
+
# With customer_master_id option parameters
|
112
|
+
balance_list_with_opts = @api.list_purchases_and_account_balances(2019, 12,
|
113
|
+
:customer_master_id => 101)
|
114
|
+
|
115
|
+
assert_equal 200, balance_list_with_opts[:status].to_i, balance_list_with_opts.inspect
|
116
|
+
assert_equal 2, balance_list_with_opts[:json].size
|
117
|
+
assert(balance_list_with_opts[:json].all? { |x| x[:customer_master_code] == "101"})
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class ReimbursementReasonMasterTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super("reimbursement_reason_masters")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_reimbursement_reason_masters
|
12
|
+
reimbursement_reason_masters_list = @api.list_reimbursement_reason_masters
|
13
|
+
assert_equal 200, reimbursement_reason_masters_list[:status].to_i, reimbursement_reason_masters_list.inspect
|
14
|
+
assert reimbursement_reason_masters_list[:json]
|
15
|
+
assert !reimbursement_reason_masters_list[:json].empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_show_reimbursement_reason_master
|
19
|
+
reim_reason_msts = @api.list_reimbursement_reason_masters
|
20
|
+
reim_reason_mst_id = reim_reason_msts[:json].first[:id]
|
21
|
+
reim_reason_mst = @api.show_reimbursement_reason_master(reim_reason_mst_id)
|
22
|
+
|
23
|
+
assert_equal 200, reim_reason_mst[:status].to_i, reim_reason_mst.inspect
|
24
|
+
assert_equal reim_reason_mst[:json][:id], reim_reason_mst_id
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class ReimbursementsTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@reimbursement_1 = {
|
9
|
+
applicant: 'Irfan',
|
10
|
+
application_term: '2016-03-01',
|
11
|
+
staff_code: 'EP2000',
|
12
|
+
memo: 'aaaaaaaa'
|
13
|
+
}
|
14
|
+
|
15
|
+
@reimbursement_2 = {
|
16
|
+
applicant: 'Matsuno',
|
17
|
+
application_term: '2016-03-01',
|
18
|
+
staff_code: 'EP2000',
|
19
|
+
memo: 'aaaaaaaa'
|
20
|
+
}
|
21
|
+
super("reimbursements")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_list_reimbursements
|
25
|
+
reimbursement_a = @api.create_reimbursement(@reimbursement_1)
|
26
|
+
reimbursement_b = @api.create_reimbursement(@reimbursement_2)
|
27
|
+
|
28
|
+
reimbursement_a_id = reimbursement_a[:json][:id]
|
29
|
+
reimbursement_b_id = reimbursement_b[:json][:id]
|
30
|
+
|
31
|
+
reimbursements_list = @api.list_reimbursements(2016, 3)
|
32
|
+
assert_equal 200, reimbursements_list[:status].to_i, reimbursements_list.inspect
|
33
|
+
assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_a_id })
|
34
|
+
assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_b_id })
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_show_reimbursement
|
38
|
+
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
39
|
+
reimbursement = @api.show_reimbursement(reimbursement[:json][:id])
|
40
|
+
|
41
|
+
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
42
|
+
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_update_reimbursement
|
46
|
+
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
47
|
+
options = {
|
48
|
+
applicant: 'test',
|
49
|
+
dept_code: 'COMMON'
|
50
|
+
}
|
51
|
+
updated_reimbursement = @api.update_reimbursement(reimbursement[:json][:id], options)
|
52
|
+
assert_equal 200, updated_reimbursement[:status].to_i, updated_reimbursement.inspect
|
53
|
+
assert_equal options[:applicant], updated_reimbursement[:json][:applicant]
|
54
|
+
assert_equal options[:dept_code], updated_reimbursement[:json][:dept_code]
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_create_reimbursement
|
58
|
+
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
59
|
+
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
60
|
+
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_create_reimbursement_and_transactions
|
64
|
+
request_body = {
|
65
|
+
applicant: 'Matsuno',
|
66
|
+
application_term: '2016-03-01',
|
67
|
+
staff_code: 'EP2000',
|
68
|
+
memo: 'aaaaaaaa',
|
69
|
+
pay_date: '2020-1-13',
|
70
|
+
applicant_staff_code: 'test_applicant_code',
|
71
|
+
transactions: [
|
72
|
+
{
|
73
|
+
transaction_timestamp: '2020-1-1',
|
74
|
+
price_value: 1000,
|
75
|
+
reason_code: 'SUPPLIES'
|
76
|
+
}
|
77
|
+
]
|
78
|
+
}
|
79
|
+
|
80
|
+
reimbursement = @api.create_reimbursement(request)
|
81
|
+
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
82
|
+
assert_equal request_body[:applicant], reimbursement[:json][:applicant]
|
83
|
+
assert_equal request_body[:pay_date], reimbursement[:json][:pay_date]
|
84
|
+
assert_equal request_body[:applicant_staff_code], reimbursement[:json][:applicant_staff_code]
|
85
|
+
|
86
|
+
reimbursement_transactions = @api.list_reimbursement_transactions(reimbursement[:json][:id])
|
87
|
+
assert_equal 200, reimbursement_transactions[:status].to_i, reimbursement_transactions.inspect
|
88
|
+
assert_equal 1, reimbursement_transactions[:json].size
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class ReimbursementsTransactionsTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@reimbursement_tx_1 = {
|
9
|
+
transaction_timestamp: '2016-03-01',
|
10
|
+
price_value: 10_000,
|
11
|
+
dc: 'c',
|
12
|
+
tax_type: 'tax',
|
13
|
+
reason_code: 'SUPPLIES',
|
14
|
+
brief: 'everyting going well',
|
15
|
+
memo: 'easy',
|
16
|
+
data_partner: { link_url: 'www.example.com/5', id_code: '5' }
|
17
|
+
}
|
18
|
+
|
19
|
+
@reimbursement_tx_2 = {
|
20
|
+
transaction_timestamp: '2016-03-01',
|
21
|
+
price_value: 20_000,
|
22
|
+
dc: 'c',
|
23
|
+
tax_type: 'tax',
|
24
|
+
reason_code: 'SUPPLIES',
|
25
|
+
brief: 'not well',
|
26
|
+
memo: 'hard',
|
27
|
+
data_partner: { link_url: 'www.example.com/6', id_code: '6' }
|
28
|
+
}
|
29
|
+
|
30
|
+
super("reimbursement_transactions")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_reimbursement_transaction
|
34
|
+
options = @reimbursement_tx_1.merge({ :reimbursement_id => 300 })
|
35
|
+
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
36
|
+
assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
|
37
|
+
assert_equal @reimbursement_tx_1[:price_value], reimbursement_transaction[:json][:price_value]
|
38
|
+
assert_equal @reimbursement_tx_1[:data_partner][:id_code], reimbursement_transaction[:json][:data_partner][:id_code]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_update_reimbursement_transaction
|
42
|
+
options = @reimbursement_tx_1.merge({ :reimbursement_id => 300 })
|
43
|
+
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
44
|
+
updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => 'SUPPLIES', :data_partner => { :id_code => '500' } }
|
45
|
+
|
46
|
+
updated_reimbursement_transaction = @api.update_reimbursement_transaction(updates)
|
47
|
+
assert_equal 200, updated_reimbursement_transaction[:status].to_i, updated_reimbursement_transaction.inspect
|
48
|
+
assert_equal updates[:id].to_i, updated_reimbursement_transaction[:json][:id].to_i
|
49
|
+
assert_equal updates[:price_value].to_i, updated_reimbursement_transaction[:json][:price_value].to_i
|
50
|
+
assert_equal updates[:reason_code], updated_reimbursement_transaction[:json][:reason_code]
|
51
|
+
assert_equal updates[:data_partner][:id_code], updated_reimbursement_transaction[:json][:data_partner][:id_code]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_list_reimbursement_transactions
|
55
|
+
options = { :reimbursement_id => 300 }
|
56
|
+
reimbursement_transaction_1 = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
|
57
|
+
reimbursement_transaction_2 = @api.create_reimbursement_transaction(@reimbursement_tx_2.merge(options))
|
58
|
+
|
59
|
+
reimbursement_transactions = @api.list_reimbursement_transactions(300)
|
60
|
+
assert_equal 200, reimbursement_transactions[:status].to_i, reimbursement_transactions.inspect
|
61
|
+
assert(reimbursement_transactions[:json].any? { |x| x[:id] == reimbursement_transaction_1[:json][:id] })
|
62
|
+
assert(reimbursement_transactions[:json].any? { |x| x[:id] == reimbursement_transaction_2[:json][:id] })
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_show_reimbursement_transaction
|
66
|
+
options = { :reimbursement_id => 300 }
|
67
|
+
reimbursement_transaction = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
|
68
|
+
reimbursement_transaction = @api.show_reimbursement_transaction(reimbursement_transaction[:json][:id])
|
69
|
+
|
70
|
+
assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
|
71
|
+
assert_equal options[:reimbursement_id], reimbursement_transaction[:json][:reimbursement_id]
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class SaleTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@sale_201608 = {
|
9
|
+
price_including_tax: 10_800,
|
10
|
+
realization_timestamp: '2016-08-01',
|
11
|
+
customer_master_code: '101',
|
12
|
+
dept_code: 'SETSURITSU',
|
13
|
+
reason_master_code: 'SALES',
|
14
|
+
dc: 'd',
|
15
|
+
memo: '',
|
16
|
+
tax_code: 1007,
|
17
|
+
scheduled_memo: 'This is a scheduled memo.',
|
18
|
+
scheduled_receive_timestamp: '2016-09-25',
|
19
|
+
data_partner: { link_url: 'www.example.com/1', id_code: '1', partner_code: 'Example' }
|
20
|
+
}
|
21
|
+
|
22
|
+
@sale_201609 = {
|
23
|
+
price_including_tax: 10_800,
|
24
|
+
realization_timestamp: '2016-09-01',
|
25
|
+
customer_master_code: '101',
|
26
|
+
dept_code: 'SETSURITSU',
|
27
|
+
reason_master_code: 'SALES',
|
28
|
+
dc: 'd',
|
29
|
+
memo: '',
|
30
|
+
tax_code: 1007,
|
31
|
+
scheduled_memo: 'This is a scheduled memo.',
|
32
|
+
scheduled_receive_timestamp: '2016-09-25',
|
33
|
+
data_partner: { link_url: 'www.example.com/2', id_code: '2' }
|
34
|
+
}
|
35
|
+
|
36
|
+
@sale_201702 = {
|
37
|
+
price_including_tax: 10_800,
|
38
|
+
realization_timestamp: '2017-02-28',
|
39
|
+
customer_master_code: '105',
|
40
|
+
reason_master_code: 'SALES',
|
41
|
+
dc: 'd',
|
42
|
+
memo: '',
|
43
|
+
tax_code: 18,
|
44
|
+
scheduled_memo: 'This is a scheduled memo.',
|
45
|
+
scheduled_receive_timestamp: '2017-03-25',
|
46
|
+
data_partner: { link_url: 'www.example.com/8', id_code: '8' }
|
47
|
+
}
|
48
|
+
super("ar")
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_create_sale
|
52
|
+
sale = @api.create_sale(@sale_201608)
|
53
|
+
|
54
|
+
assert_equal 200, sale[:status].to_i, sale.inspect
|
55
|
+
assert_equal @sale_201608[:dept_code], sale[:json][:dept_code]
|
56
|
+
assert_equal @sale_201608[:data_partner][:id_code], sale[:json][:data_partner][:id_code]
|
57
|
+
assert_equal @sale_201608[:data_partner][:link_url], sale[:json][:data_partner][:link_url]
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_list_sales
|
61
|
+
august_sale_a = @api.create_sale(@sale_201608)
|
62
|
+
feb_sale = @api.create_sale(@sale_201702)
|
63
|
+
september_sale = @api.create_sale(@sale_201609)
|
64
|
+
|
65
|
+
august_sale_a_id = august_sale_a[:json][:id]
|
66
|
+
feb_sale_id = feb_sale[:json][:id]
|
67
|
+
september_sale_id = september_sale[:json][:id]
|
68
|
+
|
69
|
+
sales_list = @api.list_sales(2016, 8)
|
70
|
+
assert_equal 200, sales_list[:status].to_i, sales_list.inspect
|
71
|
+
assert sales_list[:json].size == 1
|
72
|
+
|
73
|
+
assert(sales_list[:json].any? { |x| x[:id] == august_sale_a_id })
|
74
|
+
assert(sales_list[:json].none? { |x| x[:id] == feb_sale_id })
|
75
|
+
assert(sales_list[:json].none? { |x| x[:id] == september_sale_id })
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_update_sale
|
79
|
+
sale = @api.create_sale(@sale_201608)
|
80
|
+
options = {
|
81
|
+
id: sale[:json][:id].to_i,
|
82
|
+
price_including_tax: 25_000,
|
83
|
+
memo: 'Updated memo',
|
84
|
+
data_partner: { id_code: "100" }
|
85
|
+
}
|
86
|
+
|
87
|
+
updated_sale = @api.update_sale(options)
|
88
|
+
assert_equal 200, updated_sale[:status].to_i, updated_sale[:json]
|
89
|
+
assert_equal options[:id], updated_sale[:json][:id]
|
90
|
+
assert_equal options[:memo], updated_sale[:json][:memo]
|
91
|
+
assert_equal options[:price_including_tax], updated_sale[:json][:price_including_tax]
|
92
|
+
assert_equal options[:data_partner][:id_code], updated_sale[:json][:data_partner][:id_code]
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_find_or_create_sale
|
96
|
+
with_key = @sale_201608.merge!({:key => { "id_code" => "1", "partner_code" => "Example"}})
|
97
|
+
sale1 = @api.find_or_create_sale(with_key)
|
98
|
+
|
99
|
+
assert_equal 200, sale1[:status].to_i, sale1.inspect
|
100
|
+
assert_equal @sale_201608[:dept_code], sale1[:json][:dept_code]
|
101
|
+
assert_equal @sale_201608[:data_partner][:id_code], sale1[:json][:data_partner][:id_code]
|
102
|
+
assert_equal @sale_201608[:data_partner][:partner_code], sale1[:json][:data_partner][:partner_code]
|
103
|
+
|
104
|
+
key_options = { key: { id_code: sale1[:json][:data_partner][:id_code], partner_code: sale1[:json][:data_partner][:partner_code] } }
|
105
|
+
sale2 = @api.find_or_create_sale(@sale_201608.merge(key_options))
|
106
|
+
assert_equal sale2[:json][:id], sale1[:json][:id]
|
107
|
+
assert_equal sale2[:json][:data_partner][:id_code], sale1[:json][:data_partner][:id_code]
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_list_sales_and_account_balances
|
111
|
+
# Without customer_master_code and ar_segment option parameters
|
112
|
+
balance_lists = @api.list_sales_and_account_balances(2019, 12)
|
113
|
+
assert_equal 200, balance_lists[:status].to_i, balance_lists.inspect
|
114
|
+
assert_equal 3, balance_lists[:json].size
|
115
|
+
|
116
|
+
# With customer_master_id option parameters
|
117
|
+
balance_list_with_opts = @api.list_sales_and_account_balances(2019, 12,
|
118
|
+
:customer_master_id => 101)
|
119
|
+
|
120
|
+
assert_equal 200, balance_list_with_opts[:status].to_i, balance_list_with_opts.inspect
|
121
|
+
assert_equal 2, balance_list_with_opts[:json].size
|
122
|
+
assert(balance_list_with_opts[:json].all? { |x| x[:customer_master_code] == "101"})
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative './common_setup_and_teardown.rb'
|
3
|
+
|
4
|
+
class ScheduledDatesTest < Minitest::Test
|
5
|
+
include CommonSetupAndTeardown
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super('scheduled_dates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_calc_scheduled_dates
|
12
|
+
response = @api.scheduled_date('2019-01-02', '1m10', '5', 'before')
|
13
|
+
assert_equal '200', response[:status]
|
14
|
+
assert_equal '2019-01-10', response[:json][:scheduled_date]
|
15
|
+
end
|
16
|
+
end
|