tsubaiso-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README-j.md +347 -0
- data/README.md +345 -0
- data/Rakefile +8 -0
- data/lib/tsubaiso_sdk.rb +135 -0
- data/sample.rb +76 -0
- data/test/test_tsubaiso_sdk.rb +97 -0
- metadata +83 -0
data/README-j.md
ADDED
@@ -0,0 +1,347 @@
|
|
1
|
+
# Tsubaiso API (beta)
|
2
|
+
|
3
|
+
このドキュメントでは Tsubaiso API のベータ版の説明をします。
|
4
|
+
Tsubaiso API ベータ版では売上明細と仕入・経費明細のデータをやりとりできます。
|
5
|
+
将来のバージョンでは、ツバイソシステムの他のモジュールにアクセスするための新しいエンドポイントが加わる予定です。
|
6
|
+
|
7
|
+
## Root Endpoint
|
8
|
+
|
9
|
+
```sh
|
10
|
+
https://tsubaiso.net
|
11
|
+
```
|
12
|
+
|
13
|
+
## リクエストのフォーマット
|
14
|
+
|
15
|
+
API へのすべてのリクエストは JSON を使って行います。
|
16
|
+
|
17
|
+
## 認証
|
18
|
+
|
19
|
+
Tsubaiso API にアクセスするためには、アクセストークンを取得する必要があります。
|
20
|
+
以下は、アクセストークンを使って売上明細一覧のデータを取得する例です。
|
21
|
+
|
22
|
+
```
|
23
|
+
$ curl -i -H "Access-Token: xxxxxxxxxxxxxxxxx" -H "Accept: application/json" -H "Content-Type: application/json" https://tsubaiso.net/ar/list
|
24
|
+
```
|
25
|
+
|
26
|
+
## レスポンスコードとエラー処理
|
27
|
+
|
28
|
+
Code | Description
|
29
|
+
--- | ---
|
30
|
+
`200 OK` | リクエスト成功 |
|
31
|
+
`204 No Content` | リクエストに成功したが返されるコンテンツはありません。
|
32
|
+
`401 Not Authorized` | アクセストークンが送られていないか正しくありません。
|
33
|
+
`403 Forbidden` | そのリクエストに必要な権限がありません。
|
34
|
+
`404 Not found` | 指定されたパスは正しくないか、リソースが見つかりません。
|
35
|
+
`422 Unprocessable Entity` | 1つ以上のパラメータが正しくないか不足しています。エラーメッセージで原因が判別できます。
|
36
|
+
`500 Internal Server Error` | サーバーで何らかのエラーが起こりました。
|
37
|
+
`503 Service Unavailable` | あなたの IP アドレスから非常に多くのリクエストがあった場合、このエラーが発生します。次のリクエストまで少し時間を開けてください。
|
38
|
+
|
39
|
+
## リソース
|
40
|
+
|
41
|
+
#### 売上明細
|
42
|
+
|
43
|
+
**/ar/list/:year/:month**
|
44
|
+
|
45
|
+
説明: このエンドポイントは特定の年月の売上明細の一覧を返します。年月パラメータが指定されなかった場合、現在の月の明細が返されます。
|
46
|
+
|
47
|
+
HTTP メソッド: GET
|
48
|
+
|
49
|
+
URL 構成例:
|
50
|
+
```sh
|
51
|
+
https://tsubaiso.net/ar/list/2015/10
|
52
|
+
```
|
53
|
+
|
54
|
+
JSON レスポンスの例:
|
55
|
+
```
|
56
|
+
[
|
57
|
+
{
|
58
|
+
"ar_reason_master_id": 0,
|
59
|
+
"ar_receipt_attachments_count": null,
|
60
|
+
"code": null,
|
61
|
+
"created_at": "2015/10/05 15:26:43 +0900",
|
62
|
+
"customer_master_id": 101,
|
63
|
+
"dc": "d",
|
64
|
+
"dept_code": "DEPT A",
|
65
|
+
"id": 8833,
|
66
|
+
"memo": "500 widgets",
|
67
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
68
|
+
"regist_user_code": "sample_user",
|
69
|
+
"sales_journal_dc_id": 6832,
|
70
|
+
"scheduled_memo": null,
|
71
|
+
"scheduled_receive_timestamp": null,
|
72
|
+
"update_user_code": null,
|
73
|
+
"updated_at": "2015/10/05 15:26:43 +0900",
|
74
|
+
"account_code": "501",
|
75
|
+
"sales_price": 5000,
|
76
|
+
"sales_tax": 400,
|
77
|
+
"sales_tax_type": 18
|
78
|
+
}, {
|
79
|
+
"ar_reason_master_id": 121278,
|
80
|
+
"ar_receipt_attachments_count": null,
|
81
|
+
"code": null,
|
82
|
+
"created_at": "2015/10/05 17:39:34 +0900",
|
83
|
+
"customer_master_id": 895820,
|
84
|
+
"dc": "d",
|
85
|
+
"dept_code": "DEPT B",
|
86
|
+
"id": 8834,
|
87
|
+
"memo": "100 clocks",
|
88
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
89
|
+
"regist_user_code": "sample_user",
|
90
|
+
"sales_journal_dc_id": 8834,
|
91
|
+
"scheduled_memo": null,
|
92
|
+
"scheduled_receive_timestamp": null,
|
93
|
+
"update_user_code": null,
|
94
|
+
"updated_at": "2015/10/05 17:39:34 +0900",
|
95
|
+
"account_code": "500",
|
96
|
+
"sales_price": 10000,
|
97
|
+
"sales_tax": 800,
|
98
|
+
"sales_tax_type": 0
|
99
|
+
}
|
100
|
+
]
|
101
|
+
```
|
102
|
+
|
103
|
+
**/ar/show/:id**
|
104
|
+
|
105
|
+
説明: このエンドポイントは単一の売上明細を返します。
|
106
|
+
|
107
|
+
HTTP メソッド: GET
|
108
|
+
|
109
|
+
URL 構成例:
|
110
|
+
``` sh
|
111
|
+
https://tsubaiso.net/ar/show/8833
|
112
|
+
```
|
113
|
+
|
114
|
+
JSON レスポンスの例:
|
115
|
+
```
|
116
|
+
{
|
117
|
+
"ar_reason_master_id": 0,
|
118
|
+
"ar_receipt_attachments_count": null,
|
119
|
+
"code": null,
|
120
|
+
"created_at": "2015/10/05 15:26:43 +0900",
|
121
|
+
"customer_master_id": 101,
|
122
|
+
"dc": "d",
|
123
|
+
"dept_code": "DEPT A",
|
124
|
+
"id": 8833,
|
125
|
+
"memo": "500 widgets",
|
126
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
127
|
+
"regist_user_code": "sample_user",
|
128
|
+
"sales_journal_dc_id": 6832,
|
129
|
+
"scheduled_memo": null,
|
130
|
+
"scheduled_receive_timestamp": null,
|
131
|
+
"update_user_code": null,
|
132
|
+
"updated_at": "2015/10/05 15:26:43 +0900",
|
133
|
+
"account_code": "501",
|
134
|
+
"sales_price": 5000,
|
135
|
+
"sales_tax": 400,
|
136
|
+
"sales_tax_type": 18
|
137
|
+
}
|
138
|
+
```
|
139
|
+
|
140
|
+
**/ar/create**
|
141
|
+
|
142
|
+
説明: 売上明細を新規作成します。作成に成功した場合、新規作成された明細が JSON として返されます。
|
143
|
+
|
144
|
+
HTTP メソッド: POST
|
145
|
+
|
146
|
+
URL 構成例:
|
147
|
+
```sh
|
148
|
+
https://tsubaiso.net/ar/create
|
149
|
+
```
|
150
|
+
|
151
|
+
Parameters:
|
152
|
+
|
153
|
+
Parameter | Necessity | Type | Description
|
154
|
+
--- | --- | --- | ---
|
155
|
+
`price` | *required* | Integer | 売上高(税込)
|
156
|
+
`realization_timestamp` | *required* | String | 明細の実現日。 "YYYY-MM-DD" 形式
|
157
|
+
`customer_master_code` | *required* | String | 取引先コード
|
158
|
+
`reason_master_code` | *required* | String | 明細の原因コード。仕訳を作成するために使われます。
|
159
|
+
`dc` | *required* | String | 原因区分。 'd' は debit の意で「増加」に、'c' は credit の意で「減少」になります。
|
160
|
+
`memo` | *required* | String | メモ。値は空文字でも構いませんが必須項目です。
|
161
|
+
`tax_code` | *required* | Integer | 税区分コード
|
162
|
+
`year` | *optional* | Integer | 年
|
163
|
+
`month` | *optional* | Integer | 月
|
164
|
+
`dept_code` | *optional* | String | 部門コード
|
165
|
+
`sales_tax` | *optional* | Integer | 消費税額。指定されなかった場合、自動で計算されます。
|
166
|
+
`scheduled_receipt_timestamp` | *optional* | String | 入金予定日。 “YYYY-MM-DD”形式
|
167
|
+
`scheduled_memo` | *optional* | String | 入金予定に関するメモ
|
168
|
+
|
169
|
+
リクエストの例:
|
170
|
+
```sh
|
171
|
+
curl -i -H "Content-Type: application/json" -H "Accept: application/json" -H "Access-Token: XXXXXXXXXXXXXX" -X POST -d '{"year": 2015, "month": 10, "price": 5000, "realization_timestamp": "2015-10-31", "customer_master_code": "101", "dept_code": "DEPT A", "reason_master_code": "SALES", "dc": "d", "memo": "500 widgets", "tax_code": 0}' https://tsubaiso.net/ar/create
|
172
|
+
```
|
173
|
+
|
174
|
+
**/ar/destroy/:id**
|
175
|
+
|
176
|
+
説明: 指定された id の売上明細を削除します。成功した場合 204 No Content が返ります。
|
177
|
+
|
178
|
+
HTTP メソッド: POST
|
179
|
+
|
180
|
+
URL 構成例:
|
181
|
+
```sh
|
182
|
+
https://tsubaiso.net/ar/destroy/8833
|
183
|
+
```
|
184
|
+
|
185
|
+
#### 仕入・経費明細
|
186
|
+
|
187
|
+
**/ap_payments/list/:year/:month**
|
188
|
+
|
189
|
+
説明: このエンドポイントは特定の年月の仕入・経費明細の一覧を返します。年月パラメータが指定されなかった場合、現在の月の明細が返されます。
|
190
|
+
|
191
|
+
HTTP メソッド: GET
|
192
|
+
|
193
|
+
URL 構成例:
|
194
|
+
``` sh
|
195
|
+
https://tsubaiso.net/ap_payments/list/2015/10
|
196
|
+
```
|
197
|
+
|
198
|
+
JSON レスポンスの例:
|
199
|
+
```
|
200
|
+
[
|
201
|
+
{
|
202
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
203
|
+
"ap_payment_attachments_count": null,
|
204
|
+
"ap_reason_master_id": 1,
|
205
|
+
"buying_journal_dc_id": 9835,
|
206
|
+
"code": null,
|
207
|
+
"created_at": "2015/10/06 15:45:21 +0900",
|
208
|
+
"customer_master_id": 8201,
|
209
|
+
"dc": "c",
|
210
|
+
"dept_code": "DEPT C",
|
211
|
+
"id": 6621,
|
212
|
+
"memo": "Office Supplies for Frank",
|
213
|
+
"need_tax_deduction": null,
|
214
|
+
"port_type": 1,
|
215
|
+
"preset_withholding_tax_amount": null,
|
216
|
+
"regist_user_code": "sample_user",
|
217
|
+
"scheduled_memo": null,
|
218
|
+
"scheduled_pay_timestamp": null,
|
219
|
+
"update_user_code": null,
|
220
|
+
"updated_at": "2015/10/06 15:45:21 +0900",
|
221
|
+
"withholding_tax_base": null,
|
222
|
+
"withholding_tax_segment": null,
|
223
|
+
"account_code": "604",
|
224
|
+
"buying_price": 5000,
|
225
|
+
"buying_tax": 400,
|
226
|
+
"buying_tax_type": 0
|
227
|
+
}, {
|
228
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
229
|
+
"ap_payment_attachments_count": null,
|
230
|
+
"ap_reason_master_id": 1,
|
231
|
+
"buying_journal_dc_id": 9836,
|
232
|
+
"code": null,
|
233
|
+
"created_at": "2015/10/06 15:48:42 +0900",
|
234
|
+
"customer_master_id": 101,
|
235
|
+
"dc": "c",
|
236
|
+
"dept_code": "SETSURITSU",
|
237
|
+
"id": 622,
|
238
|
+
"memo": "Television for Cafeteria",
|
239
|
+
"need_tax_deduction": null,
|
240
|
+
"port_type": 1,
|
241
|
+
"preset_withholding_tax_amount": null,
|
242
|
+
"regist_user_code": "client_user",
|
243
|
+
"scheduled_memo": null,
|
244
|
+
"scheduled_pay_timestamp": null,
|
245
|
+
"update_user_code": null,
|
246
|
+
"updated_at": "2015/10/06 15:48:42 +0900",
|
247
|
+
"withholding_tax_base": null,
|
248
|
+
"withholding_tax_segment": null,
|
249
|
+
"account_code": "604",
|
250
|
+
"buying_price": 10000,
|
251
|
+
"buying_tax": 800,
|
252
|
+
"buying_tax_type": 0
|
253
|
+
}
|
254
|
+
]
|
255
|
+
```
|
256
|
+
|
257
|
+
**/ap_payments/show/:id**
|
258
|
+
|
259
|
+
説明: このエンドポイントは単一の仕入・経費明細を返します。
|
260
|
+
|
261
|
+
HTTP メソッド: GET
|
262
|
+
|
263
|
+
URL 構成例:
|
264
|
+
``` sh
|
265
|
+
https://tsubaiso.net/ap_payments/show/6621
|
266
|
+
```
|
267
|
+
|
268
|
+
JSON レスポンスの例:
|
269
|
+
```
|
270
|
+
{
|
271
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
272
|
+
"ap_payment_attachments_count": null,
|
273
|
+
"ap_reason_master_id": 1,
|
274
|
+
"buying_journal_dc_id": 9835,
|
275
|
+
"code": null,
|
276
|
+
"created_at": "2015/10/06 15:45:21 +0900",
|
277
|
+
"customer_master_id": 8201,
|
278
|
+
"dc": "c",
|
279
|
+
"dept_code": "DEPT C",
|
280
|
+
"id": 6621,
|
281
|
+
"memo": "Office Supplies for Frank",
|
282
|
+
"need_tax_deduction": null,
|
283
|
+
"port_type": 1,
|
284
|
+
"preset_withholding_tax_amount": null,
|
285
|
+
"regist_user_code": "sample_user",
|
286
|
+
"scheduled_memo": null,
|
287
|
+
"scheduled_pay_timestamp": null,
|
288
|
+
"update_user_code": null,
|
289
|
+
"updated_at": "2015/10/06 15:45:21 +0900",
|
290
|
+
"withholding_tax_base": null,
|
291
|
+
"withholding_tax_segment": null,
|
292
|
+
"account_code": "604",
|
293
|
+
"buying_price": 5000,
|
294
|
+
"buying_tax": 400,
|
295
|
+
"buying_tax_type": 0
|
296
|
+
}
|
297
|
+
```
|
298
|
+
|
299
|
+
**/ap_payments/create**
|
300
|
+
|
301
|
+
説明: 仕入・経費明細を新規作成します。作成に成功した場合、新規作成された明細が JSON として返されます。
|
302
|
+
|
303
|
+
HTTP メソッド: POST
|
304
|
+
|
305
|
+
URL 構成例:
|
306
|
+
```sh
|
307
|
+
https://tsubaiso.net/ap_payments/create
|
308
|
+
```
|
309
|
+
|
310
|
+
Parameters:
|
311
|
+
|
312
|
+
Parameter | Necessity | Type | Description
|
313
|
+
--- | --- | --- | ---
|
314
|
+
`price` | *required* | Integer | 発生額(税込)
|
315
|
+
`accrual_timestamp` | *required* | String | 発生日。 "YYYY-MM-DD" 形式
|
316
|
+
`customer_master_code` | *required* | String | 取引先コード
|
317
|
+
`reason_master_code` | *required* | String | 明細の原因コード。仕訳を作成するために使われます。
|
318
|
+
`dc` | *required* | String | 原因区分。 'd' は「減少」に、'c' は「増加」になります。
|
319
|
+
`memo` | *required* | String | メモ。値は空文字でも構いませんが必須項目です。
|
320
|
+
`tax_code` | *required* | Integer | 税区分コード
|
321
|
+
`port_type` | *required* | Integer | エリア区分。 1 は「国内」、 2 は「国外」
|
322
|
+
`year` | *optional* | Integer | 明細の年。 年が指定された場合は月も必須項目になります。年が指定されない場合は現在の年が使われます。
|
323
|
+
`month` | *optional* | Integer | 明細の月。月が指定された場合は年も必須項目になります。月が指定されない場合は現在の月が使われます。
|
324
|
+
`dept_code` | *optional* | String | 部門コード
|
325
|
+
`buying_tax` | *optional* | Integer | 消費税額。省略された場合は自動で計算されます。
|
326
|
+
`scheduled_pay_timestamp` | *optional* | String | 支払予定日。 "YYYY-MM-DD" 形式
|
327
|
+
`scheduled_memo` | *optional* | String | 支払いに関する追加のメモ
|
328
|
+
`need_tax_deduction` | *optional* | Integer | 源泉徴収の対象とするか否か。 0:しない, 1:する
|
329
|
+
`preset_withholding_tax_amount` | *optional* | Integer | 事前設定源泉徴収額
|
330
|
+
`withholding_tax_base` | *optional* | Integer | 源泉徴収基準額。 1:消費税込額, 2:消費税抜額
|
331
|
+
`withholding_tax_segment` | *optional* | String | 源泉徴収区分コード (例: "nta2795"。 次のページを参照してください https://www.nta.go.jp/taxanswer/gensen/2795.htm)
|
332
|
+
|
333
|
+
リクエストの例:
|
334
|
+
``` sh
|
335
|
+
curl -i -H "Content-Type: application/json" -H "Accept: application/json" -H "Access-Token: XXXXXXXXXXXXXX" -X POST -d '{"year": 2015, "month": 8, "price": 5000, "accrual_timestamp": "2015-10-31", "customer_master_code": "8201", "dept_code": "DEPT C", "reason_master_code": "BUYING_IN", "dc": "c", "memo": "Office Supplies for Frank", "tax_code": 0, "port_type": 1 }' https://tsubaiso.net/ap_payments/create
|
336
|
+
```
|
337
|
+
|
338
|
+
**/ap/destroy/:id**
|
339
|
+
|
340
|
+
説明: 指定された id の仕入・経費明細を削除します。成功した場合 204 No Content が返ります。
|
341
|
+
|
342
|
+
HTTP メソッド: POST
|
343
|
+
|
344
|
+
URL 構成例:
|
345
|
+
```sh
|
346
|
+
https://tsubaiso.net/ap/destroy/6621
|
347
|
+
```
|
data/README.md
ADDED
@@ -0,0 +1,345 @@
|
|
1
|
+
# Tsubaiso API (beta)
|
2
|
+
|
3
|
+
This is the documentation for the beta version of the Tsubaiso API. The beta version currently handles accounts receivables and accounts payable transactions. Future versions of this API will add new endpoints to access other modules of the Tsubaiso system.
|
4
|
+
|
5
|
+
## Root Endpoint
|
6
|
+
|
7
|
+
```sh
|
8
|
+
https://tsubaiso.net
|
9
|
+
```
|
10
|
+
|
11
|
+
|
12
|
+
## Request Format
|
13
|
+
|
14
|
+
We ask that all requests to the API be made using JSON.
|
15
|
+
|
16
|
+
## Authentication
|
17
|
+
|
18
|
+
The user must provide their access token in order to access the Tsubaiso API.
|
19
|
+
|
20
|
+
```
|
21
|
+
$ curl -i -H "Access-Token: xxxxxxxxxxxxxxxxx" -H "Accept: application/json" -H "Content-Type: application/json" https://tsubaiso.net/ar/list
|
22
|
+
```
|
23
|
+
|
24
|
+
## Response Codes and Error Handling
|
25
|
+
|
26
|
+
Code | Description
|
27
|
+
--- | ---
|
28
|
+
`200 OK` | A successful request was made. |
|
29
|
+
`204 No Content` | A successful request was made but no content is passed back.
|
30
|
+
`401 Not Authorized` | The access token was not provided or was incorrect.
|
31
|
+
`403 Forbidden` | You do not have the correct privileges to make this request.
|
32
|
+
`404 Not found` | Path is incorrect or resource was not found at the specified path.
|
33
|
+
`422 Unprocessable Entity` | One or more parameters were incorrect or insufficient. The error message will tell you the reason.
|
34
|
+
`500 Internal Server Error` | There was an error on the server.
|
35
|
+
`503 Service Unavailable` | This error occurs when there are too many requests coming from your IP address. Wait a little bit to make your next request.
|
36
|
+
|
37
|
+
## Resources
|
38
|
+
|
39
|
+
#### Accounts Receivables
|
40
|
+
|
41
|
+
**/ar/list/:year/:month**
|
42
|
+
|
43
|
+
Description: This endpoint returns a list of accounts receivables transactions for a particular month. If no year and month parameters are provided. It returns the transactions for the current month.
|
44
|
+
|
45
|
+
Method: GET
|
46
|
+
|
47
|
+
URL Structure:
|
48
|
+
```sh
|
49
|
+
https://tsubaiso.net/ar/list/2015/10
|
50
|
+
```
|
51
|
+
|
52
|
+
Sample JSON response:
|
53
|
+
```
|
54
|
+
[
|
55
|
+
{
|
56
|
+
"ar_reason_master_id": 0,
|
57
|
+
"ar_receipt_attachments_count": null,
|
58
|
+
"code": null,
|
59
|
+
"created_at": "2015/10/05 15:26:43 +0900",
|
60
|
+
"customer_master_id": 101,
|
61
|
+
"dc": "d",
|
62
|
+
"dept_code": "DEPT A",
|
63
|
+
"id": 8833,
|
64
|
+
"memo": "500 widgets",
|
65
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
66
|
+
"regist_user_code": "sample_user",
|
67
|
+
"sales_journal_dc_id": 6832,
|
68
|
+
"scheduled_memo": null,
|
69
|
+
"scheduled_receive_timestamp": null,
|
70
|
+
"update_user_code": null,
|
71
|
+
"updated_at": "2015/10/05 15:26:43 +0900",
|
72
|
+
"account_code": "501",
|
73
|
+
"sales_price": 5000,
|
74
|
+
"sales_tax": 400,
|
75
|
+
"sales_tax_type": 18
|
76
|
+
}, {
|
77
|
+
"ar_reason_master_id": 121278,
|
78
|
+
"ar_receipt_attachments_count": null,
|
79
|
+
"code": null,
|
80
|
+
"created_at": "2015/10/05 17:39:34 +0900",
|
81
|
+
"customer_master_id": 895820,
|
82
|
+
"dc": "d",
|
83
|
+
"dept_code": "DEPT B",
|
84
|
+
"id": 8834,
|
85
|
+
"memo": "100 clocks",
|
86
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
87
|
+
"regist_user_code": "sample_user",
|
88
|
+
"sales_journal_dc_id": 8834,
|
89
|
+
"scheduled_memo": null,
|
90
|
+
"scheduled_receive_timestamp": null,
|
91
|
+
"update_user_code": null,
|
92
|
+
"updated_at": "2015/10/05 17:39:34 +0900",
|
93
|
+
"account_code": "500",
|
94
|
+
"sales_price": 10000,
|
95
|
+
"sales_tax": 800,
|
96
|
+
"sales_tax_type": 0
|
97
|
+
}
|
98
|
+
]
|
99
|
+
```
|
100
|
+
|
101
|
+
**/ar/show/:id**
|
102
|
+
|
103
|
+
Description: This endpoint returns a single accounts receivable transaction.
|
104
|
+
|
105
|
+
Method: GET
|
106
|
+
|
107
|
+
URL Structure:
|
108
|
+
``` sh
|
109
|
+
https://tsubaiso.net/ar/show/8833
|
110
|
+
```
|
111
|
+
|
112
|
+
Sample JSON response:
|
113
|
+
```
|
114
|
+
{
|
115
|
+
"ar_reason_master_id": 0,
|
116
|
+
"ar_receipt_attachments_count": null,
|
117
|
+
"code": null,
|
118
|
+
"created_at": "2015/10/05 15:26:43 +0900",
|
119
|
+
"customer_master_id": 101,
|
120
|
+
"dc": "d",
|
121
|
+
"dept_code": "DEPT A",
|
122
|
+
"id": 8833,
|
123
|
+
"memo": "500 widgets",
|
124
|
+
"realization_timestamp": "2015/10/31 00:00:00 +0900",
|
125
|
+
"regist_user_code": "sample_user",
|
126
|
+
"sales_journal_dc_id": 6832,
|
127
|
+
"scheduled_memo": null,
|
128
|
+
"scheduled_receive_timestamp": null,
|
129
|
+
"update_user_code": null,
|
130
|
+
"updated_at": "2015/10/05 15:26:43 +0900",
|
131
|
+
"account_code": "501",
|
132
|
+
"sales_price": 5000,
|
133
|
+
"sales_tax": 400,
|
134
|
+
"sales_tax_type": 18
|
135
|
+
}
|
136
|
+
```
|
137
|
+
|
138
|
+
**/ar/create**
|
139
|
+
|
140
|
+
Description: Creates a new accounts receivable transaction. The created transaction will be sent back as JSON if successful.
|
141
|
+
|
142
|
+
Method: POST
|
143
|
+
|
144
|
+
URL Structure:
|
145
|
+
```sh
|
146
|
+
https://tsubaiso.net/ar/create
|
147
|
+
```
|
148
|
+
|
149
|
+
Parameters:
|
150
|
+
|
151
|
+
Parameter | Necessity | Type | Description
|
152
|
+
--- | --- | --- | ---
|
153
|
+
`price` | *required* | Integer | Amount of the transaction.
|
154
|
+
`realization_timestamp` | *required* | String | Actual date of the transaction. Format must be "YYYY-MM-DD"
|
155
|
+
`customer_master_code` | *required* | String | Code of the transaction party.
|
156
|
+
`reason_master_code` | *required* | String | Reason of the transaction. This is used to create the journal entry.
|
157
|
+
`dc` | *required* | String | 'd' if the transaction was a debit to AR, 'c' if it was a credit.
|
158
|
+
`memo` | *required* | String | Memo for the transaction. Can be blank but must be provided.
|
159
|
+
`tax_code` | *required* | Integer | Tax code for the transaction.
|
160
|
+
`year` | *optional* | Integer | Year of the transaction.
|
161
|
+
`month` | *optional* | Integer | Month of the transaction.
|
162
|
+
`dept_code` | *optional* | String | Code of the internal department involved.
|
163
|
+
`sales_tax` | *optional* | Integer | Sales tax on the transaction. Is automatically calculated if not provided.
|
164
|
+
`scheduled_receipt_timestamp` | *optional* | String | Date of receipt. Format must be “YYYY-MM-DD”.
|
165
|
+
`scheduled_memo` | *optional* | String | Optional memo regarding receipt of funds.
|
166
|
+
|
167
|
+
Sample Request:
|
168
|
+
```sh
|
169
|
+
curl -i -H "Content-Type: application/json" -H "Accept: application/json" -H "Access-Token: XXXXXXXXXXXXXX" -X POST -d '{"year": 2015, "month": 10, "price": 5000, "realization_timestamp": "2015-10-31", "customer_master_code": "101", "dept_code": "DEPT A", "reason_master_code": "SALES", "dc": "d", "memo": "500 widgets", "tax_code": 0}' https://tsubaiso.net/ar/create
|
170
|
+
```
|
171
|
+
|
172
|
+
**/ar/destroy/:id**
|
173
|
+
|
174
|
+
Description: Destroys the accounts receivable transaction specified as the id. Returns a status of 204 No Content.
|
175
|
+
|
176
|
+
Method: POST
|
177
|
+
|
178
|
+
URL Structure:
|
179
|
+
```sh
|
180
|
+
https://tsubaiso.net/ar/destroy/8833
|
181
|
+
```
|
182
|
+
|
183
|
+
#### Accounts Payables
|
184
|
+
|
185
|
+
**/ap_payments/list/:year/:month**
|
186
|
+
|
187
|
+
Description: Returns a list of accounts payables transactions for a particular month. If no year and month parameters are provided. It returns the transactions for the current month.
|
188
|
+
|
189
|
+
Method: GET
|
190
|
+
|
191
|
+
URL Structure:
|
192
|
+
``` sh
|
193
|
+
https://tsubaiso.net/ap_payments/list/2015/10
|
194
|
+
```
|
195
|
+
|
196
|
+
Sample JSON response:
|
197
|
+
```
|
198
|
+
[
|
199
|
+
{
|
200
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
201
|
+
"ap_payment_attachments_count": null,
|
202
|
+
"ap_reason_master_id": 1,
|
203
|
+
"buying_journal_dc_id": 9835,
|
204
|
+
"code": null,
|
205
|
+
"created_at": "2015/10/06 15:45:21 +0900",
|
206
|
+
"customer_master_id": 8201,
|
207
|
+
"dc": "c",
|
208
|
+
"dept_code": "DEPT C",
|
209
|
+
"id": 6621,
|
210
|
+
"memo": "Office Supplies for Frank",
|
211
|
+
"need_tax_deduction": null,
|
212
|
+
"port_type": 1,
|
213
|
+
"preset_withholding_tax_amount": null,
|
214
|
+
"regist_user_code": "sample_user",
|
215
|
+
"scheduled_memo": null,
|
216
|
+
"scheduled_pay_timestamp": null,
|
217
|
+
"update_user_code": null,
|
218
|
+
"updated_at": "2015/10/06 15:45:21 +0900",
|
219
|
+
"withholding_tax_base": null,
|
220
|
+
"withholding_tax_segment": null,
|
221
|
+
"account_code": "604",
|
222
|
+
"buying_price": 5000,
|
223
|
+
"buying_tax": 400,
|
224
|
+
"buying_tax_type": 0
|
225
|
+
}, {
|
226
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
227
|
+
"ap_payment_attachments_count": null,
|
228
|
+
"ap_reason_master_id": 1,
|
229
|
+
"buying_journal_dc_id": 9836,
|
230
|
+
"code": null,
|
231
|
+
"created_at": "2015/10/06 15:48:42 +0900",
|
232
|
+
"customer_master_id": 101,
|
233
|
+
"dc": "c",
|
234
|
+
"dept_code": "SETSURITSU",
|
235
|
+
"id": 622,
|
236
|
+
"memo": "Television for Cafeteria",
|
237
|
+
"need_tax_deduction": null,
|
238
|
+
"port_type": 1,
|
239
|
+
"preset_withholding_tax_amount": null,
|
240
|
+
"regist_user_code": "client_user",
|
241
|
+
"scheduled_memo": null,
|
242
|
+
"scheduled_pay_timestamp": null,
|
243
|
+
"update_user_code": null,
|
244
|
+
"updated_at": "2015/10/06 15:48:42 +0900",
|
245
|
+
"withholding_tax_base": null,
|
246
|
+
"withholding_tax_segment": null,
|
247
|
+
"account_code": "604",
|
248
|
+
"buying_price": 10000,
|
249
|
+
"buying_tax": 800,
|
250
|
+
"buying_tax_type": 0
|
251
|
+
}
|
252
|
+
]
|
253
|
+
```
|
254
|
+
|
255
|
+
**/ap_payments/show/:id**
|
256
|
+
|
257
|
+
Description: This endpoint returns a single accounts payable transaction.
|
258
|
+
|
259
|
+
Method: GET
|
260
|
+
|
261
|
+
URL Structure:
|
262
|
+
``` sh
|
263
|
+
https://tsubaiso.net/ap_payments/show/6621
|
264
|
+
```
|
265
|
+
|
266
|
+
Sample JSON response:
|
267
|
+
```
|
268
|
+
{
|
269
|
+
"accrual_timestamp": "2015/10/31 00:00:00 +0900",
|
270
|
+
"ap_payment_attachments_count": null,
|
271
|
+
"ap_reason_master_id": 1,
|
272
|
+
"buying_journal_dc_id": 9835,
|
273
|
+
"code": null,
|
274
|
+
"created_at": "2015/10/06 15:45:21 +0900",
|
275
|
+
"customer_master_id": 8201,
|
276
|
+
"dc": "c",
|
277
|
+
"dept_code": "DEPT C",
|
278
|
+
"id": 6621,
|
279
|
+
"memo": "Office Supplies for Frank",
|
280
|
+
"need_tax_deduction": null,
|
281
|
+
"port_type": 1,
|
282
|
+
"preset_withholding_tax_amount": null,
|
283
|
+
"regist_user_code": "sample_user",
|
284
|
+
"scheduled_memo": null,
|
285
|
+
"scheduled_pay_timestamp": null,
|
286
|
+
"update_user_code": null,
|
287
|
+
"updated_at": "2015/10/06 15:45:21 +0900",
|
288
|
+
"withholding_tax_base": null,
|
289
|
+
"withholding_tax_segment": null,
|
290
|
+
"account_code": "604",
|
291
|
+
"buying_price": 5000,
|
292
|
+
"buying_tax": 400,
|
293
|
+
"buying_tax_type": 0
|
294
|
+
}
|
295
|
+
```
|
296
|
+
|
297
|
+
**/ap_payments/create**
|
298
|
+
|
299
|
+
Description: Creates a new accounts payable transaction. The created transaction will be sent back as JSON if successful.
|
300
|
+
|
301
|
+
Method: POST
|
302
|
+
|
303
|
+
URL Structure:
|
304
|
+
```sh
|
305
|
+
https://tsubaiso.net/ap_payments/create
|
306
|
+
```
|
307
|
+
|
308
|
+
Parameters:
|
309
|
+
|
310
|
+
Parameter | Necessity | Type | Description
|
311
|
+
--- | --- | --- | ---
|
312
|
+
`price` | *required* | Integer | Amount of the transaction.
|
313
|
+
`accrual_timestamp` | *required* | String | Actual date of the transaction. Format must be "YYYY-MM-DD"
|
314
|
+
`customer_master_code` | *required* | String | Code of the transaction party.
|
315
|
+
`reason_master_code` | *required* | String | Reason of the transaction. This is used to create the journal entry.
|
316
|
+
`dc` | *required* | String | 'd' if the transaction was a debit to AP, 'c' if it was a credit.
|
317
|
+
`memo` | *required* | String | Memo for the transaction. Can be blank but must be provided.
|
318
|
+
`tax_code` | *required* | Integer | Tax code for the transaction.
|
319
|
+
`port_type` | *required* | Integer | 1 for domestic transaction. 2 for foreign transaction.
|
320
|
+
`year` | *optional* | Integer | Year of the transaction. If provided, month must be provided as well. Will use current year if not provided.
|
321
|
+
`month` | *optional* | Integer | Month of the transaction. If provided, year must be provided as well. Will use current month if not provided.
|
322
|
+
`dept_code` | *optional* | String | Code of the internal department involved.
|
323
|
+
`buying_tax` | *optional* | Integer | Sales tax on the transaction. Is automatically calculated if not provided.
|
324
|
+
`scheduled_pay_timestamp` | *optional* | String | Date of payment. Format must be "YYYY-MM-DD".
|
325
|
+
`scheduled_memo` | *optional* | String | Optional memo regarding payment of funds.
|
326
|
+
`need_tax_deduction` | *optional* | Integer | 1 if tax needs to be withheld. 0 if not necessary.
|
327
|
+
`preset_withholding_tax_amount` | *optional* | Integer | Withholding tax amount
|
328
|
+
`withholding_tax_base` | *optional* | Integer | 1 if withholding tax includes sales tax, 2 if it does not.
|
329
|
+
`withholding_tax_segment` | *optional* | String | National Tax Agency tax code (ex: "nta2795" references https://www.nta.go.jp/taxanswer/gensen/2795.htm)
|
330
|
+
|
331
|
+
Sample Request:
|
332
|
+
``` sh
|
333
|
+
curl -i -H "Content-Type: application/json" -H "Accept: application/json" -H "Access-Token: XXXXXXXXXXXXXX" -X POST -d '{"year": 2015, "month": 8, "price": 5000, "accrual_timestamp": "2015-10-31", "customer_master_code": "8201", "dept_code": "DEPT C", "reason_master_code": "BUYING_IN", "dc": "c", "memo": "Office Supplies for Frank", "tax_code": 0, "port_type": 1 }' https://tsubaiso.net/ap_payments/create
|
334
|
+
```
|
335
|
+
|
336
|
+
**/ap/destroy/:id**
|
337
|
+
|
338
|
+
Description: Destroys the accounts payable transaction specified as the id. Returns a status of 204 No Content.
|
339
|
+
|
340
|
+
Method: POST
|
341
|
+
|
342
|
+
URL Structure:
|
343
|
+
```sh
|
344
|
+
https://tsubaiso.net/ap/destroy/6621
|
345
|
+
```
|
data/Rakefile
ADDED
data/lib/tsubaiso_sdk.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
class TsubaisoSDK
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@base_url = options[:base_url] || 'https://tsubaiso.net'
|
7
|
+
@access_token = options[:access_token]
|
8
|
+
end
|
9
|
+
|
10
|
+
def list_sales(year, month)
|
11
|
+
params = { "year" => year,
|
12
|
+
"month" => month,
|
13
|
+
"format" => "json"
|
14
|
+
}
|
15
|
+
uri = URI.parse(@base_url + "/ar/list/?year=#{year}&month=#{month}")
|
16
|
+
api_request(uri, "GET", params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list_purchases(year, month)
|
20
|
+
params = { "year" => year,
|
21
|
+
"month" => month,
|
22
|
+
"format" => "json"
|
23
|
+
}
|
24
|
+
uri = URI.parse(@base_url + "/ap_payments/list/?year=#{year}&month=#{month}")
|
25
|
+
api_request(uri, "GET", params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_sale(voucher)
|
29
|
+
sale_id = voucher.scan(/\d/).join("")
|
30
|
+
params = { "id" => sale_id,
|
31
|
+
"format" => "json"
|
32
|
+
}
|
33
|
+
uri = URI.parse(@base_url + "/ar/show/#{sale_id}")
|
34
|
+
api_request(uri, "GET", params)
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_purchase(voucher)
|
38
|
+
purchase_id = voucher.scan(/\d/).join("")
|
39
|
+
params = { "id" => purchase_id,
|
40
|
+
"format" => "json"
|
41
|
+
}
|
42
|
+
uri = URI.parse(@base_url + "/ap_payments/show/#{purchase_id}")
|
43
|
+
api_request(uri, "GET", params)
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_sale(options)
|
47
|
+
params = { "price" => options[:price],
|
48
|
+
"year" => options[:year],
|
49
|
+
"month" => options[:month],
|
50
|
+
"realization_timestamp" => options[:realization_timestamp],
|
51
|
+
"customer_master_code" => options[:customer_master_code],
|
52
|
+
"dept_code" => options[:dept_code],
|
53
|
+
"reason_master_code" => options[:reason_master_code],
|
54
|
+
"dc" => options[:dc],
|
55
|
+
"memo" => options[:memo],
|
56
|
+
"tax_code" => options[:tax_code],
|
57
|
+
"sales_tax" => options[:sales_tax],
|
58
|
+
"scheduled_memo" => options[:scheduled_memo],
|
59
|
+
"scheduled_receive_timestamp" => options[:scheduled_receive_timestamp],
|
60
|
+
"format" => "json"
|
61
|
+
}
|
62
|
+
uri = URI.parse(@base_url + '/ar/create')
|
63
|
+
api_request(uri, "POST", params)
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_purchase(options)
|
67
|
+
params = { "price" => options[:price],
|
68
|
+
"year" => options[:year],
|
69
|
+
"month" => options[:month],
|
70
|
+
"accrual_timestamp" => options[:accrual_timestamp],
|
71
|
+
"customer_master_code" => options[:customer_master_code],
|
72
|
+
"dept_code" => options[:dept_code],
|
73
|
+
"reason_master_code" => options[:reason_master_code],
|
74
|
+
"dc" => options[:dc],
|
75
|
+
"memo" => options[:memo],
|
76
|
+
"tax_code" => options[:tax_code],
|
77
|
+
"port_type" => options[:port_type],
|
78
|
+
"format" => "json"
|
79
|
+
}
|
80
|
+
uri = URI.parse(@base_url + '/ap_payments/create')
|
81
|
+
api_request(uri, "POST", params)
|
82
|
+
end
|
83
|
+
|
84
|
+
def destroy_sale(voucher)
|
85
|
+
sale_id = voucher.scan(/\d/).join("")
|
86
|
+
params = { "id" => sale_id,
|
87
|
+
"format" => "json"
|
88
|
+
}
|
89
|
+
uri = URI.parse(@base_url + "/ar/destroy/#{sale_id}")
|
90
|
+
api_request(uri, "POST", params)
|
91
|
+
end
|
92
|
+
|
93
|
+
def destroy_purchase(voucher)
|
94
|
+
purchase_id = voucher.scan(/\d/).join("")
|
95
|
+
params = { "id" => purchase_id,
|
96
|
+
"format" => "json"
|
97
|
+
}
|
98
|
+
uri = URI.parse(@base_url + "/ap/destroy/#{purchase_id}")
|
99
|
+
api_request(uri, "POST", params)
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def api_request(uri, http_verb, params)
|
105
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
106
|
+
http.use_ssl = true if @base_url =~ /^https/
|
107
|
+
if http_verb == "GET"
|
108
|
+
request = Net::HTTP::Get.new(uri.path)
|
109
|
+
else
|
110
|
+
request = Net::HTTP::Post.new(uri.path)
|
111
|
+
end
|
112
|
+
request["Access-Token"] = @access_token
|
113
|
+
request.set_form_data(params)
|
114
|
+
response = http.request(request)
|
115
|
+
if response.body
|
116
|
+
return {:status => response.code, :json => symbolize_keys(JSON.load(response.body))}
|
117
|
+
else
|
118
|
+
return response.code
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def symbolize_keys(data)
|
123
|
+
if data.class == Array
|
124
|
+
data.each_with_index do |hash, index|
|
125
|
+
data[index] = hash.each_with_object({}) do |(k,v), memo|
|
126
|
+
memo[k.to_sym] = v
|
127
|
+
end
|
128
|
+
end
|
129
|
+
else
|
130
|
+
data = data.each_with_object({}) do |(k,v), memo|
|
131
|
+
memo[k.to_sym] = v
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/sample.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
$LOAD_PATH << 'lib/'
|
4
|
+
require 'tsubaiso_sdk'
|
5
|
+
|
6
|
+
class Sample
|
7
|
+
def initialize(sample)
|
8
|
+
@sample = sample
|
9
|
+
api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
|
10
|
+
@sample.each do | line |
|
11
|
+
if line[:action] == "List"
|
12
|
+
if line[:module] == "Sales"
|
13
|
+
res = api.list_sales(line[:year], line[:month])
|
14
|
+
puts res[:json]
|
15
|
+
end
|
16
|
+
if line[:module] == "Purchases"
|
17
|
+
res = api.list_purchases(line[:year], line[:month])
|
18
|
+
puts res[:json]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
if line[:action] == "Show"
|
22
|
+
if line[:module] == "Sales"
|
23
|
+
res = api.show_sale(line[:voucher])
|
24
|
+
puts res[:json]
|
25
|
+
end
|
26
|
+
if line[:module] == "Purchases"
|
27
|
+
res = api.show_purchase(line[:voucher])
|
28
|
+
puts res[:json]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
if line[:action] == "Create"
|
32
|
+
if line[:module] == "Sales"
|
33
|
+
res = api.create_sale(line)
|
34
|
+
if res[:status].to_i == 422
|
35
|
+
puts res[:json]
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if line[:module] == "Purchases"
|
40
|
+
res = api.create_purchase(line)
|
41
|
+
if res[:status].to_i == 422
|
42
|
+
puts res[:json]
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
if line[:action] == "Destroy"
|
48
|
+
if line[:module] == "Sales"
|
49
|
+
res = api.destroy_sale(line[:voucher])
|
50
|
+
end
|
51
|
+
if line[:module] == "Purchases"
|
52
|
+
res = api.destroy_purchase(line[:voucher])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Sample.new([
|
60
|
+
{ action: "Create", module: "Sales", price: 10000, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" },
|
61
|
+
{ action: "Create", module: "Purchases", price: 5000, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1 },
|
62
|
+
{ action: "Create", module: "Sales", price: 95000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'd', memo: "決算会社/マーチャントの相殺", tax_code: 0 },
|
63
|
+
{ action: "Create", module: "Sales", price: 10000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "OTHERS_DECREASE", dc: 'c', memo: "決算会社/マーチャントの相殺", tax_code: 0 },
|
64
|
+
{ action: "Create", module: "Sales", price: 5000, year: 2015, month: 9, realization_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'c', memo: "決算会社/決済会社の相殺", tax_code: 0 },
|
65
|
+
{ action: "Create", module: "Purchases", price: 5000, year: 2015, month: 9, accrual_timestamp: "2015-09-25", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_DECREASE", dc: 'd', memo: "決算会社/決済会社の相殺", tax_code: 0, port_type: 1 },
|
66
|
+
{ action: "Create", module: "Purchases", price: 90000, year: 2015, month: 9, accrual_timestamp: "2015-09-30", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'c', memo: "売掛金/未払金振替", tax_code: 0, port_type: 1 },
|
67
|
+
{ action: "Create", module: "Sales", price: 90000, year: 2015, month: 9, realization_timestamp: "2015-09-30", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "OTHERS_INCREASE", dc: 'd', memo: "売掛金/未払い金振替", tax_code: 0 },
|
68
|
+
{ action: "Show", module: "Sales", voucher: "AR834"},
|
69
|
+
{ action: "Show", module: "Purchases", voucher: "AP622"},
|
70
|
+
{ action: "Destroy", module: "Sales", voucher: "AR839"},
|
71
|
+
{ action: "Destroy", module: "Purchases", voucher: "AP625"},
|
72
|
+
{ action: "List", module: "Sales", year: 2015, month: 9},
|
73
|
+
{ action: "List", module: "Purchases", year: 2015, month: 9}
|
74
|
+
])
|
75
|
+
|
76
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require './lib/tsubaiso_sdk'
|
3
|
+
|
4
|
+
class TsubaisoSDKTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@api = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: ENV["SDK_ACCESS_TOKEN"] })
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_failed_request
|
11
|
+
@api_fail = TsubaisoSDK.new({ base_url: ENV["SDK_BASE_URL"], access_token: "fake token" })
|
12
|
+
sale = @api_fail.create_sale({ price: 10800, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
13
|
+
|
14
|
+
assert_equal 401, sale[:status].to_i
|
15
|
+
assert_equal "Bad credentials", sale[:json][:error]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_sale
|
19
|
+
sale = @api.create_sale({ price: 10800, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
20
|
+
|
21
|
+
assert_equal 200, sale[:status].to_i
|
22
|
+
assert_equal "SETSURITSU", sale[:json][:dept_code]
|
23
|
+
|
24
|
+
deleted_sale = @api.destroy_sale("AR#{sale[:json][:id]}")
|
25
|
+
assert_equal 204, deleted_sale.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_purchase
|
29
|
+
purchase = @api.create_purchase({ price: 5400, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1})
|
30
|
+
|
31
|
+
assert_equal 200, purchase[:status].to_i
|
32
|
+
assert_equal "SETSURITSU", purchase[:json][:dept_code]
|
33
|
+
|
34
|
+
deleted_purchase = @api.destroy_purchase("AP#{purchase[:json][:id]}")
|
35
|
+
assert_equal 204, deleted_purchase.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_show_sale
|
39
|
+
sale = @api.create_sale({ price: 10800, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
40
|
+
|
41
|
+
get_sale = @api.show_sale("AR#{sale[:json][:id]}")
|
42
|
+
assert_equal 200, get_sale[:status].to_i
|
43
|
+
assert_equal get_sale[:json][:sales_price], sale[:json][:sales_price]
|
44
|
+
|
45
|
+
deleted_sale = @api.destroy_sale("AR#{sale[:json][:id]}")
|
46
|
+
assert_equal 204, deleted_sale.to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_show_purchase
|
50
|
+
purchase = @api.create_purchase({ price: 5400, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1})
|
51
|
+
|
52
|
+
get_purchase = @api.show_purchase("AP#{purchase[:json][:id]}")
|
53
|
+
assert_equal 200, get_purchase[:status].to_i
|
54
|
+
assert_equal get_purchase[:json][:id], purchase[:json][:id]
|
55
|
+
|
56
|
+
deleted_purchase = @api.destroy_purchase("AP#{purchase[:json][:id]}")
|
57
|
+
assert_equal 204, deleted_purchase.to_i
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_list_sales
|
61
|
+
august_sale_a = @api.create_sale({ price: 10800, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
62
|
+
august_sale_b = @api.create_sale({ price: 10800, year: 2015, month: 8, realization_timestamp: "2015-08-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
63
|
+
september_sale = @api.create_sale({ price: 10800, year: 2015, month: 9, realization_timestamp: "2015-09-01", customer_master_code: "101", dept_code: "SETSURITSU", reason_master_code: "SALES", dc: 'd', memo: "", tax_code: 1007, scheduled_memo: "This is a scheduled memo.", scheduled_receive_timestamp: "2015-09-25" })
|
64
|
+
|
65
|
+
sales_list = @api.list_sales(2015, 8)
|
66
|
+
assert_equal 200, sales_list[:status].to_i
|
67
|
+
assert_equal 2, sales_list[:json].count
|
68
|
+
|
69
|
+
deleted_sale_a = @api.destroy_sale("AR#{august_sale_a[:json][:id]}")
|
70
|
+
assert_equal 204, deleted_sale_a.to_i
|
71
|
+
|
72
|
+
deleted_sale_b = @api.destroy_sale("AR#{august_sale_b[:json][:id]}")
|
73
|
+
assert_equal 204, deleted_sale_b.to_i
|
74
|
+
|
75
|
+
deleted_sale_c = @api.destroy_sale("AR#{september_sale[:json][:id]}")
|
76
|
+
assert_equal 204, deleted_sale_c.to_i
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_list_purchases
|
80
|
+
august_purchase_a = @api.create_purchase({ price: 5400, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1})
|
81
|
+
august_purchase_b = @api.create_purchase({ price: 5400, year: 2015, month: 8, accrual_timestamp: "2015-08-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1})
|
82
|
+
september_purchase = @api.create_purchase({ price: 5400, year: 2015, month: 9, accrual_timestamp: "2015-09-01", customer_master_code: "102", dept_code: "SETSURITSU", reason_master_code: "BUYING_IN", dc: 'c', memo: "", tax_code: 1007, port_type: 1})
|
83
|
+
|
84
|
+
purchase_list = @api.list_purchases(2015, 8)
|
85
|
+
assert_equal 200, purchase_list[:status].to_i
|
86
|
+
assert_equal 2, purchase_list[:json].count
|
87
|
+
|
88
|
+
deleted_purchase_a = @api.destroy_purchase("AP#{august_purchase_a[:json][:id]}")
|
89
|
+
assert_equal 204, deleted_purchase_a.to_i
|
90
|
+
|
91
|
+
deleted_purchase_b = @api.destroy_purchase("AP#{august_purchase_b[:json][:id]}")
|
92
|
+
assert_equal 204, deleted_purchase_b.to_i
|
93
|
+
|
94
|
+
deleted_purchase_c = @api.destroy_purchase("AP#{september_purchase[:json][:id]}")
|
95
|
+
assert_equal 204, deleted_purchase_c.to_i
|
96
|
+
end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tsubaiso-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tsubaiso, Inc.
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A library of methods that directly uses Tsubaiso API web endpoints.
|
47
|
+
email: apisupport@tsubaiso.net
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- lib/tsubaiso_sdk.rb
|
53
|
+
- test/test_tsubaiso_sdk.rb
|
54
|
+
- Rakefile
|
55
|
+
- sample.rb
|
56
|
+
- README.md
|
57
|
+
- README-j.md
|
58
|
+
homepage: https://github.com/tsubaiso/tsubaiso-sdk-ruby
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.23
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: SDK for the Tsubaiso API
|
83
|
+
test_files: []
|