tsubaiso-sdk 1.2.5 → 1.2.6

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.
data/sample.rb CHANGED
@@ -1,42 +1,40 @@
1
-
2
- # -*- coding: utf-8 -*-
3
1
  $LOAD_PATH << 'lib/'
4
2
  require 'tsubaiso_sdk'
5
3
 
6
4
  class Sample
7
5
  def initialize(sample)
8
6
  @sample = sample
9
- api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
7
+ api = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
10
8
  @sample.each do | line |
11
- if line[:action] == "List"
12
- if line[:module] == "Sales"
9
+ if line[:action] == 'List'
10
+ if line[:module] == 'Sales'
13
11
  res = api.list_sales(line[:year], line[:month])
14
12
  puts res[:json]
15
13
  end
16
- if line[:module] == "Purchases"
14
+ if line[:module] == 'Purchases'
17
15
  res = api.list_purchases(line[:year], line[:month])
18
16
  puts res[:json]
19
17
  end
20
18
  end
21
- if line[:action] == "Show"
22
- if line[:module] == "Sales"
19
+ if line[:action] == 'Show'
20
+ if line[:module] == 'Sales'
23
21
  res = api.show_sale(line[:voucher])
24
22
  puts res[:json]
25
23
  end
26
- if line[:module] == "Purchases"
24
+ if line[:module] == 'Purchases'
27
25
  res = api.show_purchase(line[:voucher])
28
26
  puts res[:json]
29
27
  end
30
28
  end
31
- if line[:action] == "Create"
32
- if line[:module] == "Sales"
29
+ if line[:action] == 'Create'
30
+ if line[:module] == 'Sales'
33
31
  res = api.create_sale(line)
34
32
  if res[:status].to_i == 422
35
33
  puts res[:json]
36
34
  exit
37
35
  end
38
36
  end
39
- if line[:module] == "Purchases"
37
+ if line[:module] == 'Purchases'
40
38
  res = api.create_purchase(line)
41
39
  if res[:status].to_i == 422
42
40
  puts res[:json]
@@ -44,11 +42,11 @@ class Sample
44
42
  end
45
43
  end
46
44
  end
47
- if line[:action] == "Destroy"
48
- if line[:module] == "Sales"
45
+ if line[:action] == 'Destroy'
46
+ if line[:module] == 'Sales'
49
47
  res = api.destroy_sale(line[:voucher])
50
48
  end
51
- if line[:module] == "Purchases"
49
+ if line[:module] == 'Purchases'
52
50
  res = api.destroy_purchase(line[:voucher])
53
51
  end
54
52
  end
@@ -56,21 +54,110 @@ class Sample
56
54
  end
57
55
  end
58
56
 
59
- Sample.new([
60
- { action: "Create", module: "Sales", price: 10000, year: 2015, month: 8, realization_timestamp: "2015-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: "2015-09-25" },
61
- { action: "Create", module: "Purchases", price: 5000, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1 },
62
- { action: "Create", module: "Sales", price: 95000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'd', memo: "決算会社/マーチャントの相殺", tax_code: 0 },
63
- { action: "Create", module: "Sales", price: 10000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "OTHERS_DECREASE", dc: 'c', memo: "決算会社/マーチャントの相殺", tax_code: 0 },
64
- { action: "Create", module: "Sales", price: 5000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'c', memo: "決算会社/決済会社の相殺", tax_code: 0 },
65
- { action: "Create", module: "Purchases", price: 5000, year: 2015, month: 9, accrual_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_DECREASE", dc: 'd', memo: "決算会社/決済会社の相殺", tax_code: 0, port_type: 1 },
66
- { action: "Create", module: "Purchases", price: 90000, year: 2015, month: 9, accrual_timestamp: "2015-09-30", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'c', memo: "売掛金/未払金振替", tax_code: 0, port_type: 1 },
67
- { action: "Create", module: "Sales", price: 90000, year: 2015, month: 9, realization_timestamp: "2015-09-30", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'd', memo: "売掛金/未払い金振替", tax_code: 0 },
68
- { action: "Show", module: "Sales", voucher: "AR834"},
69
- { action: "Show", module: "Purchases", voucher: "AP622"},
70
- { action: "Destroy", module: "Sales", voucher: "AR839"},
71
- { action: "Destroy", module: "Purchases", voucher: "AP625"},
72
- { action: "List", module: "Sales", year: 2015, month: 9},
73
- { action: "List", module: "Purchases", year: 2015, month: 9}
74
- ])
75
-
76
-
57
+ Sample.new([{ action: 'Create',
58
+ module: 'Sales',
59
+ price: 10_000,
60
+ year: 2015,
61
+ month: 8,
62
+ realization_timestamp: '2015-08-01',
63
+ customer_master_code: '101',
64
+ dept_code: 'SETSURITSU',
65
+ reason_master_code: 'SALES',
66
+ dc: 'd',
67
+ memo: '',
68
+ tax_code: 1007,
69
+ scheduled_memo: 'This is a scheduled memo.',
70
+ scheduled_receive_timestamp: '2015-09-25' },
71
+ { action: 'Create',
72
+ module: 'Purchases',
73
+ price: 5000,
74
+ year: 2015,
75
+ month: 8,
76
+ accrual_timestamp: '2015-08-01',
77
+ customer_master_code: '102',
78
+ dept_code: 'SETSURITSU',
79
+ reason_master_code: 'BUYING_IN',
80
+ dc: 'c',
81
+ memo: '',
82
+ tax_code: 1007,
83
+ port_type: 1 },
84
+ { action: 'Create',
85
+ module: 'Sales',
86
+ price: 95_000,
87
+ year: 2015,
88
+ month: 9,
89
+ realization_timestamp: '2015-09-25',
90
+ customer_master_code: '102',
91
+ dept_code: 'SETSURITSU',
92
+ reason_master_code: 'OTHERS_INCREASE',
93
+ dc: 'd',
94
+ memo: '決算会社/マーチャントの相殺',
95
+ tax_code: 0 },
96
+ { action: 'Create',
97
+ module: 'Sales',
98
+ price: 10_000,
99
+ year: 2015,
100
+ month: 9,
101
+ realization_timestamp: '2015-09-25',
102
+ customer_master_code: '101',
103
+ dept_code: 'SETSURITSU',
104
+ reason_master_code: 'OTHERS_DECREASE',
105
+ dc: 'c',
106
+ memo: '決算会社/マーチャントの相殺',
107
+ tax_code: 0 },
108
+ { action: 'Create',
109
+ module: 'Sales',
110
+ price: 5000,
111
+ year: 2015,
112
+ month: 9,
113
+ realization_timestamp: '2015-09-25',
114
+ customer_master_code: '102',
115
+ dept_code: 'SETSURITSU',
116
+ reason_master_code: 'OTHERS_INCREASE',
117
+ dc: 'c',
118
+ memo: '決算会社/決済会社の相殺',
119
+ tax_code: 0 },
120
+ { action: 'Create',
121
+ module: 'Purchases',
122
+ price: 5000,
123
+ year: 2015,
124
+ month: 9,
125
+ accrual_timestamp: '2015-09-25',
126
+ customer_master_code: '102',
127
+ dept_code: 'SETSURITSU',
128
+ reason_master_code: 'OTHERS_DECREASE',
129
+ dc: 'd',
130
+ memo: '決算会社/決済会社の相殺',
131
+ tax_code: 0,
132
+ port_type: 1 },
133
+ { action: 'Create',
134
+ module: 'Purchases',
135
+ price: 90_000,
136
+ year: 2015,
137
+ month: 9,
138
+ accrual_timestamp: '2015-09-30',
139
+ customer_master_code: '101',
140
+ dept_code: 'SETSURITSU',
141
+ reason_master_code: 'OTHERS_INCREASE',
142
+ dc: 'c',
143
+ memo: '売掛金/未払金振替',
144
+ tax_code: 0,
145
+ port_type: 1 },
146
+ { action: 'Create',
147
+ module: 'Sales',
148
+ price: 90_000,
149
+ year: 2015,
150
+ month: 9,
151
+ realization_timestamp: '2015-09-30',
152
+ customer_master_code: '102',
153
+ dept_code: 'SETSURITSU',
154
+ reason_master_code: 'OTHERS_INCREASE',
155
+ dc: 'd',
156
+ memo: '売掛金/未払い金振替',
157
+ tax_code: 0 },
158
+ { action: 'Show', module: 'Sales', voucher: 'AR834' },
159
+ { action: 'Show', module: 'Purchases', voucher: 'AP622' },
160
+ { action: 'Destroy', module: 'Sales', voucher: 'AR839' },
161
+ { action: 'Destroy', module: 'Purchases', voucher: 'AP625' },
162
+ { action: 'List', module: 'Sales', year: 2015, month: 9 },
163
+ { action: 'List', module: 'Purchases', year: 2015, month: 9 }])
@@ -1,20 +1,64 @@
1
- # encoding: utf-8
2
1
  require 'minitest/autorun'
3
2
  require 'time'
4
3
  require './lib/tsubaiso_api'
5
4
 
6
5
  class TsubaisoAPITest < Minitest::Test
7
-
8
6
  def setup
9
- @api = TsubaisoAPI.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
10
- @customer_1000 = { name: "テスト株式会社", name_kana: "テストカブシキガイシャ", code: "10000", tax_type_for_remittance_charge: "3", used_in_ar: 1, used_in_ap: 1, is_valid: 1 }
11
-
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: "irfan test", 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
-
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
-
16
- @reimbursement_1 = { applicant: "Matsuno", application_term: "2016-03-01", staff_code: "EP2000", memo: "aaaaaaaa" }
17
- @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"} }
7
+ @api = TsubaisoAPI.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
8
+
9
+ @customer_1000 = {
10
+ name: 'テスト株式会社',
11
+ name_kana: 'テストカブシキガイシャ',
12
+ code: '10000',
13
+ tax_type_for_remittance_charge: '3',
14
+ used_in_ar: 1,
15
+ used_in_ap: 1,
16
+ is_valid: 1
17
+ }
18
+
19
+ @sale_201608 = {
20
+ price_including_tax: 10_800,
21
+ realization_timestamp: '2016-08-01',
22
+ customer_master_code: '101',
23
+ dept_code: 'SETSURITSU',
24
+ reason_master_code: 'SALES',
25
+ dc: 'd',
26
+ memo: 'irfan test',
27
+ tax_code: 1007,
28
+ scheduled_memo: 'This is a scheduled memo.',
29
+ scheduled_receive_timestamp: '2016-09-25',
30
+ data_partner: { link_url: 'www.example.com/1', id_code: '1' }
31
+ }
32
+
33
+ @sale_201702 = {
34
+ price_including_tax: 10_800,
35
+ realization_timestamp: '2017-02-28',
36
+ customer_master_code: '105',
37
+ reason_master_code: 'SALES',
38
+ dc: 'd',
39
+ memo: '',
40
+ tax_code: 18,
41
+ scheduled_memo: 'This is a scheduled memo.',
42
+ scheduled_receive_timestamp: '2017-03-25',
43
+ data_partner: { link_url: 'www.example.com/8', id_code: '8' }
44
+ }
45
+
46
+ @reimbursement_1 = {
47
+ applicant: 'Matsuno',
48
+ application_term: '2016-03-01',
49
+ staff_code: 'EP2000',
50
+ memo: 'aaaaaaaa'
51
+ }
52
+
53
+ @reimbursement_tx_1 = {
54
+ transaction_timestamp: '2016-03-01',
55
+ price_value: 10_000,
56
+ dc: 'c',
57
+ reason_code: 'SUPPLIES',
58
+ brief: 'everyting going well',
59
+ memo: 'easy',
60
+ data_partner: { link_url: 'www.example.com/5', id_code: '5' }
61
+ }
18
62
  end
19
63
 
20
64
  def test_list
@@ -25,7 +69,7 @@ class TsubaisoAPITest < Minitest::Test
25
69
  list_customers = @api.list('customer_masters')
26
70
  assert_equal 200, list_customers[:status].to_i
27
71
 
28
- assert list_customers[:json]&.any? { |x| x['code'] == @customer_1000[:code] }
72
+ assert(list_customers[:json]&.any? { |x| x['code'] == @customer_1000[:code] })
29
73
  ensure
30
74
  @api.destroy('customer_masters', id: cm[:json]['id']) if cm[:json]['id']
31
75
  end
@@ -33,7 +77,7 @@ class TsubaisoAPITest < Minitest::Test
33
77
  def test_show
34
78
  ar = @api.create('ar_receipts', @sale_201608)
35
79
  assert 200, ar[:status].to_i
36
- assert @sale_201608[:customer_master_code], ar[:json]["customer_master_code"]
80
+ assert @sale_201608[:customer_master_code], ar[:json]['customer_master_code']
37
81
 
38
82
  show_ar = @api.show('ar_receipts', id: ar[:json]['id'])
39
83
  assert successful?(show_ar[:status])
@@ -66,7 +110,7 @@ class TsubaisoAPITest < Minitest::Test
66
110
  end
67
111
 
68
112
  def test_get_and_post
69
- time = Time.mktime(@sale_201702[:realization_timestamp])
113
+ time = Time.mktime(@sale_201702[:realization_timestamp])
70
114
  balance_before = @api.get('ar_receipts/balance', { year: time.year, month: time.month })
71
115
  assert successful?(balance_before[:status])
72
116
  assert balance_before[:json].count > 0
@@ -1,42 +1,207 @@
1
- # encoding: utf-8
2
1
  require 'minitest/autorun'
3
2
  require 'time'
4
3
  require './lib/tsubaiso_sdk'
5
4
 
6
5
  class TsubaisoSDKTest < Minitest::Test
7
-
8
6
  def setup
9
- @api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
7
+ @api = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
10
8
 
11
9
  # 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: "2012-07-01", finish_date: "2012-07-31", account_codes: ["135~999","604"], dept_code: "SETSURITSU", memo: "",
31
- criteria: "dept", target_timestamp: "2017-02-01", distribution_conditions: { "SETSURITSU" => "1", "COMMON" => "1" } }
10
+ @sale_201608 = {
11
+ price_including_tax: 10_800,
12
+ realization_timestamp: '2016-08-01',
13
+ customer_master_code: '101',
14
+ dept_code: 'SETSURITSU',
15
+ reason_master_code: 'SALES',
16
+ dc: 'd',
17
+ memo: '',
18
+ tax_code: 1007,
19
+ scheduled_memo: 'This is a scheduled memo.',
20
+ scheduled_receive_timestamp: '2016-09-25',
21
+ data_partner: { link_url: 'www.example.com/1', id_code: '1' }
22
+ }
23
+
24
+ @sale_201609 = {
25
+ price_including_tax: 10_800,
26
+ realization_timestamp: '2016-09-01',
27
+ customer_master_code: '101',
28
+ dept_code: 'SETSURITSU',
29
+ reason_master_code: 'SALES',
30
+ dc: 'd',
31
+ memo: '',
32
+ tax_code: 1007,
33
+ scheduled_memo: 'This is a scheduled memo.',
34
+ scheduled_receive_timestamp: '2016-09-25',
35
+ data_partner: { link_url: 'www.example.com/2', id_code: '2' }
36
+ }
37
+
38
+ @sale_201702 = {
39
+ price_including_tax: 10_800,
40
+ realization_timestamp: '2017-02-28',
41
+ customer_master_code: '105',
42
+ reason_master_code: 'SALES',
43
+ dc: 'd',
44
+ memo: '',
45
+ tax_code: 18,
46
+ scheduled_memo: 'This is a scheduled memo.',
47
+ scheduled_receive_timestamp: '2017-03-25',
48
+ data_partner: { link_url: 'www.example.com/8', id_code: '8' }
49
+ }
50
+
51
+ @purchase_201608 = {
52
+ price_including_tax: 5400,
53
+ year: 2016,
54
+ month: 8,
55
+ accrual_timestamp: '2016-08-01',
56
+ customer_master_code: '102',
57
+ dept_code: 'SETSURITSU',
58
+ reason_master_code: 'BUYING_IN',
59
+ dc: 'c',
60
+ memo: '',
61
+ tax_code: 1007,
62
+ port_type: 1,
63
+ data_partner: { link_url: 'www.example.com/3', id_code: '3' }
64
+ }
65
+
66
+ @purchase_201609 = {
67
+ price_including_tax: 5400,
68
+ year: 2016,
69
+ month: 9,
70
+ accrual_timestamp: '2016-09-01',
71
+ customer_master_code: '102',
72
+ dept_code: 'SETSURITSU',
73
+ reason_master_code: 'BUYING_IN',
74
+ dc: 'c',
75
+ memo: '',
76
+ tax_code: 1007,
77
+ port_type: 1,
78
+ data_partner: { link_url: 'www.example.com/4', id_code: '4' }
79
+ }
80
+
81
+ @purchase_201702 = {
82
+ price_including_tax: 5400,
83
+ year: 2017,
84
+ month: 2,
85
+ accrual_timestamp: '2017-02-28',
86
+ customer_master_code: '105',
87
+ reason_master_code: 'BUYING_IN',
88
+ dc: 'c',
89
+ memo: '',
90
+ tax_code: 18,
91
+ port_type: 1,
92
+ data_partner: { link_url: 'www.example.com/9', id_code: '9' }
93
+ }
94
+
95
+ @customer_1000 = {
96
+ name: 'テスト株式会社',
97
+ name_kana: 'テストカブシキガイシャ',
98
+ code: '10000',
99
+ tax_type_for_remittance_charge: '3',
100
+ used_in_ar: 1,
101
+ used_in_ap: 1,
102
+ is_valid: 1
103
+ }
104
+
105
+ @staff_data_1 = {
106
+ code: 'QUALIFICATION',
107
+ value: 'TOEIC',
108
+ start_timestamp: '2016-01-01',
109
+ no_finish_timestamp: '1',
110
+ memo: 'First memo'
111
+ }
112
+
113
+ @reimbursement_1 = {
114
+ applicant: 'Irfan',
115
+ application_term: '2016-03-01',
116
+ staff_code: 'EP2000',
117
+ memo: 'aaaaaaaa'
118
+ }
119
+
120
+ @reimbursement_2 = {
121
+ applicant: 'Matsuno',
122
+ application_term: '2016-03-01',
123
+ staff_code: 'EP2000',
124
+ memo: 'aaaaaaaa'
125
+ }
126
+
127
+ @reimbursement_tx_1 = {
128
+ transaction_timestamp: '2016-03-01',
129
+ price_value: 10_000,
130
+ dc: 'c',
131
+ reason_code: 'SUPPLIES',
132
+ brief: 'everyting going well',
133
+ memo: 'easy',
134
+ data_partner: { link_url: 'www.example.com/5', id_code: '5' }
135
+ }
136
+
137
+ @reimbursement_tx_2 = {
138
+ transaction_timestamp: '2016-03-01',
139
+ price_value: 20_000,
140
+ dc: 'c',
141
+ reason_code: 'SUPPLIES',
142
+ brief: 'not well',
143
+ memo: 'hard',
144
+ data_partner: { link_url: 'www.example.com/6', id_code: '6' }
145
+ }
146
+
147
+ @manual_journal_1 = {
148
+ journal_timestamp: '2016-04-01',
149
+ journal_dcs: [
150
+ debit: {
151
+ account_code: 100,
152
+ price_including_tax: 1000,
153
+ tax_type: 1,
154
+ sales_tax: 100
155
+ },
156
+ credit: {
157
+ account_code: 135,
158
+ price_including_tax: 1000,
159
+ tax_type: 1,
160
+ sales_tax: 100
161
+ }
162
+ ],
163
+ data_partner: { link_url: 'www.example.com/7', id_code: '7' }
164
+ }
165
+
166
+ @dept_1 = {
167
+ sort_no: 12_345_678,
168
+ code: 'test_code',
169
+ name: 'テスト部門',
170
+ name_abbr: 'テストブモン',
171
+ color: '#ffffff',
172
+ memo: 'テストメモ',
173
+ start_date: '2016-01-01',
174
+ finish_date: '2016-01-02'
175
+ }
176
+
177
+ @tag_1 = {
178
+ code: 'test_code',
179
+ name: 'テストタグ',
180
+ sort_no: 10_000,
181
+ tag_group_code: 'DEFAULT',
182
+ start_ymd: '2016-01-01',
183
+ finish_ymd: '2016-12-31'
184
+ }
185
+
186
+ @journal_distribution_1 = {
187
+ title: 'title',
188
+ start_date: '2012-07-01',
189
+ finish_date: '2012-07-31',
190
+ account_codes: ['135~999','604'],
191
+ dept_code: 'SETSURITSU',
192
+ memo: '',
193
+ criteria: 'dept',
194
+ target_timestamp: '2017-02-01',
195
+ distribution_conditions: { 'SETSURITSU' => '1', 'COMMON' => '1' }
196
+ }
32
197
  end
33
198
 
34
199
  def test_failed_request
35
- @api_fail = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: "fake token" })
200
+ @api_fail = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: 'fake token' })
36
201
  sale = @api_fail.create_sale(@sale_201608)
37
202
 
38
203
  assert_equal 401, sale[:status].to_i, sale.inspect
39
- assert_equal "Bad credentials", sale[:json][:error]
204
+ assert_equal 'Bad credentials', sale[:json][:error]
40
205
  end
41
206
 
42
207
  def test_create_customer
@@ -44,7 +209,6 @@ class TsubaisoSDKTest < Minitest::Test
44
209
 
45
210
  assert_equal 200, customer[:status].to_i, customer.inspect
46
211
  assert_equal @customer_1000[:name], customer[:json][:name]
47
-
48
212
  ensure
49
213
  @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
50
214
  end
@@ -55,7 +219,6 @@ class TsubaisoSDKTest < Minitest::Test
55
219
  assert_equal 200, sale[:status].to_i, sale.inspect
56
220
  assert_equal @sale_201608[:dept_code], sale[:json][:dept_code]
57
221
  assert_equal @sale_201608[:data_partner][:id_code], sale[:json][:data_partner][:id_code]
58
-
59
222
  ensure
60
223
  @api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
61
224
  end
@@ -66,7 +229,6 @@ class TsubaisoSDKTest < Minitest::Test
66
229
  assert_equal 200, purchase[:status].to_i, purchase.inspect
67
230
  assert_equal @purchase_201608[:dept_code], purchase[:json][:dept_code]
68
231
  assert_equal @purchase_201608[:data_partner][:id_code], purchase[:json][:data_partner][:id_code]
69
-
70
232
  ensure
71
233
  @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
72
234
  end
@@ -80,7 +242,6 @@ class TsubaisoSDKTest < Minitest::Test
80
242
 
81
243
  assert_equal 200, staff_data[:status].to_i, staff_data.inspect
82
244
  assert_equal @staff_data_1[:value], staff_data[:json][:value]
83
-
84
245
  ensure
85
246
  @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
86
247
  end
@@ -90,9 +251,8 @@ class TsubaisoSDKTest < Minitest::Test
90
251
 
91
252
  begin
92
253
  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"]
254
+ assert_equal @manual_journal_1[:journal_dcs][0][:price_including_tax], manual_journal[:json][:journal_dcs][0]['price_including_tax']
94
255
  assert_equal @manual_journal_1[:data_partner][:id_code], manual_journal[:json][:data_partner][:id_code]
95
-
96
256
  ensure
97
257
  @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
98
258
  end
@@ -102,8 +262,7 @@ class TsubaisoSDKTest < Minitest::Test
102
262
  reimbursement = @api.create_reimbursement(@reimbursement_1)
103
263
  assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
104
264
  assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
105
-
106
- ensure
265
+ ensure
107
266
  @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
108
267
  end
109
268
 
@@ -114,8 +273,7 @@ class TsubaisoSDKTest < Minitest::Test
114
273
  assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
115
274
  assert_equal @reimbursement_tx_1[:price_value], reimbursement_transaction[:json][:price_value]
116
275
  assert_equal @reimbursement_tx_1[:data_partner][:id_code], reimbursement_transaction[:json][:data_partner][:id_code]
117
-
118
- ensure
276
+ ensure
119
277
  @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
120
278
  @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
121
279
  end
@@ -124,8 +282,7 @@ class TsubaisoSDKTest < Minitest::Test
124
282
  dept = @api.create_dept(@dept_1)
125
283
  assert_equal 200, dept[:status].to_i, dept.inspect
126
284
  assert_equal @dept_1[:code], dept[:json][:code]
127
-
128
- ensure
285
+ ensure
129
286
  @api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
130
287
  end
131
288
 
@@ -133,8 +290,7 @@ class TsubaisoSDKTest < Minitest::Test
133
290
  tag = @api.create_tag(@tag_1)
134
291
  assert_equal 200, tag[:status].to_i, tag.inspect
135
292
  assert_equal @tag_1[:code], tag[:json][:code]
136
-
137
- ensure
293
+ ensure
138
294
  @api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
139
295
  end
140
296
 
@@ -152,18 +308,19 @@ class TsubaisoSDKTest < Minitest::Test
152
308
  journals_list_after = @api.list_journals(options)
153
309
  records_after_count = journals_list_after[:json][:records].count
154
310
  assert_equal 200, journals_list_after[:status].to_i, journals_list_after.inspect
155
- assert (records_before_count != records_after_count)
156
-
311
+ assert(records_before_count != records_after_count)
157
312
  ensure
158
313
  @api.destroy_journal_distribution(journal_distribution[:json][:id]) if journal_distribution[:json][:id]
159
314
  end
160
315
 
161
316
  def test_update_sale
162
317
  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" } }
318
+ options = {
319
+ id: sale[:json][:id],
320
+ price_including_tax: 25_000,
321
+ memo: 'Updated memo',
322
+ data_partner: { id_code: '100' }
323
+ }
167
324
 
168
325
  updated_sale = @api.update_sale(options)
169
326
  assert_equal 200, updated_sale[:status].to_i, updated_sale[:json]
@@ -171,7 +328,6 @@ class TsubaisoSDKTest < Minitest::Test
171
328
  assert_equal options[:memo], updated_sale[:json][:memo]
172
329
  assert_equal options[:price_including_tax], updated_sale[:json][:price_including_tax]
173
330
  assert_equal options[:data_partner][:id_code], updated_sale[:json][:data_partner][:id_code]
174
-
175
331
  ensure
176
332
  @api.destroy_sale("AP#{sale[:json][:id]}") if sale[:json][:id]
177
333
  end
@@ -179,10 +335,12 @@ class TsubaisoSDKTest < Minitest::Test
179
335
  def test_update_purchase
180
336
  purchase = @api.create_purchase(@purchase_201608)
181
337
  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" } }
338
+ options = {
339
+ id: purchase[:json][:id],
340
+ price_including_tax: 50_000,
341
+ memo: 'Updated memo',
342
+ data_partner: { id_code: '300' }
343
+ }
186
344
 
187
345
  updated_purchase = @api.update_purchase(options)
188
346
  assert_equal 200, updated_purchase[:status].to_i, updated_purchase.inspect
@@ -190,21 +348,21 @@ class TsubaisoSDKTest < Minitest::Test
190
348
  assert_equal options[:memo], updated_purchase[:json][:memo]
191
349
  assert_equal options[:price_including_tax], updated_purchase[:json][:price_including_tax]
192
350
  assert_equal options[:data_partner][:id_code], updated_purchase[:json][:data_partner][:id_code]
193
-
194
351
  ensure
195
352
  @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
196
353
  end
197
354
 
198
355
  def test_update_customer
199
356
  customer = @api.create_customer(@customer_1000)
200
- options = { id: customer[:json][:id],
201
- name: "New Customer Name"}
357
+ options = {
358
+ id: customer[:json][:id],
359
+ name: 'New Customer Name'
360
+ }
202
361
 
203
362
  updated_customer = @api.update_customer(options)
204
363
  assert_equal 200, updated_customer[:status].to_i
205
364
  assert_equal customer[:json][:id], updated_customer[:json][:id]
206
- assert_equal "New Customer Name", updated_customer[:json][:name]
207
-
365
+ assert_equal 'New Customer Name', updated_customer[:json][:name]
208
366
  ensure
209
367
  @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
210
368
  end
@@ -215,15 +373,15 @@ class TsubaisoSDKTest < Minitest::Test
215
373
  @staff_data_1[:staff_id] = first_staff_id
216
374
 
217
375
  staff_data = @api.create_staff_data(@staff_data_1)
218
- options = { id: staff_data[:json][:id],
219
- value: "Programmer"
220
- }
376
+ options = {
377
+ id: staff_data[:json][:id],
378
+ value: 'Programmer'
379
+ }
221
380
 
222
381
  updated_staff_data = @api.update_staff_data(options)
223
382
  assert_equal 200, updated_staff_data[:status].to_i, updated_staff_data.inspect
224
383
  assert_equal staff_data[:json][:id], updated_staff_data[:json][:id]
225
- assert_equal "Programmer", updated_staff_data[:json][:value]
226
-
384
+ assert_equal 'Programmer', updated_staff_data[:json][:value]
227
385
  ensure
228
386
  @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
229
387
  end
@@ -231,14 +389,13 @@ class TsubaisoSDKTest < Minitest::Test
231
389
  def test_update_reimbursement
232
390
  reimbursement = @api.create_reimbursement(@reimbursement_1)
233
391
  options = {
234
- applicant: "test",
235
- dept_code: "COMMON"
392
+ applicant: 'test',
393
+ dept_code: 'COMMON'
236
394
  }
237
395
  updated_reimbursement = @api.update_reimbursement(reimbursement[:json][:id], options)
238
396
  assert_equal 200, updated_reimbursement[:status].to_i, updated_reimbursement.inspect
239
397
  assert_equal options[:applicant], updated_reimbursement[:json][:applicant]
240
398
  assert_equal options[:dept_code], updated_reimbursement[:json][:dept_code]
241
-
242
399
  ensure
243
400
  @api.destroy_reimbursement(updated_reimbursement[:json][:id] || reimbursement[:json][:id]) if updated_reimbursement[:json][:id] || reimbursement[:json][:id]
244
401
  end
@@ -247,7 +404,7 @@ class TsubaisoSDKTest < Minitest::Test
247
404
  reimbursement = @api.create_reimbursement(@reimbursement_1)
248
405
  options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id].to_i })
249
406
  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" } }
407
+ updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => 'SUPPLIES', :data_partner => { :id_code => '500' } }
251
408
 
252
409
  updated_reimbursement_transaction = @api.update_reimbursement_transaction(updates)
253
410
  assert_equal 200, updated_reimbursement_transaction[:status].to_i, updated_reimbursement_transaction.inspect
@@ -255,7 +412,6 @@ class TsubaisoSDKTest < Minitest::Test
255
412
  assert_equal updates[:price_value].to_i, updated_reimbursement_transaction[:json][:price_value].to_i
256
413
  assert_equal updates[:reason_code], updated_reimbursement_transaction[:json][:reason_code]
257
414
  assert_equal updates[:data_partner][:id_code], updated_reimbursement_transaction[:json][:data_partner][:id_code]
258
-
259
415
  ensure
260
416
  @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
261
417
  @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
@@ -263,10 +419,11 @@ class TsubaisoSDKTest < Minitest::Test
263
419
 
264
420
  def test_update_manual_journal
265
421
  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
- }
422
+ options = {
423
+ id: manual_journal[:json][:id],
424
+ journal_dcs: manual_journal[:json][:journal_dcs],
425
+ data_partner: { :id_code => '700' }
426
+ }
270
427
  options[:journal_dcs][0][:debit][:price_including_tax] = 2000
271
428
  options[:journal_dcs][0][:credit][:price_including_tax] = 2000
272
429
 
@@ -274,26 +431,25 @@ class TsubaisoSDKTest < Minitest::Test
274
431
  assert_equal 200, updated_manual_journal[:status].to_i, updated_manual_journal.inspect
275
432
  assert_equal options[:journal_dcs][0][:debit][:price_including_tax], updated_manual_journal[:json][:journal_dcs][0][:debit][:price_including_tax]
276
433
  assert_equal options[:data_partner][:id_code], updated_manual_journal[:json][:data_partner][:id_code]
277
-
278
434
  ensure
279
435
  @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
280
436
  end
281
437
 
282
438
  def test_update_dept
283
439
  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
- }
440
+ options = {
441
+ id: dept[:json][:id],
442
+ sort_no: 98_765,
443
+ memo: 'updated at test',
444
+ name: '更新部門',
445
+ name_abbr: '更新部門'
446
+ }
290
447
 
291
448
  updated_dept = @api.update_dept(dept[:json][:id], options)
292
449
  assert_equal 200, updated_dept[:status].to_i, updated_dept.inspect
293
450
  assert_equal options[:memo], updated_dept[:json][:memo]
294
451
  assert_equal options[:name], updated_dept[:json][:name]
295
452
  assert_equal options[:name_abbr], updated_dept[:json][:name_abbr]
296
-
297
453
  ensure
298
454
  @api.destroy_dept(updated_dept[:json][:id] || dept[:json][:id]) if updated_dept[:json][:id] || dept[:json][:id]
299
455
  end
@@ -301,9 +457,10 @@ class TsubaisoSDKTest < Minitest::Test
301
457
  def test_update_tag
302
458
  tag = @api.create_tag(@tag_1)
303
459
  assert tag[:json][:id], tag
304
- options = { name: "更新タグ",
305
- code: "updated_tag"
306
- }
460
+ options = {
461
+ name: '更新タグ',
462
+ code: 'updated_tag'
463
+ }
307
464
 
308
465
  updated_tag = @api.update_tag(tag[:json][:id], options)
309
466
  assert_equal 200, updated_tag[:status].to_i, updated_tag.inspect
@@ -319,7 +476,6 @@ class TsubaisoSDKTest < Minitest::Test
319
476
  get_sale = @api.show_sale("AR#{sale[:json][:id]}")
320
477
  assert_equal 200, get_sale[:status].to_i, get_sale.inspect
321
478
  assert_equal sale[:json][:price_including_tax], get_sale[:json][:price_including_tax]
322
-
323
479
  ensure
324
480
  @api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
325
481
  end
@@ -330,7 +486,6 @@ class TsubaisoSDKTest < Minitest::Test
330
486
  get_purchase = @api.show_purchase("AP#{purchase[:json][:id]}")
331
487
  assert_equal 200, get_purchase[:status].to_i, get_purchase.inspect
332
488
  assert_equal purchase[:json][:id], get_purchase[:json][:id]
333
-
334
489
  ensure
335
490
  @api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
336
491
  end
@@ -341,7 +496,6 @@ class TsubaisoSDKTest < Minitest::Test
341
496
  get_customer = @api.show_customer(customer[:json][:id])
342
497
  assert_equal 200, get_customer[:status].to_i, get_customer.inspect
343
498
  assert_equal customer[:json][:id], get_customer[:json][:id]
344
-
345
499
  ensure
346
500
  @api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
347
501
  end
@@ -362,21 +516,21 @@ class TsubaisoSDKTest < Minitest::Test
362
516
 
363
517
  staff_data = @api.create_staff_data(@staff_data_1)
364
518
 
365
- #get data using id
519
+ # get data using id
366
520
  get_staff_data = @api.show_staff_data(staff_data[:json][:id])
367
521
  assert_equal 200, get_staff_data[:status].to_i, get_staff_data.inspect
368
522
  assert_equal staff_data[:json][:id], get_staff_data[:json][:id]
369
523
 
370
- options = { staff_id: staff_data[:json][:staff_id],
371
- code: staff_data[:json][:code],
372
- time: staff_data[:json][:start_timestamp]
373
- }
524
+ options = {
525
+ staff_id: staff_data[:json][:staff_id],
526
+ code: staff_data[:json][:code],
527
+ time: staff_data[:json][:start_timestamp]
528
+ }
374
529
 
375
- #get data using staff id and code
530
+ # get data using staff id and code
376
531
  get_staff_data_2 = @api.show_staff_data(options)
377
532
  assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data.inspect
378
533
  assert_equal staff_data[:json][:id], get_staff_data_2[:json][:id]
379
-
380
534
  ensure
381
535
  @api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
382
536
  end
@@ -396,7 +550,7 @@ class TsubaisoSDKTest < Minitest::Test
396
550
 
397
551
  options = { code: first_staff_datum_master_code }
398
552
 
399
- #get data using code
553
+ # get data using code
400
554
  get_staff_data_2 = @api.show_staff_datum_master(options)
401
555
  assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data_2.inspect
402
556
  assert_equal first_staff_datum_master_code, get_staff_data_2[:json][:code]
@@ -429,7 +583,6 @@ class TsubaisoSDKTest < Minitest::Test
429
583
 
430
584
  assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
431
585
  assert_equal options[:reimbursement_id], reimbursement_transaction[:json][:reimbursement_id]
432
-
433
586
  ensure
434
587
  @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
435
588
  @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
@@ -443,20 +596,18 @@ class TsubaisoSDKTest < Minitest::Test
443
596
  manual_journal = @api.show_manual_journal(first_manual_journal_id)
444
597
  assert_equal 200, manual_journal[:status].to_i, manual_journal.inspect
445
598
  assert_equal first_manual_journal_id, manual_journal[:json][:id]
446
-
447
599
  ensure
448
600
  @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
449
601
  end
450
602
 
451
603
  def test_show_journal
452
604
  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" })
605
+ journals_list = @api.list_journals({ start_date: '2016-04-01', finish_date: '2016-04-30' })
454
606
  first_journal_id = journals_list[:json][:records].first[:id]
455
607
 
456
608
  journal = @api.show_journal(first_journal_id)
457
609
  assert_equal 200, journal[:status].to_i, journal.inspect
458
610
  assert_equal first_journal_id, journal[:json][:records][:id]
459
-
460
611
  ensure
461
612
  @api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
462
613
  end
@@ -528,10 +679,9 @@ class TsubaisoSDKTest < Minitest::Test
528
679
 
529
680
  sales_list = @api.list_sales(2016, 8)
530
681
  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
-
682
+ assert(sales_list[:json].any? { |x| x[:id] == august_sale_a_id })
683
+ assert(sales_list[:json].any? { |x| x[:id] == august_sale_b_id })
684
+ assert(sales_list[:json].none? { |x| x[:id] == september_sale_id })
535
685
  ensure
536
686
  @api.destroy_sale("AR#{august_sale_a[:json][:id]}") if august_sale_a[:json][:id]
537
687
  @api.destroy_sale("AR#{august_sale_b[:json][:id]}") if august_sale_b[:json][:id]
@@ -556,14 +706,18 @@ class TsubaisoSDKTest < Minitest::Test
556
706
 
557
707
  customer_masters_list = @api.list_customers
558
708
  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
709
+ assert(customer_masters_list[:json].any? { |x| x[:code] == new_sale[:json][:customer_master_code] })
710
+ filtered_cm = customer_masters_list[:json].select { |x| x[:code] == new_sale[:json][:customer_master_code] }.first
561
711
 
562
712
  # 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])
713
+ balance_list = @api.list_sales_and_account_balances(realization_timestamp.year,
714
+ realization_timestamp.month,
715
+ :customer_master_id => filtered_cm[:id],
716
+ :ar_segment => filtered_cm[:used_in_ar])
717
+
564
718
  assert_equal 200, balance_list[:status].to_i, balance_list.inspect
565
719
  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] }
720
+ assert(balance_list[:json].all? { |x| x[:customer_master_code] == filtered_cm[:code] && x[:ar_segment] == filtered_cm[:used_in_ar] })
567
721
  ensure
568
722
  @api.destroy_sale("AR#{new_sale[:json][:id]}") if new_sale[:json][:id]
569
723
  end
@@ -579,10 +733,9 @@ class TsubaisoSDKTest < Minitest::Test
579
733
 
580
734
  purchase_list = @api.list_purchases(2016, 8)
581
735
  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
-
736
+ assert(purchase_list[:json].any? { |x| x[:id] == august_purchase_a_id })
737
+ assert(purchase_list[:json].any? { |x| x[:id] == august_purchase_b_id })
738
+ assert(purchase_list[:json].none? { |x| x[:id] == september_purchase_id })
586
739
  ensure
587
740
  @api.destroy_purchase("AP#{august_purchase_a[:json][:id]}") if august_purchase_a[:json][:id]
588
741
  @api.destroy_purchase("AP#{august_purchase_b[:json][:id]}") if august_purchase_b[:json][:id]
@@ -607,16 +760,20 @@ class TsubaisoSDKTest < Minitest::Test
607
760
 
608
761
  customer_masters_list = @api.list_customers
609
762
  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
763
+ assert(customer_masters_list[:json].any? { |x| x[:code] == new_purchase[:json][:customer_master_code] })
764
+ filtered_customer_master = customer_masters_list[:json].select { |x| x[:code] == new_purchase[:json][:customer_master_code] }.first
612
765
  customer_master_id = filtered_customer_master[:id]
613
766
  ap_segment = filtered_customer_master[:used_in_ap]
614
767
 
615
768
  # 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)
769
+ balance_list = @api.list_purchases_and_account_balances(accrual_timestamp.year,
770
+ accrual_timestamp.month,
771
+ :customer_master_id => customer_master_id,
772
+ :ap_segment => ap_segment)
773
+
617
774
  assert_equal 200, balance_list[:status].to_i, balance_list.inspect
618
775
  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 }
776
+ assert(balance_list[:json].all? { |x| x[:customer_master_id] == customer_master_id && x[:ap_segment] == ap_segment })
620
777
  ensure
621
778
  @api.destroy_purchase("AP#{new_purchase[:json][:id]}") if new_purchase[:json][:id]
622
779
  end
@@ -628,8 +785,7 @@ class TsubaisoSDKTest < Minitest::Test
628
785
 
629
786
  customer_list = @api.list_customers
630
787
  assert_equal 200, customer_list[:status].to_i, customer_list.inspect
631
- assert customer_list[:json].any?{ |x| x[:id] == customer_1000_id }
632
-
788
+ assert(customer_list[:json].any? { |x| x[:id] == customer_1000_id })
633
789
  ensure
634
790
  @api.destroy_customer(customer_1000[:json][:id]) if customer_1000[:json][:id]
635
791
  end
@@ -637,7 +793,7 @@ class TsubaisoSDKTest < Minitest::Test
637
793
  def test_list_staff
638
794
  staff_list = @api.list_staff
639
795
  assert_equal 200, staff_list[:status].to_i, staff_list.inspect
640
- assert(staff_list.size > 0)
796
+ assert !staff_list.empty?
641
797
  end
642
798
 
643
799
  def test_list_staff_data
@@ -646,19 +802,21 @@ class TsubaisoSDKTest < Minitest::Test
646
802
 
647
803
  staff_data_list = @api.list_staff_data(first_staff_id)
648
804
  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 }
805
+ assert(staff_data_list[:json].all? { |x| x[:staff_id] == first_staff_id })
650
806
  end
651
807
 
652
808
  def test_list_staff_datum_masters
653
809
  staff_datum_masters_list = @api.list_staff_datum_masters
654
810
  assert_equal 200, staff_datum_masters_list[:status].to_i, staff_datum_masters_list.inspect
655
- assert(staff_datum_masters_list.size > 0)
811
+ assert !staff_datum_masters_list.empty?
656
812
  end
657
813
 
658
814
  def test_list_manual_journals
659
815
  manual_journals_list = @api.list_manual_journals(2016, 4)
816
+ puts 'list'
817
+ puts manual_journals_list.inspect
660
818
  assert_equal 200, manual_journals_list[:status].to_i, manual_journals_list.inspect
661
- assert(manual_journals_list.size > 0)
819
+ assert !manual_journals_list.empty?
662
820
  end
663
821
 
664
822
  def test_list_journals
@@ -666,8 +824,12 @@ class TsubaisoSDKTest < Minitest::Test
666
824
  september_sale = @api.create_sale(@sale_201609)
667
825
  august_purchase = @api.create_purchase(@purchase_201608)
668
826
  september_purchase = @api.create_purchase(@purchase_201609)
827
+ assert_equal 200, august_sale[:status].to_i
828
+ assert_equal 200, september_sale[:status].to_i
829
+ assert_equal 200, august_purchase[:status].to_i
830
+ assert_equal 200, september_purchase[:status].to_i
669
831
 
670
- options = { start_date: "2016-08-01", finish_date: "2016-08-31" }
832
+ options = { start_date: '2016-08-01', finish_date: '2016-08-31' }
671
833
  journals_list = @api.list_journals(options)
672
834
  records = journals_list[:json][:records]
673
835
  assert_equal 200, journals_list[:status].to_i, journals_list.inspect
@@ -675,7 +837,7 @@ class TsubaisoSDKTest < Minitest::Test
675
837
  assert_includes record_timestamps, Time.parse(august_sale[:json][:realization_timestamp])
676
838
  assert_includes record_timestamps, Time.parse(august_purchase[:json][:accrual_timestamp])
677
839
 
678
- options = { price: 10800 }
840
+ options = { price: 10_800 }
679
841
  journals_list = @api.list_journals(options)
680
842
  records = journals_list[:json][:records]
681
843
  assert_equal 200, journals_list[:status].to_i, journals_list.inspect
@@ -683,7 +845,7 @@ class TsubaisoSDKTest < Minitest::Test
683
845
  assert_includes record_prices, august_sale[:json][:price_including_tax]
684
846
  assert_includes record_prices, september_sale[:json][:price_including_tax]
685
847
 
686
- options = { dept_code: "SETSURITSU" }
848
+ options = { dept_code: 'SETSURITSU' }
687
849
  journals_list = @api.list_journals(options)
688
850
  records = journals_list[:json][:records]
689
851
  assert_equal 200, journals_list[:status].to_i, journals_list.inspect
@@ -692,7 +854,6 @@ class TsubaisoSDKTest < Minitest::Test
692
854
  assert_includes record_depts, september_sale[:json][:dept_code]
693
855
  assert_includes record_depts, august_purchase[:json][:dept_code]
694
856
  assert_includes record_depts, september_purchase[:json][:dept_code]
695
-
696
857
  ensure
697
858
  @api.destroy_sale("AR#{august_sale[:json][:id]}") if august_sale[:json][:id]
698
859
  @api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
@@ -709,9 +870,8 @@ class TsubaisoSDKTest < Minitest::Test
709
870
 
710
871
  reimbursements_list = @api.list_reimbursements(2016, 3)
711
872
  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
-
873
+ assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_a_id })
874
+ assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_b_id })
715
875
  ensure
716
876
  @api.destroy_reimbursement(reimbursement_a_id) if reimbursement_a_id
717
877
  @api.destroy_reimbursement(reimbursement_b_id) if reimbursement_b_id
@@ -721,7 +881,7 @@ class TsubaisoSDKTest < Minitest::Test
721
881
  reimbursement_reason_masters_list = @api.list_reimbursement_reason_masters
722
882
  assert_equal 200, reimbursement_reason_masters_list[:status].to_i, reimbursement_reason_masters_list.inspect
723
883
  assert reimbursement_reason_masters_list[:json]
724
- assert(reimbursement_reason_masters_list[:json].size > 0)
884
+ assert !reimbursement_reason_masters_list[:json].empty?
725
885
  end
726
886
 
727
887
  def test_list_reimbursement_transactions
@@ -732,12 +892,11 @@ class TsubaisoSDKTest < Minitest::Test
732
892
 
733
893
  reimbursement_transactions = @api.list_reimbursement_transactions(reimbursement[:json][:id])
734
894
  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
-
895
+ assert(reimbursement_transactions[:json].any? { |x| x[:id] == reimbursement_transaction_1[:json][:id] })
896
+ assert(reimbursement_transactions[:json].any? { |x| x[:id] == reimbursement_transaction_2[:json][:id] })
738
897
  ensure
739
898
  @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]
899
+ @api.destroy_reimbursement_transaction(reimbursement_transaction_2[:json][:id]) if reimbursement_transaction_2[:json][:id]
741
900
  @api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
742
901
  end
743
902
 
@@ -747,8 +906,7 @@ class TsubaisoSDKTest < Minitest::Test
747
906
 
748
907
  depts = @api.list_depts
749
908
  assert_equal 200, depts[:status].to_i, depts.inspect
750
- assert depts[:json].any?{ |x| x[:id] == dept[:json][:id] }
751
-
909
+ assert(depts[:json].any? { |x| x[:id] == dept[:json][:id] })
752
910
  ensure
753
911
  @api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
754
912
  end
@@ -758,8 +916,7 @@ class TsubaisoSDKTest < Minitest::Test
758
916
 
759
917
  tags = @api.list_tags
760
918
  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
-
919
+ assert(tags[:json][@tag_1[:tag_group_code].to_sym].any? { |x| x[:id] == tag[:json][:id] })
763
920
  ensure
764
921
  @api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
765
922
  end
@@ -768,35 +925,35 @@ class TsubaisoSDKTest < Minitest::Test
768
925
  bonuses_list = @api.list_bonuses(1, 2016)
769
926
  assert_equal 200, bonuses_list[:status].to_i, bonuses_list.inspect
770
927
  assert bonuses_list[:json]
771
- assert(bonuses_list[:json].size > 0)
928
+ assert !bonuses_list[:json].empty?
772
929
  end
773
930
 
774
931
  def test_list_payrolls
775
932
  payrolls_list = @api.list_payrolls(2016, 2)
776
933
 
777
934
  assert_equal 200, payrolls_list[:status].to_i, payrolls_list.inspect
778
- assert(payrolls_list.size > 0)
935
+ assert !payrolls_list.empty?
779
936
  end
780
937
 
781
938
  def test_list_ar_reason_masters
782
939
  ar_reason_masters_list = @api.list_ar_reason_masters
783
940
  assert_equal 200, ar_reason_masters_list[:status].to_i, ar_reason_masters_list.inspect
784
941
  assert ar_reason_masters_list[:json]
785
- assert(ar_reason_masters_list[:json].size > 0)
942
+ assert !ar_reason_masters_list[:json].empty?
786
943
  end
787
944
 
788
945
  def test_list_ap_reason_masters
789
946
  ap_reason_masters_list = @api.list_ap_reason_masters
790
947
  assert_equal 200, ap_reason_masters_list[:status].to_i, ap_reason_masters_list.inspect
791
948
  assert ap_reason_masters_list[:json]
792
- assert(ap_reason_masters_list[:json].size > 0)
949
+ assert !ap_reason_masters_list[:json].empty?
793
950
  end
794
951
 
795
952
  def test_list_fixed_assets
796
953
  list = @api.list_fixed_assets
797
954
  assert_equal 200, list[:status].to_i, list.inspect
798
955
  assert list[:json]
799
- assert(list[:json].size > 0)
956
+ assert !list[:json].empty?
800
957
  end
801
958
 
802
959
  private