tsubaiso-sdk 1.2.6 → 1.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -2
- data/lib/tsubaiso_sdk.rb +1167 -128
- data/test/stubbings/stub_register.rb +196 -0
- data/test/tsubaiso_sdk/common_setup_and_teardown.rb +23 -0
- data/test/tsubaiso_sdk/test_ap_reason_masters.rb +26 -0
- data/test/tsubaiso_sdk/test_api_history.rb +27 -0
- data/test/tsubaiso_sdk/test_ar_reason_masters.rb +26 -0
- data/test/tsubaiso_sdk/test_bank_account.rb +34 -0
- data/test/tsubaiso_sdk/test_bank_account_master.rb +119 -0
- data/test/tsubaiso_sdk/test_bank_account_transaction.rb +61 -0
- data/test/tsubaiso_sdk/test_bank_reason_master.rb +90 -0
- data/test/tsubaiso_sdk/test_bonus.rb +26 -0
- data/test/tsubaiso_sdk/test_corporate_master.rb +27 -0
- data/test/tsubaiso_sdk/test_customer.rb +71 -0
- data/test/tsubaiso_sdk/test_dept.rb +66 -0
- data/test/tsubaiso_sdk/test_fixed_assets.rb +18 -0
- data/test/tsubaiso_sdk/test_journal.rb +53 -0
- data/test/tsubaiso_sdk/test_journal_distribution.rb +29 -0
- data/test/tsubaiso_sdk/test_manual_journal.rb +84 -0
- data/test/tsubaiso_sdk/test_payrolles.rb +26 -0
- data/test/tsubaiso_sdk/test_petty_cash_reason_master.rb +72 -0
- data/test/tsubaiso_sdk/test_physical_inventory_master.rb +84 -0
- data/test/tsubaiso_sdk/test_purchase.rb +120 -0
- data/test/tsubaiso_sdk/test_reimbursement_reason_master.rb +27 -0
- data/test/tsubaiso_sdk/test_reimbursements.rb +90 -0
- data/test/tsubaiso_sdk/test_reimbursements_transactions.rb +75 -0
- data/test/tsubaiso_sdk/test_sale.rb +125 -0
- data/test/tsubaiso_sdk/test_scheduled_dates.rb +16 -0
- data/test/tsubaiso_sdk/test_staff.rb +26 -0
- data/test/tsubaiso_sdk/test_staff_data.rb +71 -0
- data/test/tsubaiso_sdk/test_staff_datum_master.rb +37 -0
- data/test/tsubaiso_sdk/test_tag.rb +53 -0
- data/test/tsubaiso_sdk/test_tax_master.rb +25 -0
- metadata +34 -5
- data/test/test_tsubaiso_sdk.rb +0 -964
data/test/test_tsubaiso_sdk.rb
DELETED
@@ -1,964 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'time'
|
3
|
-
require './lib/tsubaiso_sdk'
|
4
|
-
|
5
|
-
class TsubaisoSDKTest < Minitest::Test
|
6
|
-
def setup
|
7
|
-
@api = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
|
8
|
-
|
9
|
-
# data
|
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
|
-
}
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_failed_request
|
200
|
-
@api_fail = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: 'fake token' })
|
201
|
-
sale = @api_fail.create_sale(@sale_201608)
|
202
|
-
|
203
|
-
assert_equal 401, sale[:status].to_i, sale.inspect
|
204
|
-
assert_equal 'Bad credentials', sale[:json][:error]
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_create_customer
|
208
|
-
customer = @api.create_customer(@customer_1000)
|
209
|
-
|
210
|
-
assert_equal 200, customer[:status].to_i, customer.inspect
|
211
|
-
assert_equal @customer_1000[:name], customer[:json][:name]
|
212
|
-
ensure
|
213
|
-
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_create_sale
|
217
|
-
sale = @api.create_sale(@sale_201608)
|
218
|
-
|
219
|
-
assert_equal 200, sale[:status].to_i, sale.inspect
|
220
|
-
assert_equal @sale_201608[:dept_code], sale[:json][:dept_code]
|
221
|
-
assert_equal @sale_201608[:data_partner][:id_code], sale[:json][:data_partner][:id_code]
|
222
|
-
ensure
|
223
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
|
224
|
-
end
|
225
|
-
|
226
|
-
def test_create_purchase
|
227
|
-
purchase = @api.create_purchase(@purchase_201608)
|
228
|
-
|
229
|
-
assert_equal 200, purchase[:status].to_i, purchase.inspect
|
230
|
-
assert_equal @purchase_201608[:dept_code], purchase[:json][:dept_code]
|
231
|
-
assert_equal @purchase_201608[:data_partner][:id_code], purchase[:json][:data_partner][:id_code]
|
232
|
-
ensure
|
233
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_create_staff_data
|
237
|
-
staff_list = @api.list_staff
|
238
|
-
first_staff_id = staff_list[:json].first[:id]
|
239
|
-
@staff_data_1[:staff_id] = first_staff_id
|
240
|
-
|
241
|
-
staff_data = @api.create_staff_data(@staff_data_1)
|
242
|
-
|
243
|
-
assert_equal 200, staff_data[:status].to_i, staff_data.inspect
|
244
|
-
assert_equal @staff_data_1[:value], staff_data[:json][:value]
|
245
|
-
ensure
|
246
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_create_manual_journal
|
250
|
-
manual_journal = @api.create_manual_journal(@manual_journal_1)
|
251
|
-
|
252
|
-
begin
|
253
|
-
assert_equal 200, manual_journal[:status].to_i, manual_journal.inspect
|
254
|
-
assert_equal @manual_journal_1[:journal_dcs][0][:price_including_tax], manual_journal[:json][:journal_dcs][0]['price_including_tax']
|
255
|
-
assert_equal @manual_journal_1[:data_partner][:id_code], manual_journal[:json][:data_partner][:id_code]
|
256
|
-
ensure
|
257
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_create_reimbursement
|
262
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
263
|
-
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
264
|
-
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
265
|
-
ensure
|
266
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_create_reimbursement_transaction
|
270
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
271
|
-
options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id] })
|
272
|
-
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
273
|
-
assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
|
274
|
-
assert_equal @reimbursement_tx_1[:price_value], reimbursement_transaction[:json][:price_value]
|
275
|
-
assert_equal @reimbursement_tx_1[:data_partner][:id_code], reimbursement_transaction[:json][:data_partner][:id_code]
|
276
|
-
ensure
|
277
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
278
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_create_dept
|
282
|
-
dept = @api.create_dept(@dept_1)
|
283
|
-
assert_equal 200, dept[:status].to_i, dept.inspect
|
284
|
-
assert_equal @dept_1[:code], dept[:json][:code]
|
285
|
-
ensure
|
286
|
-
@api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
|
287
|
-
end
|
288
|
-
|
289
|
-
def test_create_tag
|
290
|
-
tag = @api.create_tag(@tag_1)
|
291
|
-
assert_equal 200, tag[:status].to_i, tag.inspect
|
292
|
-
assert_equal @tag_1[:code], tag[:json][:code]
|
293
|
-
ensure
|
294
|
-
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_create_journal_distribution
|
298
|
-
options = { start_date: @journal_distribution_1[:target_timestamp], finish_date: @journal_distribution_1[:target_timestamp] }
|
299
|
-
|
300
|
-
journals_list_before = @api.list_journals(options)
|
301
|
-
records_before_count = journals_list_before[:json][:records].count
|
302
|
-
assert_equal 200, journals_list_before[:status].to_i, journals_list_before.inspect
|
303
|
-
|
304
|
-
journal_distribution = @api.create_journal_distribution(@journal_distribution_1)
|
305
|
-
assert_equal 200, journal_distribution[:status].to_i, journal_distribution.inspect
|
306
|
-
assert_equal Time.parse(@journal_distribution_1[:target_timestamp]), Time.parse(journal_distribution[:json][:target_ym])
|
307
|
-
|
308
|
-
journals_list_after = @api.list_journals(options)
|
309
|
-
records_after_count = journals_list_after[:json][:records].count
|
310
|
-
assert_equal 200, journals_list_after[:status].to_i, journals_list_after.inspect
|
311
|
-
assert(records_before_count != records_after_count)
|
312
|
-
ensure
|
313
|
-
@api.destroy_journal_distribution(journal_distribution[:json][:id]) if journal_distribution[:json][:id]
|
314
|
-
end
|
315
|
-
|
316
|
-
def test_update_sale
|
317
|
-
sale = @api.create_sale(@sale_201608)
|
318
|
-
options = {
|
319
|
-
id: sale[:json][:id],
|
320
|
-
price_including_tax: 25_000,
|
321
|
-
memo: 'Updated memo',
|
322
|
-
data_partner: { id_code: '100' }
|
323
|
-
}
|
324
|
-
|
325
|
-
updated_sale = @api.update_sale(options)
|
326
|
-
assert_equal 200, updated_sale[:status].to_i, updated_sale[:json]
|
327
|
-
assert_equal options[:id], updated_sale[:json][:id]
|
328
|
-
assert_equal options[:memo], updated_sale[:json][:memo]
|
329
|
-
assert_equal options[:price_including_tax], updated_sale[:json][:price_including_tax]
|
330
|
-
assert_equal options[:data_partner][:id_code], updated_sale[:json][:data_partner][:id_code]
|
331
|
-
ensure
|
332
|
-
@api.destroy_sale("AP#{sale[:json][:id]}") if sale[:json][:id]
|
333
|
-
end
|
334
|
-
|
335
|
-
def test_update_purchase
|
336
|
-
purchase = @api.create_purchase(@purchase_201608)
|
337
|
-
assert purchase[:json][:id], purchase
|
338
|
-
options = {
|
339
|
-
id: purchase[:json][:id],
|
340
|
-
price_including_tax: 50_000,
|
341
|
-
memo: 'Updated memo',
|
342
|
-
data_partner: { id_code: '300' }
|
343
|
-
}
|
344
|
-
|
345
|
-
updated_purchase = @api.update_purchase(options)
|
346
|
-
assert_equal 200, updated_purchase[:status].to_i, updated_purchase.inspect
|
347
|
-
assert_equal options[:id], updated_purchase[:json][:id]
|
348
|
-
assert_equal options[:memo], updated_purchase[:json][:memo]
|
349
|
-
assert_equal options[:price_including_tax], updated_purchase[:json][:price_including_tax]
|
350
|
-
assert_equal options[:data_partner][:id_code], updated_purchase[:json][:data_partner][:id_code]
|
351
|
-
ensure
|
352
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
353
|
-
end
|
354
|
-
|
355
|
-
def test_update_customer
|
356
|
-
customer = @api.create_customer(@customer_1000)
|
357
|
-
options = {
|
358
|
-
id: customer[:json][:id],
|
359
|
-
name: 'New Customer Name'
|
360
|
-
}
|
361
|
-
|
362
|
-
updated_customer = @api.update_customer(options)
|
363
|
-
assert_equal 200, updated_customer[:status].to_i
|
364
|
-
assert_equal customer[:json][:id], updated_customer[:json][:id]
|
365
|
-
assert_equal 'New Customer Name', updated_customer[:json][:name]
|
366
|
-
ensure
|
367
|
-
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
368
|
-
end
|
369
|
-
|
370
|
-
def test_update_staff_data
|
371
|
-
staff_list = @api.list_staff
|
372
|
-
first_staff_id = staff_list[:json].first[:id]
|
373
|
-
@staff_data_1[:staff_id] = first_staff_id
|
374
|
-
|
375
|
-
staff_data = @api.create_staff_data(@staff_data_1)
|
376
|
-
options = {
|
377
|
-
id: staff_data[:json][:id],
|
378
|
-
value: 'Programmer'
|
379
|
-
}
|
380
|
-
|
381
|
-
updated_staff_data = @api.update_staff_data(options)
|
382
|
-
assert_equal 200, updated_staff_data[:status].to_i, updated_staff_data.inspect
|
383
|
-
assert_equal staff_data[:json][:id], updated_staff_data[:json][:id]
|
384
|
-
assert_equal 'Programmer', updated_staff_data[:json][:value]
|
385
|
-
ensure
|
386
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
387
|
-
end
|
388
|
-
|
389
|
-
def test_update_reimbursement
|
390
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
391
|
-
options = {
|
392
|
-
applicant: 'test',
|
393
|
-
dept_code: 'COMMON'
|
394
|
-
}
|
395
|
-
updated_reimbursement = @api.update_reimbursement(reimbursement[:json][:id], options)
|
396
|
-
assert_equal 200, updated_reimbursement[:status].to_i, updated_reimbursement.inspect
|
397
|
-
assert_equal options[:applicant], updated_reimbursement[:json][:applicant]
|
398
|
-
assert_equal options[:dept_code], updated_reimbursement[:json][:dept_code]
|
399
|
-
ensure
|
400
|
-
@api.destroy_reimbursement(updated_reimbursement[:json][:id] || reimbursement[:json][:id]) if updated_reimbursement[:json][:id] || reimbursement[:json][:id]
|
401
|
-
end
|
402
|
-
|
403
|
-
def test_update_reimbursement_transaction
|
404
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
405
|
-
options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id].to_i })
|
406
|
-
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
407
|
-
updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => 'SUPPLIES', :data_partner => { :id_code => '500' } }
|
408
|
-
|
409
|
-
updated_reimbursement_transaction = @api.update_reimbursement_transaction(updates)
|
410
|
-
assert_equal 200, updated_reimbursement_transaction[:status].to_i, updated_reimbursement_transaction.inspect
|
411
|
-
assert_equal updates[:id].to_i, updated_reimbursement_transaction[:json][:id].to_i
|
412
|
-
assert_equal updates[:price_value].to_i, updated_reimbursement_transaction[:json][:price_value].to_i
|
413
|
-
assert_equal updates[:reason_code], updated_reimbursement_transaction[:json][:reason_code]
|
414
|
-
assert_equal updates[:data_partner][:id_code], updated_reimbursement_transaction[:json][:data_partner][:id_code]
|
415
|
-
ensure
|
416
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
417
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
418
|
-
end
|
419
|
-
|
420
|
-
def test_update_manual_journal
|
421
|
-
manual_journal = @api.create_manual_journal(@manual_journal_1)
|
422
|
-
options = {
|
423
|
-
id: manual_journal[:json][:id],
|
424
|
-
journal_dcs: manual_journal[:json][:journal_dcs],
|
425
|
-
data_partner: { :id_code => '700' }
|
426
|
-
}
|
427
|
-
options[:journal_dcs][0][:debit][:price_including_tax] = 2000
|
428
|
-
options[:journal_dcs][0][:credit][:price_including_tax] = 2000
|
429
|
-
|
430
|
-
updated_manual_journal = @api.update_manual_journal(options)
|
431
|
-
assert_equal 200, updated_manual_journal[:status].to_i, updated_manual_journal.inspect
|
432
|
-
assert_equal options[:journal_dcs][0][:debit][:price_including_tax], updated_manual_journal[:json][:journal_dcs][0][:debit][:price_including_tax]
|
433
|
-
assert_equal options[:data_partner][:id_code], updated_manual_journal[:json][:data_partner][:id_code]
|
434
|
-
ensure
|
435
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
436
|
-
end
|
437
|
-
|
438
|
-
def test_update_dept
|
439
|
-
dept = @api.create_dept(@dept_1)
|
440
|
-
options = {
|
441
|
-
id: dept[:json][:id],
|
442
|
-
sort_no: 98_765,
|
443
|
-
memo: 'updated at test',
|
444
|
-
name: '更新部門',
|
445
|
-
name_abbr: '更新部門'
|
446
|
-
}
|
447
|
-
|
448
|
-
updated_dept = @api.update_dept(dept[:json][:id], options)
|
449
|
-
assert_equal 200, updated_dept[:status].to_i, updated_dept.inspect
|
450
|
-
assert_equal options[:memo], updated_dept[:json][:memo]
|
451
|
-
assert_equal options[:name], updated_dept[:json][:name]
|
452
|
-
assert_equal options[:name_abbr], updated_dept[:json][:name_abbr]
|
453
|
-
ensure
|
454
|
-
@api.destroy_dept(updated_dept[:json][:id] || dept[:json][:id]) if updated_dept[:json][:id] || dept[:json][:id]
|
455
|
-
end
|
456
|
-
|
457
|
-
def test_update_tag
|
458
|
-
tag = @api.create_tag(@tag_1)
|
459
|
-
assert tag[:json][:id], tag
|
460
|
-
options = {
|
461
|
-
name: '更新タグ',
|
462
|
-
code: 'updated_tag'
|
463
|
-
}
|
464
|
-
|
465
|
-
updated_tag = @api.update_tag(tag[:json][:id], options)
|
466
|
-
assert_equal 200, updated_tag[:status].to_i, updated_tag.inspect
|
467
|
-
assert_equal options[:name], updated_tag[:json][:name]
|
468
|
-
assert_equal options[:code], updated_tag[:json][:code]
|
469
|
-
ensure
|
470
|
-
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
471
|
-
end
|
472
|
-
|
473
|
-
def test_show_sale
|
474
|
-
sale = @api.create_sale(@sale_201608)
|
475
|
-
|
476
|
-
get_sale = @api.show_sale("AR#{sale[:json][:id]}")
|
477
|
-
assert_equal 200, get_sale[:status].to_i, get_sale.inspect
|
478
|
-
assert_equal sale[:json][:price_including_tax], get_sale[:json][:price_including_tax]
|
479
|
-
ensure
|
480
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
|
481
|
-
end
|
482
|
-
|
483
|
-
def test_show_purchase
|
484
|
-
purchase = @api.create_purchase(@purchase_201608)
|
485
|
-
|
486
|
-
get_purchase = @api.show_purchase("AP#{purchase[:json][:id]}")
|
487
|
-
assert_equal 200, get_purchase[:status].to_i, get_purchase.inspect
|
488
|
-
assert_equal purchase[:json][:id], get_purchase[:json][:id]
|
489
|
-
ensure
|
490
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
491
|
-
end
|
492
|
-
|
493
|
-
def test_show_customer
|
494
|
-
customer = @api.create_customer(@customer_1000)
|
495
|
-
|
496
|
-
get_customer = @api.show_customer(customer[:json][:id])
|
497
|
-
assert_equal 200, get_customer[:status].to_i, get_customer.inspect
|
498
|
-
assert_equal customer[:json][:id], get_customer[:json][:id]
|
499
|
-
ensure
|
500
|
-
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
501
|
-
end
|
502
|
-
|
503
|
-
def test_show_staff
|
504
|
-
staff_list = @api.list_staff
|
505
|
-
first_staff_id = staff_list[:json].first[:id]
|
506
|
-
|
507
|
-
get_staff_member = @api.show_staff(first_staff_id)
|
508
|
-
assert_equal 200, get_staff_member[:status].to_i, get_staff_member.inspect
|
509
|
-
assert_equal first_staff_id, get_staff_member[:json][:id]
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_show_staff_data
|
513
|
-
staff_list = @api.list_staff
|
514
|
-
first_staff_id = staff_list[:json].first[:id]
|
515
|
-
@staff_data_1[:staff_id] = first_staff_id
|
516
|
-
|
517
|
-
staff_data = @api.create_staff_data(@staff_data_1)
|
518
|
-
|
519
|
-
# get data using id
|
520
|
-
get_staff_data = @api.show_staff_data(staff_data[:json][:id])
|
521
|
-
assert_equal 200, get_staff_data[:status].to_i, get_staff_data.inspect
|
522
|
-
assert_equal staff_data[:json][:id], get_staff_data[:json][:id]
|
523
|
-
|
524
|
-
options = {
|
525
|
-
staff_id: staff_data[:json][:staff_id],
|
526
|
-
code: staff_data[:json][:code],
|
527
|
-
time: staff_data[:json][:start_timestamp]
|
528
|
-
}
|
529
|
-
|
530
|
-
# get data using staff id and code
|
531
|
-
get_staff_data_2 = @api.show_staff_data(options)
|
532
|
-
assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data.inspect
|
533
|
-
assert_equal staff_data[:json][:id], get_staff_data_2[:json][:id]
|
534
|
-
ensure
|
535
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
536
|
-
end
|
537
|
-
|
538
|
-
def test_show_staff_datum_master
|
539
|
-
staff_datum_masters_list = @api.list_staff_datum_masters
|
540
|
-
first_staff_datum_master_id = staff_datum_masters_list[:json].first[:id]
|
541
|
-
|
542
|
-
get_staff_datum_master = @api.show_staff_datum_master(first_staff_datum_master_id)
|
543
|
-
assert_equal 200, get_staff_datum_master[:status].to_i, get_staff_datum_master.inspect
|
544
|
-
assert_equal first_staff_datum_master_id, get_staff_datum_master[:json][:id]
|
545
|
-
end
|
546
|
-
|
547
|
-
def test_show_staff_datum_master_by_code
|
548
|
-
staff_datum_masters_list = @api.list_staff_datum_masters
|
549
|
-
first_staff_datum_master_code = staff_datum_masters_list[:json].first[:code]
|
550
|
-
|
551
|
-
options = { code: first_staff_datum_master_code }
|
552
|
-
|
553
|
-
# get data using code
|
554
|
-
get_staff_data_2 = @api.show_staff_datum_master(options)
|
555
|
-
assert_equal 200, get_staff_data_2[:status].to_i, get_staff_data_2.inspect
|
556
|
-
assert_equal first_staff_datum_master_code, get_staff_data_2[:json][:code]
|
557
|
-
end
|
558
|
-
|
559
|
-
def test_show_reimbursement
|
560
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
561
|
-
reimbursement = @api.show_reimbursement(reimbursement[:json][:id])
|
562
|
-
|
563
|
-
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
564
|
-
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
565
|
-
ensure
|
566
|
-
@api.destroy_reimbursement(reimbursement[:json][:id])
|
567
|
-
end
|
568
|
-
|
569
|
-
def test_show_reimbursement_reason_master
|
570
|
-
reim_reason_msts = @api.list_reimbursement_reason_masters
|
571
|
-
reim_reason_mst_id = reim_reason_msts[:json].first[:id]
|
572
|
-
reim_reason_mst = @api.show_reimbursement_reason_master(reim_reason_mst_id)
|
573
|
-
|
574
|
-
assert_equal 200, reim_reason_mst[:status].to_i, reim_reason_mst.inspect
|
575
|
-
assert_equal reim_reason_mst[:json][:id], reim_reason_mst_id
|
576
|
-
end
|
577
|
-
|
578
|
-
def test_show_reimbursement_transaction
|
579
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
580
|
-
options = { :reimbursement_id => reimbursement[:json][:id].to_i }
|
581
|
-
reimbursement_transaction = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
|
582
|
-
reimbursement_transaction = @api.show_reimbursement_transaction(reimbursement_transaction[:json][:id])
|
583
|
-
|
584
|
-
assert_equal 200, reimbursement_transaction[:status].to_i, reimbursement_transaction.inspect
|
585
|
-
assert_equal options[:reimbursement_id], reimbursement_transaction[:json][:reimbursement_id]
|
586
|
-
ensure
|
587
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
588
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
589
|
-
end
|
590
|
-
|
591
|
-
def test_show_manual_journal
|
592
|
-
@api.create_manual_journal(@manual_journal_1)
|
593
|
-
manual_journals_list = @api.list_manual_journals(2016, 4)
|
594
|
-
first_manual_journal_id = manual_journals_list[:json].first[:id]
|
595
|
-
|
596
|
-
manual_journal = @api.show_manual_journal(first_manual_journal_id)
|
597
|
-
assert_equal 200, manual_journal[:status].to_i, manual_journal.inspect
|
598
|
-
assert_equal first_manual_journal_id, manual_journal[:json][:id]
|
599
|
-
ensure
|
600
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
601
|
-
end
|
602
|
-
|
603
|
-
def test_show_journal
|
604
|
-
manual_journal = @api.create_manual_journal(@manual_journal_1)
|
605
|
-
journals_list = @api.list_journals({ start_date: '2016-04-01', finish_date: '2016-04-30' })
|
606
|
-
first_journal_id = journals_list[:json][:records].first[:id]
|
607
|
-
|
608
|
-
journal = @api.show_journal(first_journal_id)
|
609
|
-
assert_equal 200, journal[:status].to_i, journal.inspect
|
610
|
-
assert_equal first_journal_id, journal[:json][:records][:id]
|
611
|
-
ensure
|
612
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
613
|
-
end
|
614
|
-
|
615
|
-
def test_show_dept
|
616
|
-
dept = @api.create_dept(@dept_1)
|
617
|
-
dept = @api.show_dept(dept[:json][:id])
|
618
|
-
|
619
|
-
assert_equal 200, dept[:status].to_i, dept.inspect
|
620
|
-
assert_equal @dept_1[:memo], dept[:json][:memo]
|
621
|
-
ensure
|
622
|
-
@api.destroy_dept(dept[:json][:id])
|
623
|
-
end
|
624
|
-
|
625
|
-
def test_show_tag
|
626
|
-
tag = @api.create_tag(@tag_1)
|
627
|
-
tag = @api.show_tag(tag[:json][:id])
|
628
|
-
|
629
|
-
assert_equal 200, tag[:status].to_i, tag.inspect
|
630
|
-
assert_equal @tag_1[:name], tag[:json][:name]
|
631
|
-
ensure
|
632
|
-
@api.destroy_tag(tag[:json][:id])
|
633
|
-
end
|
634
|
-
|
635
|
-
def test_show_bonus
|
636
|
-
bonuses = @api.list_bonuses(1, 2016)
|
637
|
-
bonus_id = bonuses[:json].first[:id]
|
638
|
-
bonus = @api.show_bonus(bonus_id)
|
639
|
-
|
640
|
-
assert_equal 200, bonus[:status].to_i, bonus.inspect
|
641
|
-
assert_equal bonus[:json][:id], bonus_id
|
642
|
-
end
|
643
|
-
|
644
|
-
def test_show_payroll
|
645
|
-
payrolls_list = @api.list_payrolls(2017, 2)
|
646
|
-
first_payroll_id = payrolls_list[:json].first[:id]
|
647
|
-
|
648
|
-
payroll = @api.show_payroll(first_payroll_id)
|
649
|
-
assert_equal 200, payroll[:status].to_i, payroll.inspect
|
650
|
-
assert_equal first_payroll_id, payroll[:json][:id]
|
651
|
-
end
|
652
|
-
|
653
|
-
def test_show_ar_reason_master
|
654
|
-
ar_reason_masters = @api.list_ar_reason_masters
|
655
|
-
ar_reason_master_id = ar_reason_masters[:json].first[:id]
|
656
|
-
ar_reason_master = @api.show_ar_reason_master(ar_reason_master_id)
|
657
|
-
|
658
|
-
assert_equal 200, ar_reason_master[:status].to_i, ar_reason_master.inspect
|
659
|
-
assert_equal ar_reason_master[:json][:id], ar_reason_master_id
|
660
|
-
end
|
661
|
-
|
662
|
-
def test_show_ap_reason_master
|
663
|
-
ap_reason_masters = @api.list_ap_reason_masters
|
664
|
-
first_ap_reason_master = ap_reason_masters[:json].first
|
665
|
-
ap_reason_master = @api.show_ap_reason_master(first_ap_reason_master[:id])
|
666
|
-
|
667
|
-
assert_equal 200, ap_reason_master[:status].to_i, ap_reason_master.inspect
|
668
|
-
assert_equal first_ap_reason_master[:reason_code], ap_reason_master[:json][:reason_code]
|
669
|
-
end
|
670
|
-
|
671
|
-
def test_list_sales
|
672
|
-
august_sale_a = @api.create_sale(@sale_201608)
|
673
|
-
august_sale_b = @api.create_sale(@sale_201608)
|
674
|
-
september_sale = @api.create_sale(@sale_201609)
|
675
|
-
|
676
|
-
august_sale_a_id = august_sale_a[:json][:id]
|
677
|
-
august_sale_b_id = august_sale_b[:json][:id]
|
678
|
-
september_sale_id = september_sale[:json][:id]
|
679
|
-
|
680
|
-
sales_list = @api.list_sales(2016, 8)
|
681
|
-
assert_equal 200, sales_list[:status].to_i, sales_list.inspect
|
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 })
|
685
|
-
ensure
|
686
|
-
@api.destroy_sale("AR#{august_sale_a[:json][:id]}") if august_sale_a[:json][:id]
|
687
|
-
@api.destroy_sale("AR#{august_sale_b[:json][:id]}") if august_sale_b[:json][:id]
|
688
|
-
@api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
|
689
|
-
end
|
690
|
-
|
691
|
-
def test_list_sales_and_account_balances
|
692
|
-
realization_timestamp = Time.parse(@sale_201702[:realization_timestamp])
|
693
|
-
|
694
|
-
# Without customer_master_code and ar_segment option parameters
|
695
|
-
balance_list_before = @api.list_sales_and_account_balances(realization_timestamp.year, realization_timestamp.month)
|
696
|
-
assert_equal 200, balance_list_before[:status].to_i, balance_list_before.inspect
|
697
|
-
|
698
|
-
new_sale = @api.create_sale(@sale_201702)
|
699
|
-
assert_equal 200, new_sale[:status].to_i, new_sale.inspect
|
700
|
-
assert(new_sale[:json].count > 0)
|
701
|
-
|
702
|
-
balance_list_after = @api.list_sales_and_account_balances(realization_timestamp.year, realization_timestamp.month)
|
703
|
-
assert_equal 200, balance_list_after[:status].to_i, balance_list_after.inspect
|
704
|
-
assert(balance_list_after[:json].count > 0)
|
705
|
-
assert(balance_list_after[:json] != balance_list_before[:json])
|
706
|
-
|
707
|
-
customer_masters_list = @api.list_customers
|
708
|
-
assert_equal 200, customer_masters_list[:status].to_i, customer_masters_list.inspect
|
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
|
711
|
-
|
712
|
-
# With customer_master_id and ar_segment option parameters
|
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
|
-
|
718
|
-
assert_equal 200, balance_list[:status].to_i, balance_list.inspect
|
719
|
-
assert(balance_list[:json].count > 0)
|
720
|
-
assert(balance_list[:json].all? { |x| x[:customer_master_code] == filtered_cm[:code] && x[:ar_segment] == filtered_cm[:used_in_ar] })
|
721
|
-
ensure
|
722
|
-
@api.destroy_sale("AR#{new_sale[:json][:id]}") if new_sale[:json][:id]
|
723
|
-
end
|
724
|
-
|
725
|
-
def test_list_purchases
|
726
|
-
august_purchase_a = @api.create_purchase(@purchase_201608)
|
727
|
-
august_purchase_b = @api.create_purchase(@purchase_201608)
|
728
|
-
september_purchase = @api.create_purchase(@purchase_201609)
|
729
|
-
|
730
|
-
august_purchase_a_id = august_purchase_a[:json][:id]
|
731
|
-
august_purchase_b_id = august_purchase_b[:json][:id]
|
732
|
-
september_purchase_id = september_purchase[:json][:id]
|
733
|
-
|
734
|
-
purchase_list = @api.list_purchases(2016, 8)
|
735
|
-
assert_equal 200, purchase_list[:status].to_i, purchase_list.inspect
|
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 })
|
739
|
-
ensure
|
740
|
-
@api.destroy_purchase("AP#{august_purchase_a[:json][:id]}") if august_purchase_a[:json][:id]
|
741
|
-
@api.destroy_purchase("AP#{august_purchase_b[:json][:id]}") if august_purchase_b[:json][:id]
|
742
|
-
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
|
743
|
-
end
|
744
|
-
|
745
|
-
def test_list_purchases_and_account_balances
|
746
|
-
accrual_timestamp = Time.parse(@purchase_201702[:accrual_timestamp])
|
747
|
-
|
748
|
-
# Without customer_master_id and ap_segment option parameters
|
749
|
-
balance_list_before = @api.list_purchases_and_account_balances(accrual_timestamp.year, accrual_timestamp.month)
|
750
|
-
assert_equal 200, balance_list_before[:status].to_i, balance_list_before.inspect
|
751
|
-
|
752
|
-
new_purchase = @api.create_purchase(@purchase_201702)
|
753
|
-
assert_equal 200, new_purchase[:status].to_i, new_purchase.inspect
|
754
|
-
assert(new_purchase[:json].count > 0)
|
755
|
-
|
756
|
-
balance_list_after = @api.list_purchases_and_account_balances(accrual_timestamp.year, accrual_timestamp.month)
|
757
|
-
assert_equal 200, balance_list_after[:status].to_i, balance_list_after.inspect
|
758
|
-
assert(balance_list_after[:json].count > 0)
|
759
|
-
assert(balance_list_after[:json] != balance_list_before[:json])
|
760
|
-
|
761
|
-
customer_masters_list = @api.list_customers
|
762
|
-
assert_equal 200, customer_masters_list[:status].to_i, customer_masters_list.inspect
|
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
|
765
|
-
customer_master_id = filtered_customer_master[:id]
|
766
|
-
ap_segment = filtered_customer_master[:used_in_ap]
|
767
|
-
|
768
|
-
# With customer_master_id and ap_segment option parameters
|
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
|
-
|
774
|
-
assert_equal 200, balance_list[:status].to_i, balance_list.inspect
|
775
|
-
assert(balance_list[:json].count > 0)
|
776
|
-
assert(balance_list[:json].all? { |x| x[:customer_master_id] == customer_master_id && x[:ap_segment] == ap_segment })
|
777
|
-
ensure
|
778
|
-
@api.destroy_purchase("AP#{new_purchase[:json][:id]}") if new_purchase[:json][:id]
|
779
|
-
end
|
780
|
-
|
781
|
-
def test_list_customers
|
782
|
-
customer_1000 = @api.create_customer(@customer_1000)
|
783
|
-
|
784
|
-
customer_1000_id = customer_1000[:json][:id]
|
785
|
-
|
786
|
-
customer_list = @api.list_customers
|
787
|
-
assert_equal 200, customer_list[:status].to_i, customer_list.inspect
|
788
|
-
assert(customer_list[:json].any? { |x| x[:id] == customer_1000_id })
|
789
|
-
ensure
|
790
|
-
@api.destroy_customer(customer_1000[:json][:id]) if customer_1000[:json][:id]
|
791
|
-
end
|
792
|
-
|
793
|
-
def test_list_staff
|
794
|
-
staff_list = @api.list_staff
|
795
|
-
assert_equal 200, staff_list[:status].to_i, staff_list.inspect
|
796
|
-
assert !staff_list.empty?
|
797
|
-
end
|
798
|
-
|
799
|
-
def test_list_staff_data
|
800
|
-
staff_list = @api.list_staff
|
801
|
-
first_staff_id = staff_list[:json].first[:id]
|
802
|
-
|
803
|
-
staff_data_list = @api.list_staff_data(first_staff_id)
|
804
|
-
assert_equal 200, staff_data_list[:status].to_i, staff_data_list.inspect
|
805
|
-
assert(staff_data_list[:json].all? { |x| x[:staff_id] == first_staff_id })
|
806
|
-
end
|
807
|
-
|
808
|
-
def test_list_staff_datum_masters
|
809
|
-
staff_datum_masters_list = @api.list_staff_datum_masters
|
810
|
-
assert_equal 200, staff_datum_masters_list[:status].to_i, staff_datum_masters_list.inspect
|
811
|
-
assert !staff_datum_masters_list.empty?
|
812
|
-
end
|
813
|
-
|
814
|
-
def test_list_manual_journals
|
815
|
-
manual_journals_list = @api.list_manual_journals(2016, 4)
|
816
|
-
puts 'list'
|
817
|
-
puts manual_journals_list.inspect
|
818
|
-
assert_equal 200, manual_journals_list[:status].to_i, manual_journals_list.inspect
|
819
|
-
assert !manual_journals_list.empty?
|
820
|
-
end
|
821
|
-
|
822
|
-
def test_list_journals
|
823
|
-
august_sale = @api.create_sale(@sale_201608)
|
824
|
-
september_sale = @api.create_sale(@sale_201609)
|
825
|
-
august_purchase = @api.create_purchase(@purchase_201608)
|
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
|
831
|
-
|
832
|
-
options = { start_date: '2016-08-01', finish_date: '2016-08-31' }
|
833
|
-
journals_list = @api.list_journals(options)
|
834
|
-
records = journals_list[:json][:records]
|
835
|
-
assert_equal 200, journals_list[:status].to_i, journals_list.inspect
|
836
|
-
record_timestamps = records.map { |x| Time.parse(x[:journal_timestamp]) }
|
837
|
-
assert_includes record_timestamps, Time.parse(august_sale[:json][:realization_timestamp])
|
838
|
-
assert_includes record_timestamps, Time.parse(august_purchase[:json][:accrual_timestamp])
|
839
|
-
|
840
|
-
options = { price: 10_800 }
|
841
|
-
journals_list = @api.list_journals(options)
|
842
|
-
records = journals_list[:json][:records]
|
843
|
-
assert_equal 200, journals_list[:status].to_i, journals_list.inspect
|
844
|
-
record_prices = records.map { |x| x[:journal_dcs].map { |y| y[:debit][:price_including_tax] } }.flatten(1)
|
845
|
-
assert_includes record_prices, august_sale[:json][:price_including_tax]
|
846
|
-
assert_includes record_prices, september_sale[:json][:price_including_tax]
|
847
|
-
|
848
|
-
options = { dept_code: 'SETSURITSU' }
|
849
|
-
journals_list = @api.list_journals(options)
|
850
|
-
records = journals_list[:json][:records]
|
851
|
-
assert_equal 200, journals_list[:status].to_i, journals_list.inspect
|
852
|
-
record_depts = records.map { |x| x[:journal_dcs].map { |y| y[:dept_code] } }.flatten(1)
|
853
|
-
assert_includes record_depts, august_sale[:json][:dept_code]
|
854
|
-
assert_includes record_depts, september_sale[:json][:dept_code]
|
855
|
-
assert_includes record_depts, august_purchase[:json][:dept_code]
|
856
|
-
assert_includes record_depts, september_purchase[:json][:dept_code]
|
857
|
-
ensure
|
858
|
-
@api.destroy_sale("AR#{august_sale[:json][:id]}") if august_sale[:json][:id]
|
859
|
-
@api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
|
860
|
-
@api.destroy_purchase("AP#{august_purchase[:json][:id]}") if august_purchase[:json][:id]
|
861
|
-
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
|
862
|
-
end
|
863
|
-
|
864
|
-
def test_list_reimbursements
|
865
|
-
reimbursement_a = @api.create_reimbursement(@reimbursement_1)
|
866
|
-
reimbursement_b = @api.create_reimbursement(@reimbursement_2)
|
867
|
-
|
868
|
-
reimbursement_a_id = reimbursement_a[:json][:id]
|
869
|
-
reimbursement_b_id = reimbursement_b[:json][:id]
|
870
|
-
|
871
|
-
reimbursements_list = @api.list_reimbursements(2016, 3)
|
872
|
-
assert_equal 200, reimbursements_list[:status].to_i, reimbursements_list.inspect
|
873
|
-
assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_a_id })
|
874
|
-
assert(reimbursements_list[:json].any? { |x| x[:id] == reimbursement_b_id })
|
875
|
-
ensure
|
876
|
-
@api.destroy_reimbursement(reimbursement_a_id) if reimbursement_a_id
|
877
|
-
@api.destroy_reimbursement(reimbursement_b_id) if reimbursement_b_id
|
878
|
-
end
|
879
|
-
|
880
|
-
def test_list_reimbursement_reason_masters
|
881
|
-
reimbursement_reason_masters_list = @api.list_reimbursement_reason_masters
|
882
|
-
assert_equal 200, reimbursement_reason_masters_list[:status].to_i, reimbursement_reason_masters_list.inspect
|
883
|
-
assert reimbursement_reason_masters_list[:json]
|
884
|
-
assert !reimbursement_reason_masters_list[:json].empty?
|
885
|
-
end
|
886
|
-
|
887
|
-
def test_list_reimbursement_transactions
|
888
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
889
|
-
options = { :reimbursement_id => reimbursement[:json][:id].to_i }
|
890
|
-
reimbursement_transaction_1 = @api.create_reimbursement_transaction(@reimbursement_tx_1.merge(options))
|
891
|
-
reimbursement_transaction_2 = @api.create_reimbursement_transaction(@reimbursement_tx_2.merge(options))
|
892
|
-
|
893
|
-
reimbursement_transactions = @api.list_reimbursement_transactions(reimbursement[:json][:id])
|
894
|
-
assert_equal 200, reimbursement_transactions[:status].to_i, reimbursement_transactions.inspect
|
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] })
|
897
|
-
ensure
|
898
|
-
@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]
|
900
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
901
|
-
end
|
902
|
-
|
903
|
-
def test_list_depts
|
904
|
-
dept = @api.create_dept(@dept_1)
|
905
|
-
assert_equal 200, dept[:status].to_i, dept.inspect
|
906
|
-
|
907
|
-
depts = @api.list_depts
|
908
|
-
assert_equal 200, depts[:status].to_i, depts.inspect
|
909
|
-
assert(depts[:json].any? { |x| x[:id] == dept[:json][:id] })
|
910
|
-
ensure
|
911
|
-
@api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
|
912
|
-
end
|
913
|
-
|
914
|
-
def test_list_tags
|
915
|
-
tag = @api.create_tag(@tag_1)
|
916
|
-
|
917
|
-
tags = @api.list_tags
|
918
|
-
assert_equal 200, tags[:status].to_i, tags.inspect
|
919
|
-
assert(tags[:json][@tag_1[:tag_group_code].to_sym].any? { |x| x[:id] == tag[:json][:id] })
|
920
|
-
ensure
|
921
|
-
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
922
|
-
end
|
923
|
-
|
924
|
-
def test_list_bonuses
|
925
|
-
bonuses_list = @api.list_bonuses(1, 2016)
|
926
|
-
assert_equal 200, bonuses_list[:status].to_i, bonuses_list.inspect
|
927
|
-
assert bonuses_list[:json]
|
928
|
-
assert !bonuses_list[:json].empty?
|
929
|
-
end
|
930
|
-
|
931
|
-
def test_list_payrolls
|
932
|
-
payrolls_list = @api.list_payrolls(2016, 2)
|
933
|
-
|
934
|
-
assert_equal 200, payrolls_list[:status].to_i, payrolls_list.inspect
|
935
|
-
assert !payrolls_list.empty?
|
936
|
-
end
|
937
|
-
|
938
|
-
def test_list_ar_reason_masters
|
939
|
-
ar_reason_masters_list = @api.list_ar_reason_masters
|
940
|
-
assert_equal 200, ar_reason_masters_list[:status].to_i, ar_reason_masters_list.inspect
|
941
|
-
assert ar_reason_masters_list[:json]
|
942
|
-
assert !ar_reason_masters_list[:json].empty?
|
943
|
-
end
|
944
|
-
|
945
|
-
def test_list_ap_reason_masters
|
946
|
-
ap_reason_masters_list = @api.list_ap_reason_masters
|
947
|
-
assert_equal 200, ap_reason_masters_list[:status].to_i, ap_reason_masters_list.inspect
|
948
|
-
assert ap_reason_masters_list[:json]
|
949
|
-
assert !ap_reason_masters_list[:json].empty?
|
950
|
-
end
|
951
|
-
|
952
|
-
def test_list_fixed_assets
|
953
|
-
list = @api.list_fixed_assets
|
954
|
-
assert_equal 200, list[:status].to_i, list.inspect
|
955
|
-
assert list[:json]
|
956
|
-
assert !list[:json].empty?
|
957
|
-
end
|
958
|
-
|
959
|
-
private
|
960
|
-
|
961
|
-
def successful?(status)
|
962
|
-
status.to_i == 200
|
963
|
-
end
|
964
|
-
end
|