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.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +4 -3
  3. data/lib/tsubaiso_api.rb +67 -0
  4. data/lib/tsubaiso_sdk.rb +1511 -384
  5. data/sample.rb +120 -33
  6. data/test/stubbings/stub_register.rb +196 -0
  7. data/test/test_tsubaiso_api.rb +149 -0
  8. data/test/tsubaiso_sdk/common_setup_and_teardown.rb +23 -0
  9. data/test/tsubaiso_sdk/test_ap_reason_masters.rb +26 -0
  10. data/test/tsubaiso_sdk/test_api_history.rb +27 -0
  11. data/test/tsubaiso_sdk/test_ar_reason_masters.rb +26 -0
  12. data/test/tsubaiso_sdk/test_bank_account.rb +34 -0
  13. data/test/tsubaiso_sdk/test_bank_account_master.rb +119 -0
  14. data/test/tsubaiso_sdk/test_bank_account_transaction.rb +61 -0
  15. data/test/tsubaiso_sdk/test_bank_reason_master.rb +90 -0
  16. data/test/tsubaiso_sdk/test_bonus.rb +26 -0
  17. data/test/tsubaiso_sdk/test_corporate_master.rb +27 -0
  18. data/test/tsubaiso_sdk/test_customer.rb +71 -0
  19. data/test/tsubaiso_sdk/test_dept.rb +66 -0
  20. data/test/tsubaiso_sdk/test_fixed_assets.rb +18 -0
  21. data/test/tsubaiso_sdk/test_journal.rb +53 -0
  22. data/test/tsubaiso_sdk/test_journal_distribution.rb +29 -0
  23. data/test/tsubaiso_sdk/test_manual_journal.rb +84 -0
  24. data/test/tsubaiso_sdk/test_payrolles.rb +26 -0
  25. data/test/tsubaiso_sdk/test_petty_cash_reason_master.rb +72 -0
  26. data/test/tsubaiso_sdk/test_physical_inventory_master.rb +84 -0
  27. data/test/tsubaiso_sdk/test_purchase.rb +120 -0
  28. data/test/tsubaiso_sdk/test_reimbursement_reason_master.rb +27 -0
  29. data/test/tsubaiso_sdk/test_reimbursements.rb +90 -0
  30. data/test/tsubaiso_sdk/test_reimbursements_transactions.rb +75 -0
  31. data/test/tsubaiso_sdk/test_sale.rb +125 -0
  32. data/test/tsubaiso_sdk/test_scheduled_dates.rb +16 -0
  33. data/test/tsubaiso_sdk/test_staff.rb +26 -0
  34. data/test/tsubaiso_sdk/test_staff_data.rb +71 -0
  35. data/test/tsubaiso_sdk/test_staff_datum_master.rb +37 -0
  36. data/test/tsubaiso_sdk/test_tag.rb +53 -0
  37. data/test/tsubaiso_sdk/test_tax_master.rb +25 -0
  38. metadata +37 -6
  39. data/test/test_tsubaiso_sdk.rb +0 -807
@@ -0,0 +1,26 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class StaffTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ super("staffs")
9
+ end
10
+
11
+ def test_show_staff
12
+ staff_list = @api.list_staff
13
+ first_staff_id = staff_list[:json].first[:id]
14
+
15
+ get_staff_member = @api.show_staff(first_staff_id)
16
+ assert_equal 200, get_staff_member[:status].to_i, get_staff_member.inspect
17
+ assert_equal first_staff_id, get_staff_member[:json][:id]
18
+ end
19
+
20
+ def test_list_staff
21
+ staff_list = @api.list_staff
22
+ assert_equal 200, staff_list[:status].to_i, staff_list.inspect
23
+ assert !staff_list.empty?
24
+ end
25
+
26
+ end
@@ -0,0 +1,71 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class StaffDataTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ @staff_data_1 = {
9
+ staff_id: 300,
10
+ code: 'QUALIFICATION',
11
+ value: 'TOEIC',
12
+ start_timestamp: '2016-01-01',
13
+ no_finish_timestamp: '1',
14
+ memo: 'First memo'
15
+ }
16
+ super("staff_data")
17
+ end
18
+
19
+ def test_create_staff_data
20
+ # NOTE : So far Tsubaiso SDK does not support create new staff.
21
+ # NOTE : This test assume that staff who has id: 300 is exist.
22
+ staff_data = @api.create_staff_data(@staff_data_1)
23
+ assert_equal 200, staff_data[:status].to_i, staff_data.inspect
24
+ @staff_data_1.each_pair do |key, val|
25
+ assert staff_data[:json][key] != nil, "#{key} not found."
26
+ assert_equal val, staff_data[:json][key], "col :#{key}, #{val} was expected but #{staff_data[:json][key]} was found."
27
+ end
28
+ end
29
+
30
+ def test_show_staff_data
31
+ staff_data = @api.create_staff_data(@staff_data_1)
32
+
33
+ # get data using id (of data)
34
+ get_staff_data = @api.show_staff_data(staff_data[:json][:id].to_i)
35
+ assert_equal 200, get_staff_data[:status].to_i, get_staff_data.inspect
36
+ assert_equal staff_data[:json][:id], get_staff_data[:json][:id]
37
+
38
+ options = {
39
+ staff_id: staff_data[:json][:staff_id],
40
+ code: staff_data[:json][:code],
41
+ time: staff_data[:json][:start_timestamp]
42
+ }
43
+
44
+ # get data using staff id and code (packed in Hash)
45
+ get_staff_data_2 = @api.show_staff_data(options)
46
+ assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data.inspect
47
+ assert_equal staff_data[:json][:id], get_staff_data_2[:json][:id]
48
+ end
49
+
50
+
51
+ def test_list_staff_data
52
+ staff_data = @api.list_staff_data(@staff_data_1[:staff_id])
53
+ assert_equal 200, staff_data[:status].to_i, staff_data.inspect
54
+ @staff_data_1.each_pair do |key, val|
55
+ assert staff_data[:json][0][key] != nil, "#{key} not found."
56
+ assert_equal val, staff_data[:json][0][key], "col :#{key}, #{val} was expected but #{staff_data[:json][0][key]} was found."
57
+ end
58
+ end
59
+
60
+ def test_update_staff_data
61
+ options = {
62
+ staff_id: 0,
63
+ value: 'Programmer'
64
+ }
65
+
66
+ updated_staff_data = @api.update_staff_data(options)
67
+ assert_equal 200, updated_staff_data[:status].to_i, updated_staff_data.inspect
68
+ assert_equal options[:staff_id], updated_staff_data[:json][:id].to_i
69
+ assert_equal 'Programmer', updated_staff_data[:json][:value]
70
+ end
71
+ end
@@ -0,0 +1,37 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class StaffDatumMasterTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ super("staff_datum_masters")
9
+ end
10
+
11
+ def test_show_staff_datum_master
12
+ staff_datum_masters_list = @api.list_staff_datum_masters
13
+ first_staff_datum_master_id = staff_datum_masters_list[:json].first[:id]
14
+
15
+ get_staff_datum_master = @api.show_staff_datum_master(first_staff_datum_master_id)
16
+ assert_equal 200, get_staff_datum_master[:status].to_i, get_staff_datum_master.inspect
17
+ assert_equal first_staff_datum_master_id, get_staff_datum_master[:json][:id]
18
+ end
19
+
20
+ def test_show_staff_datum_master_by_code
21
+ staff_datum_masters_list = @api.list_staff_datum_masters
22
+ first_staff_datum_master_code = staff_datum_masters_list[:json].first[:code]
23
+
24
+ options = { code: first_staff_datum_master_code }
25
+
26
+ # get data using code
27
+ get_staff_data_2 = @api.show_staff_datum_master(options)
28
+ assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data_2.inspect
29
+ assert_equal first_staff_datum_master_code, get_staff_data_2[:json][:code]
30
+ end
31
+
32
+ def test_list_staff_datum_masters
33
+ staff_datum_masters_list = @api.list_staff_datum_masters
34
+ assert_equal 200, staff_datum_masters_list[:status].to_i, staff_datum_masters_list.inspect
35
+ assert !staff_datum_masters_list.empty?
36
+ end
37
+ end
@@ -0,0 +1,53 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class TagsTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ @tag_1 = {
9
+ code: 'test_code',
10
+ name: 'テストタグ',
11
+ sort_no: 10_000,
12
+ tag_group_code: 'DEFAULT',
13
+ start_ymd: '2016-01-01',
14
+ finish_ymd: '2016-12-31'
15
+ }
16
+ super("tags")
17
+ end
18
+
19
+ def test_create_tag
20
+ tag = @api.create_tag(@tag_1)
21
+ assert_equal 200, tag[:status].to_i, tag.inspect
22
+ assert_equal @tag_1[:code], tag[:json][:code]
23
+ end
24
+
25
+ def test_update_tag
26
+ tag = @api.create_tag(@tag_1)
27
+ assert tag[:json][:id], tag
28
+ options = {
29
+ name: '更新タグ'
30
+ }
31
+
32
+ updated_tag = @api.update_tag(tag[:json][:id], options)
33
+ assert_equal 200, updated_tag[:status].to_i, updated_tag.inspect
34
+ assert_equal options[:name], updated_tag[:json][:name]
35
+ end
36
+
37
+ def test_list_tags
38
+ tag = @api.create_tag(@tag_1)
39
+
40
+ tags = @api.list_tags
41
+ assert_equal 200, tags[:status].to_i, tags.inspect
42
+ assert(tags[:json][@tag_1[:tag_group_code].to_sym].any? { |x| x[:id] == tag[:json][:id] })
43
+ end
44
+
45
+ def test_show_tag
46
+ tag = @api.create_tag(@tag_1)
47
+ tag = @api.show_tag(tag[:json][:id])
48
+
49
+ assert_equal 200, tag[:status].to_i, tag.inspect
50
+ assert_equal @tag_1[:name], tag[:json][:name]
51
+ end
52
+
53
+ end
@@ -0,0 +1,25 @@
1
+ require 'minitest/autorun'
2
+ require_relative './common_setup_and_teardown.rb'
3
+
4
+ class TexMasterTest < Minitest::Test
5
+ include CommonSetupAndTeardown
6
+
7
+ def setup
8
+ super("tax_masters")
9
+ end
10
+
11
+ def test_list_tax_masters
12
+ tax_masters = @api.list_tax_masters
13
+ assert_equal 200, tax_masters[:status].to_i, tax_masters.inspect
14
+ assert !tax_masters[:json].empty?
15
+ end
16
+
17
+ def test_show_tax_master
18
+ tax_masters = @api.list_tax_masters
19
+ first_tax_master = tax_masters[:json].first
20
+ tax_master = @api.show_tax_master(first_tax_master[:id])
21
+
22
+ assert_equal 200, tax_master[:status].to_i, tax_master.inspect
23
+ assert_equal first_tax_master[:name], tax_master[:json][:name]
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsubaiso-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsubaiso, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -58,9 +58,41 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - README.md
60
60
  - Rakefile
61
+ - lib/tsubaiso_api.rb
61
62
  - lib/tsubaiso_sdk.rb
62
63
  - sample.rb
63
- - test/test_tsubaiso_sdk.rb
64
+ - test/stubbings/stub_register.rb
65
+ - test/test_tsubaiso_api.rb
66
+ - test/tsubaiso_sdk/common_setup_and_teardown.rb
67
+ - test/tsubaiso_sdk/test_ap_reason_masters.rb
68
+ - test/tsubaiso_sdk/test_api_history.rb
69
+ - test/tsubaiso_sdk/test_ar_reason_masters.rb
70
+ - test/tsubaiso_sdk/test_bank_account.rb
71
+ - test/tsubaiso_sdk/test_bank_account_master.rb
72
+ - test/tsubaiso_sdk/test_bank_account_transaction.rb
73
+ - test/tsubaiso_sdk/test_bank_reason_master.rb
74
+ - test/tsubaiso_sdk/test_bonus.rb
75
+ - test/tsubaiso_sdk/test_corporate_master.rb
76
+ - test/tsubaiso_sdk/test_customer.rb
77
+ - test/tsubaiso_sdk/test_dept.rb
78
+ - test/tsubaiso_sdk/test_fixed_assets.rb
79
+ - test/tsubaiso_sdk/test_journal.rb
80
+ - test/tsubaiso_sdk/test_journal_distribution.rb
81
+ - test/tsubaiso_sdk/test_manual_journal.rb
82
+ - test/tsubaiso_sdk/test_payrolles.rb
83
+ - test/tsubaiso_sdk/test_petty_cash_reason_master.rb
84
+ - test/tsubaiso_sdk/test_physical_inventory_master.rb
85
+ - test/tsubaiso_sdk/test_purchase.rb
86
+ - test/tsubaiso_sdk/test_reimbursement_reason_master.rb
87
+ - test/tsubaiso_sdk/test_reimbursements.rb
88
+ - test/tsubaiso_sdk/test_reimbursements_transactions.rb
89
+ - test/tsubaiso_sdk/test_sale.rb
90
+ - test/tsubaiso_sdk/test_scheduled_dates.rb
91
+ - test/tsubaiso_sdk/test_staff.rb
92
+ - test/tsubaiso_sdk/test_staff_data.rb
93
+ - test/tsubaiso_sdk/test_staff_datum_master.rb
94
+ - test/tsubaiso_sdk/test_tag.rb
95
+ - test/tsubaiso_sdk/test_tax_master.rb
64
96
  homepage: https://github.com/tsubaiso/tsubaiso-sdk-ruby
65
97
  licenses:
66
98
  - MIT
@@ -73,15 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
105
  requirements:
74
106
  - - ">="
75
107
  - !ruby/object:Gem::Version
76
- version: 1.9.3
108
+ version: '2.2'
77
109
  required_rubygems_version: !ruby/object:Gem::Requirement
78
110
  requirements:
79
111
  - - ">="
80
112
  - !ruby/object:Gem::Version
81
113
  version: '0'
82
114
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.6.13
115
+ rubygems_version: 3.0.3
85
116
  signing_key:
86
117
  specification_version: 4
87
118
  summary: SDK for the Tsubaiso API
@@ -1,807 +0,0 @@
1
- # encoding: utf-8
2
- require 'minitest/autorun'
3
- require 'time'
4
- require './lib/tsubaiso_sdk'
5
-
6
- class TsubaisoSDKTest < Minitest::Test
7
-
8
- def setup
9
- @api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
10
-
11
- # data
12
- @sale_201608 = { price_including_tax: 10800, realization_timestamp: "2016-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2016-09-25", data_partner: { link_url: "www.example.com/1", id_code: "1"} }
13
- @sale_201609 = { price_including_tax: 10800, realization_timestamp: "2016-09-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2016-09-25", data_partner: { link_url: "www.example.com/2", id_code: "2"} }
14
- @sale_201702 = { price_including_tax: 10800, realization_timestamp: "2017-02-28", customer_master_code: "105", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 18, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2017-03-25", data_partner: { link_url: "www.example.com/8", id_code: "8"} }
15
- @purchase_201608 = { price_including_tax: 5400, year: 2016, month: 8, accrual_timestamp: "2016-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1, data_partner: { link_url: "www.example.com/3", id_code: "3"} }
16
- @purchase_201609 = { price_including_tax: 5400, year: 2016, month: 9, accrual_timestamp: "2016-09-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1, data_partner: { link_url: "www.example.com/4", id_code: "4"} }
17
- @purchase_201702 = { price_including_tax: 5400, year: 2017, month: 2, accrual_timestamp: "2017-02-28", customer_master_code: "105", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 18, port_type: 1, data_partner: { link_url: "www.example.com/9", id_code: "9"} }
18
-
19
- @customer_1000 = { name: "テスト株式会社", name_kana: "テストカブシキガイシャ", code: "10000", tax_type_for_remittance_charge: "3", used_in_ar: 1, used_in_ap: 1, is_valid: 1 }
20
- @staff_data_1 = { code: "QUALIFICATION", value: "TOEIC", start_timestamp: "2016-01-01", no_finish_timestamp: "1", memo: "First memo" }
21
- @reimbursement_1 = { applicant: "Irfan", application_term: "2016-03-01", staff_code: "EP2000", memo: "aaaaaaaa" }
22
- @reimbursement_2 = { applicant: "Matsuno", application_term: "2016-03-01", staff_code: "EP2000", memo: "aaaaaaaa" }
23
- @reimbursement_tx_1 = { transaction_timestamp: "2016-03-01", price_value: 10000, dc:"c", reason_code:"SUPPLIES", brief:"everyting going well", memo:"easy", data_partner: { link_url: "www.example.com/5", id_code: "5"} }
24
- @reimbursement_tx_2 = { transaction_timestamp: "2016-03-01", price_value: 20000, dc:"c", reason_code:"SUPPLIES", brief:"not well", memo:"hard", data_partner: { link_url: "www.example.com/6", id_code: "6"} }
25
- @manual_journal_1 = {journal_timestamp: "2016-04-01", journal_dcs: [
26
- debit: {account_code: 100, price_including_tax: 1000, tax_type: 1, sales_tax: 100},
27
- credit: {account_code: 135, price_including_tax: 1000, tax_type: 1, sales_tax: 100} ], data_partner: { link_url: "www.example.com/7", id_code: "7"} }
28
- @dept_1= {sort_no: 12345678, code: 'test_code', name: 'テスト部門', name_abbr: 'テストブモン', color: '#ffffff', memo: 'テストメモ', start_date: '2016-01-01', finish_date: '2016-01-02'}
29
- @tag_1 = {code: 'test_code', name: 'テストタグ', sort_no: 10000, tag_group_code: "DEFAULT", start_ymd: '2016-01-01', finish_ymd: '2016-12-31'}
30
- @journal_distribution_1 = { title: 'title', start_date: "2016-09-01", finish_date: "2016-09-30", account_codes: ["135~999","604"], dept_code: "SETSURITSU", memo: "",
31
- criteria: "dept", target_timestamp: "2017-02-01", distribution_conditions: { "SETSURITSU" => "1", "SYSTEM" => "1" } }
32
- end
33
-
34
- def test_failed_request
35
- @api_fail = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: "fake token" })
36
- sale = @api_fail.create_sale(@sale_201608)
37
-
38
- assert_equal 401, sale[:status].to_i, sale.inspect
39
- assert_equal "Bad credentials", sale[:json][:error]
40
- end
41
-
42
- def test_create_customer
43
- customer = @api.create_customer(@customer_1000)
44
-
45
- assert_equal 200, customer[:status].to_i, customer.inspect
46
- assert_equal @customer_1000[:name], customer[:json][:name]
47
-
48
- ensure
49
- @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
50
- end
51
-
52
- def test_create_sale
53
- sale = @api.create_sale(@sale_201608)
54
-
55
- assert_equal 200, sale[:status].to_i, sale.inspect
56
- assert_equal @sale_201608[:dept_code], sale[:json][:dept_code]
57
- assert_equal @sale_201608[:data_partner][:id_code], sale[:json][:data_partner][:id_code]
58
-
59
- ensure
60
- @api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
61
- end
62
-
63
- def test_create_purchase
64
- purchase = @api.create_purchase(@purchase_201608)
65
-
66
- assert_equal 200, purchase[:status].to_i, purchase.inspect
67
- assert_equal @purchase_201608[:dept_code], purchase[:json][:dept_code]
68
- assert_equal @purchase_201608[:data_partner][:id_code], purchase[:json][:data_partner][:id_code]
69
-
70
- ensure
71
- @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
72
- end
73
-
74
- def test_create_staff_data
75
- staff_list = @api.list_staff
76
- first_staff_id = staff_list[:json].first[:id]
77
- @staff_data_1[:staff_id] = first_staff_id
78
-
79
- staff_data = @api.create_staff_data(@staff_data_1)
80
-
81
- assert_equal 200, staff_data[:status].to_i, staff_data.inspect
82
- assert_equal @staff_data_1[:value], staff_data[:json][:value]
83
-
84
- ensure
85
- @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
86
- end
87
-
88
- def test_create_manual_journal
89
- manual_journal = @api.create_manual_journal(@manual_journal_1)
90
-
91
- begin
92
- assert_equal 200, manual_journal[:status].to_i, manual_journal.inspect
93
- assert_equal @manual_journal_1[:journal_dcs][0][:price_including_tax], manual_journal[:json][:journal_dcs][0]["price_including_tax"]
94
- assert_equal @manual_journal_1[:data_partner][:id_code], manual_journal[:json][:data_partner][:id_code]
95
-
96
- ensure
97
- @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
98
- end
99
- end
100
-
101
- def test_create_reimbursement
102
- reimbursement = @api.create_reimbursement(@reimbursement_1)
103
- assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
104
- assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
105
-
106
- ensure
107
- @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
108
- end
109
-
110
- def test_create_reimbursement_transaction
111
- reimbursement = @api.create_reimbursement(@reimbursement_1)
112
- options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id] })
113
- reimbursement_transaction = @api.create_reimbursement_transaction(options)
114
- assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
115
- assert_equal @reimbursement_tx_1[:price_value], reimbursement_transaction[:json][:price_value]
116
- assert_equal @reimbursement_tx_1[:data_partner][:id_code], reimbursement_transaction[:json][:data_partner][:id_code]
117
-
118
- ensure
119
- @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
120
- @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
121
- end
122
-
123
- def test_create_dept
124
- dept = @api.create_dept(@dept_1)
125
- assert_equal 200, dept[:status].to_i, dept.inspect
126
- assert_equal @dept_1[:code], dept[:json][:code]
127
-
128
- ensure
129
- @api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
130
- end
131
-
132
- def test_create_tag
133
- tag = @api.create_tag(@tag_1)
134
- assert_equal 200, tag[:status].to_i, tag.inspect
135
- assert_equal @tag_1[:code], tag[:json][:code]
136
-
137
- ensure
138
- @api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
139
- end
140
-
141
- def test_create_journal_distribution
142
- options = { start_date: @journal_distribution_1[:target_timestamp], finish_date: @journal_distribution_1[:target_timestamp] }
143
-
144
- journals_list_before = @api.list_journals(options)
145
- records_before_count = journals_list_before[:json][:records].count
146
- assert_equal 200, journals_list_before[:status].to_i, journals_list_before.inspect
147
-
148
- journal_distribution = @api.create_journal_distribution(@journal_distribution_1)
149
- assert_equal 200, journal_distribution[:status].to_i, journal_distribution.inspect
150
- assert_equal Time.parse(@journal_distribution_1[:target_timestamp]), Time.parse(journal_distribution[:json][:target_ym])
151
-
152
- journals_list_after = @api.list_journals(options)
153
- records_after_count = journals_list_after[:json][:records].count
154
- assert_equal 200, journals_list_after[:status].to_i, journals_list_after.inspect
155
- assert (records_before_count != records_after_count)
156
-
157
- ensure
158
- @api.destroy_journal_distribution(journal_distribution[:json][:id]) if journal_distribution[:json][:id]
159
- end
160
-
161
- def test_update_sale
162
- sale = @api.create_sale(@sale_201608)
163
- options = { id: sale[:json][:id],
164
- price_including_tax: 25000,
165
- memo: "Updated memo",
166
- data_partner: { id_code: "100" } }
167
-
168
- updated_sale = @api.update_sale(options)
169
- assert_equal 200, updated_sale[:status].to_i, updated_sale[:json]
170
- assert_equal options[:id], updated_sale[:json][:id]
171
- assert_equal options[:memo], updated_sale[:json][:memo]
172
- assert_equal options[:price_including_tax], updated_sale[:json][:price_including_tax]
173
- assert_equal options[:data_partner][:id_code], updated_sale[:json][:data_partner][:id_code]
174
-
175
- ensure
176
- @api.destroy_sale("AP#{sale[:json][:id]}") if sale[:json][:id]
177
- end
178
-
179
- def test_update_purchase
180
- purchase = @api.create_purchase(@purchase_201608)
181
- assert purchase[:json][:id], purchase
182
- options = { id: purchase[:json][:id],
183
- price_including_tax: 50000,
184
- memo: "Updated memo",
185
- data_partner: { id_code: "300" } }
186
-
187
- updated_purchase = @api.update_purchase(options)
188
- assert_equal 200, updated_purchase[:status].to_i, updated_purchase.inspect
189
- assert_equal options[:id], updated_purchase[:json][:id]
190
- assert_equal options[:memo], updated_purchase[:json][:memo]
191
- assert_equal options[:price_including_tax], updated_purchase[:json][:price_including_tax]
192
- assert_equal options[:data_partner][:id_code], updated_purchase[:json][:data_partner][:id_code]
193
-
194
- ensure
195
- @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
196
- end
197
-
198
- def test_update_customer
199
- customer = @api.create_customer(@customer_1000)
200
- options = { id: customer[:json][:id],
201
- name: "New Customer Name"}
202
-
203
- updated_customer = @api.update_customer(options)
204
- assert_equal 200, updated_customer[:status].to_i
205
- assert_equal customer[:json][:id], updated_customer[:json][:id]
206
- assert_equal "New Customer Name", updated_customer[:json][:name]
207
-
208
- ensure
209
- @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
210
- end
211
-
212
- def test_update_staff_data
213
- staff_list = @api.list_staff
214
- first_staff_id = staff_list[:json].first[:id]
215
- @staff_data_1[:staff_id] = first_staff_id
216
-
217
- staff_data = @api.create_staff_data(@staff_data_1)
218
- options = { id: staff_data[:json][:id],
219
- value: "Programmer"
220
- }
221
-
222
- updated_staff_data = @api.update_staff_data(options)
223
- assert_equal 200, updated_staff_data[:status].to_i, updated_staff_data.inspect
224
- assert_equal staff_data[:json][:id], updated_staff_data[:json][:id]
225
- assert_equal "Programmer", updated_staff_data[:json][:value]
226
-
227
- ensure
228
- @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
229
- end
230
-
231
- def test_update_reimbursement
232
- reimbursement = @api.create_reimbursement(@reimbursement_1)
233
- options = {
234
- applicant: "test",
235
- dept_code: "COMMON"
236
- }
237
- updated_reimbursement = @api.update_reimbursement(reimbursement[:json][:id], options)
238
- assert_equal 200, updated_reimbursement[:status].to_i, updated_reimbursement.inspect
239
- assert_equal options[:applicant], updated_reimbursement[:json][:applicant]
240
- assert_equal options[:dept_code], updated_reimbursement[:json][:dept_code]
241
-
242
- ensure
243
- @api.destroy_reimbursement(updated_reimbursement[:json][:id] || reimbursement[:json][:id]) if updated_reimbursement[:json][:id] || reimbursement[:json][:id]
244
- end
245
-
246
- def test_update_reimbursement_transaction
247
- reimbursement = @api.create_reimbursement(@reimbursement_1)
248
- options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id].to_i })
249
- reimbursement_transaction = @api.create_reimbursement_transaction(options)
250
- updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => "SUPPLIES", :data_partner => { :id_code => "500" } }
251
-
252
- updated_reimbursement_transaction = @api.update_reimbursement_transaction(updates)
253
- assert_equal 200, updated_reimbursement_transaction[:status].to_i, updated_reimbursement_transaction.inspect
254
- assert_equal updates[:id].to_i, updated_reimbursement_transaction[:json][:id].to_i
255
- assert_equal updates[:price_value].to_i, updated_reimbursement_transaction[:json][:price_value].to_i
256
- assert_equal updates[:reason_code], updated_reimbursement_transaction[:json][:reason_code]
257
- assert_equal updates[:data_partner][:id_code], updated_reimbursement_transaction[:json][:data_partner][:id_code]
258
-
259
- ensure
260
- @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
261
- @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
262
- end
263
-
264
- def test_update_manual_journal
265
- manual_journal = @api.create_manual_journal(@manual_journal_1)
266
- options = { id: manual_journal[:json][:id],
267
- journal_dcs: manual_journal[:json][:journal_dcs],
268
- data_partner: { :id_code => "700" }
269
- }
270
- options[:journal_dcs][0][:debit][:price_including_tax] = 2000
271
- options[:journal_dcs][0][:credit][:price_including_tax] = 2000
272
-
273
- updated_manual_journal = @api.update_manual_journal(options)
274
- assert_equal 200, updated_manual_journal[:status].to_i, updated_manual_journal.inspect
275
- assert_equal options[:journal_dcs][0][:debit][:price_including_tax], updated_manual_journal[:json][:journal_dcs][0][:debit][:price_including_tax]
276
- assert_equal options[:data_partner][:id_code], updated_manual_journal[:json][:data_partner][:id_code]
277
-
278
- ensure
279
- @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
280
- end
281
-
282
- def test_update_dept
283
- dept = @api.create_dept(@dept_1)
284
- options = { id: dept[:json][:id],
285
- sort_no: 98765,
286
- memo: "updated at test",
287
- name: "更新部門",
288
- name_abbr: "更新部門",
289
- }
290
-
291
- updated_dept = @api.update_dept(dept[:json][:id], options)
292
- assert_equal 200, updated_dept[:status].to_i, updated_dept.inspect
293
- assert_equal options[:memo], updated_dept[:json][:memo]
294
- assert_equal options[:name], updated_dept[:json][:name]
295
- assert_equal options[:name_abbr], updated_dept[:json][:name_abbr]
296
-
297
- ensure
298
- @api.destroy_dept(updated_dept[:json][:id] || dept[:json][:id]) if updated_dept[:json][:id] || dept[:json][:id]
299
- end
300
-
301
- def test_update_tag
302
- tag = @api.create_tag(@tag_1)
303
- assert tag[:json][:id], tag
304
- options = { name: "更新タグ",
305
- code: "updated_tag"
306
- }
307
-
308
- updated_tag = @api.update_tag(tag[:json][:id], options)
309
- assert_equal 200, updated_tag[:status].to_i, updated_tag.inspect
310
- assert_equal options[:name], updated_tag[:json][:name]
311
- assert_equal options[:code], updated_tag[:json][:code]
312
- ensure
313
- @api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
314
- end
315
-
316
- def test_show_sale
317
- sale = @api.create_sale(@sale_201608)
318
-
319
- get_sale = @api.show_sale("AR#{sale[:json][:id]}")
320
- assert_equal 200, get_sale[:status].to_i, get_sale.inspect
321
- assert_equal sale[:json][:price_including_tax], get_sale[:json][:price_including_tax]
322
-
323
- ensure
324
- @api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
325
- end
326
-
327
- def test_show_purchase
328
- purchase = @api.create_purchase(@purchase_201608)
329
-
330
- get_purchase = @api.show_purchase("AP#{purchase[:json][:id]}")
331
- assert_equal 200, get_purchase[:status].to_i, get_purchase.inspect
332
- assert_equal purchase[:json][:id], get_purchase[:json][:id]
333
-
334
- ensure
335
- @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
336
- end
337
-
338
- def test_show_customer
339
- customer = @api.create_customer(@customer_1000)
340
-
341
- get_customer = @api.show_customer(customer[:json][:id])
342
- assert_equal 200, get_customer[:status].to_i, get_customer.inspect
343
- assert_equal customer[:json][:id], get_customer[:json][:id]
344
-
345
- ensure
346
- @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
347
- end
348
-
349
- def test_show_staff
350
- staff_list = @api.list_staff
351
- first_staff_id = staff_list[:json].first[:id]
352
-
353
- get_staff_member = @api.show_staff(first_staff_id)
354
- assert_equal 200, get_staff_member[:status].to_i, get_staff_member.inspect
355
- assert_equal first_staff_id, get_staff_member[:json][:id]
356
- end
357
-
358
- def test_show_staff_data
359
- staff_list = @api.list_staff
360
- first_staff_id = staff_list[:json].first[:id]
361
- @staff_data_1[:staff_id] = first_staff_id
362
-
363
- staff_data = @api.create_staff_data(@staff_data_1)
364
-
365
- #get data using id
366
- get_staff_data = @api.show_staff_data(staff_data[:json][:id])
367
- assert_equal 200, get_staff_data[:status].to_i, get_staff_data.inspect
368
- assert_equal staff_data[:json][:id], get_staff_data[:json][:id]
369
-
370
- options = { staff_id: staff_data[:json][:staff_id],
371
- code: staff_data[:json][:code],
372
- time: staff_data[:json][:start_timestamp]
373
- }
374
-
375
- #get data using staff id and code
376
- get_staff_data_2 = @api.show_staff_data(options)
377
- assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data.inspect
378
- assert_equal staff_data[:json][:id], get_staff_data_2[:json][:id]
379
-
380
- ensure
381
- @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
382
- end
383
-
384
- def test_show_staff_datum_master
385
- staff_datum_masters_list = @api.list_staff_datum_masters
386
- first_staff_datum_master_id = staff_datum_masters_list[:json].first[:id]
387
-
388
- get_staff_datum_master = @api.show_staff_datum_master(first_staff_datum_master_id)
389
- assert_equal 200, get_staff_datum_master[:status].to_i, get_staff_datum_master.inspect
390
- assert_equal first_staff_datum_master_id, get_staff_datum_master[:json][:id]
391
- end
392
-
393
- def test_show_staff_datum_master_by_code
394
- staff_datum_masters_list = @api.list_staff_datum_masters
395
- first_staff_datum_master_code = staff_datum_masters_list[:json].first[:code]
396
-
397
- options = { code: first_staff_datum_master_code }
398
-
399
- #get data using code
400
- get_staff_data_2 = @api.show_staff_datum_master(options)
401
- assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data_2.inspect
402
- assert_equal first_staff_datum_master_code, get_staff_data_2[:json][:code]
403
- end
404
-
405
- def test_show_reimbursement
406
- reimbursement = @api.create_reimbursement(@reimbursement_1)
407
- reimbursement = @api.show_reimbursement(reimbursement[:json][:id])
408
-
409
- assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
410
- assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
411
- ensure
412
- @api.destroy_reimbursement(reimbursement[:json][:id])
413
- end
414
-
415
- def test_show_reimbursement_reason_master
416
- reim_reason_msts = @api.list_reimbursement_reason_masters
417
- reim_reason_mst_id = reim_reason_msts[:json].first[:id]
418
- reim_reason_mst = @api.show_reimbursement_reason_master(reim_reason_mst_id)
419
-
420
- assert_equal 200, reim_reason_mst[:status].to_i, reim_reason_mst.inspect
421
- assert_equal reim_reason_mst[:json][:id], reim_reason_mst_id
422
- end
423
-
424
- def test_show_reimbursement_transaction
425
- reimbursement = @api.create_reimbursement(@reimbursement_1)
426
- options = { :reimbursement_id => reimbursement[:json][:id].to_i }
427
- reimbursement_transaction = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
428
- reimbursement_transaction = @api.show_reimbursement_transaction(reimbursement_transaction[:json][:id])
429
-
430
- assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
431
- assert_equal options[:reimbursement_id], reimbursement_transaction[:json][:reimbursement_id]
432
-
433
- ensure
434
- @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
435
- @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
436
- end
437
-
438
- def test_show_manual_journal
439
- @api.create_manual_journal(@manual_journal_1)
440
- manual_journals_list = @api.list_manual_journals(2016, 4)
441
- first_manual_journal_id = manual_journals_list[:json].first[:id]
442
-
443
- manual_journal = @api.show_manual_journal(first_manual_journal_id)
444
- assert_equal 200, manual_journal[:status].to_i, manual_journal.inspect
445
- assert_equal first_manual_journal_id, manual_journal[:json][:id]
446
-
447
- ensure
448
- @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
449
- end
450
-
451
- def test_show_journal
452
- manual_journal = @api.create_manual_journal(@manual_journal_1)
453
- journals_list = @api.list_journals({ start_date: "2016-04-01", finish_date: "2016-04-30" })
454
- first_journal_id = journals_list[:json][:records].first[:id]
455
-
456
- journal = @api.show_journal(first_journal_id)
457
- assert_equal 200, journal[:status].to_i, journal.inspect
458
- assert_equal first_journal_id, journal[:json][:records][:id]
459
-
460
- ensure
461
- @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
462
- end
463
-
464
- def test_show_dept
465
- dept = @api.create_dept(@dept_1)
466
- dept = @api.show_dept(dept[:json][:id])
467
-
468
- assert_equal 200, dept[:status].to_i, dept.inspect
469
- assert_equal @dept_1[:memo], dept[:json][:memo]
470
- ensure
471
- @api.destroy_dept(dept[:json][:id])
472
- end
473
-
474
- def test_show_tag
475
- tag = @api.create_tag(@tag_1)
476
- tag = @api.show_tag(tag[:json][:id])
477
-
478
- assert_equal 200, tag[:status].to_i, tag.inspect
479
- assert_equal @tag_1[:name], tag[:json][:name]
480
- ensure
481
- @api.destroy_tag(tag[:json][:id])
482
- end
483
-
484
- def test_show_bonus
485
- bonuses = @api.list_bonuses(1, 2016)
486
- bonus_id = bonuses[:json].first[:id]
487
- bonus = @api.show_bonus(bonus_id)
488
-
489
- assert_equal 200, bonus[:status].to_i, bonus.inspect
490
- assert_equal bonus[:json][:id], bonus_id
491
- end
492
-
493
- def test_show_payroll
494
- payrolls_list = @api.list_payrolls(2017, 2)
495
- first_payroll_id = payrolls_list[:json].first[:id]
496
-
497
- payroll = @api.show_payroll(first_payroll_id)
498
- assert_equal 200, payroll[:status].to_i, payroll.inspect
499
- assert_equal first_payroll_id, payroll[:json][:id]
500
- end
501
-
502
- def test_show_ar_reason_master
503
- ar_reason_masters = @api.list_ar_reason_masters
504
- ar_reason_master_id = ar_reason_masters[:json].first[:id]
505
- ar_reason_master = @api.show_ar_reason_master(ar_reason_master_id)
506
-
507
- assert_equal 200, ar_reason_master[:status].to_i, ar_reason_master.inspect
508
- assert_equal ar_reason_master[:json][:id], ar_reason_master_id
509
- end
510
-
511
- def test_show_ap_reason_master
512
- ap_reason_masters = @api.list_ap_reason_masters
513
- first_ap_reason_master = ap_reason_masters[:json].first
514
- ap_reason_master = @api.show_ap_reason_master(first_ap_reason_master[:id])
515
-
516
- assert_equal 200, ap_reason_master[:status].to_i, ap_reason_master.inspect
517
- assert_equal first_ap_reason_master[:reason_code], ap_reason_master[:json][:reason_code]
518
- end
519
-
520
- def test_list_sales
521
- august_sale_a = @api.create_sale(@sale_201608)
522
- august_sale_b = @api.create_sale(@sale_201608)
523
- september_sale = @api.create_sale(@sale_201609)
524
-
525
- august_sale_a_id = august_sale_a[:json][:id]
526
- august_sale_b_id = august_sale_b[:json][:id]
527
- september_sale_id = september_sale[:json][:id]
528
-
529
- sales_list = @api.list_sales(2016, 8)
530
- assert_equal 200, sales_list[:status].to_i, sales_list.inspect
531
- assert sales_list[:json].any?{ |x| x[:id] == august_sale_a_id }
532
- assert sales_list[:json].any?{ |x| x[:id] == august_sale_b_id }
533
- assert !sales_list[:json].any?{ |x| x[:id] == september_sale_id }
534
-
535
- ensure
536
- @api.destroy_sale("AR#{august_sale_a[:json][:id]}") if august_sale_a[:json][:id]
537
- @api.destroy_sale("AR#{august_sale_b[:json][:id]}") if august_sale_b[:json][:id]
538
- @api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
539
- end
540
-
541
- def test_list_sales_and_account_balances
542
- realization_timestamp = Time.parse(@sale_201702[:realization_timestamp])
543
-
544
- # Without customer_master_code and ar_segment option parameters
545
- balance_list_before = @api.list_sales_and_account_balances(realization_timestamp.year, realization_timestamp.month)
546
- assert_equal 200, balance_list_before[:status].to_i, balance_list_before.inspect
547
-
548
- new_sale = @api.create_sale(@sale_201702)
549
- assert_equal 200, new_sale[:status].to_i, new_sale.inspect
550
- assert(new_sale[:json].count > 0)
551
-
552
- balance_list_after = @api.list_sales_and_account_balances(realization_timestamp.year, realization_timestamp.month)
553
- assert_equal 200, balance_list_after[:status].to_i, balance_list_after.inspect
554
- assert(balance_list_after[:json].count > 0)
555
- assert(balance_list_after[:json] != balance_list_before[:json])
556
-
557
- customer_masters_list = @api.list_customers
558
- assert_equal 200, customer_masters_list[:status].to_i, customer_masters_list.inspect
559
- assert customer_masters_list[:json].any?{ |x| x[:code] == new_sale[:json][:customer_master_code] }
560
- filtered_cm = customer_masters_list[:json].select{ |x| x[:code] == new_sale[:json][:customer_master_code] }.first
561
-
562
- # With customer_master_id and ar_segment option parameters
563
- balance_list = @api.list_sales_and_account_balances(realization_timestamp.year, realization_timestamp.month, :customer_master_id => filtered_cm[:id], :ar_segment => filtered_cm[:used_in_ar])
564
- assert_equal 200, balance_list[:status].to_i, balance_list.inspect
565
- assert(balance_list[:json].count > 0)
566
- assert balance_list[:json].all?{ |x| x[:customer_master_code] == filtered_cm[:code] && x[:ar_segment] == filtered_cm[:used_in_ar] }
567
- ensure
568
- @api.destroy_sale("AR#{new_sale[:json][:id]}") if new_sale[:json][:id]
569
- end
570
-
571
- def test_list_purchases
572
- august_purchase_a = @api.create_purchase(@purchase_201608)
573
- august_purchase_b = @api.create_purchase(@purchase_201608)
574
- september_purchase = @api.create_purchase(@purchase_201609)
575
-
576
- august_purchase_a_id = august_purchase_a[:json][:id]
577
- august_purchase_b_id = august_purchase_b[:json][:id]
578
- september_purchase_id = september_purchase[:json][:id]
579
-
580
- purchase_list = @api.list_purchases(2016, 8)
581
- assert_equal 200, purchase_list[:status].to_i, purchase_list.inspect
582
- assert purchase_list[:json].any?{ |x| x[:id] == august_purchase_a_id }
583
- assert purchase_list[:json].any?{ |x| x[:id] == august_purchase_b_id }
584
- assert !purchase_list[:json].any?{ |x| x[:id] == september_purchase_id }
585
-
586
- ensure
587
- @api.destroy_purchase("AP#{august_purchase_a[:json][:id]}") if august_purchase_a[:json][:id]
588
- @api.destroy_purchase("AP#{august_purchase_b[:json][:id]}") if august_purchase_b[:json][:id]
589
- @api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
590
- end
591
-
592
- def test_list_purchases_and_account_balances
593
- accrual_timestamp = Time.parse(@purchase_201702[:accrual_timestamp])
594
-
595
- # Without customer_master_id and ap_segment option parameters
596
- balance_list_before = @api.list_purchases_and_account_balances(accrual_timestamp.year, accrual_timestamp.month)
597
- assert_equal 200, balance_list_before[:status].to_i, balance_list_before.inspect
598
-
599
- new_purchase = @api.create_purchase(@purchase_201702)
600
- assert_equal 200, new_purchase[:status].to_i, new_purchase.inspect
601
- assert(new_purchase[:json].count > 0)
602
-
603
- balance_list_after = @api.list_purchases_and_account_balances(accrual_timestamp.year, accrual_timestamp.month)
604
- assert_equal 200, balance_list_after[:status].to_i, balance_list_after.inspect
605
- assert(balance_list_after[:json].count > 0)
606
- assert(balance_list_after[:json] != balance_list_before[:json])
607
-
608
- customer_masters_list = @api.list_customers
609
- assert_equal 200, customer_masters_list[:status].to_i, customer_masters_list.inspect
610
- assert customer_masters_list[:json].any?{ |x| x[:code] == new_purchase[:json][:customer_master_code] }
611
- filtered_customer_master = customer_masters_list[:json].select{ |x| x[:code] == new_purchase[:json][:customer_master_code] }.first
612
- customer_master_id = filtered_customer_master[:id]
613
- ap_segment = filtered_customer_master[:used_in_ap]
614
-
615
- # With customer_master_id and ap_segment option parameters
616
- balance_list = @api.list_purchases_and_account_balances(accrual_timestamp.year, accrual_timestamp.month, :customer_master_id => customer_master_id, :ap_segment => ap_segment)
617
- assert_equal 200, balance_list[:status].to_i, balance_list.inspect
618
- assert(balance_list[:json].count > 0)
619
- assert balance_list[:json].all?{ |x| x[:customer_master_id] == customer_master_id && x[:ap_segment] == ap_segment }
620
- ensure
621
- @api.destroy_purchase("AP#{new_purchase[:json][:id]}") if new_purchase[:json][:id]
622
- end
623
-
624
- def test_list_customers
625
- customer_1000 = @api.create_customer(@customer_1000)
626
-
627
- customer_1000_id = customer_1000[:json][:id]
628
-
629
- customer_list = @api.list_customers
630
- assert_equal 200, customer_list[:status].to_i, customer_list.inspect
631
- assert customer_list[:json].any?{ |x| x[:id] == customer_1000_id }
632
-
633
- ensure
634
- @api.destroy_customer(customer_1000[:json][:id]) if customer_1000[:json][:id]
635
- end
636
-
637
- def test_list_staff
638
- staff_list = @api.list_staff
639
- assert_equal 200, staff_list[:status].to_i, staff_list.inspect
640
- assert(staff_list.size > 0)
641
- end
642
-
643
- def test_list_staff_data
644
- staff_list = @api.list_staff
645
- first_staff_id = staff_list[:json].first[:id]
646
-
647
- staff_data_list = @api.list_staff_data(first_staff_id)
648
- assert_equal 200, staff_data_list[:status].to_i, staff_data_list.inspect
649
- assert staff_data_list[:json].all?{ |x| x[:staff_id] == first_staff_id }
650
- end
651
-
652
- def test_list_staff_datum_masters
653
- staff_datum_masters_list = @api.list_staff_datum_masters
654
- assert_equal 200, staff_datum_masters_list[:status].to_i, staff_datum_masters_list.inspect
655
- assert(staff_datum_masters_list.size > 0)
656
- end
657
-
658
- def test_list_manual_journals
659
- manual_journals_list = @api.list_manual_journals(2016, 4)
660
- assert_equal 200, manual_journals_list[:status].to_i, manual_journals_list.inspect
661
- assert(manual_journals_list.size > 0)
662
- end
663
-
664
- def test_list_journals
665
- august_sale = @api.create_sale(@sale_201608)
666
- september_sale = @api.create_sale(@sale_201609)
667
- august_purchase = @api.create_purchase(@purchase_201608)
668
- september_purchase = @api.create_purchase(@purchase_201609)
669
-
670
- options = { start_date: "2016-08-01", finish_date: "2016-08-31" }
671
- journals_list = @api.list_journals(options)
672
- records = journals_list[:json][:records]
673
- assert_equal 200, journals_list[:status].to_i, journals_list.inspect
674
- record_timestamps = records.map { |x| Time.parse(x[:journal_timestamp]) }
675
- assert_includes record_timestamps, Time.parse(august_sale[:json][:realization_timestamp])
676
- assert_includes record_timestamps, Time.parse(august_purchase[:json][:accrual_timestamp])
677
-
678
- options = { price: 10800 }
679
- journals_list = @api.list_journals(options)
680
- records = journals_list[:json][:records]
681
- assert_equal 200, journals_list[:status].to_i, journals_list.inspect
682
- record_prices = records.map { |x| x[:journal_dcs].map { |y| y[:debit][:price_including_tax] } }.flatten(1)
683
- assert_includes record_prices, august_sale[:json][:price_including_tax]
684
- assert_includes record_prices, september_sale[:json][:price_including_tax]
685
-
686
- options = { dept_code: "SETSURITSU" }
687
- journals_list = @api.list_journals(options)
688
- records = journals_list[:json][:records]
689
- assert_equal 200, journals_list[:status].to_i, journals_list.inspect
690
- record_depts = records.map { |x| x[:journal_dcs].map { |y| y[:dept_code] } }.flatten(1)
691
- assert_includes record_depts, august_sale[:json][:dept_code]
692
- assert_includes record_depts, september_sale[:json][:dept_code]
693
- assert_includes record_depts, august_purchase[:json][:dept_code]
694
- assert_includes record_depts, september_purchase[:json][:dept_code]
695
-
696
- ensure
697
- @api.destroy_sale("AR#{august_sale[:json][:id]}") if august_sale[:json][:id]
698
- @api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
699
- @api.destroy_purchase("AP#{august_purchase[:json][:id]}") if august_purchase[:json][:id]
700
- @api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
701
- end
702
-
703
- def test_list_reimbursements
704
- reimbursement_a = @api.create_reimbursement(@reimbursement_1)
705
- reimbursement_b = @api.create_reimbursement(@reimbursement_2)
706
-
707
- reimbursement_a_id = reimbursement_a[:json][:id]
708
- reimbursement_b_id = reimbursement_b[:json][:id]
709
-
710
- reimbursements_list = @api.list_reimbursements(2016, 3)
711
- assert_equal 200, reimbursements_list[:status].to_i, reimbursements_list.inspect
712
- assert reimbursements_list[:json].any?{ |x| x[:id] == reimbursement_a_id }
713
- assert reimbursements_list[:json].any?{ |x| x[:id] == reimbursement_b_id }
714
-
715
- ensure
716
- @api.destroy_reimbursement(reimbursement_a_id) if reimbursement_a_id
717
- @api.destroy_reimbursement(reimbursement_b_id) if reimbursement_b_id
718
- end
719
-
720
- def test_list_reimbursement_reason_masters
721
- reimbursement_reason_masters_list = @api.list_reimbursement_reason_masters
722
- assert_equal 200, reimbursement_reason_masters_list[:status].to_i, reimbursement_reason_masters_list.inspect
723
- assert reimbursement_reason_masters_list[:json]
724
- assert(reimbursement_reason_masters_list[:json].size > 0)
725
- end
726
-
727
- def test_list_reimbursement_transactions
728
- reimbursement = @api.create_reimbursement(@reimbursement_1)
729
- options = { :reimbursement_id => reimbursement[:json][:id].to_i }
730
- reimbursement_transaction_1 = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
731
- reimbursement_transaction_2 = @api.create_reimbursement_transaction(@reimbursement_tx_2.merge(options))
732
-
733
- reimbursement_transactions = @api.list_reimbursement_transactions(reimbursement[:json][:id])
734
- assert_equal 200, reimbursement_transactions[:status].to_i, reimbursement_transactions.inspect
735
- assert reimbursement_transactions[:json].any?{ |x| x[:id] == reimbursement_transaction_1[:json][:id] }
736
- assert reimbursement_transactions[:json].any?{ |x| x[:id] == reimbursement_transaction_2[:json][:id] }
737
-
738
- ensure
739
- @api.destroy_reimbursement_transaction(reimbursement_transaction_1[:json][:id]) if reimbursement_transaction_1[:json][:id]
740
- @api.destroy_reimbursement_transaction(reimbursement_transaction_1[:json][:id]) if reimbursement_transaction_1[:json][:id]
741
- @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
742
- end
743
-
744
- def test_list_depts
745
- dept = @api.create_dept(@dept_1)
746
- assert_equal 200, dept[:status].to_i, dept.inspect
747
-
748
- depts = @api.list_depts
749
- assert_equal 200, depts[:status].to_i, depts.inspect
750
- assert depts[:json].any?{ |x| x[:id] == dept[:json][:id] }
751
-
752
- ensure
753
- @api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
754
- end
755
-
756
- def test_list_tags
757
- tag = @api.create_tag(@tag_1)
758
-
759
- tags = @api.list_tags
760
- assert_equal 200, tags[:status].to_i, tags.inspect
761
- assert tags[:json][@tag_1[:tag_group_code].to_sym].any?{ |x| x[:id] == tag[:json][:id] }
762
-
763
- ensure
764
- @api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
765
- end
766
-
767
- def test_list_bonuses
768
- bonuses_list = @api.list_bonuses(1, 2016)
769
- assert_equal 200, bonuses_list[:status].to_i, bonuses_list.inspect
770
- assert bonuses_list[:json]
771
- assert(bonuses_list[:json].size > 0)
772
- end
773
-
774
- def test_list_payrolls
775
- payrolls_list = @api.list_payrolls(2016, 2)
776
-
777
- assert_equal 200, payrolls_list[:status].to_i, payrolls_list.inspect
778
- assert(payrolls_list.size > 0)
779
- end
780
-
781
- def test_list_ar_reason_masters
782
- ar_reason_masters_list = @api.list_ar_reason_masters
783
- assert_equal 200, ar_reason_masters_list[:status].to_i, ar_reason_masters_list.inspect
784
- assert ar_reason_masters_list[:json]
785
- assert(ar_reason_masters_list[:json].size > 0)
786
- end
787
-
788
- def test_list_ap_reason_masters
789
- ap_reason_masters_list = @api.list_ap_reason_masters
790
- assert_equal 200, ap_reason_masters_list[:status].to_i, ap_reason_masters_list.inspect
791
- assert ap_reason_masters_list[:json]
792
- assert(ap_reason_masters_list[:json].size > 0)
793
- end
794
-
795
- def test_list_fixed_assets
796
- list = @api.list_fixed_assets
797
- assert_equal 200, list[:status].to_i, list.inspect
798
- assert list[:json]
799
- assert(list[:json].size > 0)
800
- end
801
-
802
- private
803
-
804
- def successful?(status)
805
- status.to_i == 200
806
- end
807
- end