tsubaiso-sdk 1.2.0 → 1.2.1
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 +4 -4
- data/lib/tsubaiso_sdk.rb +18 -4
- data/test/test_tsubaiso_sdk.rb +75 -221
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0bbf2f5710b7de3360f142a25fdcd8eb59e9a7f
|
4
|
+
data.tar.gz: eab335d57909cb4e2d1e1f5aad428693198d263f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b318b0cc37320a8490194ee268c37dc7b389528b733f5bd0cbd77648bfd37b0d8e45c304afc1007be0a8351082241f04983d628fe1bab042aa3a06e130827ff
|
7
|
+
data.tar.gz: 8171a64299a6050899bd91327f4b12b3f6dd10a3dc47734ec2e60a484cadc220e71bf14d27bec63e620b3696127a1444ef723d4718b046167ffac165b062dc6c
|
data/lib/tsubaiso_sdk.rb
CHANGED
@@ -164,6 +164,13 @@ class TsubaisoSDK
|
|
164
164
|
api_request(uri, "GET", params)
|
165
165
|
end
|
166
166
|
|
167
|
+
# Alpha version now.
|
168
|
+
def list_fixed_assets
|
169
|
+
params = { "format" => "json" }
|
170
|
+
uri = URI.parse(@base_url + "/fixed_assets/list/")
|
171
|
+
api_request(uri, "GET", params)
|
172
|
+
end
|
173
|
+
|
167
174
|
def show_sale(voucher)
|
168
175
|
sale_id = voucher.scan(/\d/).join("")
|
169
176
|
params = { "format" => "json" }
|
@@ -438,11 +445,11 @@ class TsubaisoSDK
|
|
438
445
|
"dept_code" => options[:dept_code],
|
439
446
|
"tag_list" => options[:tag_list]
|
440
447
|
},
|
448
|
+
"title" => options[:title],
|
441
449
|
"target_timestamp" => options[:target_timestamp],
|
442
450
|
"memo" => options[:memo],
|
443
451
|
"criteria" => options[:criteria],
|
444
|
-
"distribution_conditions" => options[:distribution_conditions]
|
445
|
-
"title" => options[:title]
|
452
|
+
"distribution_conditions" => options[:distribution_conditions]
|
446
453
|
}
|
447
454
|
uri = URI.parse(@base_url + '/journal_distributions/create/')
|
448
455
|
api_request(uri, "POST", params)
|
@@ -624,6 +631,13 @@ class TsubaisoSDK
|
|
624
631
|
api_request(uri, "POST", params)
|
625
632
|
end
|
626
633
|
|
634
|
+
# Alpha version now.
|
635
|
+
def destroy_fixed_asset(fixed_asset_id)
|
636
|
+
params = { "format" => "json" }
|
637
|
+
uri = URI.parse(@base_url + "/fixed_assets/destroy/#{fixed_asset_id}")
|
638
|
+
api_request(uri, "POST", params)
|
639
|
+
end
|
640
|
+
|
627
641
|
private
|
628
642
|
|
629
643
|
def api_request(uri, http_verb, params)
|
@@ -642,10 +656,10 @@ class TsubaisoSDK
|
|
642
656
|
begin
|
643
657
|
{:status => response.code, :json => recursive_symbolize_keys(JSON.load(response.body))}
|
644
658
|
rescue
|
645
|
-
|
659
|
+
response.body
|
646
660
|
end
|
647
661
|
else
|
648
|
-
|
662
|
+
response.code
|
649
663
|
end
|
650
664
|
end
|
651
665
|
|
data/test/test_tsubaiso_sdk.rb
CHANGED
@@ -1,41 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
require 'time'
|
4
4
|
require './lib/tsubaiso_sdk'
|
5
5
|
|
6
|
-
class TsubaisoSDKTest < Test
|
7
|
-
|
8
|
-
class <<self
|
9
|
-
def startup
|
10
|
-
@sdk = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
|
11
|
-
|
12
|
-
# Master data prepare
|
13
|
-
|
14
|
-
# Customer master
|
15
|
-
customer_101 = { name: "取引先101", name_kana: "イチマルイチ", code: "101",
|
16
|
-
tax_type_for_remittance_charge: "3", used_in_ar: 1, used_in_ap: 1, is_valid: 1}
|
17
|
-
# ar_account_code: "135~999" , ap_account_code: "310~999" }
|
18
|
-
|
19
|
-
customer_102 = { name: "取引先102", name_kana: "トリヒキサキニ", code: "102",
|
20
|
-
tax_type_for_remittance_charge: "3", used_in_ar: 1, used_in_ap: 1, is_valid: 1}
|
21
|
-
# ar_account_code: "135~999" , ap_account_code: "310~999" }
|
22
|
-
|
23
|
-
customer_105 = { name: "取引先105", name_kana: "トリヒキサキご", code: "105",
|
24
|
-
tax_type_for_remittance_charge: "3", used_in_ar: 1, used_in_ap: 1, is_valid: 1}
|
25
|
-
# ar_account_code: "135~999" , ap_account_code: "310~999" }
|
26
|
-
|
27
|
-
@res_101 = @sdk.create_customer(customer_101)
|
28
|
-
@res_102 = @sdk.create_customer(customer_102)
|
29
|
-
@res_105 = @sdk.create_customer(customer_105)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def shutdown
|
34
|
-
@sdk.destroy_customer(@res_101[:json][:id]) if @res_101 && @res_101[:status].to_i == 200
|
35
|
-
@sdk.destroy_customer(@res_102[:json][:id]) if @res_102 && @res_102[:status].to_i == 200
|
36
|
-
@sdk.destroy_customer(@res_105[:json][:id]) if @res_105 && @res_105[:status].to_i == 200
|
37
|
-
end
|
38
|
-
end
|
6
|
+
class TsubaisoSDKTest < Minitest::Test
|
39
7
|
|
40
8
|
def setup
|
41
9
|
@api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
|
@@ -50,23 +18,23 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
50
18
|
|
51
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 }
|
52
20
|
@staff_data_1 = { code: "QUALIFICATION", value: "TOEIC", start_timestamp: "2016-01-01", no_finish_timestamp: "1", memo: "First memo" }
|
53
|
-
@reimbursement_1 = { applicant: "Irfan", application_term: "2016-03-01", memo: "aaaaaaaa" }
|
54
|
-
@reimbursement_2 = { applicant: "Matsuno", application_term: "2016-03-01", memo: "aaaaaaaa" }
|
55
|
-
@reimbursement_tx_1 = { transaction_timestamp: "2016-03-01", price_value: 10000, dc:"c", reason_code:"
|
56
|
-
@reimbursement_tx_2 = { transaction_timestamp: "2016-03-01", price_value: 20000, dc:"c", reason_code:"
|
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"} }
|
57
25
|
@manual_journal_1 = {journal_timestamp: "2016-04-01", journal_dcs: [
|
58
|
-
debit: {account_code:
|
59
|
-
credit: {account_code:
|
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"} }
|
60
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'}
|
61
29
|
@tag_1 = {code: 'test_code', name: 'テストタグ', sort_no: 10000, tag_group_code: "DEFAULT", start_ymd: '2016-01-01', finish_ymd: '2016-12-31'}
|
62
|
-
@journal_distribution_1 = { start_date: "2016-09-01", finish_date: "2016-09-30", account_codes: ["135~999","604"], dept_code: "SETSURITSU", memo: "",
|
63
|
-
|
64
|
-
distribution_conditions: { "SETSURITSU" => "1", "SYSTEM" => "1" } }
|
30
|
+
@journal_distribution_1 = { title: 'title', start_date: "2016-09-01", finish_date: "2016-09-30", account_codes: ["135~999","604"], dept_code: "SETSURITSU", memo: "",
|
31
|
+
criteria: "dept", target_timestamp: "2017-02-01", distribution_conditions: { "SETSURITSU" => "1", "SYSTEM" => "1" } }
|
65
32
|
end
|
66
33
|
|
67
34
|
def test_failed_request
|
68
35
|
@api_fail = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: "fake token" })
|
69
36
|
sale = @api_fail.create_sale(@sale_201608)
|
37
|
+
|
70
38
|
assert_equal 401, sale[:status].to_i, sale.inspect
|
71
39
|
assert_equal "Bad credentials", sale[:json][:error]
|
72
40
|
end
|
@@ -78,7 +46,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
78
46
|
assert_equal @customer_1000[:name], customer[:json][:name]
|
79
47
|
|
80
48
|
ensure
|
81
|
-
@api.destroy_customer(customer[:json][:id]) if
|
49
|
+
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
82
50
|
end
|
83
51
|
|
84
52
|
def test_create_sale
|
@@ -89,7 +57,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
89
57
|
assert_equal @sale_201608[:data_partner][:id_code], sale[:json][:data_partner][:id_code]
|
90
58
|
|
91
59
|
ensure
|
92
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if
|
60
|
+
@api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
|
93
61
|
end
|
94
62
|
|
95
63
|
def test_create_purchase
|
@@ -100,7 +68,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
100
68
|
assert_equal @purchase_201608[:data_partner][:id_code], purchase[:json][:data_partner][:id_code]
|
101
69
|
|
102
70
|
ensure
|
103
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if
|
71
|
+
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
104
72
|
end
|
105
73
|
|
106
74
|
def test_create_staff_data
|
@@ -114,7 +82,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
114
82
|
assert_equal @staff_data_1[:value], staff_data[:json][:value]
|
115
83
|
|
116
84
|
ensure
|
117
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if
|
85
|
+
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
118
86
|
end
|
119
87
|
|
120
88
|
def test_create_manual_journal
|
@@ -126,7 +94,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
126
94
|
assert_equal @manual_journal_1[:data_partner][:id_code], manual_journal[:json][:data_partner][:id_code]
|
127
95
|
|
128
96
|
ensure
|
129
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal)
|
97
|
+
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
130
98
|
end
|
131
99
|
end
|
132
100
|
|
@@ -136,7 +104,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
136
104
|
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
137
105
|
|
138
106
|
ensure
|
139
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if
|
107
|
+
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
140
108
|
end
|
141
109
|
|
142
110
|
def test_create_reimbursement_transaction
|
@@ -148,8 +116,8 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
148
116
|
assert_equal @reimbursement_tx_1[:data_partner][:id_code], reimbursement_transaction[:json][:data_partner][:id_code]
|
149
117
|
|
150
118
|
ensure
|
151
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if
|
152
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if
|
119
|
+
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
120
|
+
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
153
121
|
end
|
154
122
|
|
155
123
|
def test_create_dept
|
@@ -158,7 +126,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
158
126
|
assert_equal @dept_1[:code], dept[:json][:code]
|
159
127
|
|
160
128
|
ensure
|
161
|
-
@api.destroy_dept(dept[:json][:id]) if
|
129
|
+
@api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
|
162
130
|
end
|
163
131
|
|
164
132
|
def test_create_tag
|
@@ -167,13 +135,10 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
167
135
|
assert_equal @tag_1[:code], tag[:json][:code]
|
168
136
|
|
169
137
|
ensure
|
170
|
-
@api.destroy_tag(tag[:json][:id]) if
|
138
|
+
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
171
139
|
end
|
172
140
|
|
173
141
|
def test_create_journal_distribution
|
174
|
-
|
175
|
-
sale = @api.create_sale(@sale_201609)
|
176
|
-
|
177
142
|
options = { start_date: @journal_distribution_1[:target_timestamp], finish_date: @journal_distribution_1[:target_timestamp] }
|
178
143
|
|
179
144
|
journals_list_before = @api.list_journals(options)
|
@@ -190,8 +155,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
190
155
|
assert (records_before_count != records_after_count)
|
191
156
|
|
192
157
|
ensure
|
193
|
-
@api.destroy_journal_distribution(journal_distribution[:json][:id]) if
|
194
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if successful?(sale)
|
158
|
+
@api.destroy_journal_distribution(journal_distribution[:json][:id]) if journal_distribution[:json][:id]
|
195
159
|
end
|
196
160
|
|
197
161
|
def test_update_sale
|
@@ -209,12 +173,12 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
209
173
|
assert_equal options[:data_partner][:id_code], updated_sale[:json][:data_partner][:id_code]
|
210
174
|
|
211
175
|
ensure
|
212
|
-
@api.destroy_sale("AP#{sale[:json][:id]}") if
|
176
|
+
@api.destroy_sale("AP#{sale[:json][:id]}") if sale[:json][:id]
|
213
177
|
end
|
214
178
|
|
215
|
-
|
216
179
|
def test_update_purchase
|
217
180
|
purchase = @api.create_purchase(@purchase_201608)
|
181
|
+
assert purchase[:json][:id], purchase
|
218
182
|
options = { id: purchase[:json][:id],
|
219
183
|
price_including_tax: 50000,
|
220
184
|
memo: "Updated memo",
|
@@ -228,7 +192,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
228
192
|
assert_equal options[:data_partner][:id_code], updated_purchase[:json][:data_partner][:id_code]
|
229
193
|
|
230
194
|
ensure
|
231
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if
|
195
|
+
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
232
196
|
end
|
233
197
|
|
234
198
|
def test_update_customer
|
@@ -242,7 +206,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
242
206
|
assert_equal "New Customer Name", updated_customer[:json][:name]
|
243
207
|
|
244
208
|
ensure
|
245
|
-
@api.destroy_customer(customer[:json][:id]) if
|
209
|
+
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
246
210
|
end
|
247
211
|
|
248
212
|
def test_update_staff_data
|
@@ -261,7 +225,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
261
225
|
assert_equal "Programmer", updated_staff_data[:json][:value]
|
262
226
|
|
263
227
|
ensure
|
264
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if
|
228
|
+
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
265
229
|
end
|
266
230
|
|
267
231
|
def test_update_reimbursement
|
@@ -276,14 +240,14 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
276
240
|
assert_equal options[:dept_code], updated_reimbursement[:json][:dept_code]
|
277
241
|
|
278
242
|
ensure
|
279
|
-
@api.destroy_reimbursement(updated_reimbursement[:json][:id] || reimbursement[:json][:id]) if
|
243
|
+
@api.destroy_reimbursement(updated_reimbursement[:json][:id] || reimbursement[:json][:id]) if updated_reimbursement[:json][:id] || reimbursement[:json][:id]
|
280
244
|
end
|
281
245
|
|
282
246
|
def test_update_reimbursement_transaction
|
283
247
|
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
284
248
|
options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id].to_i })
|
285
249
|
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
286
|
-
updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => "
|
250
|
+
updates = { :id => reimbursement_transaction[:json][:id], :price_value => 9999, :reason_code => "SUPPLIES", :data_partner => { :id_code => "500" } }
|
287
251
|
|
288
252
|
updated_reimbursement_transaction = @api.update_reimbursement_transaction(updates)
|
289
253
|
assert_equal 200, updated_reimbursement_transaction[:status].to_i, updated_reimbursement_transaction.inspect
|
@@ -293,8 +257,8 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
293
257
|
assert_equal updates[:data_partner][:id_code], updated_reimbursement_transaction[:json][:data_partner][:id_code]
|
294
258
|
|
295
259
|
ensure
|
296
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if
|
297
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if
|
260
|
+
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
261
|
+
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
298
262
|
end
|
299
263
|
|
300
264
|
def test_update_manual_journal
|
@@ -312,7 +276,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
312
276
|
assert_equal options[:data_partner][:id_code], updated_manual_journal[:json][:data_partner][:id_code]
|
313
277
|
|
314
278
|
ensure
|
315
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal)
|
279
|
+
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
316
280
|
end
|
317
281
|
|
318
282
|
def test_update_dept
|
@@ -331,11 +295,12 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
331
295
|
assert_equal options[:name_abbr], updated_dept[:json][:name_abbr]
|
332
296
|
|
333
297
|
ensure
|
334
|
-
@api.destroy_dept(updated_dept[:json][:id] || dept[:json][:id]) if
|
298
|
+
@api.destroy_dept(updated_dept[:json][:id] || dept[:json][:id]) if updated_dept[:json][:id] || dept[:json][:id]
|
335
299
|
end
|
336
300
|
|
337
301
|
def test_update_tag
|
338
302
|
tag = @api.create_tag(@tag_1)
|
303
|
+
assert tag[:json][:id], tag
|
339
304
|
options = { name: "更新タグ",
|
340
305
|
code: "updated_tag"
|
341
306
|
}
|
@@ -344,9 +309,8 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
344
309
|
assert_equal 200, updated_tag[:status].to_i, updated_tag.inspect
|
345
310
|
assert_equal options[:name], updated_tag[:json][:name]
|
346
311
|
assert_equal options[:code], updated_tag[:json][:code]
|
347
|
-
|
348
312
|
ensure
|
349
|
-
@api.destroy_tag(
|
313
|
+
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
350
314
|
end
|
351
315
|
|
352
316
|
def test_show_sale
|
@@ -357,7 +321,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
357
321
|
assert_equal sale[:json][:price_including_tax], get_sale[:json][:price_including_tax]
|
358
322
|
|
359
323
|
ensure
|
360
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if
|
324
|
+
@api.destroy_sale("AR#{sale[:json][:id]}") if sale[:json][:id]
|
361
325
|
end
|
362
326
|
|
363
327
|
def test_show_purchase
|
@@ -368,7 +332,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
368
332
|
assert_equal purchase[:json][:id], get_purchase[:json][:id]
|
369
333
|
|
370
334
|
ensure
|
371
|
-
@api.destroy_purchase("AP#{purchase[:json][:id]}") if
|
335
|
+
@api.destroy_purchase("AP#{purchase[:json][:id]}") if purchase[:json][:id]
|
372
336
|
end
|
373
337
|
|
374
338
|
def test_show_customer
|
@@ -379,7 +343,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
379
343
|
assert_equal customer[:json][:id], get_customer[:json][:id]
|
380
344
|
|
381
345
|
ensure
|
382
|
-
@api.destroy_customer(customer[:json][:id]) if
|
346
|
+
@api.destroy_customer(customer[:json][:id]) if customer[:json][:id]
|
383
347
|
end
|
384
348
|
|
385
349
|
def test_show_staff
|
@@ -414,7 +378,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
414
378
|
assert_equal staff_data[:json][:id], get_staff_data_2[:json][:id]
|
415
379
|
|
416
380
|
ensure
|
417
|
-
@api.destroy_staff_data(staff_data[:json][:id]) if
|
381
|
+
@api.destroy_staff_data(staff_data[:json][:id]) if staff_data[:json][:id]
|
418
382
|
end
|
419
383
|
|
420
384
|
def test_show_staff_datum_master
|
@@ -445,7 +409,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
445
409
|
assert_equal 200, reimbursement[:status].to_i, reimbursement.inspect
|
446
410
|
assert_equal @reimbursement_1[:applicant], reimbursement[:json][:applicant]
|
447
411
|
ensure
|
448
|
-
@api.destroy_reimbursement(reimbursement[:json][:id])
|
412
|
+
@api.destroy_reimbursement(reimbursement[:json][:id])
|
449
413
|
end
|
450
414
|
|
451
415
|
def test_show_reimbursement_reason_master
|
@@ -467,8 +431,8 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
467
431
|
assert_equal options[:reimbursement_id], reimbursement_transaction[:json][:reimbursement_id]
|
468
432
|
|
469
433
|
ensure
|
470
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if
|
471
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if
|
434
|
+
@api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id]) if reimbursement_transaction[:json][:id]
|
435
|
+
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
472
436
|
end
|
473
437
|
|
474
438
|
def test_show_manual_journal
|
@@ -481,7 +445,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
481
445
|
assert_equal first_manual_journal_id, manual_journal[:json][:id]
|
482
446
|
|
483
447
|
ensure
|
484
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal)
|
448
|
+
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
485
449
|
end
|
486
450
|
|
487
451
|
def test_show_journal
|
@@ -494,7 +458,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
494
458
|
assert_equal first_journal_id, journal[:json][:records][:id]
|
495
459
|
|
496
460
|
ensure
|
497
|
-
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal)
|
461
|
+
@api.destroy_manual_journal(manual_journal[:json][:id]) if successful?(manual_journal[:status])
|
498
462
|
end
|
499
463
|
|
500
464
|
def test_show_dept
|
@@ -504,7 +468,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
504
468
|
assert_equal 200, dept[:status].to_i, dept.inspect
|
505
469
|
assert_equal @dept_1[:memo], dept[:json][:memo]
|
506
470
|
ensure
|
507
|
-
@api.destroy_dept(dept[:json][:id])
|
471
|
+
@api.destroy_dept(dept[:json][:id])
|
508
472
|
end
|
509
473
|
|
510
474
|
def test_show_tag
|
@@ -514,7 +478,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
514
478
|
assert_equal 200, tag[:status].to_i, tag.inspect
|
515
479
|
assert_equal @tag_1[:name], tag[:json][:name]
|
516
480
|
ensure
|
517
|
-
@api.destroy_tag(tag[:json][:id])
|
481
|
+
@api.destroy_tag(tag[:json][:id])
|
518
482
|
end
|
519
483
|
|
520
484
|
def test_show_bonus
|
@@ -527,7 +491,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
527
491
|
end
|
528
492
|
|
529
493
|
def test_show_payroll
|
530
|
-
payrolls_list = @api.list_payrolls(
|
494
|
+
payrolls_list = @api.list_payrolls(2017, 2)
|
531
495
|
first_payroll_id = payrolls_list[:json].first[:id]
|
532
496
|
|
533
497
|
payroll = @api.show_payroll(first_payroll_id)
|
@@ -569,9 +533,9 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
569
533
|
assert !sales_list[:json].any?{ |x| x[:id] == september_sale_id }
|
570
534
|
|
571
535
|
ensure
|
572
|
-
@api.destroy_sale("AR#{august_sale_a[:json][:id]}") if
|
573
|
-
@api.destroy_sale("AR#{august_sale_b[:json][:id]}") if
|
574
|
-
@api.destroy_sale("AR#{september_sale[:json][:id]}") if
|
536
|
+
@api.destroy_sale("AR#{august_sale_a[:json][:id]}") if august_sale_a[:json][:id]
|
537
|
+
@api.destroy_sale("AR#{august_sale_b[:json][:id]}") if august_sale_b[:json][:id]
|
538
|
+
@api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
|
575
539
|
end
|
576
540
|
|
577
541
|
def test_list_sales_and_account_balances
|
@@ -601,7 +565,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
601
565
|
assert(balance_list[:json].count > 0)
|
602
566
|
assert balance_list[:json].all?{ |x| x[:customer_master_code] == filtered_cm[:code] && x[:ar_segment] == filtered_cm[:used_in_ar] }
|
603
567
|
ensure
|
604
|
-
@api.destroy_sale("AR#{new_sale[:json][:id]}") if
|
568
|
+
@api.destroy_sale("AR#{new_sale[:json][:id]}") if new_sale[:json][:id]
|
605
569
|
end
|
606
570
|
|
607
571
|
def test_list_purchases
|
@@ -620,9 +584,9 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
620
584
|
assert !purchase_list[:json].any?{ |x| x[:id] == september_purchase_id }
|
621
585
|
|
622
586
|
ensure
|
623
|
-
@api.destroy_purchase("AP#{august_purchase_a[:json][:id]}") if
|
624
|
-
@api.destroy_purchase("AP#{august_purchase_b[:json][:id]}") if
|
625
|
-
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if
|
587
|
+
@api.destroy_purchase("AP#{august_purchase_a[:json][:id]}") if august_purchase_a[:json][:id]
|
588
|
+
@api.destroy_purchase("AP#{august_purchase_b[:json][:id]}") if august_purchase_b[:json][:id]
|
589
|
+
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
|
626
590
|
end
|
627
591
|
|
628
592
|
def test_list_purchases_and_account_balances
|
@@ -654,7 +618,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
654
618
|
assert(balance_list[:json].count > 0)
|
655
619
|
assert balance_list[:json].all?{ |x| x[:customer_master_id] == customer_master_id && x[:ap_segment] == ap_segment }
|
656
620
|
ensure
|
657
|
-
@api.destroy_purchase("AP#{new_purchase[:json][:id]}") if
|
621
|
+
@api.destroy_purchase("AP#{new_purchase[:json][:id]}") if new_purchase[:json][:id]
|
658
622
|
end
|
659
623
|
|
660
624
|
def test_list_customers
|
@@ -667,7 +631,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
667
631
|
assert customer_list[:json].any?{ |x| x[:id] == customer_1000_id }
|
668
632
|
|
669
633
|
ensure
|
670
|
-
@api.destroy_customer(customer_1000[:json][:id]) if
|
634
|
+
@api.destroy_customer(customer_1000[:json][:id]) if customer_1000[:json][:id]
|
671
635
|
end
|
672
636
|
|
673
637
|
def test_list_staff
|
@@ -730,10 +694,10 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
730
694
|
assert_includes record_depts, september_purchase[:json][:dept_code]
|
731
695
|
|
732
696
|
ensure
|
733
|
-
@api.destroy_sale("AR#{august_sale[:json][:id]}") if
|
734
|
-
@api.destroy_sale("AR#{september_sale[:json][:id]}") if
|
735
|
-
@api.destroy_purchase("AP#{august_purchase[:json][:id]}") if
|
736
|
-
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if
|
697
|
+
@api.destroy_sale("AR#{august_sale[:json][:id]}") if august_sale[:json][:id]
|
698
|
+
@api.destroy_sale("AR#{september_sale[:json][:id]}") if september_sale[:json][:id]
|
699
|
+
@api.destroy_purchase("AP#{august_purchase[:json][:id]}") if august_purchase[:json][:id]
|
700
|
+
@api.destroy_purchase("AP#{september_purchase[:json][:id]}") if september_purchase[:json][:id]
|
737
701
|
end
|
738
702
|
|
739
703
|
def test_list_reimbursements
|
@@ -772,20 +736,21 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
772
736
|
assert reimbursement_transactions[:json].any?{ |x| x[:id] == reimbursement_transaction_2[:json][:id] }
|
773
737
|
|
774
738
|
ensure
|
775
|
-
@api.destroy_reimbursement_transaction(reimbursement_transaction_1[:json][:id]) if
|
776
|
-
@api.destroy_reimbursement_transaction(
|
777
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if
|
739
|
+
@api.destroy_reimbursement_transaction(reimbursement_transaction_1[:json][:id]) if reimbursement_transaction_1[:json][:id]
|
740
|
+
@api.destroy_reimbursement_transaction(reimbursement_transaction_1[:json][:id]) if reimbursement_transaction_1[:json][:id]
|
741
|
+
@api.destroy_reimbursement(reimbursement[:json][:id]) if reimbursement[:json][:id]
|
778
742
|
end
|
779
743
|
|
780
744
|
def test_list_depts
|
781
745
|
dept = @api.create_dept(@dept_1)
|
746
|
+
assert_equal 200, dept[:status].to_i, dept.inspect
|
782
747
|
|
783
748
|
depts = @api.list_depts
|
784
749
|
assert_equal 200, depts[:status].to_i, depts.inspect
|
785
750
|
assert depts[:json].any?{ |x| x[:id] == dept[:json][:id] }
|
786
751
|
|
787
752
|
ensure
|
788
|
-
@api.destroy_dept(dept[:json][:id]) if
|
753
|
+
@api.destroy_dept(dept[:json][:id]) if dept[:json][:id]
|
789
754
|
end
|
790
755
|
|
791
756
|
def test_list_tags
|
@@ -796,7 +761,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
796
761
|
assert tags[:json][@tag_1[:tag_group_code].to_sym].any?{ |x| x[:id] == tag[:json][:id] }
|
797
762
|
|
798
763
|
ensure
|
799
|
-
@api.destroy_tag(tag[:json][:id]) if
|
764
|
+
@api.destroy_tag(tag[:json][:id]) if tag[:json][:id]
|
800
765
|
end
|
801
766
|
|
802
767
|
def test_list_bonuses
|
@@ -810,7 +775,7 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
810
775
|
payrolls_list = @api.list_payrolls(2016, 2)
|
811
776
|
|
812
777
|
assert_equal 200, payrolls_list[:status].to_i, payrolls_list.inspect
|
813
|
-
assert(payrolls_list
|
778
|
+
assert(payrolls_list.size > 0)
|
814
779
|
end
|
815
780
|
|
816
781
|
def test_list_ar_reason_masters
|
@@ -827,127 +792,16 @@ class TsubaisoSDKTest < Test::Unit::TestCase
|
|
827
792
|
assert(ap_reason_masters_list[:json].size > 0)
|
828
793
|
end
|
829
794
|
|
830
|
-
def
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
show_res = @api.show_res("AR#{sale[:json][:id]}")
|
837
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
838
|
-
end
|
839
|
-
|
840
|
-
def test_destroy_purchase
|
841
|
-
purchase = @api.create_purchase(@purchase_201608)
|
842
|
-
|
843
|
-
destroy_res = @api.destroy_purchase("AP#{purchase[:json][:id]}")
|
844
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
845
|
-
|
846
|
-
show_res = @api.show_purchase("AP#{purchase[:json][:id]}")
|
847
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
848
|
-
end
|
849
|
-
|
850
|
-
def test_destroy_customer
|
851
|
-
customer = @api.create_customer(@customer_1000)
|
852
|
-
|
853
|
-
destroy_res = @api.destroy_customer(customer[:json][:id])
|
854
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
855
|
-
|
856
|
-
show_res = @api.show_customer(customer[:json][:id])
|
857
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
858
|
-
end
|
859
|
-
|
860
|
-
def test_destroy_staff_data
|
861
|
-
staff_list = @api.list_staff
|
862
|
-
first_staff_id = staff_list[:json].first[:id]
|
863
|
-
@staff_data_1[:staff_id] = first_staff_id
|
864
|
-
staff_data = @api.create_staff_data(@staff_data_1)
|
865
|
-
|
866
|
-
destroy_res = @api.destroy_staff_data(staff_data[:json][:id])
|
867
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
868
|
-
|
869
|
-
show_res = @api.show_staff_data(staff_data[:json][:id])
|
870
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
871
|
-
end
|
872
|
-
|
873
|
-
def test_destroy_manual_journal
|
874
|
-
manual_journal = @api.create_manual_journal(@manual_journal_1)
|
875
|
-
|
876
|
-
destroy_res = @api.destroy_manual_journal(manual_journal[:json][:id])
|
877
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
878
|
-
|
879
|
-
show_res = @api.show_manual_journal(manual_journal[:json][:id])
|
880
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
881
|
-
end
|
882
|
-
|
883
|
-
def test_destroy_reimbursement
|
884
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
885
|
-
|
886
|
-
destroy_res = @api.destroy_reimbursement(reimbursement[:json][:id])
|
887
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
888
|
-
|
889
|
-
show_res = @api.show_reimbursement(reimbursement[:json][:id])
|
890
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
891
|
-
end
|
892
|
-
|
893
|
-
def test_destroy_reimbursement_transaction
|
894
|
-
reimbursement = @api.create_reimbursement(@reimbursement_1)
|
895
|
-
options = @reimbursement_tx_1.merge({ :reimbursement_id => reimbursement[:json][:id] })
|
896
|
-
reimbursement_transaction = @api.create_reimbursement_transaction(options)
|
897
|
-
|
898
|
-
destroy_res = @api.destroy_reimbursement_transaction(reimbursement_transaction[:json][:id])
|
899
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
900
|
-
|
901
|
-
show_res = @api.show_reimbursement_transaction(reimbursement_transaction[:json][:id])
|
902
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
903
|
-
|
904
|
-
ensure
|
905
|
-
@api.destroy_reimbursement(reimbursement[:json][:id]) if successful?(reimbursement)
|
906
|
-
end
|
907
|
-
|
908
|
-
def test_destroy_dept
|
909
|
-
dept = @api.create_dept(@dept_1)
|
910
|
-
|
911
|
-
destroy_res = @api.destroy_dept(dept[:json][:id])
|
912
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
913
|
-
|
914
|
-
show_res = @api.show_dept(dept[:json][:id])
|
915
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
916
|
-
end
|
917
|
-
|
918
|
-
def test_destroy_tag
|
919
|
-
tag = @api.create_tag(@tag_1)
|
920
|
-
|
921
|
-
destroy_res = @api.destroy_tag(tag[:json][:id])
|
922
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
923
|
-
|
924
|
-
show_res = @api.show_tag(tag[:json][:id])
|
925
|
-
assert_equal 404, show_res[:status].to_i, show_res.inspect
|
926
|
-
end
|
927
|
-
|
928
|
-
def test_destroy_journal_distribution
|
929
|
-
sale = @api.create_sale(@sale_201609)
|
930
|
-
options = { start_date: @journal_distribution_1[:target_timestamp], finish_date: @journal_distribution_1[:target_timestamp] }
|
931
|
-
journals_list_before = @api.list_journals(options)
|
932
|
-
records_before_count = journals_list_before[:json][:records].count
|
933
|
-
journal_distribution = @api.create_journal_distribution(@journal_distribution_1)
|
934
|
-
journals_list_after = @api.list_journals(options)
|
935
|
-
records_after_count = journals_list_after[:json][:records].count
|
936
|
-
assert (records_before_count < records_after_count)
|
937
|
-
|
938
|
-
destroy_res = @api.destroy_journal_distribution(journal_distribution[:json][:id])
|
939
|
-
assert_equal 204, destroy_res[:status].to_i, destroy_res.inspect
|
940
|
-
|
941
|
-
journals_list_after_destroy = @api.list_journals(options)
|
942
|
-
records_count_after_destroy = journals_list_after_destroy[:json][:records].count
|
943
|
-
assert (records_before_count == records_count_after_destroy)
|
944
|
-
|
945
|
-
ensure
|
946
|
-
@api.destroy_sale("AR#{sale[:json][:id]}") if successful?(sale)
|
795
|
+
def test_list_fixed_assets
|
796
|
+
list = @api.list_fixed_assets
|
797
|
+
assert_equal 200, list[:status].to_i, list.inspect
|
798
|
+
assert list[:json]
|
799
|
+
assert(list[:json].size > 0)
|
947
800
|
end
|
948
801
|
|
949
802
|
private
|
950
|
-
|
951
|
-
|
803
|
+
|
804
|
+
def successful?(status)
|
805
|
+
status.to_i == 200
|
952
806
|
end
|
953
807
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsubaiso-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tsubaiso, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -31,25 +31,25 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.8.3
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: minitest
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '5.4'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 5.4.3
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '5.4'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 5.4.3
|
53
53
|
description: A library of methods that directly uses Tsubaiso API web endpoints.
|
54
54
|
email: apisupport@tsubaiso.net
|
55
55
|
executables: []
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.6.
|
84
|
+
rubygems_version: 2.6.13
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: SDK for the Tsubaiso API
|