tsubaiso-sdk 1.2.5 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -3
- data/lib/tsubaiso_api.rb +12 -12
- data/lib/tsubaiso_sdk.rb +1529 -384
- data/sample.rb +120 -33
- data/test/stubbings/stub_register.rb +196 -0
- data/test/test_tsubaiso_api.rb +58 -14
- 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 +35 -6
- data/test/test_tsubaiso_sdk.rb +0 -807
data/sample.rb
CHANGED
@@ -1,42 +1,40 @@
|
|
1
|
-
|
2
|
-
# -*- coding: utf-8 -*-
|
3
1
|
$LOAD_PATH << 'lib/'
|
4
2
|
require 'tsubaiso_sdk'
|
5
3
|
|
6
4
|
class Sample
|
7
5
|
def initialize(sample)
|
8
6
|
@sample = sample
|
9
|
-
api = TsubaisoSDK.new({ base_url: ENV[
|
7
|
+
api = TsubaisoSDK.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
|
10
8
|
@sample.each do | line |
|
11
|
-
if line[:action] ==
|
12
|
-
if line[:module] ==
|
9
|
+
if line[:action] == 'List'
|
10
|
+
if line[:module] == 'Sales'
|
13
11
|
res = api.list_sales(line[:year], line[:month])
|
14
12
|
puts res[:json]
|
15
13
|
end
|
16
|
-
if line[:module] ==
|
14
|
+
if line[:module] == 'Purchases'
|
17
15
|
res = api.list_purchases(line[:year], line[:month])
|
18
16
|
puts res[:json]
|
19
17
|
end
|
20
18
|
end
|
21
|
-
if line[:action] ==
|
22
|
-
if line[:module] ==
|
19
|
+
if line[:action] == 'Show'
|
20
|
+
if line[:module] == 'Sales'
|
23
21
|
res = api.show_sale(line[:voucher])
|
24
22
|
puts res[:json]
|
25
23
|
end
|
26
|
-
if line[:module] ==
|
24
|
+
if line[:module] == 'Purchases'
|
27
25
|
res = api.show_purchase(line[:voucher])
|
28
26
|
puts res[:json]
|
29
27
|
end
|
30
28
|
end
|
31
|
-
if line[:action] ==
|
32
|
-
if line[:module] ==
|
29
|
+
if line[:action] == 'Create'
|
30
|
+
if line[:module] == 'Sales'
|
33
31
|
res = api.create_sale(line)
|
34
32
|
if res[:status].to_i == 422
|
35
33
|
puts res[:json]
|
36
34
|
exit
|
37
35
|
end
|
38
36
|
end
|
39
|
-
if line[:module] ==
|
37
|
+
if line[:module] == 'Purchases'
|
40
38
|
res = api.create_purchase(line)
|
41
39
|
if res[:status].to_i == 422
|
42
40
|
puts res[:json]
|
@@ -44,11 +42,11 @@ class Sample
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
47
|
-
if line[:action] ==
|
48
|
-
if line[:module] ==
|
45
|
+
if line[:action] == 'Destroy'
|
46
|
+
if line[:module] == 'Sales'
|
49
47
|
res = api.destroy_sale(line[:voucher])
|
50
48
|
end
|
51
|
-
if line[:module] ==
|
49
|
+
if line[:module] == 'Purchases'
|
52
50
|
res = api.destroy_purchase(line[:voucher])
|
53
51
|
end
|
54
52
|
end
|
@@ -56,21 +54,110 @@ class Sample
|
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
59
|
-
Sample.new([
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
Sample.new([{ action: 'Create',
|
58
|
+
module: 'Sales',
|
59
|
+
price: 10_000,
|
60
|
+
year: 2015,
|
61
|
+
month: 8,
|
62
|
+
realization_timestamp: '2015-08-01',
|
63
|
+
customer_master_code: '101',
|
64
|
+
dept_code: 'SETSURITSU',
|
65
|
+
reason_master_code: 'SALES',
|
66
|
+
dc: 'd',
|
67
|
+
memo: '',
|
68
|
+
tax_code: 1007,
|
69
|
+
scheduled_memo: 'This is a scheduled memo.',
|
70
|
+
scheduled_receive_timestamp: '2015-09-25' },
|
71
|
+
{ action: 'Create',
|
72
|
+
module: 'Purchases',
|
73
|
+
price: 5000,
|
74
|
+
year: 2015,
|
75
|
+
month: 8,
|
76
|
+
accrual_timestamp: '2015-08-01',
|
77
|
+
customer_master_code: '102',
|
78
|
+
dept_code: 'SETSURITSU',
|
79
|
+
reason_master_code: 'BUYING_IN',
|
80
|
+
dc: 'c',
|
81
|
+
memo: '',
|
82
|
+
tax_code: 1007,
|
83
|
+
port_type: 1 },
|
84
|
+
{ action: 'Create',
|
85
|
+
module: 'Sales',
|
86
|
+
price: 95_000,
|
87
|
+
year: 2015,
|
88
|
+
month: 9,
|
89
|
+
realization_timestamp: '2015-09-25',
|
90
|
+
customer_master_code: '102',
|
91
|
+
dept_code: 'SETSURITSU',
|
92
|
+
reason_master_code: 'OTHERS_INCREASE',
|
93
|
+
dc: 'd',
|
94
|
+
memo: '決算会社/マーチャントの相殺',
|
95
|
+
tax_code: 0 },
|
96
|
+
{ action: 'Create',
|
97
|
+
module: 'Sales',
|
98
|
+
price: 10_000,
|
99
|
+
year: 2015,
|
100
|
+
month: 9,
|
101
|
+
realization_timestamp: '2015-09-25',
|
102
|
+
customer_master_code: '101',
|
103
|
+
dept_code: 'SETSURITSU',
|
104
|
+
reason_master_code: 'OTHERS_DECREASE',
|
105
|
+
dc: 'c',
|
106
|
+
memo: '決算会社/マーチャントの相殺',
|
107
|
+
tax_code: 0 },
|
108
|
+
{ action: 'Create',
|
109
|
+
module: 'Sales',
|
110
|
+
price: 5000,
|
111
|
+
year: 2015,
|
112
|
+
month: 9,
|
113
|
+
realization_timestamp: '2015-09-25',
|
114
|
+
customer_master_code: '102',
|
115
|
+
dept_code: 'SETSURITSU',
|
116
|
+
reason_master_code: 'OTHERS_INCREASE',
|
117
|
+
dc: 'c',
|
118
|
+
memo: '決算会社/決済会社の相殺',
|
119
|
+
tax_code: 0 },
|
120
|
+
{ action: 'Create',
|
121
|
+
module: 'Purchases',
|
122
|
+
price: 5000,
|
123
|
+
year: 2015,
|
124
|
+
month: 9,
|
125
|
+
accrual_timestamp: '2015-09-25',
|
126
|
+
customer_master_code: '102',
|
127
|
+
dept_code: 'SETSURITSU',
|
128
|
+
reason_master_code: 'OTHERS_DECREASE',
|
129
|
+
dc: 'd',
|
130
|
+
memo: '決算会社/決済会社の相殺',
|
131
|
+
tax_code: 0,
|
132
|
+
port_type: 1 },
|
133
|
+
{ action: 'Create',
|
134
|
+
module: 'Purchases',
|
135
|
+
price: 90_000,
|
136
|
+
year: 2015,
|
137
|
+
month: 9,
|
138
|
+
accrual_timestamp: '2015-09-30',
|
139
|
+
customer_master_code: '101',
|
140
|
+
dept_code: 'SETSURITSU',
|
141
|
+
reason_master_code: 'OTHERS_INCREASE',
|
142
|
+
dc: 'c',
|
143
|
+
memo: '売掛金/未払金振替',
|
144
|
+
tax_code: 0,
|
145
|
+
port_type: 1 },
|
146
|
+
{ action: 'Create',
|
147
|
+
module: 'Sales',
|
148
|
+
price: 90_000,
|
149
|
+
year: 2015,
|
150
|
+
month: 9,
|
151
|
+
realization_timestamp: '2015-09-30',
|
152
|
+
customer_master_code: '102',
|
153
|
+
dept_code: 'SETSURITSU',
|
154
|
+
reason_master_code: 'OTHERS_INCREASE',
|
155
|
+
dc: 'd',
|
156
|
+
memo: '売掛金/未払い金振替',
|
157
|
+
tax_code: 0 },
|
158
|
+
{ action: 'Show', module: 'Sales', voucher: 'AR834' },
|
159
|
+
{ action: 'Show', module: 'Purchases', voucher: 'AP622' },
|
160
|
+
{ action: 'Destroy', module: 'Sales', voucher: 'AR839' },
|
161
|
+
{ action: 'Destroy', module: 'Purchases', voucher: 'AP625' },
|
162
|
+
{ action: 'List', module: 'Sales', year: 2015, month: 9 },
|
163
|
+
{ action: 'List', module: 'Purchases', year: 2015, month: 9 }])
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require "json"
|
2
|
+
require 'webmock'
|
3
|
+
require 'active_support'
|
4
|
+
require_relative '../../lib/tsubaiso_sdk.rb'
|
5
|
+
|
6
|
+
include WebMock::API
|
7
|
+
|
8
|
+
class StubRegister
|
9
|
+
include TsubaisoSDK::UrlBuilder
|
10
|
+
|
11
|
+
def initialize(resource, root_url, token)
|
12
|
+
@common_request_headers = {
|
13
|
+
'Accept'=>'*/*',
|
14
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
15
|
+
'Content-Type'=>'application/json',
|
16
|
+
'User-Agent'=>'Ruby'
|
17
|
+
}
|
18
|
+
@root_url = root_url
|
19
|
+
@common_request_headers.merge!( {"Access-Token" => token} )
|
20
|
+
@created_records = []
|
21
|
+
|
22
|
+
stub_create(resource)
|
23
|
+
stub_destroy(resource)
|
24
|
+
stub_list(resource)
|
25
|
+
resource == 'api_histories' ? stub_index(resource) : stub_show(resource)
|
26
|
+
stub_balance(resource)
|
27
|
+
stub_update(resource)
|
28
|
+
stub_find_or_create(resource)
|
29
|
+
stub_calc(resource)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def load_json(resource, method, req_or_res = 'request')
|
35
|
+
path = "test/stubbings/fixtures/#{resource}_#{method}_#{req_or_res}.json"
|
36
|
+
return nil unless File.exist?(path)
|
37
|
+
JSON.load(File.read(path))
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_attrs(record, index, resource)
|
41
|
+
return_params = record ? record.dup : {}
|
42
|
+
|
43
|
+
new_attributes = load_json(resource, 'create' ,'response')
|
44
|
+
return_params.deep_merge!(new_attributes) if new_attributes
|
45
|
+
|
46
|
+
return_params.merge!({
|
47
|
+
:id => index.to_s,
|
48
|
+
:created_at => Time.now.to_s,
|
49
|
+
:updated_at => Time.now.to_s
|
50
|
+
})
|
51
|
+
|
52
|
+
return_params['tag_list'] = record['tag_list'].split(',') if record['tag_list']&.kind_of?(String)
|
53
|
+
return_params
|
54
|
+
end
|
55
|
+
|
56
|
+
def stub_calc(resource)
|
57
|
+
return unless load_json(resource, 'calc')
|
58
|
+
stub_requests(:get, url(@root_url, resource, 'calc'), {'scheduled_date': '2019-01-10'}, load_json(resource, 'calc'))
|
59
|
+
end
|
60
|
+
|
61
|
+
def stub_balance(resource)
|
62
|
+
if load_json(resource, 'balance')
|
63
|
+
expect_param = load_json(resource, 'balance')
|
64
|
+
return_body = load_json(resource, 'balance', 'response')
|
65
|
+
stub_requests(:get, url(@root_url, resource, 'balance'), return_body, expect_param)
|
66
|
+
stub_requests(:get, url(@root_url, resource, 'balance'), return_body, expect_param.merge({customer_master_id: 101})) { |record| record['customer_master_code'] == '101'}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def stub_find_or_create(resource)
|
71
|
+
# NOTE: This stub support ar_receipts, ap_payments
|
72
|
+
if load_json(resource, 'find_or_create')
|
73
|
+
expected_param = load_json(resource, 'find_or_create')
|
74
|
+
return_body = add_attrs(expected_param, 99, resource)
|
75
|
+
stub_requests(:post, url(@root_url, resource, 'find_or_create'), return_body, expected_param)
|
76
|
+
@created_records << return_body
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def stub_update(resource)
|
81
|
+
if load_json(resource, 'update')
|
82
|
+
param = load_json(resource, 'update')
|
83
|
+
stub_requests(:post, url(@root_url, resource, 'update') + '/0', @created_records[0].merge(param), param)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def stub_show(resource)
|
88
|
+
@created_records.each do |record|
|
89
|
+
stub_requests(:get, url(@root_url, resource, "show") + '/' + record[:id], record) unless resource == 'journals' || resource == 'corporate_masters'
|
90
|
+
|
91
|
+
case resource
|
92
|
+
when 'customer_masters', 'staff_datum_masters'
|
93
|
+
# NOTE: Serch by Code (support customer_master_show & staff_datum_master_show & corporate_masters)
|
94
|
+
stub_requests(:get, url(@root_url, resource, 'show'), record, { code: record['code'] })
|
95
|
+
when 'staff_data'
|
96
|
+
# NOTE: Serch by code and staff_id (support staff_data)
|
97
|
+
expected_body = {
|
98
|
+
staff_id: record['staff_id'],
|
99
|
+
code: record['code'],
|
100
|
+
time: record['start_timestamp']
|
101
|
+
}
|
102
|
+
stub_requests(:get, url(@root_url, resource, 'show'), record, expected_body)
|
103
|
+
when 'corporate_masters'
|
104
|
+
stub_requests(:get, url(@root_url, resource, 'show') + '/' + record[:id], record, { ccode: record['corporate_code'] })
|
105
|
+
stub_requests(:get, url(@root_url, resource, 'show') + '/' + record[:id], record, { ccode: nil })
|
106
|
+
stub_requests(:get, url(@root_url, resource, 'show'), record, { ccode: record['corporate_code'] })
|
107
|
+
when 'journals'
|
108
|
+
stub_requests(:get, url(@root_url, resource, 'show') + '/' + record[:id], { 'record': record })
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def stub_requests(http_method, url, created_records, expected_body = {}, &condition)
|
114
|
+
response_body = condition ? created_records.select(&condition) : created_records
|
115
|
+
|
116
|
+
stub_request(http_method, url)
|
117
|
+
.with(
|
118
|
+
{ headers: @common_request_headers }.merge({ body: expected_body.merge(format: 'json') })
|
119
|
+
)
|
120
|
+
.to_return(
|
121
|
+
{ status: 200 }.merge( { body: response_body.to_json } )
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
125
|
+
def stub_index(resource)
|
126
|
+
# NOTE: for api_history
|
127
|
+
stub_requests(:get, url(@root_url, resource, 'index'), load_json(resource, 'index', 'response'))
|
128
|
+
end
|
129
|
+
|
130
|
+
def stub_list(resource)
|
131
|
+
if @created_records.size == 0
|
132
|
+
# This conditions is for modules which support only list & show.
|
133
|
+
load_json(resource,'list','response')&.each_with_index do |record, i|
|
134
|
+
@created_records << add_attrs(record, i, resource)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
case resource
|
139
|
+
when 'bank_accounts'
|
140
|
+
stub_requests(:get, url(@root_url, resource, 'list', 2016, 8), @created_records)
|
141
|
+
when 'manual_journals'
|
142
|
+
stub_requests(:get, url(@root_url, resource, 'list', 2016, 4), @created_records)
|
143
|
+
when 'payrolls'
|
144
|
+
stub_requests(:get, url(@root_url, resource, 'list', 2017, 2), @created_records)
|
145
|
+
when 'ar'
|
146
|
+
stub_requests(:get, url(@root_url, resource, 'list', 2016, 8), @created_records){ |record| record['realization_timestamp'] =~ /2016-08-\d{2}/}
|
147
|
+
when 'ap_payments'
|
148
|
+
stub_requests(:get, url(@root_url, resource, 'list', 2016, 8), @created_records){ |record| record['accrual_timestamp'] =~ /2016-08-\d{2}/}
|
149
|
+
when 'staff_data'
|
150
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { staff_id: 300 })
|
151
|
+
when 'bank_account_transactions'
|
152
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { bank_account_id: 0})
|
153
|
+
when 'reimbursements'
|
154
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { year: 2016, month: 3})
|
155
|
+
when 'api_histories'
|
156
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { year: 2019, month: 12}){ |record| record['access_timestamp'] =~ /2019\/12\/\d{2}/}
|
157
|
+
when 'reimbursement_transactions'
|
158
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { id: 300 }) { |record| record['reimbursement_id'] == 300 }
|
159
|
+
when 'tags'
|
160
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records.group_by{ |record| record['tag_group_code'] })
|
161
|
+
when 'bonuses'
|
162
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records, { target_year: 2016, bonus_no: 1 })
|
163
|
+
when 'journals'
|
164
|
+
stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'start_date': '2019-12-01', 'finish_date': '2019-12-31'} )
|
165
|
+
stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'price_min': 10800, 'price_max': 10800} )
|
166
|
+
stub_requests(:get, url(@root_url, resource, 'list'), {'records': @created_records}, { 'dept_code': 'SETSURITSU' } )
|
167
|
+
else
|
168
|
+
stub_requests(:get, url(@root_url, resource, 'list'), @created_records)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def stub_destroy(resource)
|
173
|
+
@created_records.each_with_index do |record, index|
|
174
|
+
stub_request(:post, url(@root_url, resource, 'destroy') + "/" + record[:id])
|
175
|
+
.with(
|
176
|
+
headers: @common_request_headers
|
177
|
+
)
|
178
|
+
.to_return(
|
179
|
+
status: 204
|
180
|
+
)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def stub_create(resource)
|
185
|
+
load_json(resource, 'create')&.each_with_index do |record, i|
|
186
|
+
if resource == 'journal_distributions'
|
187
|
+
return_body = add_attrs({}, i, resource)
|
188
|
+
else
|
189
|
+
return_body = add_attrs(record, i, resource)
|
190
|
+
end
|
191
|
+
stub_requests(:post, url(@root_url, resource, 'create'), return_body, record)
|
192
|
+
@created_records << return_body
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
data/test/test_tsubaiso_api.rb
CHANGED
@@ -1,20 +1,64 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require 'minitest/autorun'
|
3
2
|
require 'time'
|
4
3
|
require './lib/tsubaiso_api'
|
5
4
|
|
6
5
|
class TsubaisoAPITest < Minitest::Test
|
7
|
-
|
8
6
|
def setup
|
9
|
-
@api = TsubaisoAPI.new({ base_url: ENV[
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
@api = TsubaisoAPI.new({ base_url: ENV['SDK_BASE_URL'], access_token: ENV['SDK_ACCESS_TOKEN'] })
|
8
|
+
|
9
|
+
@customer_1000 = {
|
10
|
+
name: 'テスト株式会社',
|
11
|
+
name_kana: 'テストカブシキガイシャ',
|
12
|
+
code: '10000',
|
13
|
+
tax_type_for_remittance_charge: '3',
|
14
|
+
used_in_ar: 1,
|
15
|
+
used_in_ap: 1,
|
16
|
+
is_valid: 1
|
17
|
+
}
|
18
|
+
|
19
|
+
@sale_201608 = {
|
20
|
+
price_including_tax: 10_800,
|
21
|
+
realization_timestamp: '2016-08-01',
|
22
|
+
customer_master_code: '101',
|
23
|
+
dept_code: 'SETSURITSU',
|
24
|
+
reason_master_code: 'SALES',
|
25
|
+
dc: 'd',
|
26
|
+
memo: 'irfan test',
|
27
|
+
tax_code: 1007,
|
28
|
+
scheduled_memo: 'This is a scheduled memo.',
|
29
|
+
scheduled_receive_timestamp: '2016-09-25',
|
30
|
+
data_partner: { link_url: 'www.example.com/1', id_code: '1' }
|
31
|
+
}
|
32
|
+
|
33
|
+
@sale_201702 = {
|
34
|
+
price_including_tax: 10_800,
|
35
|
+
realization_timestamp: '2017-02-28',
|
36
|
+
customer_master_code: '105',
|
37
|
+
reason_master_code: 'SALES',
|
38
|
+
dc: 'd',
|
39
|
+
memo: '',
|
40
|
+
tax_code: 18,
|
41
|
+
scheduled_memo: 'This is a scheduled memo.',
|
42
|
+
scheduled_receive_timestamp: '2017-03-25',
|
43
|
+
data_partner: { link_url: 'www.example.com/8', id_code: '8' }
|
44
|
+
}
|
45
|
+
|
46
|
+
@reimbursement_1 = {
|
47
|
+
applicant: 'Matsuno',
|
48
|
+
application_term: '2016-03-01',
|
49
|
+
staff_code: 'EP2000',
|
50
|
+
memo: 'aaaaaaaa'
|
51
|
+
}
|
52
|
+
|
53
|
+
@reimbursement_tx_1 = {
|
54
|
+
transaction_timestamp: '2016-03-01',
|
55
|
+
price_value: 10_000,
|
56
|
+
dc: 'c',
|
57
|
+
reason_code: 'SUPPLIES',
|
58
|
+
brief: 'everyting going well',
|
59
|
+
memo: 'easy',
|
60
|
+
data_partner: { link_url: 'www.example.com/5', id_code: '5' }
|
61
|
+
}
|
18
62
|
end
|
19
63
|
|
20
64
|
def test_list
|
@@ -25,7 +69,7 @@ class TsubaisoAPITest < Minitest::Test
|
|
25
69
|
list_customers = @api.list('customer_masters')
|
26
70
|
assert_equal 200, list_customers[:status].to_i
|
27
71
|
|
28
|
-
assert
|
72
|
+
assert(list_customers[:json]&.any? { |x| x['code'] == @customer_1000[:code] })
|
29
73
|
ensure
|
30
74
|
@api.destroy('customer_masters', id: cm[:json]['id']) if cm[:json]['id']
|
31
75
|
end
|
@@ -33,7 +77,7 @@ class TsubaisoAPITest < Minitest::Test
|
|
33
77
|
def test_show
|
34
78
|
ar = @api.create('ar_receipts', @sale_201608)
|
35
79
|
assert 200, ar[:status].to_i
|
36
|
-
assert @sale_201608[:customer_master_code], ar[:json][
|
80
|
+
assert @sale_201608[:customer_master_code], ar[:json]['customer_master_code']
|
37
81
|
|
38
82
|
show_ar = @api.show('ar_receipts', id: ar[:json]['id'])
|
39
83
|
assert successful?(show_ar[:status])
|
@@ -66,7 +110,7 @@ class TsubaisoAPITest < Minitest::Test
|
|
66
110
|
end
|
67
111
|
|
68
112
|
def test_get_and_post
|
69
|
-
time
|
113
|
+
time = Time.mktime(@sale_201702[:realization_timestamp])
|
70
114
|
balance_before = @api.get('ar_receipts/balance', { year: time.year, month: time.month })
|
71
115
|
assert successful?(balance_before[:status])
|
72
116
|
assert balance_before[:json].count > 0
|