atol 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +39 -13
- data/lib/atol/request/post_document/item/body.rb +32 -10
- data/lib/atol/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dadf4b469fa9fa9b1489d00b72d057b28e3db6a8
|
4
|
+
data.tar.gz: 731afecf6097e8767443df85c6c13a919f415b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8a892c606a28c653ba0e6bdeede5f9b96b895fe1430f80826dfd91af61126bb0b6a31ec4b261ece202da35ea1c1c0c6f624dd14daa3655192886ac020f6be9
|
7
|
+
data.tar.gz: 73e2c099851188b28784536d1755b49a8aad2cd706f6ece489e3d46d71972cb8d3eb42c3fa4e66fbdcca6533c22ec1e124d7d1244942d41e000c575d78f17e98
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -106,12 +106,32 @@ body = Atol::Request::PostDocument::Sell::Body.new(
|
|
106
106
|
|
107
107
|
Для создания `items` можно использовать класс `Atol::Request::PostDocument::Item::Body`.
|
108
108
|
|
109
|
-
Его конструктор принимает обязательные аргументы `name`, `price` и опциональный `quantity` (по умолчанию 1).
|
109
|
+
Его конструктор принимает обязательные аргументы `name`, `price`, `payment_method`, `payment_object` и опциональный `quantity` (по умолчанию 1).
|
110
|
+
|
111
|
+
Допустимые значения `payment_method`:
|
112
|
+
```ruby
|
113
|
+
[
|
114
|
+
'full_prepayment', 'prepayment', 'advance', 'full_payment',
|
115
|
+
'partial_payment', 'credit', 'credit_payment'
|
116
|
+
]
|
117
|
+
```
|
118
|
+
Допустимые значения `payment_object`:
|
119
|
+
```ruby
|
120
|
+
[
|
121
|
+
'commodity', 'excise', 'job', 'service', 'gambling_bet', 'gambling_prize',
|
122
|
+
'lottery', 'lottery_prize', 'intellectual_activity', 'payment','agent_commission',
|
123
|
+
'composite', 'another'
|
124
|
+
]
|
125
|
+
```
|
126
|
+
|
127
|
+
Например:
|
110
128
|
|
111
129
|
```ruby
|
112
130
|
item = Atol::Request::PostDocument::Item::Body.new(
|
113
131
|
name: 'product name',
|
114
132
|
price: 100,
|
133
|
+
payment_method: 'full_payment',
|
134
|
+
payment_object: 'service',
|
115
135
|
quantity: 2
|
116
136
|
).to_h
|
117
137
|
```
|
@@ -126,15 +146,21 @@ body = Atol::Request::PostDocument::Sell::Body.new(
|
|
126
146
|
Atol::Request::PostDocument::Item::Body.new(
|
127
147
|
name: 'number 9',
|
128
148
|
price: 50,
|
149
|
+
payment_method: 'full_payment',
|
150
|
+
payment_object: 'service',
|
129
151
|
quantity: 2
|
130
152
|
).to_h,
|
131
153
|
Atol::Request::PostDocument::Item::Body.new(
|
132
154
|
name: 'number 9 large',
|
133
|
-
price: 100
|
155
|
+
price: 100,
|
156
|
+
payment_method: 'full_payment',
|
157
|
+
payment_object: 'service'
|
134
158
|
).to_h,
|
135
159
|
Atol::Request::PostDocument::Item::Body.new(
|
136
160
|
name: 'number 6',
|
137
|
-
price: 60
|
161
|
+
price: 60,
|
162
|
+
payment_method: 'full_payment',
|
163
|
+
payment_object: 'service'
|
138
164
|
).to_h
|
139
165
|
]
|
140
166
|
).to_json
|
@@ -143,28 +169,28 @@ body = Atol::Request::PostDocument::Sell::Body.new(
|
|
143
169
|
Результат:
|
144
170
|
```json
|
145
171
|
|
146
|
-
{
|
147
|
-
"receipt":{
|
148
|
-
"attributes":{
|
172
|
+
{
|
173
|
+
"receipt":{
|
174
|
+
"attributes":{
|
149
175
|
"sno":"usn_income_outcome",
|
150
176
|
"email":"example@example.com"
|
151
177
|
},
|
152
|
-
"items":[
|
153
|
-
{
|
178
|
+
"items":[
|
179
|
+
{
|
154
180
|
"name":"number 9",
|
155
181
|
"price":50.0,
|
156
182
|
"quantity":2.0,
|
157
183
|
"sum":100.0,
|
158
184
|
"tax":"none"
|
159
185
|
},
|
160
|
-
{
|
186
|
+
{
|
161
187
|
"name":"number 9 large",
|
162
188
|
"price":100.0,
|
163
189
|
"quantity":1.0,
|
164
190
|
"sum":100.0,
|
165
191
|
"tax":"none"
|
166
192
|
},
|
167
|
-
{
|
193
|
+
{
|
168
194
|
"name":"number 6",
|
169
195
|
"price":60.0,
|
170
196
|
"quantity":1.0,
|
@@ -172,15 +198,15 @@ body = Atol::Request::PostDocument::Sell::Body.new(
|
|
172
198
|
"tax":"none"
|
173
199
|
}
|
174
200
|
],
|
175
|
-
"payments":[
|
176
|
-
{
|
201
|
+
"payments":[
|
202
|
+
{
|
177
203
|
"sum":260.0,
|
178
204
|
"type":1
|
179
205
|
}
|
180
206
|
],
|
181
207
|
"total":260.0
|
182
208
|
},
|
183
|
-
"service":{
|
209
|
+
"service":{
|
184
210
|
"inn":"123456789010",
|
185
211
|
"payment_address":"г. Москва, ул. Ленина, д.1 к.2"
|
186
212
|
},
|
@@ -5,13 +5,33 @@ module Atol
|
|
5
5
|
class PostDocument
|
6
6
|
module Item
|
7
7
|
class Body
|
8
|
-
|
8
|
+
BadPaymentMethodError = Class.new(StandardError)
|
9
|
+
BadPaymentObjectError = Class.new(StandardError)
|
10
|
+
|
11
|
+
PAYMENT_METHODS = [
|
12
|
+
'full_prepayment', 'prepayment', 'advance', 'full_payment',
|
13
|
+
'partial_payment', 'credit', 'credit_payment'
|
14
|
+
]
|
15
|
+
|
16
|
+
PAYMENT_OBJECTS = [
|
17
|
+
'commodity', 'excise', 'job', 'service', 'gambling_bet', 'gambling_prize',
|
18
|
+
'lottery', 'lottery_prize', 'intellectual_activity', 'payment', 'agent_commission',
|
19
|
+
'composite', 'another'
|
20
|
+
]
|
21
|
+
|
22
|
+
attr_accessor :config, :name, :price, :quantity, :payment_method, :payment_object
|
23
|
+
|
24
|
+
def initialize(config: nil, name:, price:, quantity: 1, payment_method:, payment_object:)
|
9
25
|
raise Atol::ZeroItemQuantityError if quantity.to_i.zero?
|
26
|
+
raise BadPaymentMethodError unless PAYMENT_METHODS.include?(payment_method.to_s)
|
27
|
+
raise BadPaymentObjectError unless PAYMENT_OBJECTS.include?(payment_object.to_s)
|
10
28
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
29
|
+
self.config = config || Atol.config
|
30
|
+
self.name = name
|
31
|
+
self.price = price.to_f
|
32
|
+
self.quantity = quantity.to_f
|
33
|
+
self.payment_method = payment_method.to_s
|
34
|
+
self.payment_object = payment_object.to_s
|
15
35
|
end
|
16
36
|
|
17
37
|
def to_h
|
@@ -26,11 +46,13 @@ module Atol
|
|
26
46
|
|
27
47
|
def body
|
28
48
|
@body ||= {
|
29
|
-
name:
|
30
|
-
price:
|
31
|
-
quantity:
|
32
|
-
sum: (
|
33
|
-
tax:
|
49
|
+
name: name,
|
50
|
+
price: price,
|
51
|
+
quantity: quantity,
|
52
|
+
sum: (price * quantity).round(2),
|
53
|
+
tax: config.default_tax,
|
54
|
+
payment_method: payment_method,
|
55
|
+
payment_object: payment_object
|
34
56
|
}
|
35
57
|
end
|
36
58
|
end
|
data/lib/atol/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GeorgeGorbanev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|