fiscalizer 0.0.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.rspec +2 -0
  4. data/Gemfile +0 -4
  5. data/LICENSE.txt +1 -1
  6. data/README.md +187 -171
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/doc/Tehnicka specifikacija za korisnike 1.4.pdf +0 -0
  10. data/fiscalizer.gemspec +14 -13
  11. data/lib/fiscalizer.rb +33 -4
  12. data/lib/fiscalizer/constants.rb +11 -0
  13. data/lib/fiscalizer/data_objects/echo.rb +10 -0
  14. data/lib/fiscalizer/data_objects/fee.rb +18 -0
  15. data/lib/fiscalizer/data_objects/invoice.rb +79 -0
  16. data/lib/fiscalizer/data_objects/office.rb +41 -0
  17. data/lib/fiscalizer/{tax.rb → data_objects/tax.rb} +3 -5
  18. data/lib/fiscalizer/deserializers/base.rb +58 -0
  19. data/lib/fiscalizer/deserializers/echo.rb +13 -0
  20. data/lib/fiscalizer/deserializers/invoice.rb +9 -0
  21. data/lib/fiscalizer/deserializers/office.rb +6 -0
  22. data/lib/fiscalizer/fiscalizer.rb +36 -152
  23. data/lib/fiscalizer/fiscalizers/base.rb +54 -0
  24. data/lib/fiscalizer/fiscalizers/echo.rb +13 -0
  25. data/lib/fiscalizer/fiscalizers/invoice.rb +24 -0
  26. data/lib/fiscalizer/fiscalizers/office.rb +15 -0
  27. data/lib/fiscalizer/serializers/base.rb +58 -0
  28. data/lib/fiscalizer/serializers/echo.rb +21 -0
  29. data/lib/fiscalizer/serializers/invoice.rb +92 -0
  30. data/lib/fiscalizer/serializers/office.rb +85 -0
  31. data/lib/fiscalizer/serializers/signature.rb +62 -0
  32. data/lib/fiscalizer/serializers/tax.rb +81 -0
  33. data/lib/fiscalizer/services/request_sender.rb +68 -0
  34. data/lib/fiscalizer/services/security_code_generator.rb +29 -0
  35. data/lib/fiscalizer/version.rb +1 -1
  36. data/spec/fiscalizer_spec.rb +119 -0
  37. data/spec/spec_helper.rb +9 -0
  38. metadata +67 -39
  39. data/doc/README.md +0 -3
  40. data/doc/Tehnicka_specifikacija_za_korisnike_1.2.pdf +0 -0
  41. data/example/README.md +0 -25
  42. data/example/echo_P12.rb +0 -13
  43. data/example/echo_public_and_private_keys.rb +0 -16
  44. data/example/invoice_fiscalization_passing_arguments.rb +0 -44
  45. data/example/invoice_fiscalization_passing_object.rb +0 -48
  46. data/example/office_fiscalization_passing_arguments.rb +0 -22
  47. data/example/office_fiscalization_passing_object.rb +0 -26
  48. data/lib/README.md +0 -0
  49. data/lib/fiscalizer/README.md +0 -9
  50. data/lib/fiscalizer/communication.rb +0 -305
  51. data/lib/fiscalizer/echo.rb +0 -11
  52. data/lib/fiscalizer/fee.rb +0 -20
  53. data/lib/fiscalizer/invoice.rb +0 -190
  54. data/lib/fiscalizer/office.rb +0 -66
  55. data/lib/fiscalizer/response.rb +0 -124
  56. data/test/README.md +0 -13
  57. data/test/test_echo.rb +0 -20
  58. data/test/test_fee +0 -64
  59. data/test/test_fiscalizer.rb +0 -222
  60. data/test/test_fiscalizer_communication.rb +0 -28
  61. data/test/test_invoice.rb +0 -11
  62. data/test/test_office.rb +0 -11
  63. data/test/test_tax.rb +0 -89
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3d926aeb8f7660653b31e50f8f6d9cb0d6ce358
4
- data.tar.gz: 07932327e37b033a5f728fbc070ed1ba8b66bfc7
3
+ metadata.gz: cc259947daa868463b0de723f158b9f4d5b46dc5
4
+ data.tar.gz: 1fe536eca7ea1a013f819c26c1ccfffd2aead82d
5
5
  SHA512:
6
- metadata.gz: 609ed055f9da766bf912707ea1c825c627a301ac6d5a23626f2678a836b455852d1aafac90172c673d00bc83d6eb155791d3b92bb364ad227cbcf11e2f4f26a2
7
- data.tar.gz: 2ba0fa751aa803e5a37ddc58462a1ee3306e509c4473d49100e9b2cfcbdbae821a08cc6507586a203b375556a7fdfb6c637488493ac3a180b5821d0bcbf012e6
6
+ metadata.gz: 1249e0e6e1d45c5ce5115e562e0f903336eb16e0ee41a8a27b3c0617808a6b5d342ed774d04218d13ca8cb0089ce974558d31da212fdec910fb1ad7600855afc
7
+ data.tar.gz: 37fab01aaec2515768621f022356b6722af529e1aa425166557b26670fc4ae5a5898f261de1f4c9f89e6e4be45d668353e797a2844aa5eabc9e872a3f3573cc4
data/.gitignore CHANGED
@@ -14,4 +14,5 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
- test/assets/*
17
+ test/assets/*
18
+ certificates
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in fiscalizer_ruby.gemspec
4
3
  gemspec
5
- gem 'nokogiri'
6
- gem 'xmldsig-fiscalizer'
7
- #gem 'pry-debugger'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Infinum
1
+ Copyright (c) 2017 Infinum
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,19 +2,9 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- Fiscalization is the process of transfering various document types from a business entity to the tax authorities with the goal of reducing tax fraud. In Croatia this process can be executed over the Internet, this gem is intended to automate this process.
5
+ Fiscalization is the process of transferring various document types from a business entity to the tax authorities with the goal of reducing tax fraud. In Croatia this process can be executed over the Internet and this gem is intended to automate the process.
6
6
 
7
- ## Documentation
8
-
9
- Every folder has it's own README file which explanes in detail the files in it.
10
-
11
- Examples are located in the `example` folder. Basic setup and fiscalization are demonstrated here.
12
-
13
- Tests are located in the `test` folder. Test setup is explaned there.
14
-
15
- All classes, in their separate files, are located in the `fiscalizer` folder.
16
-
17
- ## Instalation
7
+ ## Installation
18
8
 
19
9
  Add this line to your application's Gemfile:
20
10
 
@@ -29,181 +19,207 @@ Or install it yourself as:
29
19
  $ gem install fiscalizer
30
20
 
31
21
  ## Usage
32
- ### Setup
33
- To use Fiscalizer in your projects simply call `fiscalizer = Fiscalizer.new`, this will create a new fiscalizer object for you to interact with.
34
22
 
35
- Necessary parameters, that have to be set before any fiscalization occures are:
23
+ ### Setup
24
+ To use Fiscalizer initialize a new Fiscalizer object (`fiscalizer = Fiscalizer.new`) with these arguments:
36
25
 
37
- * `certificate_p12_path` : Path to your fiscal certificate (usually "FISCAL 1.p12" or "fiscal1.pfx")
26
+ * `app_cert_path` : Path to your fiscal certificate. (usually "FISCAL_1.p12" or "fiscal1.pfx")
38
27
  * `password` : Password that unlocks the certificate
39
28
 
40
- Alternatively you can set these three parameters:
29
+ Optional argument is:
30
+
31
+ * `timeout` : Specifies the number of seconds to wait for Fiscalization server to respond. (defaults to 3)
32
+
33
+ Example:
41
34
 
42
- * `key_public_path` : Path to the public key ( "fiskal1.cert" )
43
- * `key_private_path` : Path to the private key ( "privateKey.key" )
44
- * `certificate_path` : Path to the certificate ( "certificate.pem" )
35
+ ```ruby
36
+ fiscalizer = Fiscalizer.new(
37
+ app_cert_path: 'path/to/FISCAL_1.p12',
38
+ password: 'password',
39
+ timeout: 4
40
+ )
41
+ ```
42
+ #### Demo environment
45
43
 
46
- __NOTE:__ Thise parameters will override the parameters extracted from the P12 certificate!
44
+ If Fiscalizer is used in demo (test) environment, you need to set 2 additional parameters when initializing `Fiscalizer` object:
47
45
 
48
- Parameters that can also be set:
46
+ * `demo` : Specifies that Fiscalizer should send requests to FINA DEMO server. (boolean)
47
+ * `ca_cert_path` : Specifies the path to trusted CA certificates. This file should contain both FINA ROOT CA certificate and FINA DEMO CA certificate. (usually called "fina_ca.pem")
49
48
 
50
- * `url` : Specifies the URL to which the requests will be sent ( defaults to "https://cis.porezna-uprava.hr:8449/FiskalizacijaService")
51
- * `tns` : Specifies the XML namespaces to use when parsing and encoding objects ( defaults to "http://www.apis-it.hr/fin/2012/types/f73")
52
- * `schemaLocation` : Specifies the XML schema to be used for XML parsing ( defualts to "http://www.apis-it.hr/fin/2012/types/f73 FiskalizacijaSchema.xsd")
53
- * `certificate_issued_by` : Certificate issuer identifier to be used in the signature ( defaults to "OU=RDC,O=FINA,C=HR")
49
+ Example:
50
+
51
+ ```ruby
52
+ fiscalizer = Fiscalizer.new(
53
+ app_cert_path: 'path/to/FISCAL_1.p12',
54
+ password: 'password',
55
+ demo: true,
56
+ ca_cert_path: 'path/to/fina_ca.pem'
57
+ )
58
+ ```
54
59
 
55
60
  ### Fiscalization
56
61
 
57
- This gem offers two types of fiscalization, _Office space_ and _Invoice_ fiscalization. _Echo_ requests are also possible.
58
-
59
- All these methods return an `Fiscalizer::Response` object, which is explaned below.
60
-
61
- #### Invoices
62
-
63
- To fiscalize an invoice call `fiscalizer.fiscalize_invoice` and pass it an `Fiscalizer::Invoice` object.
64
-
65
- Alternatively it is possible to pass all the arguments needed to build an invoice, this will build an invoice
66
- and fiscalize it automatically.
67
-
68
- Arguments that can be passed to `fiscalizer.fiscalize_invoice`:
69
-
70
- * `uuid` : Universally Unique Identifier (String)
71
- * `time_sent` : Time the invoice fiscalization request was sent (Time)
72
- * `pin` : The fiscal entitie's PIN number (String)
73
- * `in_vat_system` : Specifies if the fical entity is in the VAT system (Boolean)
74
- * `time_issued` : Time the invoice was created (Time)
75
- * `consistance_mark` : Character that specifes where the invoice was issued, "P" for _Office space_ or "N" for _Payment machine_ (String)
76
- * `issued_number` : Nummerical invoice identifier (String ot Integer)
77
- * `issued_office` : Office space identifier where the invoice was issued (String)
78
- * `issued_machine` : Numerical payment machine identifier (String or Integer)
79
- * `tax_vat` : Array containing all VAT taxes (Array containing _Fiscalizer::Tax_ objects)
80
- * `tax_spending` : Array containing all spending taxes (Array containing _Fiscalizer::Tax_ objects)
81
- * `tax_other` : Array containing all other taxes (Array containing _Fiscalizer::Tax_ objects)
82
- * `value_tax_liberation` : Ammount that will be submitted for tax liberation (Float)
83
- * `value_tax_margin` : Ammount that will be subjected to the special tax margin process (Float)
84
- * `value_non_taxable` : Ammount that isn't subject to any taxing (Float)
85
- * `fees` : Array containing all fees (Array containing _Fiscalizer::Fee_ objects)
86
- * `summed_total` : Summed total price of the invoice (Float)
87
- * `payment_method` : Specifies the payment method, "G" for cash, "K" for card, "C" for check, "T" for transaction, "O" for other (String)
88
- * `operator_pin` : The PIN number of the person issuing the invoice (String)
89
- * `security_code` : Security code of the invoice (String)
90
- * `subsequent_delivery` : Subsequent delivery mark (Boolean)
91
- * `paragon_label` : Paragon label for invoices that have to be fiscalized after the office space or payment machine has been removed from the fiscalization system (String)
92
- * `specific_purpose` : This is an additional label in case of further expansion of the fiscalization system (String)
93
- * `unique_identifier` : Unique identifier of the invoice (String)
94
- * `reconnect_attempts` : Specifies how many times to try establishing a connection, defaults to 3 (Integer)
95
-
96
- __Note:__ `summed_total` will return the sum of all taxed values from `tax_vat`, `tax_spending`, `tax_other`
97
-
98
- #### Office spaces
99
-
100
- To fiscalize an office space call `fiscalizer.fiscalize_office` and pass it an `Fiscalizer::Office` object.
101
-
102
- Arguments that can be passed to `fiscalizer.fiscalize_office`:
103
-
104
- * `uuid` : Universally Unique Identifier (String)
105
- * `time_sent` : Time the office space fiscalization request was sent (Time)
106
- * `pin` : The fiscal entitie's PIN number (String)
107
- * `office_label` : Office space identifier string (String)
108
- * `adress_street_name` : Name of the street the where the office space is located (String)
109
- * `adress_house_num` : House number of the office space (String)
110
- * `adress_house_num_addendum` : Additional house number of the office space, eg.: "a" or "3/4" (String)
111
- * `adress_post_num` : Post office number of the office space (String)
112
- * `adress_settlement` : Settlement name of the office space's location (String)
113
- * `adress_township` : Township name of the office space's location (String)
114
- * `adress_other` : Field to specify non standart office spaces, eg.: "web store" (String)
115
- * `office_time` : Specifies the working hours of the office space, anything is valid (String)
116
- * `take_effect_date` : Date from which the change takes effect (Time)
117
- * `closure_mark` : Mark that indicates the cloasure of the office space, send "Z" to close (String)
118
- * `specific_purpose` : Software manufacturer's PIN number (String)
119
- * `reconnect_attempts` : Specifies how many times to try establishing a connection, defaults to 3 (Integer)
120
-
121
- #### Echo requests
122
-
123
- Even though echo requests are not particularly usefull for fiscalization they are described in the API and
124
- therefore they are also implemented.
125
-
126
- To make an echo request call `fiscalizer.echo` and eather pass it na `Fiscalizer::Echo` object or `text: "Your echo text"`
127
- as an argument.
128
-
129
- #### Responses
130
-
131
- Response objects are perhaps the most important objects in this Gem.
132
- They contain pre-parsed information that was returned from the fiscalization servers.
133
-
134
- Methods:
135
- * `type` : Type of the response, 0-Error, 1-Echo, 2-Office, 3-Invoice (Integer)
136
- * `errors` : Hash containg all errors returned from the server, the key is the error code, and the value is the error explanation (Hash)
137
- * `object` : Holds the object that generated the response (Echo, Invoice, Office)
138
- * `uuid` : UUID returned by the server (String)
139
- * `processed_at` : Time the request was processed (Time)
140
- * `response` : Text returned in an Echo message (String)
141
- * `unique_identifier` : Unique invoice identifier (String)
142
- * `tns` : TNS used to parse the XML responses (String)
143
- * `html_response` : Raw HTML response (HTTP::Response)
144
- * `generated_xml` : XML generated for the reqest to which this response belongs (String)
145
- * `has_error` : Returns true if there are any arrors (Boolean), alia method `errors?`
146
- * `error_codes` : Returns all error codes in an array (Array containing String)
147
- * `error_messages` : Returns all error messages in an array (Array containing String)
148
- * `type_str` : Returnes the response type as a string (String)
149
- * `echo_succeeded` : Returns true if echo message sent and returned are the same (Boolean)
150
-
151
- # Notes
152
-
153
- The public and private keys, and signing certificate are automatically extracted from a P12 certificate.
154
- But the same is not true for a PFX certificate! PFX certificates don't contain a signing certificate and
155
- therefore one has to be passed as an argument (`certificate_path`) additionaly to the PFX certificate (`certificate_p12_path`)
156
-
157
- Direct usage of the `Fiscalizer::Communication` class is not advised!
158
-
159
- # Translations
160
-
161
- * __uuid__ : UUID
162
- * __time_sent__ : Datum i vrijeme slanja
163
- * __pin__ : OIB
164
- * __office_label__ : Oznaka poslovnog prostora
165
- * __adress_street_name__ : Ime ulice
166
- * __adress_house_num__ : Kućni broj
167
- * __adress_house_num_addendum__ : Dodatak kućnom broju
168
- * __adress_post_num__ : Broj pošte
169
- * __adress_settlement__ : Nasenje
170
- * __adress_township__ : Općina
171
- * __adress_other__ : Ostali tipovo poslovnog porstora
172
- * __office_time__ : Radno vrijeme
173
- * __take_effect_date__ : Datum početka primjene
174
- * __closure_mark__ : Oznaka zatvaranja
175
- * __specific_purpose__ : Specifična namjena
176
- * __in_vat_system__ : U sustavu PDVa
177
- * __time_issued__ : Datum i vrijeme izdavanja
178
- * __consistance_mark__ : Oznaka slijednosti
179
- * __issued_number__ : Brojčana oznaka računa
180
- * __issued_office__ : Oznaka poslovnog prostora
181
- * __issued_machine__ : Oznaka naplatnog uređaja
182
- * __tax_vat__ : PDV
183
- * __tax_spending__ : PNP
184
- * __tax_other__ : Ostali porezi
185
- * __value_tax_liberation__ : Iznos oslobođenja
186
- * __value_tax_margin__ : Iznos koji se odnosi na poseban postupak oporezivanja marže
187
- * __value_non_taxable__ : Iznos koji ne podlježe oporezivanju
188
- * __fees__ : Naknade
189
- * __summed_total__ : Ukupan iznos
190
- * __payment_method__ : Način plaćanja
191
- * __operator_pin__ : OIB operatera
192
- * __security_code__ : Zaštitni kod izdavatelja (ZKI)
193
- * __subsequent_delivery__ : Oznaka nadoknadne dostave
194
- * __paragon_label__ : Oznaka paragon računa
195
- * __specific_purpose__ : Specifična namjena
196
- * __unique_identifier__ : Jedinstveni identifikator računa (JIR)
197
- * __base__ : Osnovica
198
- * __rate__ : Porezna stopa
62
+ Ficalizer class provides 3 public methods:
63
+
64
+ * `echo(message)`
65
+ * `fiscalize_invoice(invoice)`
66
+ * `fiscalize_office(office)`
67
+
68
+ #### Echo
69
+
70
+ Echo method receives a message, sends it to the Fiscalization server and returns the echo response:
71
+
72
+ ```ruby
73
+ response = fiscalizer.echo('Echo message')
74
+ response.success? # true
75
+ response.echo_response # Echo message
76
+ ```
77
+
78
+ #### Invoice
79
+
80
+ To fiscalize the invoice, you first need to create a `Fiscalizer::Invoice` object and pass it to the `fiscalize_invoice` method.
81
+
82
+ Before the fiscalization process starts, a `security_code` (ZKI) will be automatically generated and assigned to invoice.
83
+ If the fiscalization process is successful, response will contain a `unique_identifier` (JIR). Else, it will contain an array with errors (each error is a hash with `code` and `message`).
84
+
85
+ `Fiscalizer::Invoice` object can be initialized with the following arguments:
86
+
87
+ * `uuid` : Universally Unique Identifier / ID poruke (String, required)
88
+ * `time_sent` : Time the invoice fiscalization request was sent / Datum i vrijeme slanja (DateTime in format dd.mm.yyyyThh:mm:ss, required)
89
+ * `pin` : The fiscal entitie's PIN number / OIB obveznika fiskalizacije (String, required)
90
+ * `in_vat_system` : Specifies if the fical entity is in the VAT system / U sustavu PDV (Boolean, required)
91
+ * `time_issued` : Time the invoice was created / Datum i vrijeme izdavanja (DateTime, required)
92
+ * `consistance_mark` : Character that specifes where the invoice was issued, "P" for _Office space_ or "N" for _Payment machine_ / Oznaka slijednosti (String, required)
93
+ * `issued_number` : Numerical invoice identifier / Brojčana oznaka računa (0-9) (String/Integer, required)
94
+ * `issued_office` : Office space identifier where the invoice was issued / Oznaka poslovnog prostora (String, required)
95
+ * `issued_machine` : Numerical payment machine identifier / Oznaka naplatnog uređaja (String/Integer, required)
96
+ * `tax_vat` : Array containing all VAT taxes / Porez na dodanu vrijednost (Array containing _Fiscalizer::Tax_ objects, optional)
97
+ * `tax_spending` : Array containing all spending taxes / Porez na potrošnju (Array containing _Fiscalizer::Tax_ objects, optional)
98
+ * `tax_other` : Array containing all other taxes / Ostali porezi (Array containing _Fiscalizer::Tax_ objects, optional)
99
+ * `value_tax_liberation` : Amount that will be submitted for tax liberation / Iznos oslobođenja (Float, optional)
100
+ * `value_tax_margin` : Amount that will be subjected to the special tax margin process / Iznos na koji se odnosi poseban postupak oporezivanja marže (Float, optional)
101
+ * `value_non_taxable` : Amount that isn't subject to any taxing / Iznos koji ne podliježe oporezivanju (Float, optional)
102
+ * `fees` : Array containing all fees / Naknade (Array containing _Fiscalizer::Fee_ objects, optional)
103
+ * `summed_total` : Summed total price of the invoice / Ukupan iznos (Float, required)
104
+ * `payment_method` : Specifies the payment method, "G" for cash, "K" for card, "C" for check, "T" for transaction, "O" for other / Način plaćanja (String, required)
105
+ * `operator_pin` : The PIN number of the person issuing the invoice / OIB operatera na naplatnom uređaju (String, required)
106
+ * `subsequent_delivery` : Subsequent delivery mark / Oznaka naknadne dostave računa (Boolean, required)
107
+ * `paragon_label` : Paragon label for the invoice that have to be fiscalized after the office space or payment machine has stopped working / Oznaka paragon računa (String, optional)
108
+ * `specific_purpose` : This is an additional label in case of further expansion of the fiscalization system / Specifična namjena (String, optional)
109
+
110
+ After the fiscalization process, response object contains these informations:
111
+
112
+ * `raw_response` : XML with the raw response from the Fiscalization server
113
+ * `uuid` : UUID of the response
114
+ * `processed_at` : DateTime when the fiscalization is processed
115
+ * `unique_identifier` : Unique fiscalization identifier of the invoice (JIR) (can be nil if there were errors)
116
+ * `errors?` : Boolean indicating if there were any errors during the process
117
+ * `errors` : Array containing errors if any - Each error is a hash with `code` and `message`
118
+
119
+ Fiscalizer invoice object contains these informations after the fiscalization:
120
+
121
+ * `security_code` : Security code of the invoice (ZKI)
122
+ * `generated_xml` : XML that was sent to the Fiscalization server
123
+
124
+ Example:
125
+
126
+ ```ruby
127
+ invoice = YourApp::Invoice.find(...)
128
+ fiscalizer_invoice = Fiscalizer::Invoice.new(...) # convert your invoice to fiscalizer invoice
129
+ fiscalizer = Fiscalizer.new(
130
+ app_cert_path: 'path/to/FISCAL_1.p12',
131
+ password: 'password'
132
+ )
133
+
134
+ begin
135
+ response = fiscalizer.fiscalize_invoice(fiscalizer_invoice)
136
+ fail 'Fiscalization error' if response.errors? # or do something with the errors
137
+
138
+ invoice.update(jir: response.unique_identifier)
139
+ ensure
140
+ invoice.update(
141
+ fiscalization_response: response.raw_response,
142
+ fiscalization_request: fiscalizer_invoice.generated_xml,
143
+ zki: fiscalizer_invoice.security_code,
144
+ errors: response.errors
145
+ )
146
+ end
147
+ ```
148
+
149
+ #### Taxes and Fees
150
+
151
+ When initializing `Fiscalizer::Invoice`, you can set multiple taxes, as indicated above. Those taxes need to be instances of `Fiscalizer::Tax` class.
152
+
153
+ `Fiscalizer::Tax` object can be initialized with the following arguments:
154
+
155
+ * `base` : Base amount / Iznos osnovice (Float, required)
156
+ * `rate` : Tax rate / Porezna stopa (Float, required)
157
+ * `name` : Tax name / Naziv poreza (String, required)
158
+
159
+ Also, you can set multiple fees for the invoice. Fee need to be instance of the `Fiscalizer::Fee` class.
160
+
161
+ `Fiscalizer::Fee` object can be initialized with the following arguments:
162
+
163
+ * `name` : Fee name / Naziv naknade (String, required)
164
+ * `value` : Fee amount / Iznos naknade (Float, required)
165
+
166
+ #### Office
167
+
168
+ To fiscalize the office space, you first need to create a `Fiscalizer::Office` object and pass it to the `fiscalize_office` method.
169
+
170
+ `Fiscalizer::Office` object can be initialized with the following arguments:
171
+
172
+ * `uuid` : Universally Unique Identifier / ID poruke (String, required)
173
+ * `time_sent` : Time the office space fiscalization request was sent / Datum i vrijeme slanja (DateTime, required)
174
+ * `pin` : The fiscal entitie's PIN number / OIB obveznika fiskalizacije (String, required)
175
+ * `office_label` : Office space identifier / Oznaka poslovnog prostora (String, required)
176
+ * `adress_street_name` : Street name of the office space / Ulica (String, required if `address_other` is not set)
177
+ * `adress_house_num` : House number of the office space / Kućni broj (String, required if `address_other` is not set)
178
+ * `adress_house_num_addendum` : Additional house number of the office space, eg.: "a" or "3/4" / Dodatak kućnom broju (String, optional)
179
+ * `adress_post_num` : Post office number of the office space / Broj pošte (String, required if `address_other` is not set)
180
+ * `adress_settlement` : Settlement name of the office space's location / Naselje (String, optional)
181
+ * `adress_township` : Township name of the office space's location / Naziv općine ili grada (String)
182
+ * `adress_other` : Field to specify non standard office spaces, eg.: "web store" / Ostali tipovi poslovnog prostora (String, optional)
183
+ * `office_time` : Specifies the working hours of the office space / Radno vrijeme (String, required)
184
+ * `take_effect_date` : Date from which the change takes effect / Datum početka primjene (Date, required)
185
+ * `closure_mark` : Mark that indicates the closure of the office space, send "Z" to close / Oznaka zatvaranja (String, optional)
186
+ * `specific_purpose` : Software manufacturer's PIN number / Specifična namjena (String, optional)
187
+
188
+ After the fiscalization process, response object contains these informations:
189
+
190
+ * `raw_response` : XML with the raw response from the Fiscalization server
191
+ * `uuid` : UUID of the response
192
+ * `processed_at` : DateTime when the fiscalization is processed
193
+ * `errors?` : Boolean indicating if there were any errors during the process
194
+ * `errors` : Array containing errors if any - Each error is a hash with `code` and `message`
195
+
196
+ Example:
197
+
198
+ ```ruby
199
+ fiscalizer_office = Fiscalizer::Office.new(...)
200
+ fiscalizer = Fiscalizer.new(
201
+ app_cert_path: 'path/to/FISCAL_1.p12',
202
+ password: 'password'
203
+ )
204
+
205
+ response = fiscalizer.fiscalize_office(fiscalizer_office)
206
+
207
+ # do something with the response
208
+ ```
209
+
210
+ # Fiscalization specification
211
+
212
+ The official technical specification for the Fiscalization process can be found
213
+ [here](https://www.porezna-uprava.hr/HR_Fiskalizacija/Stranice/Tehni%C4%8Dke-specifikacije.aspx).
199
214
 
200
215
  # Credits
201
216
 
202
217
  Fiscalizer is maintained and sponsored by
203
- [Infinum](http://www.infinum.co).
218
+ [Infinum](https://infinum.co/).
204
219
 
205
- ![Infinum](http://www.infinum.co/system/logo.png)
220
+ ![Infinum](https://camo.githubusercontent.com/ce804b9555629d79335cf51c0bd6aedc615aeb3f/68747470733a2f2f696e66696e756d2e636f2f696e66696e756d2e706e67)
206
221
 
207
222
  # License
208
223
 
209
- Phrasing is Copyright © 2014 Infinum. It is free software, and may be redistributed under the terms specified in the LICENSE file.
224
+ The gem is available as open source under the terms of the
225
+ [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fiscalizer"
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 "irb"
14
+ # IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here