vat_payer_cz 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed8bef1efb56884b487e065a94a10dcedbf2925f
4
+ data.tar.gz: 39a9d18232a6dbdc1f1ccd24871ffb47ac74b36a
5
+ SHA512:
6
+ metadata.gz: aca716327fe729a78d29e5c535b99a0eaaaa2f491204294e58f77ccaee4af95d3c26c366a4ec0323a430f97ea684bef72d02e82c83e8ec3e0bd7631711cec0e9
7
+ data.tar.gz: e21edc47d2841f1f598be25c7b7a885b2a03fcb3208b762052788c5d5d096ab7c5bf5df5d1e12aa60e063b94fe97041d48157908e9c2394b721c86eda140bfe4
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /coverage/
4
+ /doc/
5
+ /pkg/
6
+ /spec/reports/
7
+ /tmp/
8
+ /*.gem
9
+ .docker-sync/
10
+ .git
11
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,68 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - 'db/**/*'
8
+ - 'node_modules/**/*'
9
+ - 'bin/**/*'
10
+ - 'app/views/contacts/*.json.jbuilder'
11
+ - 'config/initializers/active_record_monkey_patch.rb'
12
+ CacheRootDirectory: './tmp'
13
+
14
+ Style/PredicateName:
15
+ Exclude:
16
+ - 'spec/support/feature_macros.rb'
17
+
18
+ Style/WordArray:
19
+ MinSize: 3
20
+
21
+ Style/SymbolProc:
22
+ IgnoredMethods: validate
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+
27
+ Style/SingleLineBlockParams:
28
+ Enabled: false
29
+
30
+ Lint/UselessAccessModifier:
31
+ Enabled: false
32
+
33
+ Style/GuardClause:
34
+ Enabled: false
35
+
36
+ Style/PredicateName:
37
+ Enabled: false
38
+
39
+ Metrics/ModuleLength:
40
+ Max: 205
41
+
42
+ Metrics/LineLength:
43
+ Enabled: false
44
+
45
+ Style/EmptyMethod:
46
+ Enabled: false
47
+
48
+ Style/WordArray:
49
+ Enabled: false
50
+
51
+ # default zarovnavani vim
52
+ # ignoruje hash pokud jej pouzivame napr. jako parametr:
53
+ #
54
+ # mail to: 'info@uol.cz',
55
+ # subject: "Message: #{message.name}",
56
+ Layout/AlignHash:
57
+ EnforcedLastArgumentHashStyle: 'ignore_implicit'
58
+
59
+ # TODO vim jinak zarovnava pokud je metoda volana se zavorkou nebo bez
60
+ #
61
+ # create(:job,
62
+ # title: "Ucetni"
63
+ # VS
64
+ #
65
+ # create :job,
66
+ # title: "Ucetni"
67
+ Layout/AlignParameters:
68
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,463 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-01-15 09:04:51 +0100 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 29
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
+ # Include: **/Gemfile, **/gems.rb
13
+ Bundler/OrderedGems:
14
+ Exclude:
15
+ - 'Gemfile'
16
+
17
+ # Offense count: 3
18
+ # Cop supports --auto-correct.
19
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
20
+ Exclude:
21
+ - 'app/models/document_template.rb'
22
+ - 'app/models/sales_invoice_import.rb'
23
+ - 'lib/tasks/import_currencies_exchange.rake'
24
+
25
+ # Offense count: 5
26
+ # Cop supports --auto-correct.
27
+ # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
28
+ Layout/ExtraSpacing:
29
+ Exclude:
30
+ - 'app/controllers/users_controller.rb'
31
+ - 'app/models/contact.rb'
32
+ - 'app/models/offer.rb'
33
+ - 'app/models/sales_order.rb'
34
+
35
+ # Offense count: 1
36
+ # Cop supports --auto-correct.
37
+ # Configuration parameters: IndentationWidth.
38
+ Layout/IndentAssignment:
39
+ Exclude:
40
+ - 'app/services/cash_book_data_generator.rb'
41
+
42
+ # Offense count: 6
43
+ # Cop supports --auto-correct.
44
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
45
+ # SupportedStyles: symmetrical, new_line, same_line
46
+ Layout/MultilineArrayBraceLayout:
47
+ Exclude:
48
+ - 'app/controllers/application_controller.rb'
49
+ - 'spec/fixtures/payables.rb'
50
+ - 'spec/policies/sales_order_policy_spec.rb'
51
+
52
+ # Offense count: 57
53
+ # Cop supports --auto-correct.
54
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
55
+ # SupportedStyles: symmetrical, new_line, same_line
56
+ Layout/MultilineHashBraceLayout:
57
+ Enabled: false
58
+
59
+ # Offense count: 14
60
+ # Cop supports --auto-correct.
61
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
62
+ # SupportedStyles: symmetrical, new_line, same_line
63
+ Layout/MultilineMethodCallBraceLayout:
64
+ Exclude:
65
+ - 'app/services/accounting_records_pdf_generator.rb'
66
+ - 'spec/factories/uploaded_documents.rb'
67
+ - 'spec/models/address_spec.rb'
68
+ - 'spec/models/contact_spec.rb'
69
+ - 'spec/models/invitation_spec.rb'
70
+ - 'spec/services/paypal/statement_fetcher_spec.rb'
71
+ - 'spec/support/shared_examples/base_send_by.rb'
72
+
73
+ # Offense count: 113
74
+ # Cop supports --auto-correct.
75
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
76
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
77
+ Layout/MultilineMethodCallIndentation:
78
+ Enabled: false
79
+
80
+ # Offense count: 11
81
+ # Cop supports --auto-correct.
82
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
83
+ # SupportedStyles: aligned, indented
84
+ Layout/MultilineOperationIndentation:
85
+ Exclude:
86
+ - 'app/mailers/invitation_mailer.rb'
87
+ - 'app/models/address.rb'
88
+ - 'app/models/sales_invoice.rb'
89
+ - 'app/models/sales_invoice_item.rb'
90
+ - 'lib/tasks/intrastat_report.rake'
91
+ - 'lib/tenant_builder.rb'
92
+
93
+ # Offense count: 1
94
+ # Cop supports --auto-correct.
95
+ Layout/SpaceAroundKeyword:
96
+ Exclude:
97
+ - 'app/models/sales_order.rb'
98
+
99
+ # Offense count: 1
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: AllowForAlignment.
102
+ Layout/SpaceAroundOperators:
103
+ Exclude:
104
+ - 'app/controllers/products/products_controller.rb'
105
+
106
+ # Offense count: 9
107
+ # Cop supports --auto-correct.
108
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
109
+ # SupportedStyles: require_no_space, require_space
110
+ Layout/SpaceInLambdaLiteral:
111
+ Exclude:
112
+ - 'app/models/accounting_record.rb'
113
+ - 'app/models/currency_pair.rb'
114
+ - 'app/models/logo.rb'
115
+ - 'app/models/message.rb'
116
+ - 'app/models/product.rb'
117
+ - 'config/environments/production.rb'
118
+
119
+ # Offense count: 18
120
+ # Cop supports --auto-correct.
121
+ Layout/SpaceInsidePercentLiteralDelimiters:
122
+ Exclude:
123
+ - 'app/models/concerns/after_document_issue_attributes.rb'
124
+ - 'app/models/my_bank_account.rb'
125
+ - 'app/models/my_company.rb'
126
+ - 'app/models/vat_rate.rb'
127
+ - 'config/initializers/assets.rb'
128
+ - 'spec/models/my_bank_account_spec.rb'
129
+ - 'spec/models/sales_order_spec.rb'
130
+
131
+ # Offense count: 5
132
+ Lint/AmbiguousBlockAssociation:
133
+ Exclude:
134
+ - 'spec/models/tenant_spec.rb'
135
+ - 'spec/services/document_template_manager_spec.rb'
136
+ - 'spec/services/paypal/balance_fetcher_spec.rb'
137
+ - 'spec/services/paypal/statement_fetcher_spec.rb'
138
+
139
+ # Offense count: 9
140
+ Lint/IneffectiveAccessModifier:
141
+ Exclude:
142
+ - 'app/data_objects/interval.rb'
143
+ - 'app/models/setting.rb'
144
+ - 'app/models/tenant.rb'
145
+ - 'app/services/public_id_guesser.rb'
146
+ - 'lib/expert_fantozzi_contract.rb'
147
+ - 'lib/ldap_user_finder.rb'
148
+
149
+ # Offense count: 1
150
+ # Cop supports --auto-correct.
151
+ Lint/UnifiedInteger:
152
+ Exclude:
153
+ - 'spec/support/rspec_matchers/have_row.rb'
154
+
155
+ # Offense count: 1
156
+ # Cop supports --auto-correct.
157
+ Lint/UnneededDisable:
158
+ Exclude:
159
+ - 'app/queries/query/budget_by_days.rb'
160
+
161
+ # Offense count: 1
162
+ # Cop supports --auto-correct.
163
+ Lint/UnneededSplatExpansion:
164
+ Exclude:
165
+ - 'app/api/v1/sales_orders.rb'
166
+
167
+ # Offense count: 272
168
+ Metrics/AbcSize:
169
+ Max: 169
170
+
171
+ # Offense count: 607
172
+ # Configuration parameters: CountComments, ExcludedMethods.
173
+ Metrics/BlockLength:
174
+ Max: 1260
175
+
176
+ # Offense count: 42
177
+ # Configuration parameters: CountComments.
178
+ Metrics/ClassLength:
179
+ Max: 302
180
+
181
+ # Offense count: 56
182
+ Metrics/CyclomaticComplexity:
183
+ Max: 17
184
+
185
+ # Offense count: 219
186
+ # Configuration parameters: CountComments.
187
+ Metrics/MethodLength:
188
+ Max: 125
189
+
190
+ # Offense count: 6
191
+ # Configuration parameters: CountKeywordArgs.
192
+ Metrics/ParameterLists:
193
+ Max: 7
194
+
195
+ # Offense count: 37
196
+ Metrics/PerceivedComplexity:
197
+ Max: 17
198
+
199
+ # Offense count: 1
200
+ # Cop supports --auto-correct.
201
+ Performance/Casecmp:
202
+ Exclude:
203
+ - 'app/models/product.rb'
204
+
205
+ # Offense count: 5
206
+ # Cop supports --auto-correct.
207
+ Performance/RangeInclude:
208
+ Exclude:
209
+ - 'app/models/accounting_period.rb'
210
+ - 'app/validators/vatin_validator.rb'
211
+ - 'lib/tasks/intrastat_report.rake'
212
+
213
+ # Offense count: 1
214
+ # Cop supports --auto-correct.
215
+ Performance/RedundantBlockCall:
216
+ Exclude:
217
+ - 'spec/support/database_helper.rb'
218
+
219
+ # Offense count: 8
220
+ # Cop supports --auto-correct.
221
+ # Configuration parameters: MaxKeyValuePairs.
222
+ Performance/RedundantMerge:
223
+ Exclude:
224
+ - 'app/api/v1/demands_for_payment.rb'
225
+ - 'app/api/v1/my_bank_accounts.rb'
226
+ - 'app/api/v1/pagination_helpers.rb'
227
+ - 'app/services/frontend_modifier_symbolizer.rb'
228
+ - 'app/services/modifier_symbolizer.rb'
229
+ - 'spec/api/v1/contacts_spec.rb'
230
+
231
+ # Offense count: 3
232
+ # Cop supports --auto-correct.
233
+ Security/YAMLLoad:
234
+ Exclude:
235
+ - 'config/application.rb'
236
+ - 'lib/ldap_user_finder.rb'
237
+ - 'lib/tasks/migrate.rake'
238
+
239
+ # Offense count: 6
240
+ # Cop supports --auto-correct.
241
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
242
+ # SupportedStyles: prefer_alias, prefer_alias_method
243
+ Style/Alias:
244
+ Exclude:
245
+ - 'app/models/search/sales_order.rb'
246
+ - 'app/models/user_permission.rb'
247
+ - 'app/models/user_permissions_collection.rb'
248
+ - 'app/services/subject_to_vat_specification.rb'
249
+
250
+ # Offense count: 10
251
+ Style/AsciiComments:
252
+ Exclude:
253
+ - 'app/controllers/application_controller.rb'
254
+ - 'app/models/currency.rb'
255
+ - 'app/workers/cost_revenue_worker_base.rb'
256
+ - 'spec/factories/reports.rb'
257
+ - 'spec/models/my_bank_account_spec.rb'
258
+ - 'spec/models/vat_rate_spec.rb'
259
+
260
+ # Offense count: 6
261
+ # Cop supports --auto-correct.
262
+ # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
263
+ # SupportedStyles: assign_to_condition, assign_inside_condition
264
+ Style/ConditionalAssignment:
265
+ Exclude:
266
+ - 'app/helpers/invoice_helper.rb'
267
+ - 'app/models/address.rb'
268
+ - 'app/models/product.rb'
269
+ - 'app/services/cash_book_data_generator.rb'
270
+ - 'app/validators/bank_account_or_iban_validator.rb'
271
+ - 'app/validators/sales_invoice_validator.rb'
272
+
273
+ # Offense count: 4
274
+ # Cop supports --auto-correct.
275
+ Style/EmptyCaseCondition:
276
+ Exclude:
277
+ - 'app/decorators/concerns/document_addresses.rb'
278
+ - 'app/services/subject_to_vat_specification.rb'
279
+ - 'app/validators/linked_doc_validator.rb'
280
+
281
+ # Offense count: 1294
282
+ # Cop supports --auto-correct.
283
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
284
+ # SupportedStyles: when_needed, always, never
285
+ Style/FrozenStringLiteralComment:
286
+ Enabled: false
287
+
288
+ # Offense count: 2
289
+ Style/IdenticalConditionalBranches:
290
+ Exclude:
291
+ - 'lib/tasks/export_accounting_records_to_pdf.rake'
292
+
293
+ # Offense count: 10
294
+ Style/IfInsideElse:
295
+ Exclude:
296
+ - 'app/controllers/logos_controller.rb'
297
+ - 'app/models/currency_pair.rb'
298
+ - 'app/models/default_attrs/purchase_invoice.rb'
299
+ - 'app/models/purchase_invoice_item.rb'
300
+ - 'app/queries/query/receivables_core.rb'
301
+ - 'app/services/currency_exchange.rb'
302
+ - 'app/services/subject_to_vat_specification.rb'
303
+ - 'app/validators/vatin_validator.rb'
304
+
305
+ # Offense count: 1
306
+ # Cop supports --auto-correct.
307
+ # Configuration parameters: MaxLineLength.
308
+ Style/IfUnlessModifier:
309
+ Exclude:
310
+ - 'app/validators/vatin_validator.rb'
311
+
312
+ # Offense count: 2
313
+ # Cop supports --auto-correct.
314
+ # Configuration parameters: InverseMethods, InverseBlocks.
315
+ Style/InverseMethods:
316
+ Exclude:
317
+ - 'app/models/sales_invoice.rb'
318
+ - 'app/validators/bank_symbol_validator.rb'
319
+
320
+ # Offense count: 2
321
+ Style/MultilineBlockChain:
322
+ Exclude:
323
+ - 'app/controllers/contracts/most_used_controller.rb'
324
+
325
+ # Offense count: 1
326
+ # Cop supports --auto-correct.
327
+ Style/MultilineIfModifier:
328
+ Exclude:
329
+ - 'app/services/currency_exchange.rb'
330
+
331
+ # Offense count: 2
332
+ Style/MultipleComparison:
333
+ Exclude:
334
+ - 'app/helpers/report_helper.rb'
335
+ - 'lib/core_ext/date.rb'
336
+
337
+ # Offense count: 134
338
+ # Cop supports --auto-correct.
339
+ Style/MutableConstant:
340
+ Enabled: false
341
+
342
+ # Offense count: 4
343
+ # Cop supports --auto-correct.
344
+ Style/NestedParenthesizedCalls:
345
+ Exclude:
346
+ - 'app/controllers/contacts_controller.rb'
347
+ - 'app/decorators/concerns/document_addresses.rb'
348
+ - 'app/models/purchase_order.rb'
349
+ - 'app/services/logo_upload.rb'
350
+
351
+ # Offense count: 1
352
+ # Cop supports --auto-correct.
353
+ # Configuration parameters: EnforcedOctalStyle, SupportedOctalStyles.
354
+ # SupportedOctalStyles: zero_with_o, zero_only
355
+ Style/NumericLiteralPrefix:
356
+ Exclude:
357
+ - 'spec/factories/bank_payments.rb'
358
+
359
+ # Offense count: 14
360
+ # Cop supports --auto-correct.
361
+ # Configuration parameters: Strict.
362
+ Style/NumericLiterals:
363
+ MinDigits: 11
364
+
365
+ # Offense count: 35
366
+ # Cop supports --auto-correct.
367
+ # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
368
+ # SupportedStyles: predicate, comparison
369
+ Style/NumericPredicate:
370
+ Enabled: false
371
+
372
+ # Offense count: 1
373
+ # Cop supports --auto-correct.
374
+ # Configuration parameters: AllowSafeAssignment.
375
+ Style/ParenthesesAroundCondition:
376
+ Exclude:
377
+ - 'app/models/default_attrs/purchase_invoice.rb'
378
+
379
+ # Offense count: 101
380
+ # Cop supports --auto-correct.
381
+ # Configuration parameters: PreferredDelimiters.
382
+ Style/PercentLiteralDelimiters:
383
+ Enabled: false
384
+
385
+ # Offense count: 10
386
+ # Cop supports --auto-correct.
387
+ Style/RedundantParentheses:
388
+ Exclude:
389
+ - 'app/controllers/application_controller.rb'
390
+ - 'app/models/cash_book_report.rb'
391
+ - 'app/models/concerns/cost_revenue_report_base.rb'
392
+ - 'app/models/contract_report.rb'
393
+ - 'app/models/costs_by_contacts_report.rb'
394
+ - 'app/models/purchase_invoice_item.rb'
395
+ - 'app/queries/query/receivables_core.rb'
396
+ - 'spec/models/external_notification_spec.rb'
397
+
398
+ # Offense count: 3
399
+ # Cop supports --auto-correct.
400
+ # Configuration parameters: AllowMultipleReturnValues.
401
+ Style/RedundantReturn:
402
+ Exclude:
403
+ - 'app/data_objects/interval.rb'
404
+
405
+ # Offense count: 44
406
+ # Cop supports --auto-correct.
407
+ # Configuration parameters: ConvertCodeThatCanStartToReturnNil.
408
+ Style/SafeNavigation:
409
+ Enabled: false
410
+
411
+ # Offense count: 55
412
+ # Cop supports --auto-correct.
413
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
414
+ # SupportedStyles: only_raise, only_fail, semantic
415
+ Style/SignalException:
416
+ Enabled: false
417
+
418
+ # Offense count: 1
419
+ # Cop supports --auto-correct.
420
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
421
+ # SupportedStyles: single_quotes, double_quotes
422
+ Style/StringLiterals:
423
+ Exclude:
424
+ - 'spec/models/invitation_spec.rb'
425
+
426
+ # Offense count: 160
427
+ # Cop supports --auto-correct.
428
+ # Configuration parameters: EnforcedStyle, MinSize, SupportedStyles.
429
+ # SupportedStyles: percent, brackets
430
+ Style/SymbolArray:
431
+ Enabled: false
432
+
433
+ # Offense count: 5
434
+ # Cop supports --auto-correct.
435
+ Style/UnneededInterpolation:
436
+ Exclude:
437
+ - 'app/helpers/select_helper.rb'
438
+ - 'app/mailers/notification_mailer.rb'
439
+ - 'app/models/user.rb'
440
+ - 'app/services/frontend_params_normalizer.rb'
441
+ - 'spec/features/sales/orders/order_spec.rb'
442
+
443
+ # Offense count: 43
444
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
445
+ # SupportedStyles: snake_case, normalcase, non_integer
446
+ Style/VariableNumber:
447
+ Exclude:
448
+ - 'spec/api/v1/sales_orders_spec.rb'
449
+ - 'spec/features/purchase/invoices_spec.rb'
450
+ - 'spec/features/purchase/petty_cash_disburstment_spec.rb'
451
+ - 'spec/features/sales/orders/order_spec.rb'
452
+ - 'spec/features/sales/petty_cash_income_spec.rb'
453
+ - 'spec/queries/query/cash_book_spec.rb'
454
+ - 'spec/queries/query/contracts_costs_report_spec.rb'
455
+ - 'spec/queries/query/contracts_revenues_report_spec.rb'
456
+ - 'spec/services/cash_book_data_generator_spec.rb'
457
+ - 'spec/services/generate_order_from_confirmed_payments_service_spec.rb'
458
+
459
+ # Offense count: 1
460
+ # Cop supports --auto-correct.
461
+ Style/YodaCondition:
462
+ Exclude:
463
+ - 'app/services/subject_to_vat_specification.rb'
data/Dockerfile ADDED
@@ -0,0 +1,12 @@
1
+ FROM uolcz/ruby:latest
2
+
3
+ ENV APPDIR /vat_payer_cz
4
+ RUN mkdir $APPDIR
5
+ WORKDIR $APPDIR
6
+
7
+ ENV BUNDLE_JOBS=2 \
8
+ BUNDLE_PATH=/gems \
9
+ GEM_PATH=$GEM_PATH:/gems \
10
+ PATH=$PATH:/gems/bin
11
+
12
+ ADD . .
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vat_payer_cz.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Tomas Landovsky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # VAT payer info CZ
2
+ This is Ruby wrapper for [web service for "searching information about reliability of VAT payers and their bank accounts" of Czech Republic Ministry of finance.](http://www.etrzby.cz/cs/index)
3
+
4
+ ## Installation
5
+ `gem install 'vat_payer_cz'`
6
+
7
+ ## Usage
8
+ The web service has the following three end-points:
9
+ - standard VAT payer info
10
+ - extended VAT payer info
11
+ - list of unreliable VAT payers
12
+
13
+ This gem currently implements 'standard VAT payer info'.
14
+
15
+ # Standard VAT payer info
16
+ ```ruby
17
+ vat_ids = %w(CZ27169278 CZ26168685)
18
+ VatInfo.unreliable_payer(*vat_ids)
19
+ ```
20
+ You should see something like this:
21
+ ```shell
22
+ => #<VatInfo::Response:0x0000000001ff61e8
23
+ @body=
24
+ {:status=>{:status_code=>"0", :status_text=>"OK", :odpoved_generovana=>"2018-02-08"},
25
+ :platci=>
26
+ [{:nespolehlivy_platce=>"NE",
27
+ :datum_zverejneni=>nil,
28
+ :dic=>"CZ27169278",
29
+ :cislo_fu=>"451",
30
+ :ucty=>
31
+ [{:predcisli=>nil, :cislo=>"1041150202", :kod_banky=>"5500", :iban=>nil, :datum_zverejneni=>"2013-04-01"},
32
+ {:predcisli=>nil, :cislo=>"6021446666", :kod_banky=>"6000", :iban=>nil, :datum_zverejneni=>"2013-12-05"},
33
+ {:predcisli=>nil, :cislo=>"2400915487", :kod_banky=>"2010", :iban=>nil, :datum_zverejneni=>"2016-05-05"}]},
34
+ ...
35
+ ```
36
+ ## Response
37
+ Object `VatInfo::Response`
38
+ ### status_code
39
+ `VatInfo::Response.status_code => String`
40
+ 200 - OK: Valid response was received.
41
+ 408 - Request Timeout: the web service timed out.
42
+ 503 - Service Unavailable: there was another error fetching the response.
43
+
44
+ ### body
45
+ Empty attributes have `nil` value.
46
+
47
+ `VatInfo::Response.body => Hash`
48
+ ```ruby
49
+ {
50
+ status: { Status }
51
+ platci: [ { Payer }, .. ]
52
+ }
53
+ ```
54
+ #### Status
55
+ See official docs for explanation.
56
+ ```ruby
57
+ {
58
+ status_code: String,
59
+ status_text: String,
60
+ odpoved_generovana: String # ISO 8601 Date
61
+ }
62
+ ```
63
+ #### Payer
64
+ ```ruby
65
+ {
66
+ nespolehlivy_platce: String, # "ANO" | "NE" | "NENALEZEN"
67
+ datum_zverejneni: String, # ISO 8601 Date
68
+ dic: String,
69
+ cislo_fu: String,
70
+ ucty: [ { Account }, .. ]
71
+ }
72
+ ```
73
+ #### Account
74
+ ```ruby
75
+ {
76
+ predcisli: String, # only Czech accounts
77
+ cislo: String, # only Czech accounts
78
+ kod_banky: String, # only Czech accounts
79
+ iban: String # Czech and foreign accounts
80
+ }
81
+ ```
82
+
83
+ ## Schema changes
84
+ The client will raise `VatInfo::SchemaError` exception if it thinks the schema have changed.
85
+
86
+ ## Official web service docs
87
+ In Czech: https://adisspr.mfcr.cz/adistc/adis/idpr_pub/dpr_info/ws_spdph.faces
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'vat_info'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'pry'
14
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ version: "2"
2
+
3
+ volumes:
4
+ vat_payer_cz-sync:
5
+ external: true
6
+ gem_store_235:
7
+ external: true
8
+
9
+ services:
10
+ web:
11
+ volumes:
12
+ - vat_payer_cz-sync:/vat_payer_cz:nocopy
@@ -0,0 +1,15 @@
1
+ version: "2"
2
+
3
+ volumes:
4
+ gem_store_235:
5
+
6
+ services:
7
+ web:
8
+ build:
9
+ context: .
10
+ dockerfile: Dockerfile
11
+ command: bash
12
+ tty: true
13
+ stdin_open: true
14
+ volumes:
15
+ - gem_store_235:/gems
data/docker-sync.yml ADDED
@@ -0,0 +1,10 @@
1
+ version: "2"
2
+ options:
3
+ verbose: true
4
+ compose-file-path: 'docker-compose.yml'
5
+ syncs:
6
+ vat_payer_cz-sync:
7
+ src: './'
8
+ sync_strategy: 'native_osx'
9
+ sync_excludes: ['.git/']
10
+ watch_excludes: ['.git/']
data/lib/vat_info.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'vat_info/version'
2
+ require 'vat_info/utils'
3
+ require 'vat_info/request'
4
+ require 'vat_info/response'
5
+ require 'vat_info/query'
6
+ require 'vat_info/models'
7
+
8
+ module VatInfo
9
+ def self.unreliable_payer(*vat_ids)
10
+ request = VatInfo::Request::UnreliablePayer.new(*vat_ids).to_xml
11
+ response = VatInfo::Query.call(request, :get_status_nespolehlivy_platce)
12
+
13
+ if response.ok?
14
+ status_raw = response.raw[:status_nespolehlivy_platce_response][:status]
15
+ status = VatInfo::Models::Status.new(status_raw).data
16
+
17
+ payers_raw = VatInfo::Utils.wrap_in_array(response.raw[:status_nespolehlivy_platce_response][:status_platce_dph])
18
+ payers = VatInfo::Models::VatPayers.new(payers_raw).data
19
+
20
+ response.body = status.merge(payers)
21
+ end
22
+ response
23
+ end
24
+
25
+ def self.unreliable_payer_extended
26
+ # :get_status_nespolehlivy_platce_rozsireny
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def self.unreliable_payer_list
31
+ # :get_seznam_nespolehlivy_platce
32
+ raise NotImplementedError
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ require 'vat_info/models/status'
2
+ require 'vat_info/models/vat_payers'
3
+ require 'vat_info/models/vat_payer'
4
+
5
+ module VatInfo
6
+ module Models
7
+ class InvalidStructure < StandardError; end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module VatInfo
2
+ module Models
3
+ class Status
4
+ attr_accessor :data, :params
5
+
6
+ def initialize(params = {})
7
+ @params = params
8
+ @data = {}
9
+ @data[:status] = create_status
10
+ end
11
+
12
+ def create_status
13
+ {
14
+ status_code: params.fetch(:@status_code),
15
+ status_text: params.fetch(:@status_text),
16
+ odpoved_generovana: params.fetch(:@odpoved_generovana)
17
+ }
18
+ rescue KeyError => e
19
+ raise InvalidStructure, "Response XML is missing required attributes.\n" \
20
+ "Input params were: #{params}\n" \
21
+ "Rescued error: #{e}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module VatInfo
2
+ module Models
3
+ class VatPayer
4
+ attr_accessor :data
5
+
6
+ def initialize(params)
7
+ @data = {}
8
+ @data[:nespolehlivy_platce] = params.fetch(:@nespolehlivy_platce)
9
+ @data[:dic] = params.fetch(:@dic)
10
+ @data[:datum_zverejneni] = params[:@datum_zverejneni_nespolehlivosti]
11
+ @data[:cislo_fu] = params[:@cislo_fu]
12
+ accounts = params[:zverejnene_ucty]
13
+ @data[:ucty] = accounts ? create_accounts(accounts[:ucet]) : {}
14
+ rescue KeyError => e
15
+ raise InvalidStructure, "Response XML is missing required attributes.\n" \
16
+ "Input params were: #{params}\n" \
17
+ "Rescued error: #{e}"
18
+ end
19
+
20
+ def create_accounts(accounts)
21
+ VatInfo::Utils.wrap_in_array(accounts).map do |account|
22
+ standard = account[:standardni_ucet]
23
+ non_standard = account[:nestandardni_ucet]
24
+
25
+ params = standard ? standard_account(standard) : non_standard_account(non_standard)
26
+ params.merge(datum_zverejneni: account[:@datum_zverejneni])
27
+ end
28
+ end
29
+
30
+ def standard_account(data)
31
+ {
32
+ predcisli: data[:@predcisli],
33
+ cislo: data[:@cislo],
34
+ kod_banky: data[:@kod_banky],
35
+ iban: nil
36
+ }
37
+ end
38
+
39
+ def non_standard_account(data)
40
+ {
41
+ predcisli: nil,
42
+ cislo: nil,
43
+ kod_banky: nil,
44
+ iban: data[:@cislo]
45
+ }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,16 @@
1
+ module VatInfo
2
+ module Models
3
+ class VatPayers
4
+ attr_accessor :data
5
+
6
+ def initialize(params = {})
7
+ @data = {}
8
+ @data[:platci] = create_vat_payers(params)
9
+ end
10
+
11
+ def create_vat_payers(payers)
12
+ payers.map { |payer| VatInfo::Models::VatPayer.new(payer).data }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ require 'savon'
2
+
3
+ module VatInfo
4
+ class SchemaError < StandardError; end
5
+
6
+ class Query
7
+ DOCS = 'https://adisspr.mfcr.cz/adistc/adis/idpr_pub/dpr_info/ws_spdph.faces'
8
+ WSDL = 'http://adisrws.mfcr.cz/adistc/axis2/services/rozhraniCRPDPH.rozhraniCRPDPHSOAP?wsdl'.freeze
9
+ TIMEOUT = 2
10
+
11
+ def self.call(request, endpoint, wsdl = WSDL, timeout = TIMEOUT)
12
+ client = Savon.client(wsdl: wsdl, open_timeout: timeout)
13
+
14
+ begin
15
+ response = client.call(endpoint, xml: request)
16
+ if response.success?
17
+ VatInfo::Response.new(status_code: 200, raw: response.body)
18
+ else
19
+ VatInfo::Response.new(status_code: 503)
20
+ end
21
+ rescue Net::OpenTimeout
22
+ VatInfo::Response.new(status_code: 408)
23
+ rescue Savon::SOAPFault => e
24
+ raise SchemaError, 'The SOAP schema of VAT service may have changed. Go to '\
25
+ "#{DOCS} to verify. Original error: #{e}"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ require 'nokogiri'
2
+ require 'vat_info/request/unreliable_payer'
3
+
4
+ module VatInfo
5
+ class Request
6
+ SOAP_ENV_SCHEMA = 'http://schemas.xmlsoap.org/soap/envelope/'.freeze
7
+
8
+ def envelope
9
+ Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml|
10
+ xml['soapenv'].Envelope('xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/') do
11
+ xml['soapenv'].Body do
12
+ end
13
+ end
14
+ end.doc
15
+ end
16
+
17
+ def to_xml
18
+ msg = envelope.dup
19
+ body = msg.at_xpath('//soapenv:Body')
20
+ body.add_child(self.body.root)
21
+
22
+ msg.to_xml
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ module VatInfo
2
+ class Request
3
+ class UnreliablePayer < VatInfo::Request
4
+ attr_accessor :vat_ids
5
+
6
+ def initialize(*vat_ids)
7
+ self.vat_ids = vat_ids
8
+ end
9
+
10
+ def body
11
+ Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml|
12
+ xml.StatusNespolehlivyPlatceRequest(xmlns: 'http://adis.mfcr.cz/rozhraniCRPDPH/') do
13
+ vat_ids.each { |vat_id| xml.dic(vat_id) }
14
+ end
15
+ end.doc
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module VatInfo
2
+ class Response
3
+ attr_accessor :status_code, :body, :raw
4
+
5
+ def initialize(status_code:, body: {}, raw: {})
6
+ @status_code = status_code
7
+ @body = body
8
+ @raw = raw
9
+ end
10
+
11
+ def ok?
12
+ status_code == 200
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module VatInfo
2
+ module Utils
3
+ def self.wrap_in_array(content)
4
+ content.is_a?(Array) ? content : [content]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module VatInfo
2
+ VERSION = '0.0.1'
3
+ end
data/vat_info.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'vat_info/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'vat_payer_cz'
7
+ spec.version = VatInfo::VERSION
8
+ spec.authors = ['Tomas Landovsky']
9
+ spec.email = ['landovsky@gmail.com']
10
+
11
+ spec.summary = 'Ruby wrapper for web service providing info about Czech VAT payers.'
12
+ spec.description = 'Using mfcr.cz SOAP API to get information about Czech VAT payers.'
13
+ spec.homepage = 'https://github.com/ucetnictvi-on-line/vat_payer_cz'
14
+ spec.license = 'MIT'
15
+
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'bin'
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'savon', '~> 2.12'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.13'
27
+ spec.add_development_dependency 'pry', '~> 0.11'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
30
+ spec.add_development_dependency 'vcr', '~> 4.0'
31
+ spec.add_development_dependency 'webmock', '~> 3.3'
32
+ end
33
+
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vat_payer_cz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Landovsky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.3'
111
+ description: Using mfcr.cz SOAP API to get information about Czech VAT payers.
112
+ email:
113
+ - landovsky@gmail.com
114
+ executables:
115
+ - console
116
+ - setup
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".rubocop.yml"
123
+ - ".rubocop_todo.yml"
124
+ - Dockerfile
125
+ - Gemfile
126
+ - LICENSE
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - docker-compose.override.yml
132
+ - docker-compose.yml
133
+ - docker-sync.yml
134
+ - lib/vat_info.rb
135
+ - lib/vat_info/models.rb
136
+ - lib/vat_info/models/status.rb
137
+ - lib/vat_info/models/vat_payer.rb
138
+ - lib/vat_info/models/vat_payers.rb
139
+ - lib/vat_info/query.rb
140
+ - lib/vat_info/request.rb
141
+ - lib/vat_info/request/unreliable_payer.rb
142
+ - lib/vat_info/response.rb
143
+ - lib/vat_info/utils.rb
144
+ - lib/vat_info/version.rb
145
+ - vat_info.gemspec
146
+ homepage: https://github.com/ucetnictvi-on-line/vat_payer_cz
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.5.2.1
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Ruby wrapper for web service providing info about Czech VAT payers.
170
+ test_files: []