orangedata 0.0.10 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9fa958e5956706463a6a2298893886987840b413bcea4cb4f3dc685df565ae9
4
- data.tar.gz: '087c9d1118e082e5c0f190d28d7fb585e1c72b5c2cc4e1961af5ec9034316225'
3
+ metadata.gz: 24d97c1e067049b4e767c7ca1579e623fa68753c5f486299d1a507d4bc68d66b
4
+ data.tar.gz: a97d04fd012da815eaccc8ceffba7e437ab606b4b636aef0576cf2d98f18702b
5
5
  SHA512:
6
- metadata.gz: 6039886a4592a56facf40e4a34b1d97b073c2b0f0e6c8325109ec2e8cbc3167ad507fe6aebd09c78bc4b624f07871cad74a7a2f3d305188ad4ce016bf525743a
7
- data.tar.gz: 398d24f56636d6f54833c10251e9be3243877cd74a6dc4beea7573aceed0e0ddb9c5984c6b1bb0057d39fb5b1e229be513fc4b757a21944e079120d10abe5e49
6
+ metadata.gz: 735c83060727e2985bf290924ffc03ef7f8455013aa7cc41d602a3c2fae6adc1e151e693ef5b72caa320947da3884cc6af0bf264915f3bdc5252203271464385
7
+ data.tar.gz: ed6c5f041c686f1acdb1f50f42b625ba6b0384123a0cc23e7681939c2694969091fbf019cb30cee24e999e77aa7e53da42175d27d66984b1873a0a43ada7aaeb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+
5
+ - breaking: drop support for EOL versions of ruby (< 2.7)
6
+ - possibly breaking: added vat20 to match current protocol
7
+
8
+ ## 0.1.0
9
+
10
+ - Deprecated support for EOL ruby versions < 2.6 - gem may continue to work, but will not be tested against
11
+ - Switched CI to github actions
12
+ - ruby 3.0, 3.1 support
13
+
3
14
  ## 0.0.10
4
15
  - Changed cashless print title per law change
5
16
 
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  git_source(:github){|repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # All dependencies are in orangedata.gemspec
8
- gemspec
8
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orangedata (0.0.10)
4
+ orangedata (1.0.0)
5
5
  faraday (>= 0.15)
6
6
  faraday_middleware
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  rexml
16
16
  diff-lcs (1.5.0)
17
17
  docile (1.4.0)
18
- faraday (1.10.2)
18
+ faraday (1.10.3)
19
19
  faraday-em_http (~> 1.0)
20
20
  faraday-em_synchrony (~> 1.0)
21
21
  faraday-excon (~> 1.1)
@@ -44,7 +44,7 @@ GEM
44
44
  json (2.6.2)
45
45
  json-schema (3.0.0)
46
46
  addressable (>= 2.8)
47
- multipart-post (2.2.3)
47
+ multipart-post (2.3.0)
48
48
  parallel (1.22.1)
49
49
  parser (3.1.2.1)
50
50
  ast (~> 2.4.1)
@@ -108,4 +108,4 @@ DEPENDENCIES
108
108
  webmock
109
109
 
110
110
  BUNDLED WITH
111
- 1.17.3
111
+ 2.3.10
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/orangedata.svg)](https://badge.fury.io/rb/orangedata)
4
4
  ![Gem downloads](https://img.shields.io/gem/dt/orangedata.svg)
5
- [![Build Status](https://travis-ci.org/Vasfed/orangedata.svg?branch=master)](https://travis-ci.org/Vasfed/orangedata)
5
+ ![Build Status](https://github.com/Vasfed/orangedata/actions/workflows/test.yml/badge.svg?branch=master)
6
6
 
7
7
  A ruby client for orangedata.ru service.
8
8
  Target service is pretty local to RU, so parts of readme will be in russian.
@@ -35,9 +35,9 @@ gem 'orangedata'
35
35
 
36
36
  ### Пробитие чека
37
37
 
38
- Описание полей смотреть в [официальной документации](https://github.com/orangedata-official/API), названия маппинга и некоторые коментарии есть [в схеме данных](lib/orange_data/schema_definitions.yml) (метасхема расширений [тут](spec/lib/extensions_metaschema.yml)).
38
+ Описание полей смотреть в [официальной документации](https://github.com/orangedata-official/API), названия маппинга и некоторые комментарии есть [в схеме данных](lib/orange_data/schema_definitions.yml) (метасхема расширений [тут](spec/lib/extensions_metaschema.yml)).
39
39
 
40
- Для `enum`-полей есть маппинг, например `content.positions[0].tax` принимает значения: `:vat_18`, `:vat_10`, `:vat_18_118`, `:vat_10_110`, `:vat_0`, `:vat_not_charged`.
40
+ Для `enum`-полей есть маппинг, например `content.positions[0].tax` принимает значения: `:vat_20`, `:vat_10`, `:vat_20_120`, `:vat_10_110`, `:vat_0`, `:vat_not_charged`.
41
41
 
42
42
  Простейший чек в тестовом окружении:
43
43
 
@@ -101,8 +101,8 @@ correction = OrangeData::Correction.income(inn:"123456789012", id:"12345678990")
101
101
  sum_cash: 1.23, sum_card: 2.34,
102
102
  sum_prepaid: 5.67, sum_credit: 4.56, sum_counterclaim: 3.45,
103
103
 
104
- vat_18: 1.34, vat_10: 2.34, vat_0: 3.34,
105
- vat_not_charged: 4.34, vat_18_118: 5.34, vat_10_110: 6.34,
104
+ vat_20: 1.34, vat_10: 2.34, vat_0: 3.34,
105
+ vat_not_charged: 4.34, vat_20_120: 5.34, vat_10_110: 6.34,
106
106
  taxation_system: :simplified,
107
107
 
108
108
  automat_number: "123456789",
@@ -135,7 +135,7 @@ res = transport.get_correction(correction.inn, correction.id)
135
135
 
136
136
  Если все прошло гладко - теперь у вас есть файлик `my_production.yml` со всеми реквизитами доступа к продакшн-кассе. Обращаться с ним стоит как и с любой другой очень чувствительной информацией, например не стоит коммитить его (ну или как минимум, убрать из него поля `signature_key_pass` и `certificate_key_pass` и хранить отдельно)
137
137
 
138
- Дальше публичный ключ с предыдущего шага отправляется в ЛК, там его сохряняем, "подключаем интеграцию", и пользуемся:
138
+ Дальше публичный ключ с предыдущего шага отправляется в ЛК, там его сохраняем, "подключаем интеграцию", и пользуемся:
139
139
 
140
140
  ```ruby
141
141
  transport = OrangeData::Transport.new(OrangeData::Transport::DEFAULT_PRODUCTION_API_URL, OrangeData::Credentials.from_hash(YAML.load_file('my_production.yml')))
@@ -50,41 +50,22 @@ module OrangeData
50
50
  end
51
51
 
52
52
  def from_hash(hash)
53
- OpenSSL::PKey::RSA.new.tap do |key|
54
- if key.respond_to?(:set_key)
55
- # ruby 2.5+
56
- # a bit ugly - simulating with_indifferent_access
57
- if hash['n'] || hash[:n]
58
- # public key only has n and e (without them - there's no key actually)
59
- key.set_key(
60
- OpenSSL::BN.new(Base64.decode64(hash['n'] || hash[:n]), 2),
61
- OpenSSL::BN.new(Base64.decode64(hash['e'] || hash[:e]), 2),
62
- (hash['d'] || hash[:d]) && OpenSSL::BN.new(Base64.decode64(hash['d'] || hash[:d]), 2)
63
- )
64
- end
65
-
66
- if hash['p'] || hash[:p]
67
- key.set_factors(
68
- OpenSSL::BN.new(Base64.decode64(hash['p'] || hash[:p]), 2),
69
- OpenSSL::BN.new(Base64.decode64(hash['q'] || hash[:q]), 2)
70
- )
71
- if hash['dmp1'] || hash[:dmp1]
72
- key.set_crt_params(
73
- OpenSSL::BN.new(Base64.decode64(hash['dmp1'] || hash[:dmp1]), 2),
74
- OpenSSL::BN.new(Base64.decode64(hash['dmq1'] || hash[:dmq1]), 2),
75
- OpenSSL::BN.new(Base64.decode64(hash['iqmp'] || hash[:iqmp]), 2)
76
- )
77
- end
78
- end
79
- else
80
- # ruby 2.3 and may be older
81
- key.params.each_key do |param|
82
- if (v = hash[param] || hash[param.to_sym])
83
- key.send(:"#{param}=", OpenSSL::BN.new(Base64.decode64(v), 2))
84
- end
85
- end
86
- end
53
+ factors = %i[n e d p q dmp1 dmq1 iqmp] # order is important
54
+ hash = hash.transform_keys(&:to_sym).slice(*factors).compact.transform_values do |value|
55
+ OpenSSL::ASN1::Integer(OpenSSL::BN.new(Base64.decode64(value), 2))
87
56
  end
57
+
58
+ raise 'Need at least n and e key params' unless hash.key?(:n) && hash.key?(:e)
59
+
60
+ data_sequence = if hash.keys == factors
61
+ # all factors present => have private key
62
+ OpenSSL::ASN1::Sequence([OpenSSL::ASN1::Integer(0)] + hash.values)
63
+ else
64
+ # only public key
65
+ OpenSSL::ASN1::Sequence(hash.slice(:n, :e).values)
66
+ end
67
+
68
+ OpenSSL::PKey::RSA.new(OpenSSL::ASN1::Sequence(data_sequence).to_der)
88
69
  end
89
70
 
90
71
  def load_from(val, key_pass=nil)
@@ -241,14 +222,14 @@ module OrangeData
241
222
  end
242
223
  end
243
224
 
244
- from_hash(
225
+ from_hash({
245
226
  title: title || "Generated from #{File.basename(path)}",
246
227
  signature_key_name: signature_key_name || File.basename(client_cert).gsub(/\..*/, ''),
247
228
  certificate: File.read(client_cert),
248
229
  certificate_key: File.read(client_cert.sub(/.crt\z/, '.key')),
249
230
  certificate_key_pass: cert_key_pass,
250
231
  signature_key: signature_key
251
- )
232
+ })
252
233
  end
253
234
 
254
235
  def self.read_certs_from_zip_pack(rubyzip_object, signature_key_name:nil, cert_key_pass:nil, title:nil, signature_key:nil)
@@ -269,14 +250,14 @@ module OrangeData
269
250
  end
270
251
  end
271
252
 
272
- from_hash(
253
+ from_hash({
273
254
  title: title || "Generated from zip",
274
255
  signature_key_name: signature_key_name || File.basename(client_cert.name).gsub(/\..*/, ''),
275
256
  certificate: client_cert.get_input_stream.read,
276
257
  certificate_key: client_key.get_input_stream.read,
277
258
  certificate_key_pass: cert_key_pass,
278
259
  signature_key: signature_key
279
- )
260
+ })
280
261
  end
281
262
 
282
263
  # публичная часть ключа подписи в формате пригодном для отдачи в ЛК
@@ -273,13 +273,19 @@ definitions:
273
273
  x-enum:
274
274
  vat_18:
275
275
  val: 1
276
- title: ставка НДС 18%
276
+ title: ставка НДС 18% (старая, теперь 20)
277
+ vat_20:
278
+ val: 1
279
+ title: ставка НДС 20%
277
280
  vat_10:
278
281
  val: 2
279
282
  title: ставка НДС 10%
280
283
  vat_18_118:
281
284
  val: 3
282
- title: ставка НДС расч. 18/118
285
+ title: ставка НДС расч. 18/118 (старая)
286
+ vat_20_120:
287
+ val: 3
288
+ title: ставка НДС расч. 20/120
283
289
  vat_10_110:
284
290
  val: 4
285
291
  title: ставка НДС расч. 10/110
@@ -742,10 +748,10 @@ definitions:
742
748
  type: number
743
749
 
744
750
  tax1Sum:
745
- title: Сумма НДС чека по ставке 18%
751
+ title: Сумма НДС чека по ставке 20%
746
752
  x-comment: осторожно, номера в названии поля не соответствуют значениям в CheckPosition.tax
747
753
  x-tag-id: 1102
748
- x-alias: vat_18
754
+ x-alias: vat_20
749
755
  type: number
750
756
  format: double
751
757
  tax2Sum:
@@ -768,9 +774,9 @@ definitions:
768
774
  type: number
769
775
  tax5Sum:
770
776
  format: double
771
- title: Сумма НДС чека по расч. ставке 18/118
777
+ title: Сумма НДС чека по расч. ставке 20/120
772
778
  x-tag-id: 1106
773
- x-alias: vat_18_118
779
+ x-alias: vat_20_120
774
780
  type: number
775
781
  tax6Sum:
776
782
  format: double
@@ -949,4 +955,3 @@ definitions:
949
955
  description: URL для отправки результатов обработки чека POST запросом
950
956
  type: [string, "null"]
951
957
  maxLength: 1024
952
-
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OrangeData
4
4
 
5
- VERSION = "0.0.10"
5
+ VERSION = "1.0.0"
6
6
 
7
7
  end
data/orangedata.gemspec CHANGED
@@ -16,14 +16,14 @@ Gem::Specification.new do |spec|
16
16
  spec.license = "MIT"
17
17
 
18
18
  spec.files = Dir.chdir(File.expand_path('.', __dir__)) do
19
- `git ls-files -z`.split("\x0").reject{|f| f.match(%r{^(test|spec|features)/}) }
19
+ `git ls-files -z`.split("\x0").reject{|f| f.start_with?('.') || f.match(%r{^(test|spec|features|tmp)/}) }
20
20
  end
21
21
 
22
22
  # spec.bindir = "exe"
23
23
  # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- # spec.required_ruby_version = ">=2.1"
26
+ # spec.required_ruby_version = ">=2.6"
27
27
 
28
28
  spec.add_dependency "faraday", ">=0.15"
29
29
  spec.add_dependency "faraday_middleware"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orangedata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -157,10 +157,6 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - ".gitignore"
161
- - ".rspec"
162
- - ".rubocop.yml"
163
- - ".travis.yml"
164
160
  - CHANGELOG.md
165
161
  - Gemfile
166
162
  - Gemfile.lock
@@ -179,7 +175,6 @@ files:
179
175
  - lib/orange_data/version.rb
180
176
  - lib/orangedata.rb
181
177
  - orangedata.gemspec
182
- - tmp/.keep
183
178
  homepage: https://github.com/Vasfed/orangedata
184
179
  licenses:
185
180
  - MIT
@@ -199,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
194
  - !ruby/object:Gem::Version
200
195
  version: '0'
201
196
  requirements: []
202
- rubygems_version: 3.1.6
197
+ rubygems_version: 3.4.1
203
198
  signing_key:
204
199
  specification_version: 4
205
200
  summary: Ruby client for orangedata.ru service
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /.rspec_status
10
- /*.yml
11
- .DS_Store
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,105 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- SuggestExtensions: false
4
- # DefaultFormatter: fuubar
5
- # TargetRubyVersion: 2.1
6
- TargetRubyVersion: 2.3
7
- Exclude:
8
- - 'spec/fixtures/**/*'
9
- - 'tmp/**/*'
10
-
11
- Gemspec/RequiredRubyVersion: { Enabled: false }
12
-
13
- Metrics/LineLength:
14
- Max: 130
15
- Exclude:
16
- - 'spec/**/*'
17
-
18
- Metrics/BlockLength:
19
- Enabled: false
20
- Exclude:
21
- - 'spec/**/*'
22
-
23
- Metrics/BlockNesting:
24
- Max: 4
25
-
26
- Metrics/MethodLength:
27
- Max: 20
28
- Enabled: false
29
-
30
- Metrics/ClassLength: { Enabled: false }
31
-
32
- Metrics/AbcSize:
33
- # Max: 50
34
- Enabled: false
35
-
36
- Metrics/CyclomaticComplexity:
37
- Max: 50
38
-
39
- Metrics/PerceivedComplexity:
40
- Max: 50
41
-
42
- Metrics/ParameterLists:
43
- Max: 10
44
-
45
- Style/StringLiterals:
46
- Enabled: false
47
- # EnforcedStyle: double_quotes
48
-
49
- Style/RedundantReturn: { Enabled: false }
50
-
51
- Layout/ArgumentAlignment:
52
- EnforcedStyle: with_fixed_indentation
53
-
54
- Layout/SpaceBeforeBlockBraces:
55
- EnforcedStyle: no_space
56
-
57
- Layout/SpaceAroundEqualsInParameterDefault:
58
- EnforcedStyle: no_space
59
-
60
- Layout/SpaceAfterColon: { Enabled: false }
61
- Layout/SpaceAroundOperators: { Enabled: false }
62
-
63
- Layout/EndAlignment:
64
- EnforcedStyleAlignWith: variable
65
-
66
- Layout/SpaceInsideBlockBraces:
67
- SpaceBeforeBlockParameters: false
68
-
69
- Layout/EmptyLinesAroundBlockBody:
70
- Exclude:
71
- - 'spec/**/*'
72
-
73
- Layout/EmptyLinesAroundModuleBody:
74
- Enabled: false
75
- # EnforcedStyle: empty_lines_except_namespace
76
- Layout/EmptyLinesAroundClassBody:
77
- Enabled: false
78
- # EnforcedStyle: empty_lines_except_namespace
79
-
80
- Layout/DotPosition:
81
- # so that code can be copied to console
82
- EnforcedStyle: trailing
83
-
84
- Layout/FirstHashElementIndentation:
85
- EnforcedStyle: consistent
86
-
87
- Layout/EmptyLines: { Enabled: false }
88
- Style/AsciiComments: { Enabled: false }
89
-
90
- Style/Documentation:
91
- # TODO
92
- Enabled: false
93
-
94
- Style/BlockDelimiters:
95
- Enabled: false
96
- Exclude:
97
- - 'spec/**/*'
98
-
99
- # trailing commas make simpler diffs
100
- Style/TrailingCommaInHashLiteral: { Enabled: false }
101
- Style/TrailingCommaInArrayLiteral: { Enabled: false }
102
- Style/KeywordParametersOrder: { Enabled: false }
103
-
104
- Naming/AccessorMethodName: { Enabled: false }
105
- Naming/VariableNumber: { Enabled: false }
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3
7
- - 2.5
8
- - 2.6
9
- before_install: gem install bundler -v 1.16.6
data/tmp/.keep DELETED
File without changes