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