sunat_books 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efd1903840f068f411f75c6c1f8fae4899ffe48fc28a803785a3831203e81ba4
4
- data.tar.gz: f1365594c65b1a0b1c13858cfdb3b65db727e7b566120619e124fa54f3702841
3
+ metadata.gz: 1d074f71e576ad2528da91297e05d1acfd14480829e7b77db8c27b3a13bd3943
4
+ data.tar.gz: cdc8de2ebedfe75f5e9169d82530b4c7d1b50c37909c1e2c8aae2f1f4d29104d
5
5
  SHA512:
6
- metadata.gz: f349ce044cc13391c2b67f7aab70edf73952c3a8159b5282697d8c935171bf73f16c0a0b34aaaa5d4912a68f94031d37a0a8cd5e84c463b839341ecfc95b9b83
7
- data.tar.gz: b8ba1d475126a7ac3e5883df8146bfd9ca01a96149a8e30dbcce37b99c4892eb0f15651370e6256dd1bf2aedf669259818d1e460a44c3c5a532bb331007032ea
6
+ metadata.gz: f5f87bcfa3ff0da39d7885cd8ddb5ab3d4aa2c607905e589f2c0ae2d9022f3dd7955deeae45bdc11c045f92719a3e4e4b17174059ee9d520916f6dbb6d6ccfeb
7
+ data.tar.gz: a42ef020ec2668c7bdbc674e44bbcc8bbfbed4240cfb27a591de483c61c2749d5cebbc26180d1dea3eb71de81a3bf0ca343982b1bfdecc06e89551ce995d8103
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
3
4
  Style/Documentation:
4
5
  Enabled: false
5
6
  Style/StringLiterals:
@@ -26,3 +27,6 @@ Style/HashTransformKeys:
26
27
 
27
28
  Style/HashTransformValues:
28
29
  Enabled: true
30
+
31
+ Lint/MissingSuper:
32
+ Enabled: false
@@ -6,3 +6,4 @@ require "sunat_books/pdf/simplified_diary"
6
6
  require "sunat_books/ple/buys"
7
7
  require "sunat_books/ple/sales"
8
8
  require "sunat_books/csv/base"
9
+ require "sunat_books/errors/invalid_layout_error"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SunatBooks
4
+ module Errors
5
+ class InvalidLayoutError < StandardError
6
+ end
7
+ end
8
+ end
@@ -65,7 +65,7 @@ module SunatBooks
65
65
  def table_head(fields, book_name, layout)
66
66
  thead = []
67
67
  fields.each do |h|
68
- if h.class == Hash
68
+ if h.instance_of? Hash
69
69
  r = sub_head(h, book_name, layout)
70
70
  thead << r
71
71
  else
@@ -9,8 +9,7 @@ module PagesUtils
9
9
  last_page
10
10
  else
11
11
  yield if block
12
- new_page = setup_new_page(pages, last_page, 2)
13
- new_page
12
+ setup_new_page(pages, last_page, 2)
14
13
  end
15
14
  end
16
15
 
@@ -37,7 +36,7 @@ module PagesUtils
37
36
  end
38
37
 
39
38
  def not_moviment_page(data)
40
- data << [content: "SIN MOVIMIENTO EN EL PERIODO", colspan: 5]
39
+ data << [{ content: "SIN MOVIMIENTO EN EL PERIODO", colspan: 5 }]
41
40
  end
42
41
 
43
42
  def setup_final_row_data(page, ticket, data)
@@ -62,7 +62,7 @@ module Utils
62
62
 
63
63
  def field_value(ticket, field)
64
64
  value = available_value?(ticket, field)
65
- value = formated_number(value) if value.class == BigDecimal
65
+ value = formated_number(value) if value.instance_of? BigDecimal
66
66
  value
67
67
  end
68
68
 
@@ -24,6 +24,8 @@ module SunatBooks
24
24
  def initialize(ruc, tickets, month, year, options = {})
25
25
  @book_format = options[:book_format]
26
26
  yml_path = options[:yml] || default_yml(book_format)
27
+ raise SunatBooks::Errors::InvalidLayoutError unless File.exist?(yml_path)
28
+
27
29
  fields = YAML.load_file(yml_path)
28
30
  check_layout(options, fields)
29
31
  content = !tickets.empty? ? 1 : 0
@@ -2,25 +2,25 @@
2
2
  - cuo # Código Unico de Operación, software (max 40)
3
3
  - correlative # 2 ..10
4
4
  - operation_date # 'dd/mm/yyyy'
5
- - pay_date # 'dd/mm/yyyy'
5
+ - payment_date # 'dd/mm/yyyy'
6
6
  - document_type # 2
7
7
  - document_serial # max 20
8
- - dua_year_emition
8
+ - dua_year
9
9
  - document_number # max 20
10
10
  - total_diary_operation_non_credit # max 20
11
11
  - provider_document_type
12
12
  - provider_document_number # max 15
13
13
  - provider_name # max 100
14
- - document_bi_export_only
15
- - document_igv_export_only
16
- - document_bi_export_n_no_tax
17
- - document_igv_export_n_no_tax
18
- - document_bi_export_non_tax
19
- - document_igv_export_non_tax
20
- - document_non_tax
21
- - documentn_isc
22
- - document_other_tax
23
- - document_total
14
+ - bi_exported_only
15
+ - igv_exported_only
16
+ - bi_exported_non_taxable
17
+ - igv_exported_non_taxable
18
+ - bi_non_taxable_only
19
+ - igv_non_taxable_only
20
+ - non_taxable
21
+ - isc_tax
22
+ - other_tax
23
+ - total_operation
24
24
  - currency_code
25
25
  - exchange_rate # 1 entero, 3 decimales
26
26
  - modified_document_date
@@ -31,11 +31,11 @@
31
31
  - detraction_date
32
32
  - detraction_number
33
33
  - apply_retention? # retention ? '1'
34
- - clasification_goods_services_adquired
35
- - contract_or_project
36
- - inconsistent_exchange
37
- - inconsistent_provider_inactive
38
- - inconsistent_provider_igv_exoneration
39
- - inconsistent_dni_buy_liquidation
34
+ - adquired_clasification
35
+ - contract_uid
36
+ - exchange_rate_error
37
+ - provider_inactive_error
38
+ - provider_exoneration_error
39
+ - provider_document_number_error # dni en liquidaciones compra
40
40
  - payment_method
41
41
  - anotation_oportunity
@@ -5,23 +5,23 @@
5
5
  - document_type
6
6
  - document_serial
7
7
  - document_number
8
- - document_bi
9
- - other_concepts
10
- - document_total
11
- - document_type_tax_credit
12
- - document_serial_tax_credit
13
- - dua_year_emition
14
- - document_tax_pay
8
+ - bi
9
+ - other_concept
10
+ - total_operation
11
+ - document_type
12
+ - document_serial
13
+ - dua_year
14
+ - document_number
15
15
  - retention_amount
16
16
  - currency_code
17
17
  - exchange_rate
18
- - not_domiciled_residence_country
19
- - not_domiciled_name
20
- - not_domiciled_address
21
- - not_domiciled_document_number
22
- - payment_beneficiary_tax_document_number
23
- - payment_beneficiary_name
24
- - payment_beneficiary_residence_country
18
+ - provider_country_code
19
+ - provider_name
20
+ - provider_address
21
+ - provider_document_number
22
+ - beneficiary_document_number
23
+ - beneficiary_name
24
+ - beneficiary_country_code
25
25
  - economic_link_type
26
26
  - gross_income
27
27
  - deduction
@@ -2,7 +2,7 @@
2
2
  - cuo
3
3
  - correlative
4
4
  - operation_date
5
- - pay_date
5
+ - payment_date
6
6
  - document_type
7
7
  - document_serial
8
8
  - document_number
@@ -10,10 +10,10 @@
10
10
  - provider_document_type
11
11
  - provider_document_number
12
12
  - provider_name
13
- - document_bi
14
- - document_igv
15
- - document_other_concept
16
- - document_total
13
+ - bi
14
+ - igv
15
+ - other_concept
16
+ - total_operation
17
17
  - currency_code
18
18
  - exchange_rate
19
19
  - modified_document_date
@@ -23,9 +23,9 @@
23
23
  - detraction_date
24
24
  - detraction_number
25
25
  - apply_retention?
26
- - clasification_goods_services_adquired
27
- - inconsistent_exchange
28
- - inconsistent_provider_inactive
29
- - inconsistent_provider_igv_exoneration
26
+ - adquired_clasification
27
+ - exchange_rate_error
28
+ - provider_inactive_error
29
+ - provider_exoneration_error
30
30
  - payment_method
31
31
  - anotation_oportunity
@@ -2,7 +2,7 @@
2
2
  - cuo
3
3
  - correlative
4
4
  - operation_date
5
- - pay_date
5
+ - payment_date
6
6
  - document_type
7
7
  - document_serial
8
8
  - initial_document_number
@@ -10,8 +10,8 @@
10
10
  - client_document_type
11
11
  - client_document_number
12
12
  - client_name
13
- - bi_exported_operation
14
- - bi_taxable_operation
13
+ - bi_exported
14
+ - bi_taxable
15
15
  - bi_discount
16
16
  - igv_tax
17
17
  - igv_discount
@@ -24,10 +24,11 @@
24
24
  - total_operation
25
25
  - currency_code
26
26
  - exchange_rate
27
- - original_document_date
28
- - original_document_type
29
- - original_document_serial
30
- - original_document_number
27
+ - modified_document_date
28
+ - modified_document_type
29
+ - modified_document_serial
30
+ - modified_document_number
31
31
  - contract_uid
32
- - payment_way
32
+ - exchange_rate_error
33
+ - payment_method
33
34
  - anotation_oportunity
@@ -2,7 +2,7 @@
2
2
  - cuo
3
3
  - correlative
4
4
  - operation_date
5
- - pay_date
5
+ - payment_date
6
6
  - document_type
7
7
  - document_serial
8
8
  - initial_document_number
@@ -10,16 +10,16 @@
10
10
  - client_document_type
11
11
  - client_document_number
12
12
  - client_name
13
- - bi_taxable_operation
13
+ - bi_taxable
14
14
  - igv_tax
15
- - non_taxable
15
+ - other_concept
16
16
  - total_operation
17
17
  - currency_code
18
18
  - exchange_rate
19
- - original_document_date
20
- - original_document_type
21
- - original_document_serial
22
- - original_document_number
19
+ - modified_document_date
20
+ - modified_document_type
21
+ - modified_document_serial
22
+ - modified_document_number
23
23
  - exchange_rate_error
24
- - payment_way
24
+ - payment_method
25
25
  - anotation_oportunity
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sunat_books"
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
  s.summary = "A ruby gem to get accounting books for SUNAT"
7
7
  s.description = s.summary
8
8
  s.authors = ["César Carruitero"]
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = `git ls-files`.split("\n")
14
14
 
15
- s.add_runtime_dependency("activesupport", "> 4.1")
15
+ s.add_runtime_dependency("activesupport")
16
16
  s.add_runtime_dependency("i18n", "~> 1.8")
17
17
  s.add_runtime_dependency("prawn", "~> 2.0")
18
18
  s.add_runtime_dependency("prawn-table", "~> 0.2")
@@ -22,4 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency("pdf-inspector", "~> 1.3.0")
23
23
  s.add_development_dependency("pry", "~> 0.10")
24
24
  s.add_development_dependency("rubocop", "~> 0.48")
25
+
26
+ s.required_ruby_version = ">= 2.5.0"
25
27
  end
@@ -13,7 +13,7 @@ require "pdf/inspector"
13
13
 
14
14
  def get_line(array, object)
15
15
  str = ""
16
- array.each { |f| str += object.send(f.to_s) + "|" }
16
+ array.each { |f| str += "#{object.send(f.to_s)}|" }
17
17
  str
18
18
  end
19
19
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../helper"
4
+
5
+ setup do
6
+ @tickets = [{}]
7
+ @ruc = "102392839213"
8
+ end
9
+
10
+ test "raise error when layout file doesnt exist" do
11
+ assert_raise SunatBooks::Errors::InvalidLayoutError do
12
+ SunatBooks::Ple::Base.new(@ruc, @tickets, 10, 2013, { yml: "not-file" })
13
+ end
14
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunat_books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - César Carruitero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2020-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,7 @@ files:
154
154
  - lib/sunat_books/common_utils.rb
155
155
  - lib/sunat_books/csv/base.rb
156
156
  - lib/sunat_books/csv/option_error.rb
157
+ - lib/sunat_books/errors/invalid_layout_error.rb
157
158
  - lib/sunat_books/pdf/base.rb
158
159
  - lib/sunat_books/pdf/buys.rb
159
160
  - lib/sunat_books/pdf/count_sum.rb
@@ -191,6 +192,7 @@ files:
191
192
  - test/pdf/pages_utils_test.rb
192
193
  - test/pdf/sales_test.rb
193
194
  - test/pdf/utils_test.rb
195
+ - test/ple/base_test.rb
194
196
  - test/ple/buys_test.rb
195
197
  - test/ple/sales_test.rb
196
198
  - test/ple/utils_test.rb
@@ -206,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
208
  requirements:
207
209
  - - ">="
208
210
  - !ruby/object:Gem::Version
209
- version: '0'
211
+ version: 2.5.0
210
212
  required_rubygems_version: !ruby/object:Gem::Requirement
211
213
  requirements:
212
214
  - - ">="